diff --git a/action.php b/action.php index 5f17d70..f3920b4 100644 --- a/action.php +++ b/action.php @@ -72,7 +72,7 @@ $message = $message.$oppplayer->linkTo().'.'; } if ($match->player_reportable_check() == true) { - $message = $message.' (Report Result)'; + $message = $message.' (Report Result)'; } } } elseif ($match->result != 'BYE' && $match->verification == 'failed') { @@ -86,7 +86,7 @@ if ($match->player_reportable_check() == true) { $message = "The reported result wasn't consistent with your opponent's, please resubmit $event->name vs. ".$oppplayer->linkTo().'.'; - $message = $message.'(Report Result)'; + $message = $message.'(Report Result)'; } else { $message = "You have an unreported match in $match->eventname."; } diff --git a/admin/infobot.php b/admin/infobot.php index 5a1fc1c..7d50f8f 100644 --- a/admin/infobot.php +++ b/admin/infobot.php @@ -28,5 +28,5 @@ $player->setPassword($challenge); echo "Your temporary password for {$CONFIG['site_name']} is $challenge"; } else { - echo 'Unknown Action'; + echo "Unknown Action: {$_REQUEST['mode']}"; } diff --git a/event.php b/event.php index e9581da..30a1957 100644 --- a/event.php +++ b/event.php @@ -1134,7 +1134,7 @@ function kValueDropMenu($kvalue) $kvalue = -1; } $names = ['' => '- K-Value -', 8 => 'Casual (Alt Event)', 16 => 'Regular (less than 24 players)', - 24 => 'Large (24 or more players)', 32 => 'Championship', ]; + 24 => 'Large (24 or more players)', 32 => 'Championship', ]; print_select_input('K-Value', 'kvalue', $names, $kvalue); } @@ -1144,7 +1144,7 @@ function monthDropMenu($month) $month = -1; } $names = ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December', ]; + 'July', 'August', 'September', 'October', 'November', 'December', ]; echo ''; foreach ($names as $name) { $sel = (strcmp($name, $format) == 0) ? 'selected' : ''; @@ -244,9 +244,9 @@ public function getMatches($event) $data = []; while ($stmt->fetch()) { $data[] = ['playera' => $playera, - 'playerb' => $playerb, - 'result' => $result, - 'kvalue' => $kvalue, ]; + 'playerb' => $playerb, + 'result' => $result, + 'kvalue' => $kvalue, ]; } $stmt->close(); diff --git a/models/Series.php b/models/Series.php index 98ea2ca..030c765 100644 --- a/models/Series.php +++ b/models/Series.php @@ -341,20 +341,20 @@ public function currentSeason() // TODO: THESE functions are UGLY. public function getSeasonRules($season_number) { - $season_rules = ['first_pts' => 0, - 'second_pts' => 0, - 'semi_pts' => 0, - 'quarter_pts' => 0, - 'participation_pts' => 0, - 'rounds_pts' => 0, - 'decklist_pts' => 0, - 'win_pts' => 0, - 'loss_pts' => 0, - 'bye_pts' => 0, - 'must_decklist' => 0, - 'cutoff_ord' => 0, - 'master_link' => '', - 'format' => '', ]; + $season_rules = ['first_pts' => 0, + 'second_pts' => 0, + 'semi_pts' => 0, + 'quarter_pts' => 0, + 'participation_pts' => 0, + 'rounds_pts' => 0, + 'decklist_pts' => 0, + 'win_pts' => 0, + 'loss_pts' => 0, + 'bye_pts' => 0, + 'must_decklist' => 0, + 'cutoff_ord' => 0, + 'master_link' => '', + 'format' => '', ]; $db = Database::getConnection(); $stmt = $db->prepare('SELECT series, first_pts, second_pts, semi_pts, quarter_pts, participation_pts, diff --git a/player.php b/player.php index ba5d909..c804987 100644 --- a/player.php +++ b/player.php @@ -65,41 +65,6 @@ } else { $result = "Your challenge is wrong. Get a new one by sending the message '!verify {$CONFIG['infobot_prefix']}' to pdbot on MTGO!"; } - } elseif ($_POST['action'] == 'finalize_result') { - // write results to matches table - $drop = false; - if (isset($_POST['drop'])) { - $drop = $_POST['drop'] == 'Y'; - } - if ($drop) { - $match = new Match($_POST['match_id']); - $eventname = $match->getEventNamebyMatchid(); - $event = new Event($eventname); - $event->dropPlayer($player->name); - } - if ($_POST['opponent'] != '0') { - $event = new Event($_POST['event']); - if ($event->isLeague()) { - $player = new Standings($event->name, $_POST['player']); - $opponent = new Standings($event->name, $_POST['opponent']); - $new_match_id = $event->addPairing($player, $opponent, $event->current_round, 'P'); - Match::saveReport($_POST['report'], $new_match_id, 'a'); - } else { - $result = 'This is not a league event!'; - } - } else { - // Non-league matches - $match = new Match($_POST['match_id']); - if ($match->playerLetter($player->name) == $_POST['player']) { - Match::saveReport($_POST['report'], $_POST['match_id'], $_POST['player']); - } else { - $result = 'Results appear to be tampered. Please only submit your own results.'; - } - } - } elseif ($_POST['action'] == 'drop') { - // drop player from event - $event = new Event($_POST['event']); - $event->dropPlayer($player->name); } } // Handle modes @@ -109,6 +74,15 @@ } switch ($dispmode) { + case 'submit_result': + case 'submit_league_result': + case 'verify_result': + case 'verify_league_result': + case 'drop_form': + echo 'oops'; + + break; + case 'alldecks': print_allContainer(); break; @@ -147,32 +121,6 @@ print_editTimeZoneForm($player, $result); break; - case 'submit_result': - if (!isset($_GET['match_id'])) { - print_mainPlayerCP($player, ''); - break; - } - print_submit_resultForm($_GET['match_id']); - break; - - case 'submit_league_result': - League_print_submit_resultForm($_GET['event'], $_GET['round'], $player, $_GET['subevent']); - break; - - case 'verify_result': - if (isset($_POST['report'])) { - $drop = (isset($_POST['drop'])) ? 'Y' : 'N'; - print_verify_resultForm($_POST['report'], $_POST['match_id'], $_POST['player'], $drop, 0, 0); - } else { - print_submit_resultForm($_REQUEST['match_id']); - } - break; - - // todo: Fold this into the above case - case 'verify_league_result': - print_verify_resultForm($_POST['report'], $_POST['match_id'], $_POST['player'], 'N', $_POST['opponent'], $_POST['event']); - break; - case 'standings': Standings::printEventStandings($_GET['event'], Player::loginName()); break; @@ -185,37 +133,6 @@ } break; - case 'drop_form': - $matches = $player->getCurrentMatches(); - $event_name = $_REQUEST['event']; - $can_drop = true; - foreach ($matches as $match) { - if (strcasecmp($event_name, $match->getEventNamebyMatchid()) != 0) { - continue; - } - if ($match->verification == 'unverified') { - $player_number = $match->playerLetter($player->name); - if ($player_number == 'b' and ($match->playerb_wins + $match->playerb_losses) > 0) { - // Fine. - } elseif ($player_number == 'a' and ($match->playera_wins + $match->playera_losses) > 0) { - // Also Fine - } else { - if ($match->player_reportable_check() == true) { - $can_drop = false; - } - } - } elseif ($match->verification == 'failed') { - $can_drop = false; - } - } - - if ($can_drop) { - print_dropConfirm($event_name, $player); - } else { - print_submit_resultForm($match->id, true); - } - break; - default: print_mainPlayerCP($player, $result); break; @@ -228,160 +145,6 @@

Drop Form

'; - echo "
- Are you sure you want to drop? This cannot be undone.
\n"; - echo "
Please be sure to submit a result for any active matches before you leave.
\n"; - echo ''; - echo ' \n"; - echo "
'; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "name}\" />\n"; - echo "\n"; - echo '
'; - echo "\n"; - echo "
\n"; - echo "\n"; - echo "
\n"; - echo "
\n"; - echo "\n"; -} - -function print_submit_resultForm($match_id, $drop = false) -{ - $match = new Match($match_id); - $event = new Event($match->getEventNamebyMatchid()); - $letter = $match->playerLetter(Player::getSessionPlayer()->name); - if ($letter == 'a') { - $opp = $match->playerb; - } else { - $opp = $match->playera; - } - $oppplayer = new Player($opp); - echo "

Report Game Results

- Enter results for $event->name round $event->current_round vs. $oppplayer->name
\n"; - - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo ''; - echo ""; - echo ""; - echo ""; - echo ""; - if ($match->allowsPlayerReportedDraws() == 1) { - echo ""; - } - echo ''; - if ($match->type !== 'Single Elimination') { - print_checkbox_input('I want to drop from this event', 'drop', $drop); - } - echo ''; - echo '
I won the match 2-0
I won the match 2-1
I lost the match 0-2
I lost the match 1-2
The match was a draw
'; - echo ''; - echo '
'; - echo '
'; - echo '
'; -} - -// *form to report League results -function League_print_submit_resultForm($event, $round, $player, $subevent) -{ - echo "

Report League Game Results

- Enter results
\n"; - echo "
Opponent
\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "name}\" />\n"; - echo ''; - - echo '\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "
'; - leagueOpponentDropMenu($event, $round, $player, $subevent); - - echo "
I won the match 2-0
I won the match 2-1
\n"; - echo "\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; -} - -//* form to confirm submission -function print_verify_resultForm($report, $match_id, $player, $drop, $opponent, $event) -{ - echo "


