-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIdea.cpp
74 lines (58 loc) · 1.58 KB
/
Idea.cpp
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
#pragma once
#ifndef WORLDSIM_IDEA_CPP
#define WORLDSIM_IDEA_CPP
/* WorldSim: Idea.cpp
#include "Idea.cpp"
An Idea is a precursor to Technology. A Character will have an idea about how to improve something. Once it spreads
to the leader or a book is written about it, it will become established as a technology. The originator of the idea
will be the one credited.
Ideas will later cover more than technology.
Each Civ and Settlement manages its own idea progress.
*/
#include "Idea.hpp"
int Idea::lastID = 0;
Idea::Idea(Character* _originator, IDEA_TYPE _type)
: id(++lastID), originator(_originator), type(_type)
{
isSpecialIdea=false;
}
Idea::Idea(const Idea& other)
: id(other.id), originator(other.originator), type(other.type)
{
isSpecialIdea=other.isSpecialIdea;
}
Idea& Idea::operator=(const Idea& other)
{
if (this != &other)
{
originator = other.originator;
// Do not change the ID
type = other.type;
}
return *this;
}
bool Idea::operator==(const Idea& other) const
{
return id == other.id;
}
std::string Idea::ideaToString(IDEA_TYPE idea)
{
switch (idea)
{
case IDEA_MINING: return "mining";
case IDEA_SMELTING: return "smelting";
case IDEA_MANUFACTURING: return "manufacturing";
case IDEA_ASTRONOMY: return "astronomy";
default: return "<UNKNOWN IDEA>";
}
}
SpecialIdea::SpecialIdea(Character* originator, IDEA_TYPE type)
: Idea(originator, type) // Call the constructor of the base class Idea
{
isSpecialIdea = true;
}
std::string SpecialIdea::discoveryText()
{
return "A special idea has been discovered.";
}
#endif // WORLDSIM_IDEA_CPP