| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- include_once 'SoccerMatchAnalysis.php';
- include_once 'SoccerMatch.php';
- include_once 'Database.php';
- class WebFunctions
- {
- function createMatchTable($matches)
- {
- echo '<table>';
- echo '<th>GameDate</th>';
- echo '<th>League</th>';
- echo '<th>Home Team</th>';
- echo '<th>Away Team</th>';
- echo '<th>Odds 1</th>';
- echo '<th>Odds X</th>';
- echo '<th>Odds 2</th>';
- echo '<th>Bet On</th>';
- echo '<th>Bet Amount</th>';
- echo '<th>Submit</th>';
- foreach ($matches as $match) {
- $this->createMatchRow($match);
- }
- echo '</table>';
- }
- function createMatchRow(SoccerMatch $match)
- {
- echo '<tr>';
- echo '<td>' . $match->getGameDate() . '</td>';
- echo '<td>' . $match->getHomeTeam()->getTeamLeague() . '</td>';
- echo '<td>' . $match->getHomeTeam()->getTeamName() . '</td>';
- echo '<td>' . $match->getAwayTeam()->getTeamName() . '</td>';
- echo '<td>' . $match->getOdds1() . '</td>';
- echo '<td>' . $match->getOddsX() . '</td>';
- echo '<td>' . $match->getOdds2() . '</td>';
- echo '<td>' . $this->getAnalysisValue($match);
- echo '</tr>';
- }
- private function getAnalysisValue(SoccerMatch $match)
- {
- $database = new Database();
- $result = 'No bet';
- $analysis = new SoccerMatchAnalysis($match);
- $leagueInfo = $database->getLeagueInfo(
- $match->getHomeTeam()->getTeamLeagueId()
- );
- if ($leagueInfo != null) {
- $homeWinsCount = $analysis->winLossRatio(
- $leagueInfo->getWinLossRatio(),
- true
- );
- $awayWinsCount = $analysis->winLossRatio(
- $leagueInfo->getWinLossRatio(),
- false
- );
- $homeWinLossRatioCount = $analysis->winLossRatioHomeAndAway(
- true,
- $leagueInfo->getWinLossRatioHomeAndAway()
- );
- $awayWinLossRatioCount = $analysis->winLossRatioHomeAndAway(
- false,
- $leagueInfo->getWinLossRatioHomeAndAway()
- );
- $homeScoringTotal = $analysis->scoringTotal(
- $leagueInfo->getScoringTotal(),
- true
- );
- $awayScoringTotal = $analysis->scoringTotal(
- $leagueInfo->getScoringTotal(),
- false
- );
- $scoringDiffLastGames = $analysis->getScoringDiffLastGames(
- $leagueInfo->getScoringDiffLastGame()
- );
- $winsCountDiff = $homeWinsCount - $awayWinsCount;
- $winLossRatioDiff = $homeWinLossRatioCount - $awayWinLossRatioCount;
- $scoringTotalDiff = $homeScoringTotal - $awayScoringTotal;
- if (
- $scoringDiffLastGames < 0 &&
- $winsCountDiff < 0 &&
- $winLossRatioDiff < 0 &&
- $scoringTotalDiff < 0
- ) {
- $result =
- ($scoringDiffLastGames +
- $winsCountDiff +
- $winLossRatioDiff +
- $scoringTotalDiff) /
- 4;
- } elseif (
- $scoringDiffLastGames > 0 &&
- $winsCountDiff > 0 &&
- $winLossRatioDiff > 0 &&
- $scoringTotalDiff > 0
- ) {
- $result =
- ($scoringDiffLastGames +
- $winsCountDiff +
- $winLossRatioDiff +
- $scoringTotalDiff) /
- 4;
- }
- }
- return $result;
- }
- }
|