-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.cpp
More file actions
114 lines (100 loc) · 3.18 KB
/
action.cpp
File metadata and controls
114 lines (100 loc) · 3.18 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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "action.h"
#include <iostream>
#include <algorithm>
std::vector<std::string> actionNames()
{
std::vector<std::string> names = {
"basicSynth",
"standardSynthesis",
"flawlessSynthesis",
"carefulSynthesis",
"carefulSynthesis2",
"pieceByPiece",
"rapidSynthesis",
"basicTouch",
"standardTouch",
"advancedTouch",
"hastyTouch",
"byregotsBlessing",
"comfortZone",
"rumination",
"mastersMend",
"mastersMend2",
"wasteNot",
"wasteNot2",
"manipulation",
"innerQuiet",
"steadyHand",
"steadyHand2",
"ingenuity",
"ingenuity2",
"greatStrides",
"innovation",
"tricksOfTheTrade"
};
return names;
}
std::string actionIdentifierToString(Action::Identifier actionIdentifier)
{
return actionNames()[actionIdentifier];
}
Action::Identifier stringToActionIdentifier(std::string actionIdentifierString)
{
std::vector<std::string> actionNameVector = actionNames();
auto it = std::find(actionNameVector.begin(), actionNameVector.end(), actionIdentifierString);
if(actionNameVector.end()==it)
{
std::cout << "Action identifier not found!" << std::endl;
}
else
{
return (Action::Identifier)std::distance(actionNameVector.begin(), it);
}
// TODO: Return error code or throw exception.
return Action::Identifier::advancedTouch;
}
void Action::print()
{
std::cout << "Action: " << shortName << " " << name << " " << level << " " << common << std::endl;
}
std::vector<Action> readActions(Json::Value root)
{
std::vector<Action> actions;
for(int i = 0; i < root.size(); ++i)
{
Action action;
action.shortName = root[i]["shortName"].asString();
action.name = root[i]["name"].asString();
action.craftingClass = stringToCraftingClass(root[i]["cls"].asString());
action.level = root[i]["level"].asInt();
action.common = root[i]["common"].asBool();
// Read data array:
Json::Value data = root[i]["data"];
action.durabilityCost = data[0].asInt();
action.cpCost = data[1].asInt();
action.successProbability = data[2].asFloat();
action.qualityIncreaseMultiplier = data[3].asFloat();
action.progressIncreaseMultiplier = data[4].asFloat();
std::string effectTypeString = data[5].asString();
if(effectTypeString=="immediate")
{
action.effectType = Action::EffectType::Immediate;
}
else if(effectTypeString=="countup")
{
action.effectType = Action::EffectType::CountUp;
}
else if(effectTypeString=="countdown")
{
action.effectType = Action::EffectType::CountDown;
}
else
{
std::cout << "Bad effect type descriptor " << effectTypeString << std::endl;
}
action.activeTurns = data[6].asInt();
action.identifier = (Action::Identifier)i;
actions.push_back(action);
}
return actions;
}