-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wonder.hpp
63 lines (53 loc) · 1.91 KB
/
Wonder.hpp
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
class Wonder;
#ifndef WONDER_H
#define WONDER_H
#include "Produce.hpp"
#include <vector>
#include <string>
#include <functional>
// Forward declare
class Player;
class Wonder {
public:
Wonder(std::string name,
std::vector< std::vector< std::vector<Produce> > > costs,
std::vector< std::vector< std::function< std::vector<Produce> (const Player& p) > > > getProduces)
: sideA_{true},
numCompleted_{0},
name_{name},
costs_{costs},
getProduces_{getProduces}
{
}
Wonder() : name_{"INVALID WONDER"}
{
}
void setSide(bool sideA) { sideA_ = sideA; }
void build() { ++numCompleted_; }
bool isFull() const { return numCompleted_ == costs_[!sideA_].size(); }
bool isSideA() const { return sideA_; }
size_t getNumCompleted() const { return numCompleted_; }
std::string getName() const { return name_; }
std::vector<Produce> getCost() const { return costs_[!sideA_][numCompleted_]; }
std::vector<Produce> getProduce(const Player& p) const {
std::vector<Produce> produce;
for (size_t i=0; i<=numCompleted_; ++i) {
std::vector<Produce> thisProduce = getProduces_[!sideA_][i](p);
produce.insert(produce.end(), thisProduce.begin(), thisProduce.end());
}
return produce;
}
std::vector<Produce> getProduceFromNext(const Player& p) const { return getProduces_[!sideA_][numCompleted_+1](p); }
private:
bool sideA_;
size_t numCompleted_;
std::string name_;
// side, then stage
std::vector< std::vector< std::vector<Produce> > > costs_;
// Note: For getProduces_, stages are 1 indexed; stage 0 is the resource given at start
std::vector< std::vector< std::function< std::vector<Produce> (const Player& p) > > > getProduces_;
};
inline std::ostream& operator<< (std::ostream& o, const Wonder& w) {
return o << w.getName();
}
#endif//WONDER_H