Example #1
0
                 if ($player->checkChallenge($_POST['challenge'])) {
                     $player->setVerified(true);
                     $result = "Successfully verified your account with MTGO.";
                     $success = true;
                 } else {
                     $result = "Your challenge doesn't match.  Get a new one by sending the message 'ua pdcmagic' to infobot on MTGO!";
                 }
             } else {
                 if ($_POST['action'] == 'finalize_result') {
                     // write results to matches table
                     Match::saveReport($_POST['report'], $_POST['match_id'], $_POST['player']);
                 } else {
                     if ($_POST['action'] == 'drop') {
                         // drop player from event
                         $event = new Event($_POST['event']);
                         $event->dropPlayer($player->name);
                     }
                 }
             }
         }
     }
 }
 // Handle modes
 $dispmode = 'playercp';
 if (isset($_GET['mode'])) {
     $dispmode = $_GET['mode'];
 }
 if (isset($_POST['mode'])) {
     $dispmode = $_POST['mode'];
 }
 //* redo this later as switch rather than elseifs, for now just kludge on
Example #2
0
function updateMatches()
{
    $event = new Event($_POST['name']);
    if (isset($_POST['matchdelete'])) {
        foreach ($_POST['matchdelete'] as $matchid) {
            Match::destroy($matchid);
        }
    }
    if (isset($_POST['dropplayer'])) {
        foreach ($_POST['dropplayer'] as $playername) {
            $event->dropPlayer($playername);
        }
    }
    if (isset($_POST['hostupdatesmatches'])) {
        for ($ndx = 0; $ndx < sizeof($_POST['hostupdatesmatches']); $ndx++) {
            $result = $_POST['matchresult'][$ndx];
            $resultForA = "notset";
            $resultForB = "notset";
            if ($result == "2-0") {
                $resultForA = "W20";
                $resultForB = "L20";
            } elseif ($result == "2-1") {
                $resultForA = "W21";
                $resultForB = "L21";
            } elseif ($result == "1-2") {
                $resultForA = "L21";
                $resultForB = "W21";
            } elseif ($result == "0-2") {
                $resultForA = "L20";
                $resultForB = "W20";
            } elseif ($result == 'D') {
                // TODO: need to figure out how to enter a draw
            }
            if (strcasecmp($resultForA, 'notset') != 0 && strcasecmp($resultForB, 'notset') != 0) {
                $matchid = $_POST['hostupdatesmatches'][$ndx];
                Match::saveReport($resultForA, $matchid, 'a');
                Match::saveReport($resultForB, $matchid, 'b');
            }
        }
    }
    if (isset($_POST['newmatchplayerA'])) {
        $pA = $_POST['newmatchplayerA'];
    } else {
        $pA = "";
    }
    if (isset($_POST['newmatchplayerB'])) {
        $pB = $_POST['newmatchplayerB'];
    } else {
        $pB = "";
    }
    if (isset($_POST['newmatchresult'])) {
        $res = $_POST['newmatchresult'];
        if ($res == "2-0") {
            $pAWins = 2;
            $pBWins = 0;
            $res = 'A';
        } elseif ($res == "2-1") {
            $pAWins = 2;
            $pBWins = 1;
            $res = 'A';
        } elseif ($res == "1-2") {
            $pAWins = 1;
            $pBWins = 2;
            $res = 'B';
        } elseif ($res == "0-2") {
            $pAWins = 0;
            $pBWins = 2;
            $res = 'B';
        } elseif ($res == 'D') {
            $pAWins = 0;
            $pBWins = 0;
            $res = 'D';
        }
    } else {
        $res = "";
    }
    if (isset($_POST['newmatchround'])) {
        $rnd = $_POST['newmatchround'];
    } else {
        $rnd = "";
    }
    if (strcmp($pA, "") != 0 && strcmp($pB, "") != 0 && strcmp($res, "") != 0 && strcmp($rnd, "") != 0) {
        if ($res == "P") {
            $event->addPairing($pA, $pB, $rnd, $res);
        } else {
            $event->addMatch($pA, $pB, $rnd, $res, $pAWins, $pBWins);
        }
    }
    if (isset($_POST['newbyeplayer']) && strcmp($_POST['newbyeplayer'], "") != 0) {
        $p = $_POST['newbyeplayer'];
        $event->addMatch($p, $p, $rnd, 'BYE');
    }
}