From 20c109df132a64073bcab9d77450e86e7870b632 Mon Sep 17 00:00:00 2001 From: Sam Tubbax Date: Sun, 18 Jan 2026 15:39:01 +0100 Subject: [PATCH 1/3] Rework council keleres UI and how its counted --- app/Draft/Settings.php | 9 +++++ app/TwilightImperium/Edition.php | 2 +- js/main.js | 66 +++++++++++++++++++------------- templates/factions.php | 5 ++- templates/generate.php | 3 +- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/app/Draft/Settings.php b/app/Draft/Settings.php index 2615220..58d0e2a 100644 --- a/app/Draft/Settings.php +++ b/app/Draft/Settings.php @@ -176,6 +176,15 @@ protected function validateTiles(): void { protected function validateFactions(): void { $factions = array_reduce($this->factionSets, fn ($sum, Edition $e) => $sum += $e->factionCount(), 0); + // if POK is included and TE isn't, then keleres could add 1 extra + if ( + in_array(Edition::PROPHECY_OF_KINGS, $this->factionSets) && + $this->includeCouncilKeleresFaction && + !in_array(Edition::THUNDERS_EDGE, $this->factionSets) + ) { + $factions++; + } + if ($factions < $this->numberOfFactions) { throw InvalidDraftSettingsException::notEnoughFactionsInSet($factions); } diff --git a/app/TwilightImperium/Edition.php b/app/TwilightImperium/Edition.php index 5906555..5ffc4f0 100644 --- a/app/TwilightImperium/Edition.php +++ b/app/TwilightImperium/Edition.php @@ -80,7 +80,7 @@ public function factionCount(): int return match($this) { Edition::BASE_GAME => 17, Edition::PROPHECY_OF_KINGS => 7, - Edition::THUNDERS_EDGE => 5, + Edition::THUNDERS_EDGE => 6, Edition::DISCORDANT_STARS => 24, Edition::DISCORDANT_STARS_PLUS => 10, }; diff --git a/js/main.js b/js/main.js index cf54d01..fcb9bed 100644 --- a/js/main.js +++ b/js/main.js @@ -26,11 +26,6 @@ $(document).ready(function () { toggleExpansion($(e.currentTarget)) }); - // @todo initial check - // @todo disable DS/DSPlus when Pok is disabled - - $('.draft-faction').on('change', faction_check); - $('#tabs nav a').on('click', function (e) { e.preventDefault(); $('#tabs nav a, .tab').removeClass('active'); @@ -140,6 +135,44 @@ function enableExpansion(expansion) { if (expansion == 'PoK') { toggleDiscordantAvailability(true); } + + toggleKeleres(); +} + +function toggleKeleres() { + const POKIsEnabled = $('[data-toggle-expansion="PoK"]').is(':checked'); + const TEIsEnabled = $('[data-toggle-expansion="TE"]').is(':checked'); + + let keleresIsAllowed = false; + let keleresIsRequired = false; + + if (TEIsEnabled) { + // keleres is checked and disabled + $('[data-set="keleres"]') + .prop('disabled', true) + .prop('checked', true) + .parent().addClass('disabled') + } else { + if (POKIsEnabled) { + // keleres is optional and enabled + $('[data-set="keleres"]') + .prop('disabled', false) + .parent().removeClass('disabled') + } else { + // keleres is unavailable and disabled + $('[data-set="keleres"]') + .prop('disabled', true) + .prop('checked', false) + .parent().addClass('disabled') + } + } + + if (keleresIsRequired) { + $('[data-set="keleres"]') + .prop('disabled', true) + .prop('checked', true) + .parent().addClass('disabled') + } } function toggleDiscordantAvailability(pokIsEnabled) { @@ -168,6 +201,8 @@ function disableExpansion(expansion) { if (expansion == 'PoK') { toggleDiscordantAvailability(false); } + + toggleKeleres(); } function update_alliance_mode() { @@ -209,27 +244,6 @@ function loading(loading = true) { } } - -function faction_check() { - let sets = []; - let max = 0; - - - $('.draft-faction').each(function (i, el) { - if ($(el).is(':checked')) { - max += parseInt($(el).data('num')); - $('.factions label[data-set="' + $(el).data('set') + '"]').removeClass('disabled'); - $('.factions label[data-set="' + $(el).data('set') + '"] input').prop('disabled', false); - } else { - $('.factions label[data-set="' + $(el).data('set') + '"]').addClass('disabled'); - $('.factions label[data-set="' + $(el).data('set') + '"] input').prop('disabled', true).prop('checked', false); - } - }); - - - $('#num_factions').attr('max', max); -} - function init_player_count() { $('#num_players').on('change', update_player_count); $('#num_players').on('keyup', update_player_count); diff --git a/templates/factions.php b/templates/factions.php index 32eed2c..f30f0fc 100644 --- a/templates/factions.php +++ b/templates/factions.php @@ -10,12 +10,13 @@ function translateSet($set): string 'te' => \App\TwilightImperium\Edition::THUNDERS_EDGE->value, 'discordant' => \App\TwilightImperium\Edition::DISCORDANT_STARS->value, 'discordantexp' => \App\TwilightImperium\Edition::DISCORDANT_STARS_PLUS->value, - 'keleres' => \App\TwilightImperium\Edition::THUNDERS_EDGE->value, + 'keleres' => 'keleres', }; } + foreach ($factions as $f) { - $fact = ' - + Note: Less options means more competitive drafting.
Number of players + 3 is kind of recommended, but this is all personal preference. @@ -247,7 +247,6 @@ The Council Keleres was introduced in Codex III and is included in Thunder's Edge. - (PoK or TE required). For simplicity's sake I'll leave it up to each group to decide how they want to handle things (including the very limited possibility of all 3 flavours also being picked). Just something to keep in mind.