forked from AA789-ai/WarzoneGame-COMP345
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerDriver.cpp
More file actions
81 lines (62 loc) · 2.97 KB
/
PlayerDriver.cpp
File metadata and controls
81 lines (62 loc) · 2.97 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "Player.h"
// Define the testPlayers function to demonstrate player object features
void testPlayers() {
// Create a player with the name "John"
std::cout << "<----------Creating Player---------->" << std::endl;
Player* player = new Player("John");
// Add territories to the player's owned territories
std::cout << "<----------Adding Territories---------->" << std::endl;
Territory* territory1 = new Territory("New York", 1, 2);
Territory* territory2 = new Territory("London", 3, 4);
player->addTerritory(territory1);
// Get the territories to defend (initially, it returns all owned territories)
std::vector<Territory*> territoriesToDefend = player->toDefend();
// Display the territories to defend
std::cout << "<----------Displaying Territories To Defend---------->" << std::endl;
std::cout << "Territories to Defend: ";
for (const Territory* territory : territoriesToDefend) {
std::cout << territory->getName() << " - ";
}
std::cout << std::endl;
// Get the territories to attack (initially, it returns an empty list)
std::vector<Territory*> territoriesToAttack = player->toAttack();
// Display the territories to attack
std::cout << "<----------Displaying Territories To Attack---------->" << std::endl;
std::cout << "Territories to Attack: ";
for (const Territory* territory : territoriesToAttack) {
std::cout << territory->getName() << ", ";
}
std::cout << std::endl;
// Get the player's orders list
OrdersList& playerOrders = player->getOrdersList();
// Issue some orders
std::cout << "<----------Issuing Orders---------->" << std::endl;
// player->issueOrder("Airlift", territory1, territory2, new int(50), nullptr, nullptr, nullptr);
// player->issueOrder("Bomb", nullptr, territory2, nullptr, nullptr, nullptr, nullptr);
// Display the player's orders list
std::cout << "<----------Displaying Orders List---------->" << std::endl;
playerOrders.print();
// Testing reinforcementPool
std::cout << "<----------Number of reinforcement pool---------->" << std::endl;
player->setReinforcementPool(50);
player->addReinforcementPool(100);
player->removeReinforcementPool(40);
std::cout << player->getReinforcementPool() << std::endl;
Deck* deck = new Deck();
std::cout << *deck << std::endl;
deck->draw(player->getHand());
deck->draw(player->getHand());
std::cout << player->getHand() << std::endl;
player->getHand().cards[0]->play(player->getHand(), 0, player->getOrdersList());
// Use the custom operator<< to print player details
std::cout << "<----------Player's Stats---------->" << std::endl;
std::cout << *player << std::endl;
// Clean up the player to prevent memory leaks
std::cout << "<----------Deleting Player---------->" << std::endl;
delete player;
}
//int main() {
// // Call the testPlayers function to demonstrate player object features
// testPlayers();
// return 0;
//}