-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathproduction.cpp
More file actions
49 lines (40 loc) · 1.07 KB
/
production.cpp
File metadata and controls
49 lines (40 loc) · 1.07 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
#include "production.h"
#include "logger.hpp"
#include "items.h"
#include "skills.h"
#include "gamedata.h"
#include "rng.hpp"
Production::Production(int it, int amt)
: itemtype(it), baseamount(amt), amount(amt), productivity(10)
{
if (Globals->RANDOM_ECONOMY)
amount += rng::get_random(amt);
skill = lookup_skill(ItemDefs[it].pSkill);
}
void Production::write_out(std::ostream& f)
{
f << (itemtype == -1 ? "NO_ITEM" : ItemDefs[itemtype].abr) << '\n';
f << amount << '\n';
f << baseamount << '\n';
if (itemtype == I_SILVER) {
f << (skill == -1 ? "NO_SKILL" : SkillDefs[skill].abbr) << '\n';
}
f << productivity << '\n';
}
void Production::read_in(std::istream& f)
{
std::string temp;
f >> std::ws >> temp;
itemtype = lookup_item(temp);
f >> amount;
f >> baseamount;
if (itemtype == I_SILVER)
f >> std::ws >> temp;
else
temp = ItemDefs[itemtype].pSkill;
skill = lookup_skill(temp);
f >> productivity;
}
std::string Production::write_report() {
return item_string(itemtype, amount);
}