Confirm Game Results

\n"; - echo "
Please confirm your entry.

\n"; - echo '

'; - if ($opponent != '0') { - echo 'Opponent: '.$opponent.'
'; - } - switch ($report) { - case 'W20': - echo 'I won the match 2-0'; - break; - case 'W21': - echo 'I won the match 2-1'; - break; - case 'L20': - echo 'I lost the match 0-2'; - break; - case 'L21': - echo 'I lost the match 1-2'; - break; - case 'D': - echo 'The match was a draw'; - break; - } - if ($drop == 1) { - $drop = 'Y'; - } - if ($drop == 'Y') { - echo "

I want to drop out of this event.
\n"; - } - echo '

'; - - echo ''; - echo '\n"; - echo ' \n"; - echo "
'; - echo "
\n"; - if ($drop == 'Y') { - echo "\n"; - } - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo "
'; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo "
\n"; - - echo "
\n"; - echo "\n"; - echo "
\n"; -} function print_changePassForm($player, $result) { @@ -697,10 +460,10 @@ function print_ActiveEvents() $round = 'main'; } if ($structure == 'League') { - $Leagues[] = "{$event->name} Round: {$event->current_round}name}&round={$event->current_round}&subevent={$subevent_id}\">Report League Game"; + $Leagues[] = "{$event->name} Round: {$event->current_round}name}&round={$event->current_round}&subevent={$subevent_id}\">Report League Game"; } if ($structure !== 'Single Elimination') { - echo "name}\">Drop From Event"; + echo "name}\">Drop From Event"; } } else { // This doesn't account for the small amount of time where Event Start time has elapsed, but Round 1 hasn't started @@ -857,13 +620,13 @@ function print_currentMatchTable($Leagues) echo '(Report Submitted)'; } else { if ($match->player_reportable_check() == true) { - echo '(Report Result)'; + echo '(Report Result)'; } else { echo 'Please report results in the report channel for this event'; } } } elseif ($match->verification == 'failed') { - echo "The reported result wasn't consistent with your opponent's, please check with the host id.'&player='.$player_number.'">(Correct Result)'; + echo "The reported result wasn't consistent with your opponent's, please check with the host id.'&player='.$player_number.'">(Correct Result)'; } elseif ($match->result == 'BYE') { } else { echo '(Reported)'; diff --git a/report.php b/report.php new file mode 100644 index 0000000..e121e06 --- /dev/null +++ b/report.php @@ -0,0 +1,293 @@ +getEventNamebyMatchid(); + $event = new Event($eventname); + $event->dropPlayer($player->name); + } + if ($_POST['opponent'] != '0') { + $event = new Event($_POST['event']); + if ($event->isLeague()) { + $player = new Standings($event->name, $_POST['player']); + $opponent = new Standings($event->name, $_POST['opponent']); + $new_match_id = $event->addPairing($player, $opponent, $event->current_round, 'P'); + Match::saveReport($_POST['report'], $new_match_id, 'a'); + redirect('player.php'); + + return; + } else { + $result = 'This is not a league event!'; + } + } else { + // Non-league matches + $match = new Match($_POST['match_id']); + if ($match->playerLetter($player->name) == $_POST['player']) { + Match::saveReport($_POST['report'], $_POST['match_id'], $_POST['player']); + redirect('player.php'); + + return; + } else { + $result = 'Results appear to be tampered. Please only submit your own results.'; + } + } + } elseif ($_POST['action'] == 'drop') { + // drop player from event + $event = new Event($_POST['event']); + $event->dropPlayer($player->name); + redirect('player.php'); + + return; + } + } +} +print_header('Player Control Panel'); +?> +
+
+
Player Control Panel
+getCurrentMatches(); + $event_name = $_REQUEST['event']; + $can_drop = true; + foreach ($matches as $match) { + if (strcasecmp($event_name, $match->getEventNamebyMatchid()) != 0) { + continue; + } + if ($match->verification == 'unverified') { + $player_number = $match->playerLetter($player->name); + if ($player_number == 'b' and ($match->playerb_wins + $match->playerb_losses) > 0) { + // Fine. + } elseif ($player_number == 'a' and ($match->playera_wins + $match->playera_losses) > 0) { + // Also Fine + } else { + if ($match->player_reportable_check() == true) { + $can_drop = false; + } + } + } elseif ($match->verification == 'failed') { + $can_drop = false; + } + } + + if ($can_drop) { + print_dropConfirm($event_name, $player); + } else { + print_submit_resultForm($match->id, true); + } + break; + default: + redirect('player.php'); + + return; + } +?> +
+
+ + + +

Drop Form

'; + echo "
+ Are you sure you want to drop? This cannot be undone.
\n"; + echo "
Please be sure to submit a result for any active matches before you leave.
\n"; + echo ''; + echo ' \n"; + echo "
'; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "name}\" />\n"; + echo "\n"; + echo '
'; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; +} + +function print_submit_resultForm($match_id, $drop = false) +{ + $match = new Match($match_id); + $event = new Event($match->getEventNamebyMatchid()); + $letter = $match->playerLetter(Player::getSessionPlayer()->name); + if ($letter == 'a') { + $opp = $match->playerb; + } else { + $opp = $match->playera; + } + $oppplayer = new Player($opp); + echo "

Report Game Results

+ Enter results for $event->name round $event->current_round vs. $oppplayer->name
\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ''; + echo ""; + echo ""; + echo ""; + echo ""; + if ($match->allowsPlayerReportedDraws() == 1) { + echo ""; + } + echo ''; + if ($match->type !== 'Single Elimination') { + print_checkbox_input('I want to drop from this event', 'drop', $drop); + } + echo ''; + echo '
I won the match 2-0
I won the match 2-1
I lost the match 0-2
I lost the match 1-2
The match was a draw
'; + echo ''; + echo '
'; + echo '
'; + echo '
'; +} + +// *form to report League results +function League_print_submit_resultForm($event, $round, $player, $subevent) +{ + echo "

Report League Game Results

+ Enter results
\n"; + echo "
Opponent
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "name}\" />\n"; + echo ''; + + echo '\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "
'; + leagueOpponentDropMenu($event, $round, $player, $subevent); + + echo "
I won the match 2-0
I won the match 2-1
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; +} + +//* form to confirm submission +function print_verify_resultForm($report, $match_id, $player, $drop, $opponent, $event) +{ + echo "


Confirm Game Results

\n"; + echo "
Please confirm your entry.

\n"; + echo '

'; + if ($opponent != '0') { + echo 'Opponent: '.$opponent.'
'; + } + switch ($report) { + case 'W20': + echo 'I won the match 2-0'; + break; + case 'W21': + echo 'I won the match 2-1'; + break; + case 'L20': + echo 'I lost the match 0-2'; + break; + case 'L21': + echo 'I lost the match 1-2'; + break; + case 'D': + echo 'The match was a draw'; + break; + } + if ($drop == 1) { + $drop = 'Y'; + } + if ($drop == 'Y') { + echo "

I want to drop out of this event.
\n"; + } + echo '

'; + + echo ''; + echo '\n"; + echo ' \n"; + echo "
'; + echo "
\n"; + if ($drop == 'Y') { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
'; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo "\n"; + echo "
\n"; +} +?> diff --git a/util/decktest.php b/util/decktest.php index 9d35898..cb05697 100644 --- a/util/decktest.php +++ b/util/decktest.php @@ -56,7 +56,7 @@ function scoredeck($id, $type, $db) { $score = 0; $convarr = ['Weak' => 1, 'Moderate' => 2, - 'Strong' => 4, 'Required' => 4, ]; + 'Strong' => 4, 'Required' => 4, ]; $query = "SELECT ti.strength, dc.qty FROM typeinfo ti LEFT OUTER JOIN deckcontents AS dc