-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopexpert.cpp
More file actions
49 lines (42 loc) · 1.29 KB
/
opexpert.cpp
File metadata and controls
49 lines (42 loc) · 1.29 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
// Implementation file for the Operations Expert class
#include "macros.h"
#include <iostream>
#include <string>
/*
1. OpExpert can build RCs without using cards. This is done directly in Hero::build_centre.
2. OpExpert can fly to any city by discarding any card at all, as long as he is at a RC. opex_flight function.
He can only do this once per turn, so he gets a flag called opex_flew_this_turn.
*/
OpExpert::OpExpert() : Hero() { bool opex_flew_this_turn = false; }
OpExpert::OpExpert(City* _ptr_city, World* _ptr_world, int _hid, std::string _spec) :
Hero(_ptr_city, _ptr_world, _hid, _spec)
{
opex_flew_this_turn = false;
}
void OpExpert::start_turn()
{
std::cout << "OpExpert::start_turn called.\n";
opex_flew_this_turn = false; moves = 4;
}
bool OpExpert::opex_flight(City& _to, std::string _card)
{
// City OpExpert is in must have a RC.
if (ptr_city->has_rc()) {
// OpExpert can discard ANY card to flyto ANY city as long as he is at a RC.
std::vector<PCard>::iterator it;
for (it = hand.begin(); it != hand.end(); it++) {
if (it->name == _card) {
ptr_city->depart_hero(hero_id);
ptr_city = &_to;
ptr_city->arrive_hero(hero_id);
hand.erase(it);
opex_flew_this_turn = true;
moves--;
return true;
}
}
return false;
} else {
return false;
}
}