WebFunctions.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. include_once 'SoccerMatchAnalysis.php';
  3. include_once 'SoccerMatch.php';
  4. include_once 'Database.php';
  5. class WebFunctions
  6. {
  7. function createMatchTable($matches)
  8. {
  9. echo '<table>';
  10. echo '<th>GameDate</th>';
  11. echo '<th>League</th>';
  12. echo '<th>Home Team</th>';
  13. echo '<th>Away Team</th>';
  14. echo '<th>Odds 1</th>';
  15. echo '<th>Odds X</th>';
  16. echo '<th>Odds 2</th>';
  17. echo '<th>Bet On</th>';
  18. echo '<th>Bet Amount</th>';
  19. echo '<th>Submit</th>';
  20. foreach ($matches as $match) {
  21. $this->createMatchRow($match);
  22. }
  23. echo '</table>';
  24. }
  25. function createMatchRow(SoccerMatch $match)
  26. {
  27. echo '<tr>';
  28. echo '<td>' . $match->getGameDate() . '</td>';
  29. echo '<td>' . $match->getHomeTeam()->getTeamLeague() . '</td>';
  30. echo '<td>' . $match->getHomeTeam()->getTeamName() . '</td>';
  31. echo '<td>' . $match->getAwayTeam()->getTeamName() . '</td>';
  32. echo '<td>' . $match->getOdds1() . '</td>';
  33. echo '<td>' . $match->getOddsX() . '</td>';
  34. echo '<td>' . $match->getOdds2() . '</td>';
  35. echo '<td>' . $this->getAnalysisValue($match);
  36. echo '</tr>';
  37. }
  38. private function getAnalysisValue(SoccerMatch $match)
  39. {
  40. $database = new Database();
  41. $result = 'No bet';
  42. $analysis = new SoccerMatchAnalysis($match);
  43. $leagueInfo = $database->getLeagueInfo(
  44. $match->getHomeTeam()->getTeamLeagueId()
  45. );
  46. if ($leagueInfo != null) {
  47. $homeWinsCount = $analysis->winLossRatio(
  48. $leagueInfo->getWinLossRatio(),
  49. true
  50. );
  51. $awayWinsCount = $analysis->winLossRatio(
  52. $leagueInfo->getWinLossRatio(),
  53. false
  54. );
  55. $homeWinLossRatioCount = $analysis->winLossRatioHomeAndAway(
  56. true,
  57. $leagueInfo->getWinLossRatioHomeAndAway()
  58. );
  59. $awayWinLossRatioCount = $analysis->winLossRatioHomeAndAway(
  60. false,
  61. $leagueInfo->getWinLossRatioHomeAndAway()
  62. );
  63. $homeScoringTotal = $analysis->scoringTotal(
  64. $leagueInfo->getScoringTotal(),
  65. true
  66. );
  67. $awayScoringTotal = $analysis->scoringTotal(
  68. $leagueInfo->getScoringTotal(),
  69. false
  70. );
  71. $scoringDiffLastGames = $analysis->getScoringDiffLastGames(
  72. $leagueInfo->getScoringDiffLastGame()
  73. );
  74. $winsCountDiff = $homeWinsCount - $awayWinsCount;
  75. $winLossRatioDiff = $homeWinLossRatioCount - $awayWinLossRatioCount;
  76. $scoringTotalDiff = $homeScoringTotal - $awayScoringTotal;
  77. if (
  78. $scoringDiffLastGames < 0 &&
  79. $winsCountDiff < 0 &&
  80. $winLossRatioDiff < 0 &&
  81. $scoringTotalDiff < 0
  82. ) {
  83. $result =
  84. ($scoringDiffLastGames +
  85. $winsCountDiff +
  86. $winLossRatioDiff +
  87. $scoringTotalDiff) /
  88. 4;
  89. } elseif (
  90. $scoringDiffLastGames > 0 &&
  91. $winsCountDiff > 0 &&
  92. $winLossRatioDiff > 0 &&
  93. $scoringTotalDiff > 0
  94. ) {
  95. $result =
  96. ($scoringDiffLastGames +
  97. $winsCountDiff +
  98. $winLossRatioDiff +
  99. $scoringTotalDiff) /
  100. 4;
  101. }
  102. }
  103. return $result;
  104. }
  105. }