-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardsDriver.cpp
More file actions
60 lines (48 loc) · 1.81 KB
/
CardsDriver.cpp
File metadata and controls
60 lines (48 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Cards.h"
#include "Map.h"
#include "Player.h"
/**
* @brief Driver function to test card draw, play, and recycle behaviour.
*/
void testCards() {
cout << "=== Cards Testing ===\n\n";
Player* player = new Player();
Deck* deck = new Deck();
// Add one of each card type
deck->addCard(make_unique<Card>(CardType::Reinforcement));
deck->addCard(make_unique<Card>(CardType::Bomb));
deck->addCard(make_unique<Card>(CardType::Blockade));
deck->addCard(make_unique<Card>(CardType::Airlift));
deck->addCard(make_unique<Card>(CardType::Diplomacy));
// Draw 5 cards into the player's hand
for (int i = 0; i < 5; ++i) {
auto card = deck->draw();
if (card)
player->getHand()->addCard(move(card));
}
// Create dummy contexts for each card
vector<CardPlayContext> contexts(5);
for (int i = 0; i < 5; ++i) {
contexts[i].source = new Territory("TerritoryA", 10, 20, "ContinentA");
contexts[i].target = new Territory("TerritoryB", 20, 30, "ContinentA");
contexts[i].targetPlayer = new Player();
contexts[i].armies = i + 3;
}
// Display state before playing cards
cout << "Initial Hand: " << *player->getHand() << endl;
cout << "Deck Before Play: " << *deck << endl << endl;
// Play all cards from the hand
player->getHand()->playAll(player, deck, contexts);
// Display state after playing cards
cout << "Deck After Play: " << *deck << endl;
cout << "Hand After Play: " << *player->getHand() << endl;
// Cleanup
for (auto& ctx : contexts) {
delete ctx.source;
delete ctx.target;
delete ctx.targetPlayer;
}
delete player;
delete deck;
cout << "\n=== Cards Testing Complete ===\n\n";
}