-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerDriver.cpp
More file actions
112 lines (98 loc) · 4.25 KB
/
PlayerDriver.cpp
File metadata and controls
112 lines (98 loc) · 4.25 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <iostream>
#include <vector>
#include "Player.h"
#include <string>
#include "PlayerDriver.h"
#include "MapLoader.h"
using namespace std;
int player::main() {
Map* map = MapLoader::loadMap("../Maps/Rectangular.map");
auto* player1 = new Player(1, "Jenny", "Smith", "white", 1, 18,
map->getTerritories());
auto* player2 = new Player(1, "Ben", "Williams", "green", 1, 18,
map->getTerritories());
cout << *player1 << endl;
cout << *player2 << endl;
vector<Player*> players;
players.emplace_back(player1);
players.emplace_back(player2);
for (auto & player : players) {
player->setPlayers(players);
player->setTerritoryAdjacencyList(map->getTerritoryAdjacencyList());
}
Deck* deck = new Deck(players.size());
Hand* hand = new Hand(deck);
// PayCoin()
cout << "Testing PayCoin(): " << endl;
cout << "Player1 has coins " << player1->getCoins() << endl;
player1->PayCoin(2);
cout << "Now player1 has coins " << player1->getCoins() << endl;
cout << endl;
// PlaceNewArmies()
cout << "Testing PlaceNewArmies(): " << endl;
Territory* territory = map->getTerritories()[0];
cout << "Player1 has " << territory->getArmiesOfPlayer(player1->getId()) << " armies at territory "
<< territory->getId() << endl;
player1->PlaceNewArmies(5, territory);
cout << "Now, player1 has " << territory->getArmiesOfPlayer(player1->getId()) << " armies at territory "
<< territory->getId() << endl;
cout << endl;
// MoveArmies()
cout << "Testing MoveArmies(): " << endl;
vector<int> neighbors = map->getTerritoryNeighborsById(territory->getId());
Territory* to = map->getTerritoryById(neighbors[0]);
player1->MoveArmies(1, territory, to, 5);
cout << "Now, player1 has " << territory->getArmiesOfPlayer(player1->getId()) << " armies at territory "
<< territory->getId() << endl;
cout << "Now, player1 has " << to->getArmiesOfPlayer(player1->getId()) << " armies at territory "
<< to->getId() << endl;
cout << endl;
// MoveOverLand()
cout << "Testing MoveOverLand(): " << endl;
cout << "Assume that player 1 has 5 moving points, and moving 2 armies overland." << endl;
int remainingPoints = player1->MoveOverLand(2, 5);
cout << "Now, player 1 has " << remainingPoints << " moving points." << endl;
cout << endl;
// MoveOverWater()
cout << "Testing MoveOverWater(): " << endl;
cout << "Assume that player 1 has 5 moving points, and moving 1 armies over water." << endl;
remainingPoints = player1->MoveOverWater(1, 5);
cout << "Now, player 1 has " << remainingPoints << " moving points." << endl;
cout << endl;
// BuildCity()
cout << "Testing BuildCity(): " << endl;
cout << "Player1 has " << territory->getCities()[player1->getId()] << " city at territory "
<< territory->getId() << endl;
cout << "Player1 is building a city..." << endl;
player1->BuildCity(territory, 1);
cout << "Now, player1 has " << territory->getCities()[player1->getId()] << " city at territory "
<< territory->getId() << endl;
cout << endl;
// DestroyArmy()
cout << "Testing DestroyArmy(): " << endl;
cout << "Player1 has " << territory->getArmiesOfPlayer(player1->getId()) << " armies at territory "
<< territory->getId() << endl;
cout << "Player2 is destroying an army of player1 at territory " << territory->getId() << endl;
player2->DestroyArmy(1, player1, territory, 1);
cout << "Now, player1 has " << territory->getArmiesOfPlayer(player1->getId()) << " armies at territory "
<< territory->getId() << endl;
cout << endl;
// AndOrAction()
cout << "Testing AndOrAction(): " << endl;
for (int i = 0; i < deck->getCards().size(); ++i) {
if (deck->getCards()[i]->getAnd()) {
cout << *deck->getCards()[i] << endl;
player1->AndOrAction(deck->getCards()[i]);
break;
}
}
cout << endl;
for (int i = 0; i < deck->getCards().size(); ++i) {
if (deck->getCards()[i]->getOr()) {
cout << *deck->getCards()[i] << endl;
player1->AndOrAction(deck->getCards()[i]);
break;
}
}
return 0;
}