-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.cpp
347 lines (323 loc) · 13.7 KB
/
MainWindow.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "Weapon.h"
#include "DamageSimulation.h"
#include "PlayerClass.h"
#include <QInputDialog>
void MainWindow::simSetup()
{
if (gal == nullptr) {
gal = new GlobalAbilityList();
}
if (this->sim == nullptr) {
this->sim = new DamageSimulation();
sim->setGlobalAbilityList(this->gal);
}
if (this->PC == nullptr) {
this->PC = new PlayerCharacter();
PC->setName("Octorion");
PC->setLevel(40);
PC->setPlayerRace("Human");
PC->setPlayerClass(PlayerClass::getClassByName("WARRIOR"));
PC->setStrength(139);
PC->setAgility(54);
PC->setStamina(134);
PC->setIntellect(26);
PC->setSpirit(59);
PC->setArmor(1310);
//PC->addTalent("Two-Handed Weapon Specialization", 4);
//PC->addTalent("Anger Management", 1);
//PC->addTalent("Impale", 2);
//current spec
PC->addTalent("Improved Charge", 2);
PC->addTalent("Improved Rend", 3);
PC->addTalent("Deep Wounds", 1);
PC->addTalent("Improved Heroic Strike", 2);
PC->addTalent("Improved Overpower", 1);
//fury spec
//PC->addTalent("Improved Battle Shout", 5);
//PC->addTalent("Improved Execute", 1);
//proposed spec
// PC->addTalent("Improved Charge", 1);
// PC->addTalent("Improved Rend", 3);
// PC->addTalent("Deep Wounds", 1);
// PC->addTalent("Improved Heroic Strike", 3);
// PC->addTalent("Improved Overpower", 2);
PC->getRunes().push_back(new Rune("Consumed by Rage"));
//PC->getRunes().push_back(new Rune("Frenzied Assault"));
//PC->getRunes().push_back(new Rune("Blood Frenzy"));
Weapon *twoHander = new Weapon();
twoHander->setMinDamage(92);
twoHander->setMaxDamage(139);
twoHander->setWeaponSpeed(3.7f);
twoHander->setSlot(ItemSlot::TwoHand);
PC->setMainHandItem(twoHander);
sim->setPC(PC);
}
if (enemy == nullptr) {
enemy = new Enemy();
enemy->setName("Target Dummy");
enemy->setHp(20000);
enemy->setPhysicalDamageReduction(0.20f);
enemy->setLevel(27);
sim->getEnemyList().push_back(enemy);
if (actionsDialog != nullptr) {
actionsDialog->setEnemyListPtr(&sim->getEnemyList());
}
}
static bool didPreBattleShout;
didPreBattleShout = false;
static bool didPreWildStrikes;
didPreWildStrikes = false;
if (availableActionsForClass == nullptr) {
availableActionsForClass = new PriorityActionList();
{
PriorityAction *PA = new PriorityAction(gal->BattleShout, 4);
PA->setInternalName("free_battle_shout");
PA->setNameOverride("Start: Free Battle Shout");
PA->setIgnoreGcd(true);
PA->setIgnoreResourceCost(true);
//bool didPreBattleShout = false;
SET_PREDICATE_WITH_TEXT(PA, [&](PlayerCharacter *PC, float timestamp) {if (!didPreBattleShout){didPreBattleShout=true;return true;} return false;});
//PA->setPredicate([&](PlayerCharacter *PC, float timestamp) {if (!didPreBattleShout){didPreBattleShout=true;return true;} return false;});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->PrintPlayerStats);
PA->setInternalName("print_player_stats");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->PrintDps);
PA->setInternalName("print_dps");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->Charge, 1);
PA->setInternalName("charge");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->MeleeMainhandAutoAttack);
PA->setInternalName("mainhand_auto");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->MeleeOffhandAutoAttack);
PA->setInternalName("offhand_auto");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->Execute, 1);
PA->setInternalName("execute");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->Rend, 3);
PA->setInternalName("rend");
//PA->setPredicate([=](PlayerCharacter *PC, float timestamp){return !PC->getTarget()->hasDebuff(gal->Rend->getGrantedDebuff());});
SET_PREDICATE_WITH_TEXT(PA, [=](PlayerCharacter *PC, float timestamp){return !PC->getTarget()->hasDebuff(gal->Rend->getGrantedDebuff());});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->Bloodrage, 1);
PA->setInternalName("bloodrage");
SET_PREDICATE_WITH_TEXT(PA, [=](PlayerCharacter *PC, float timestamp){return !PC->getTarget()->hasBuff(gal->Bloodrage->getGrantedBuff());});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->MortalStrike, 1);
PA->setInternalName("mortal_strike");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->Whirlwind, 1);
PA->setInternalName("whirlwind");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->Slam, 2);
PA->setInternalName("slam");
// PA->setPredicate([](PlayerCharacter *PC, float timestamp){if (PC->getPriorityActionList()->getActionFromAbilityName("Main-hand attack")->getAbility()->getTimeSinceLastUsed(timestamp) < 0.20f) return true; return false;});
SET_PREDICATE_WITH_TEXT(PA, [](PlayerCharacter *PC, float timestamp){if (PC->getPriorityActionList()->getActionFromAbilityName("Main-hand attack")->getAbility()->getTimeSinceLastUsed(timestamp) < 0.20f) return true; return false;});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->HeroicStrike, 4);
PA->setInternalName("heroic_strike");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->HeroicStrike, 4);
PA->setNameOverride("Heroic Strike @ 100 Rage");
PA->setInternalName("heroic_strike_100_rage");
SET_PREDICATE_WITH_TEXT(PA, [](PlayerCharacter *PC, float timestamp){if (PC->getResource() == PC->getResourceMax()) return true; return false;});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->QuickStrike, 1);
PA->setInternalName("quick_strike");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->RagingBlow, 1);
PA->setInternalName("raging_blow");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(nullptr, 1);
PA->setNameOverride("Wait for 80 rage");
PA->setInternalName("wait_for_rage");
PA->setSkipToNextActionIfUseConditionFails(false);
SET_PREDICATE_WITH_TEXT(PA, [](PlayerCharacter *PC, float timestamp){if (PC->getResource() >= 80) return true; return false;});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->QuickStrike, 1);
PA->setNameOverride("Quick Strike (Follow-Up Only)");
PA->setInternalName("qs_follow_up");
SET_PREDICATE_WITH_TEXT(PA, [](PlayerCharacter *PC, float timestamp){if (PC->getLastUsedAction() == PC->getPriorityActionList()->getActionFromInternalName("quick_strike")) return true; return false;});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->FreeWildStrikes, 1);
PA->setNameOverride("Start: Free Wild Strikes");
PA->setInternalName("free_wild_strikes");
PA->setIgnoreGcd(true);
PA->setIgnoreResourceCost(true);
SET_PREDICATE_WITH_TEXT(PA, [&](PlayerCharacter *PC, float timestamp) {if (!didPreWildStrikes){didPreWildStrikes=true;return true;} return false;});
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->Overpower, 1);
PA->setInternalName("overpower");
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->FreeBlessingOfMight, 3);
PA->setInternalName("blessing_of_might");
PA->setIgnoreGcd(true);
PA->setIgnoreResourceCost(true);
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->FreeMarkOfTheWild, 3);
PA->setInternalName("mark_of_the_wild");
PA->setIgnoreGcd(true);
PA->setIgnoreResourceCost(true);
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->FreeBlessingOfKings, 3);
PA->setInternalName("blessing_of_kings");
PA->setIgnoreGcd(true);
PA->setIgnoreResourceCost(true);
availableActionsForClass->getPriorityActions().push_back(PA);
}
{
PriorityAction *PA = new PriorityAction(gal->FreeStrengthBonus, 1);
PA->setInternalName("strength_bonus");
PA->setIgnoreGcd(true);
PA->setIgnoreResourceCost(true);
availableActionsForClass->getPriorityActions().push_back(PA);
}
}
if (PAL == nullptr) {
PAL = new PriorityActionList();
availableActionsForClass->removeExistingAction(PAL->addNewAction(availableActionsForClass->getActionFromInternalName("free_battle_shout")));
availableActionsForClass->removeExistingAction(PAL->addNewAction(availableActionsForClass->getActionFromInternalName("mainhand_auto")));
availableActionsForClass->removeExistingAction(PAL->addNewAction(availableActionsForClass->getActionFromInternalName("offhand_auto")));
if (this->PC != nullptr) {
this->PC->setPriorityActionList(PAL);
}
}
}
void MainWindow::simCleanup()
{
delete sim;
sim = nullptr;
delete PC;
PC = nullptr;
delete enemy;
enemy = nullptr;
delete PAL;
PAL = nullptr;
delete availableActionsForClass;
availableActionsForClass = nullptr;
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->simSetup();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_simButton_clicked()
{
this->simSetup();
PC->getCombatLog()->setEnabled(true);
this->sim->reset();
sim->resetIterationsData();
sim->simulate(PAL);
this->ui->simOutput->clear();
for (auto& text : PC->getCombatLog()->getLogText()) {
//this->ui->simOutput->appendPlainText(QString::fromStdString(text));
this->ui->simOutput->appendHtml(QString::fromStdString(text));
}
this->ui->simOutput->appendHtml("<br>");
std::stringstream ss;
this->sim->printIterationSummary(ss);
this->ui->simOutput->appendHtml(QString::fromStdString(ss.str()));
}
void MainWindow::on_actionsButton_clicked()
{
this->simSetup();
actionsDialog->setPC(this->PC);
actionsDialog->clearAllPriorityActions();
actionsDialog->addPriorityActionList(this->PAL);
actionsDialog->addClassPriorityActionList(this->availableActionsForClass);
//actionsDialog->setModal(true);
actionsDialog->setWindowTitle("Player Priority Actions");
actionsDialog->show();
}
void MainWindow::on_characterButton_clicked()
{
this->simSetup();
characterSheet->setPC(this->PC);
characterSheet->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
//characterSheet->setModal(true);
characterSheet->show();
}
void MainWindow::on_talentsButton_clicked()
{
this->simSetup();
//talentsDialog->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
talentsDialog->show();
}
void MainWindow::on_iterateButton_clicked()
{
QInputDialog qin;
qin.exec();
int value = qin.textValue().toInt();
if (value > 0) {
this->simSetup();
this->ui->simOutput->clear();
sim->resetIterationsData();
PC->getCombatLog()->setEnabled(false);
for (int i=0; i<value; ++i) {
this->simSetup();
this->sim->reset();
sim->simulate(PAL);
}
std::stringstream ss;
// for (auto& text : PC->getCombatLog()->getLogText()) {
// this->ui->simOutput->appendHtml(QString::fromStdString(text));
// }
this->sim->printIterationSummary(ss);
this->ui->simOutput->appendHtml(QString::fromStdString(ss.str()));
}
}