[Game] Add Command Zone support with commander tax tracking

- Add CommandZone and CommandZoneLogic for commander
  - Add CommanderTaxCounter
  - Add counter active state protocol (show/hide tax counters)
  - Add "Enable Command Zone" option in game creation dialogs
  - Add context menu actions for command zone operations

Took 9 minutes

Took 11 minutes
This commit is contained in:
DawnFire42 2026-05-21 21:30:40 -04:00 committed by Lukas Brübach
parent da4ba222c0
commit b4057a865d
73 changed files with 1540 additions and 86 deletions

View file

@ -5,6 +5,7 @@
#include <gtest/gtest.h>
#include <libcockatrice/network/server/remote/game/server_counter.h>
#include <libcockatrice/utility/trice_limits.h>
#include <limits>
TEST(ServerCounter, IncrementDoesNotOverflow)
@ -79,6 +80,37 @@ TEST(ServerCounter, MixedExtremesDoNotClamp)
EXPECT_EQ(c.getCount(), -1);
}
TEST(ServerCounter, SetCountClampsToCustomBounds)
{
Server_Counter c(1, "test", color(), 10, 50, 0, 100);
EXPECT_TRUE(c.setCount(150));
EXPECT_EQ(c.getCount(), 100);
EXPECT_TRUE(c.setCount(-10));
EXPECT_EQ(c.getCount(), 0);
}
TEST(ServerCounter, IncrementClampsToCustomBounds)
{
Server_Counter c(1, "test", color(), 10, 50, 0, 100);
EXPECT_TRUE(c.incrementCount(100));
EXPECT_EQ(c.getCount(), 100);
EXPECT_FALSE(c.incrementCount(1));
EXPECT_EQ(c.getCount(), 100);
EXPECT_TRUE(c.incrementCount(-200));
EXPECT_EQ(c.getCount(), 0);
EXPECT_FALSE(c.incrementCount(-1));
EXPECT_EQ(c.getCount(), 0);
}
TEST(ServerCounter, CustomBoundsForCommanderTax)
{
Server_Counter taxCounter(1, "tax", color(), 20, 0, 0, MAX_COUNTER_VALUE);
EXPECT_TRUE(taxCounter.setCount(1000));
EXPECT_EQ(taxCounter.getCount(), MAX_COUNTER_VALUE);
EXPECT_TRUE(taxCounter.setCount(-5));
EXPECT_EQ(taxCounter.getCount(), 0);
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);