| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?php
- include_once 'SoccerMatchAnalysis.php';
- include_once 'SoccerMatch.php';
- include_once 'Database.php';
- class WebFunctions
- {
- function createMatchTable($matches, $betLevel, $bankValue)
- {
- echo '<table id="soccerMatchTable" class="display">';
- echo '<thead>';
- echo '<tr>';
- 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>';
- echo '</tr>';
- echo '</thead>';
- echo '<tbody>';
- foreach ($matches as $match) {
- $this->createMatchRow($match, $betLevel, $bankValue);
- }
- echo '</tbody>';
- echo '</table>';
- }
- function createMatchRow(
- SoccerMatch $match,
- float $betLevel,
- float $bankValue
- ) {
- $analysisValue = $this->getAnalysisValue($match);
- if ($analysisValue != 'No bet') {
- echo '<tr>';
- echo '<td>' . $match->getGameDate() . '</td>';
- echo '<td>' . $match->getHomeTeam()->getTeamLeague() . '</td>';
- echo '<td>' . $match->getHomeTeam()->getTeamName() . '</div></td>';
- echo '<td>' . $match->getAwayTeam()->getTeamName() . '</td>';
- echo '<td><div contenteditable>' .
- $match->getOdds1() .
- '</div></td>';
- echo '<td><div contenteditable>' .
- $match->getOddsX() .
- '</div></td>';
- echo '<td><div contenteditable>' .
- $match->getOdds2() .
- '</div></td>';
- echo '<td>' . $analysisValue;
- echo '<td>' . ($bankValue * $betLevel) / 100 . '</td>';
- echo '<td><button id="submitRowButton">Submit</button></td>';
- 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;
- }
- public function createOutstandingBetsTable()
- {
- $database = new Database();
- $bets = $database->getOutstandingBets();
- if ($bets == null) {
- return;
- }
- echo '<table id="outstandingBetsTable">';
- echo '<thead>';
- echo '<tr>';
- echo '<th>Game date</th>';
- echo '<th>League</th>';
- echo '<th>Teams</th>';
- echo '<th>Bet On</th>';
- echo '<th>Bet Amount</th>';
- echo '<th>Odds</th>';
- echo '<th>Status</th>';
- echo '</tr>';
- echo '</thead>';
- foreach ($bets as $bet) {
- $this->createOutstandingBetsRow($bet);
- }
- echo '<tbody>';
- echo '</table>';
- }
- private function createOutstandingBetsRow(Bet $bet)
- {
- echo '<tr>';
- echo '<td>' . $bet->getGameDate() . '</td>';
- echo '<td>' . $bet->getLeagueName() . '</td>';
- echo '<td>' . $bet->getTeams() . '</td>';
- echo '<td>' . $bet->getBetOn() . '</td>';
- echo '<td>' . $bet->getBetAmount() . '</td>';
- echo '<td>' . $bet->getOdds() . '</td>';
- echo '<td>' . $bet->getStatus() . '</td>';
- echo '</tr>';
- }
- }
|