-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamemode.cpp
More file actions
161 lines (137 loc) · 2.86 KB
/
Copy pathgamemode.cpp
File metadata and controls
161 lines (137 loc) · 2.86 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include "cplusplus.h"
#include "gamemode.h"
#include "rating.h"
namespace gamemodes
{
std::vector<std::string> __names = { "RA2 Blitz", "Yuris Revenge", "Red Alert 2", "Red Alert", "Red Alert 2 New Maps", "Blitz 2v2", "Red Alert 2 2v2", "Unknown" };
// These names need to match column 'abbreviation' from table 'ladders'.
std::vector<std::string> __shortNames = { "blitz", "yr", "ra2", "ra", "ra2-new-maps", "blitz-2v2", "ra2-2v2", "?" };
/*!
*/
std::string name(GameMode gameMode)
{
return __names[std::min<uint32_t>(gameMode, count())];
}
/*!
*/
std::string shortName(GameMode gameMode)
{
return __shortNames[std::min<uint32_t>(gameMode, count())];
}
/*!
*/
int toIndex(const std::string &name)
{
auto it = std::find(__names.begin(), __names.end(), name);
if (it != __names.end())
{
return static_cast<int>(std::distance(__names.begin(), it));
}
else
{
auto it2 = std::find(__shortNames.begin(), __shortNames.end(), name);
return (it2!= __shortNames.end()) ? static_cast<int>(std::distance(__shortNames.begin(), it2)) : -1;
}
}
/*!
*/
std::vector<GameMode> list()
{
std::vector<GameMode> result;
for (int i = 0; i < count(); i++)
{
result.push_back(toGameMode(i));
}
return result;
}
/*!
*/
GameMode toGameMode(const std::string &name)
{
int index = toIndex(name);
if (index < 0 || index > count())
{
return gamemodes::Unknown;
}
return static_cast<GameMode>(index);
}
/*!
*/
uint32_t playerCount(GameMode gameMode)
{
switch (gameMode)
{
case Blitz:
case YurisRevenge:
case RedAlert2:
case RedAlert:
case RedAlert2NewMaps:
return 2;
case Blitz2v2:
case RedAlert2_2v2:
return 4;
case Unknown:
return 0;
default:
return 0;
}
}
/*!
*/
double decayFactor(GameMode gameMode)
{
if (gameMode == GameMode::YurisRevenge)
{
return 2.5;
}
else
{
return 3.5;
}
}
/*!
*/
double maxDeviationAfterActive(GameMode gameMode)
{
if (gameMode == GameMode::YurisRevenge)
{
return 150.0;
}
else
{
return 175.0;
}
}
/*!
*/
double deviationThresholdActive(GameMode gameMode, double currentElo)
{
dts::unused(gameMode);
return std::min(95.0, 65.0 + sqrt(abs(glicko::initialRating - currentElo)));
}
/*!
*/
double deviationThresholdInactive(GameMode gameMode, double currentElo)
{
return deviationThresholdActive(gameMode, currentElo) + 20.0;
}
/*!
*/
double deviationThresholdPeak(GameMode gameMode)
{
return deviationThresholdActive(gameMode, glicko::initialRating) * 1.0;
}
/*!
*/
uint32_t minGamesSinceActivationForPeak(GameMode gameMode)
{
if (gameMode == GameMode::RedAlert2_2v2 || gameMode == GameMode::Blitz2v2)
{
return 80;
}
else
{
return 50;
}
}
} // namespace gamemodes