mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-17 04:27:45 -07:00
[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:
parent
694adc9e64
commit
9b030a3d6b
73 changed files with 1540 additions and 86 deletions
|
|
@ -22,7 +22,8 @@ TEST(ReverseCardMoveTest, MoveCardFromBottomTest)
|
|||
// instantiate a fake server instance
|
||||
FakeServer server;
|
||||
Server_Room room(0, 0, "", "", "", "", false, "", {}, &server);
|
||||
Server_Game game(user, 1, "", "", 2, QList<int>(), false, false, false, false, false, false, 20, false, &room);
|
||||
Server_Game game(user, 1, "", "", 2, QList<int>(), false, false, false, false, false, false, 20, false, false,
|
||||
&room);
|
||||
Server_AbstractPlayer player(&game, 1, user, false, nullptr);
|
||||
Server_CardZone deckZone(&player, ZoneNames::DECK, true, ServerInfo_Zone::PublicZone);
|
||||
Server_CardZone exileZone(&player, ZoneNames::EXILE, true, ServerInfo_Zone::PublicZone);
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ TEST(ServerCardCounter, IncrementExistingCounter)
|
|||
TEST(ServerCardCounter, IncrementOverflowProtection)
|
||||
{
|
||||
Server_Card card(CardRef{"TestCard", ""}, 1, 0, 0);
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTERS_ON_CARD));
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTER_VALUE));
|
||||
EXPECT_FALSE(card.incrementCounter(1, 1));
|
||||
EXPECT_EQ(card.getCounter(1), MAX_COUNTERS_ON_CARD);
|
||||
EXPECT_EQ(card.getCounter(1), MAX_COUNTER_VALUE);
|
||||
}
|
||||
|
||||
TEST(ServerCardCounter, DecrementUnderflowProtection)
|
||||
|
|
@ -113,13 +113,13 @@ TEST(ServerCardCounter, IncrementCounterPopulatesEvent)
|
|||
TEST(ServerCardCounter, IncrementCounterEventReflectsClampedValue)
|
||||
{
|
||||
Server_Card card(CardRef{"TestCard", ""}, 1, 0, 0);
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTERS_ON_CARD - 5));
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTER_VALUE - 5));
|
||||
|
||||
Event_SetCardCounter event;
|
||||
EXPECT_TRUE(card.incrementCounter(1, 10, &event));
|
||||
|
||||
EXPECT_EQ(event.counter_id(), 1);
|
||||
EXPECT_EQ(event.counter_value(), MAX_COUNTERS_ON_CARD);
|
||||
EXPECT_EQ(event.counter_value(), MAX_COUNTER_VALUE);
|
||||
}
|
||||
|
||||
TEST(ServerCardCounter, IncrementCounterNoEventWhenNullptr)
|
||||
|
|
@ -133,7 +133,7 @@ TEST(ServerCardCounter, IncrementCounterNoEventWhenNullptr)
|
|||
TEST(ServerCardCounter, IncrementCounterEventNotPopulatedWhenUnchanged)
|
||||
{
|
||||
Server_Card card(CardRef{"TestCard", ""}, 1, 0, 0);
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTERS_ON_CARD));
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTER_VALUE));
|
||||
|
||||
Event_SetCardCounter event;
|
||||
event.set_counter_id(999);
|
||||
|
|
@ -156,7 +156,7 @@ TEST(ServerCardCounter, SetCounterClampsAboveMaxToMax)
|
|||
{
|
||||
Server_Card card(CardRef{"TestCard", ""}, 1, 0, 0);
|
||||
EXPECT_TRUE(card.setCounter(1, 1500));
|
||||
EXPECT_EQ(card.getCounter(1), MAX_COUNTERS_ON_CARD);
|
||||
EXPECT_EQ(card.getCounter(1), MAX_COUNTER_VALUE);
|
||||
}
|
||||
|
||||
TEST(ServerCardCounter, IncrementDoesNotGoBelowZero)
|
||||
|
|
@ -171,9 +171,9 @@ TEST(ServerCardCounter, IncrementDoesNotGoBelowZero)
|
|||
TEST(ServerCardCounter, IncrementDoesNotExceedMax)
|
||||
{
|
||||
Server_Card card(CardRef{"TestCard", ""}, 1, 0, 0);
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTERS_ON_CARD - 5));
|
||||
ASSERT_TRUE(card.setCounter(1, MAX_COUNTER_VALUE - 5));
|
||||
EXPECT_TRUE(card.incrementCounter(1, 10));
|
||||
EXPECT_EQ(card.getCounter(1), MAX_COUNTERS_ON_CARD);
|
||||
EXPECT_EQ(card.getCounter(1), MAX_COUNTER_VALUE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue