コード例 #1
0
ファイル: check-bets.php プロジェクト: andrecosta/SoccerWars
$matches = Match::GetAll();
foreach ($matches as $match) {
    if (strtotime($match->end_time) < strtotime('now')) {
        $team1_id = $match->progress[0]['team_id'];
        $team1_goals = $match->progress[0]['goals'];
        $team1_yellow_cards = $match->progress[0]['yellow_cards'];
        $team1_redcards = $match->progress[0]['redcards'];
        $team1_defenses = $match->progress[0]['defenses'];
        $team2_id = $match->progress[1]['team_id'];
        $team2_goals = $match->progress[1]['goals'];
        $team2_yellow_cards = $match->progress[1]['yellow_cards'];
        $team2_redcards = $match->progress[1]['redcards'];
        $team2_defenses = $match->progress[1]['defenses'];
        $team1_rank = 0;
        $team2_rank = 0;
        if ($bets = Bet::GetByMatch($match->id)) {
            foreach ($bets as $bet) {
                if ($bet->result == null) {
                    $user = User::Get($bet->user_id);
                    $result = null;
                    // Simple bet
                    if ($bet->type == 1) {
                        if ($team1_goals > $team2_goals) {
                            $result = 1;
                            $team1_rank += $bet->points_total;
                            $team2_rank -= $bet->points_total;
                        } elseif ($team1_goals == $team2_goals) {
                            $result = 0;
                        } elseif ($team1_goals > $team2_goals) {
                            $result = 2;
                            $team2_rank += $bet->points_total;