diff --git a/gatherling/Models/Deck.php b/gatherling/Models/Deck.php index b2f048a12..c3d1a876b 100644 --- a/gatherling/Models/Deck.php +++ b/gatherling/Models/Deck.php @@ -339,28 +339,21 @@ public function canEdit(string|false $username): bool public function canView(string|false $username): bool { - if ($username === false) { - return false; - } $event = $this->getEvent(); - $player = new Player($username); - if (($event->finalized && !$event->active) || $event->private_decks == 0) { return true; } elseif ($event->current_round > $event->mainrounds && !$event->private_finals) { return true; - } else { - if ( - $player->isSuper() || - $event->isHost($username) || - $event->isOrganizer($username) || - strcasecmp($username, $this->playername) == 0 - ) { - return true; - } + } elseif ($username === false) { + return false; } - - return false; + $player = new Player($username); + return ( + $player->isSuper() || + $event->isHost($username) || + $event->isOrganizer($username) || + ($this->playername !== null && strcasecmp($username, $this->playername) == 0) + ); } public function isValid(): bool diff --git a/gatherling/Models/Event.php b/gatherling/Models/Event.php index e2980cca8..c00bd153e 100644 --- a/gatherling/Models/Event.php +++ b/gatherling/Models/Event.php @@ -38,10 +38,10 @@ class Event public ?string $cohost; // has one Player - cohost // Subevents - public string|int $mainrounds; + public int $mainrounds; public string $mainstruct; public ?int $mainid; // Has one main subevent - public string|int $finalrounds; + public int $finalrounds; public string $finalstruct; public ?int $finalid; // Has one final subevent @@ -64,9 +64,9 @@ public function __construct(int|string $name = '') if ($name == '') { $this->id = 0; $this->name = ''; - $this->mainrounds = ''; + $this->mainrounds = 0; $this->mainstruct = ''; - $this->finalrounds = ''; + $this->finalrounds = 0; $this->finalstruct = ''; $this->host = null; $this->cohost = null; @@ -117,11 +117,12 @@ public function __construct(int|string $name = '') } } + // BAKERT remove all casts on mainrounds and finalrounds $this->standing = new Standings($this->name, '0'); // Main rounds $this->mainid = null; - $this->mainrounds = ''; + $this->mainrounds = 0; $this->mainstruct = ''; $sql = 'SELECT id AS mainid, rounds, type FROM subevents WHERE parent = :parent AND timing = 1'; $params = ['parent' => $this->name]; @@ -134,7 +135,7 @@ public function __construct(int|string $name = '') // Final rounds $this->finalid = null; - $this->finalrounds = ''; + $this->finalrounds = 0; $this->finalstruct = ''; $sql = 'SELECT id AS mainid, rounds, type FROM subevents WHERE parent = :parent AND timing = 2'; $params = ['parent' => $this->name]; @@ -179,9 +180,9 @@ public static function createEvent( string $player_reportable, string $late_entry_limit, string $private, - string $mainrounds, + int $mainrounds, string $mainstruct, - string $finalrounds, + int $finalrounds, string $finalstruct, string $client ): Event { @@ -220,7 +221,7 @@ public static function createEvent( $event->late_entry_limit = (int) $late_entry_limit; - if ($mainrounds == '') { + if ($mainrounds === 0) { $mainrounds = 3; } if ($mainstruct == '') { @@ -293,8 +294,8 @@ public function save(): void ]; db()->execute($sql, $params); - $this->newSubevent((int) $this->mainrounds, 1, $this->mainstruct); - $this->newSubevent((int) $this->finalrounds, 2, $this->finalstruct); + $this->newSubevent($this->mainrounds, 1, $this->mainstruct); + $this->newSubevent($this->finalrounds, 2, $this->finalstruct); } else { $sql = ' UPDATE @@ -339,19 +340,19 @@ public function save(): void db()->execute($sql, $params); if ($this->mainid == null) { - $this->newSubevent((int) $this->mainrounds, 1, $this->mainstruct); + $this->newSubevent($this->mainrounds, 1, $this->mainstruct); } else { $main = new Subevent($this->mainid); - $main->rounds = (int) $this->mainrounds; + $main->rounds = $this->mainrounds; $main->type = $this->mainstruct; $main->save(); } if ($this->finalid == null) { - $this->newSubevent((int) $this->finalrounds, 2, $this->finalstruct); + $this->newSubevent($this->finalrounds, 2, $this->finalstruct); } else { $final = new Subevent($this->finalid); - $final->rounds = (int) $this->finalrounds; + $final->rounds = $this->finalrounds; $final->type = $this->finalstruct; $final->save(); } @@ -815,9 +816,9 @@ public function addMatch(Standings $playera, Standings $playerb, int $round = -9 $draws = 0; $id = $this->mainid; - if ($round > (int) $this->mainrounds) { + if ($round > $this->mainrounds) { $id = $this->finalid; - $round = $round - (int) $this->mainrounds; + $round = $round - $this->mainrounds; } if ($round == -99) { @@ -845,9 +846,8 @@ public function assignTrophiesFromMatches(): void $t4 = []; $t8 = []; - // BAKERT redundant max here unless finalrounds can be negative XD - $finalRounds = (int) $this->finalrounds; - $totalRounds = (int) $this->mainrounds + $finalRounds; + $finalRounds = $this->finalrounds; + $totalRounds = $this->mainrounds + $finalRounds; if ($finalRounds > 0) { $finalMatches = $this->getRoundMatches($totalRounds); @@ -876,8 +876,6 @@ public function assignTrophiesFromMatches(): void } } } - - print_r(['win' => $win, 'sec' => $sec, 't4' => $t4, 't8' => $t8]); } $this->setFinalists($win, $sec, $t4, $t8); @@ -1064,9 +1062,9 @@ public static function trophySrc(string $eventname): string public function isLeague(): bool { - $test = (int) $this->current_round; - if ($test <= ((int) $this->finalrounds + (int) $this->mainrounds)) { - if ($test > (int) $this->mainrounds) { + $test = $this->current_round; + if ($test <= ($this->finalrounds + $this->mainrounds)) { + if ($test > $this->mainrounds) { $structure = $this->finalstruct; } else { $structure = $this->mainstruct; @@ -1091,9 +1089,9 @@ public function pairCurrentRound(bool $skip_invalid = false): void //Check if all matches in the current round are finished if (count($this->unfinishedMatches()) === 0) { //Check to see if we are main rounds or final, get structure - $test = (int) $this->current_round; - if ($test < ((int) $this->finalrounds + (int) $this->mainrounds)) { - if ($test >= (int) $this->mainrounds) { + $test = $this->current_round; + if ($test < ($this->finalrounds + $this->mainrounds)) { + if ($test >= $this->mainrounds) { // In the final rounds. $structure = $this->finalstruct; $subevent_id = $this->finalid; @@ -1694,9 +1692,9 @@ public function startEvent(bool $precheck): void public function structureSummary(): string { - $ret = $this->toEnglish($this->mainstruct, (int) $this->mainrounds, false); + $ret = $this->toEnglish($this->mainstruct, $this->mainrounds, false); if ($this->finalrounds > 0) { - $ret = $ret . ' followed by ' . $this->toEnglish($this->finalstruct, (int) $this->finalrounds, true); + $ret = $ret . ' followed by ' . $this->toEnglish($this->finalstruct, $this->finalrounds, true); } return $ret; } diff --git a/gatherling/Models/EventSubeventDto.php b/gatherling/Models/EventSubeventDto.php index ce1fec5b7..b7227a2ec 100644 --- a/gatherling/Models/EventSubeventDto.php +++ b/gatherling/Models/EventSubeventDto.php @@ -7,6 +7,6 @@ class EventSubeventDto extends Dto { public int $mainid; - public string $rounds; + public int $rounds; public string $type; } diff --git a/gatherling/Views/Components/RoundDropMenu.php b/gatherling/Views/Components/RoundDropMenu.php index de3e9c8d3..93e9944cd 100644 --- a/gatherling/Views/Components/RoundDropMenu.php +++ b/gatherling/Views/Components/RoundDropMenu.php @@ -11,7 +11,7 @@ class RoundDropMenu extends DropMenu public function __construct(Event $event, int|string|null $selected, int $defaultValue = 0) { $options = []; - for ($r = 1; $r <= ((int) $event->mainrounds + (int) $event->finalrounds); $r++) { + for ($r = 1; $r <= ($event->mainrounds + $event->finalrounds); $r++) { $star = $r > $event->mainrounds ? '*' : ''; $options[] = [ 'isSelected' => $selected == $r, diff --git a/gatherling/api_lib.php b/gatherling/api_lib.php index 8ab88a9e5..d6f34ec00 100644 --- a/gatherling/api_lib.php +++ b/gatherling/api_lib.php @@ -366,9 +366,9 @@ function create_event(): array argStr('player_reportable', ''), argStr('late_entry_limit', ''), argStr('private', ''), - argStr('mainrounds', ''), + (int) argStr('mainrounds', '0'), argStr('mainstruct', ''), - argStr('finalrounds', ''), + (int) argStr('finalrounds', '0'), argStr('finalstruct', ''), argStr('client', '1') ); diff --git a/gatherling/components.js b/gatherling/components.js index 636b2fc77..7adc7e853 100644 --- a/gatherling/components.js +++ b/gatherling/components.js @@ -33,6 +33,6 @@ Vue.use(Toasted); }); var app = new Vue({ - el: '#maincontainer', + el: 'body', store }) diff --git a/gatherling/event.php b/gatherling/event.php index c26b2bb51..708b4a849 100644 --- a/gatherling/event.php +++ b/gatherling/event.php @@ -270,9 +270,9 @@ function insertEvent(): Event post()->string('player_reportable'), post()->string('late_entry_limit'), post()->string('private'), - post()->string('mainrounds'), + post()->int('mainrounds'), post()->string('mainstruct'), - post()->string('finalrounds'), + post()->int('finalrounds'), post()->string('finalstruct'), post()->string('client') ); @@ -526,7 +526,10 @@ function updateMatches(): void } $rnd = post()->int('newmatchround'); - if ($pA !== '' && $pB !== '' && $rnd) { + if ($pA !== '' && $pB !== '') { + if ($rnd === 0) { + throw new InvalidArgumentException('Cannot add match to round 0'); + } $playerA = new Standings($event->name, $pA); $playerB = new Standings($event->name, $pB); if ($res == 'P') { diff --git a/gatherling/gatherling.js b/gatherling/gatherling.js index a4eaf7e41..7e54295d1 100644 --- a/gatherling/gatherling.js +++ b/gatherling/gatherling.js @@ -91,6 +91,12 @@ function formatDate(originalDate, start, timeZone, locale, short) { } else { formattedDate = date.toFormat('ccc, MMM d, yyyy'); } + if (formattedTime === 'midnight' && formattedDate === 'Today') { + formattedDate = 'This'; + } + if (formattedTime === 'midnight') { + formattedDate += ' morning'; + } return `${formattedDate} • ${formattedTime}`; } diff --git a/gatherling/styles/css/stylesheet.css b/gatherling/styles/css/stylesheet.css index 498132783..bbd1da4ee 100644 --- a/gatherling/styles/css/stylesheet.css +++ b/gatherling/styles/css/stylesheet.css @@ -206,7 +206,7 @@ hr { /* Remnants of the hacked upon 960 grid system, with everything we don't use ripped out */ -.container_12 { +body { margin-left: auto; margin-right: auto; max-width: 960px; @@ -231,11 +231,11 @@ hr { ); /* 100% width minus left and right margins */ } -.container_12 .grid_6 { +.grid_6 { max-width: 460px; } -.container_12 .grid_12 { +.grid_12 { max-width: 940px; } @@ -247,37 +247,36 @@ hr { margin-right: 0; } -.container_12 .grid_2 { +.grid_2 { max-width: 140px; } -.container_12 .grid_4 { +.grid_4 { max-width: 298px; } -.container_12 .grid_5 { +.grid_5 { max-width: 373px; - padding: 15px; } -.container_12 .grid_7 { +.grid_7 { max-width: 540px; } -.container_12 .grid_8 { +.grid_8 { max-width: 620px; } -.container_12 .grid_10 { +.grid_10 { max-width: 940px; margin-bottom: 15px; } -.container_12 .prefix_1 { +.prefix_1 { padding-left: 0; } -.container_12 .suffix_1 { +.suffix_1 { padding-right: 0; } @@ -566,7 +565,7 @@ a.create_deck_link { .ds_inputbox { margin: auto; - width: 750px; + max-width: 750px; border: 1px solid var(--control-border-color); color: var(--main-text-color); background-color: var(--highlight-background-color); @@ -575,17 +574,15 @@ a.create_deck_link { } .ds_left { - width: 590px; + max-width: 590px; background-color: var(--highlight-background-color); - float: left; padding: 3px; } .ds_right { - width: 125px; + max-width: 125px; background-color: var(--highlight-background-color); padding: 3px; - float: left; } .ds_label { @@ -598,7 +595,11 @@ a.create_deck_link { .ds_select { margin-top: 15px; display: block; - font-size: 13px; +} + +.ds_label span { + display: inline-block; + min-width: 12ch; } .ds_input { @@ -606,10 +607,9 @@ a.create_deck_link { color: var(--main-text-color); background-color: var(--highlight-background-color); border-radius: var(--control-border-radius); - width: 450px; + max-width: 450px; padding: 5px; margin: 0; - float: right; } .ds_input:hover { @@ -635,10 +635,9 @@ a.create_deck_link { margin: auto; margin-top: 13px; font-size: 13px; - width: 110px; + max-width: 110px; text-align: center; display: block; - clear: both; padding: 6px 28px; border: 1px solid var(--control-border-color); border-radius: var(--control-border-radius); @@ -670,29 +669,28 @@ a.create_deck_link { font-weight: bold; margin: auto; margin-top: 10px; - font-size: 13px; text-align: center; display: block; - clear: both; border: none; } .ds_color { appearance: none; - font-size: 15px; border: none; border-radius: 0; padding: 5px; - margin-left: 85px; margin-top: 5px; } .ds_checkbox { - padding: 10px; + padding: var(--spacing-5-static); margin: 5px; border: 1px solid var(--control-border-color); border-radius: var(--control-border-radius); background-color: var(--control-background-color); + display: inline-flex; + align-items: center; + gap: 5px; } .ds_checkbox:hover { @@ -708,7 +706,7 @@ a.create_deck_link { #ds_select { margin: 5px; margin-top: 0; - width: 140px; + max-width: 140px; height: 27px; outline: solid transparent; border: 1px solid var(--control-border-color); @@ -730,14 +728,6 @@ a.create_deck_link { overflow: hidden; } -.group::after { - clear: both; -} - -.group { - zoom: 1; -} - .banner_alert { background: var(--base-background-color); border: var(--notice-text-color) dotted; diff --git a/gatherling/styles/images/search.png b/gatherling/styles/images/search.png deleted file mode 100644 index e445f2f6e..000000000 Binary files a/gatherling/styles/images/search.png and /dev/null differ diff --git a/gatherling/templates/partials/footer.mustache b/gatherling/templates/partials/footer.mustache index ce3f9895e..49b7660e3 100644 --- a/gatherling/templates/partials/footer.mustache +++ b/gatherling/templates/partials/footer.mustache @@ -1,11 +1,10 @@ -