-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathstatistics.cpp
53 lines (42 loc) · 1.81 KB
/
statistics.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
/* Copyright (C) 2013-2014 Michal Brzozowski ([email protected])
This file is part of KeeperRL.
KeeperRL is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
KeeperRL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.gnu.org/licenses/ . */
#include "stdafx.h"
#include "statistics.h"
#include "t_string.h"
SERIALIZE_DEF(Statistics, count)
void Statistics::add(StatId id) {
++count[id];
}
void Statistics::clear() {
for (StatId id : ENUM_ALL(StatId))
count[id] = 0;
}
static TStringId getName(StatId id) {
switch (id) {
case StatId::DEATH: return TStringId("DEATHS");
case StatId::INNOCENT_KILLED: return TStringId("COLD_BLOODED_MURDERS");
case StatId::CHOPPED_HEAD: return TStringId("CHOPPED_HEADS");
case StatId::CHOPPED_LIMB: return TStringId("CHOPPED_LIMBS");
case StatId::SPELL_CAST: return TStringId("SPELLS_CAST");
case StatId::SCROLL_READ: return TStringId("SCROLLS_READ");
case StatId::WEAPON_PRODUCED: return TStringId("WEAPONS_PRODUCED");
case StatId::ARMOR_PRODUCED: return TStringId("PIECES_OF_ARMOR_PRODUCED");
case StatId::POTION_PRODUCED: return TStringId("POTIONS_PRODUCED");
}
}
vector<TString> Statistics::getText() const {
vector<TString> ret;
for (auto id : ENUM_ALL(StatId)) {
if (int n = count[id])
ret.emplace_back(TSentence(getName(id), TString(n)));
}
return ret;
}