-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttackPowers.h
1460 lines (1390 loc) · 88.1 KB
/
AttackPowers.h
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef ATTACKPOWERS_H
#define ATTACKPOWERS_H
#include "powers.h"
#ifndef ISHSC
#include "sheet.h"
#endif
class Blast: public AllPowers {
public:
Blast(): AllPowers("Blast") { }
Blast(const Blast& s): AllPowers(s) { }
Blast(Blast&& s): AllPowers(s) { }
Blast(const QJsonObject& json): AllPowers(json) { v._dice = json["dice"].toInt(0);
v._pded = json["pded"].toInt(0);
v._stun = json["stun"].toBool(false);
}
virtual Blast& operator=(const Blast& s) {
if (this != &s) {
AllPowers::operator=(s);
v = s.v;
}
return *this;
}
virtual Blast& operator=(Blast&& s) {
AllPowers::operator=(s);
v = s.v;
return *this;
}
Fraction adv() override { return Fraction(0); }
QString description(bool showEND = false) override { return optOut(showEND); }
void form(QWidget* parent, QVBoxLayout* layout) override { AllPowers::form(parent, layout);
dice = createLineEdit(parent, layout, "Dice of Damage?", std::mem_fn(&Power::numeric));
pded = createComboBox(parent, layout, "Versus?", { "PD", "ED" });
stun = createCheckBox(parent, layout, "STUN Only");
}
Fraction lim() override { return Fraction(0); }
Points points(bool noStore = false) override { if (!noStore) store();
return Points(v._dice * 5); }
void restore() override { vars s = v;
AllPowers::restore();
dice->setText(QString("%1").arg(s._dice));
pded->setCurrentIndex(s._pded);
stun->setChecked(s._stun);
v = s;
}
void store() override { AllPowers::store();
v._dice = dice->text().toInt();
v._pded = pded->currentIndex();
v._stun = stun->isChecked();
}
QJsonObject toJson() const override { QJsonObject obj = AllPowers::toJson();
obj["dice"] = v._dice;
obj["pded"] = v._pded;
obj["stun"] = v._stun;
return obj;
}
private:
struct vars {
int _dice = 0;
int _pded = -1;
bool _stun = false;
} v;
QLineEdit* dice;
QComboBox* pded;
QCheckBox* stun;
QString optOut(bool showEND) {
if (v._dice < 1 || v._pded < 0) return "<incomplete>";
QString res;
if (showEND && !nickname().isEmpty()) res = nickname() + " " + end() + " ";
res += QString("%1").arg(v._dice) + "d6 Blast vs " + ((v._pded == 0) ? "PD" : "ED");
if (v._stun) res += "; STUN Only";
return res;
}
void numeric(int) override {
QString txt = dice->text();
#ifndef ISHSC
PowerDialog::ref().updateForm();
#endif
if (txt.isEmpty() || isNumber(txt)) return;
dice->undo();
}
};
class ChangeEnvironment: public AllPowers {
private:
struct effects {
int which;
int idx;
int level;
QList<QWidget*> widgets;
QString val;
effects(int w, int i, int l, QList<QWidget*> wl = { }, QString v = "")
: which(w)
, idx(i)
, level(l)
, widgets(wl)
, val(v) { }
};
bool _create = true;
bool _data = true;
int _index;
public:
ChangeEnvironment(): AllPowers("Change Environment") { }
ChangeEnvironment(const ChangeEnvironment& s): AllPowers(s) { }
ChangeEnvironment(ChangeEnvironment&& s): AllPowers(s) { }
ChangeEnvironment(const QJsonObject& json): AllPowers(json) { QJsonArray arr = json["effects"].toArray();
_create = false;
_data = true;
for (int i = 0; i < arr.count(); ++i) {
QJsonObject obj = arr[i].toObject();
effects eff(obj["which"].toInt(0),
obj["idx"].toInt(0),
obj["level"].toInt(0),
{ },
obj["val"].toString(""));
v._effects.push_back(eff);
}
v._lasting = json["lasting"].toInt(-1);
v._varying = json["varying"].toBool(false);
v._envs = json["envs"].toInt(-1);
v._what = json["what"].toString("");
}
virtual ChangeEnvironment& operator=(const ChangeEnvironment& s) {
if (this != &s) {
AllPowers::operator=(s);
v = s.v;
}
return *this;
}
virtual ChangeEnvironment& operator=(ChangeEnvironment&& s) {
AllPowers::operator=(s);
v = s.v;
return *this;
}
Fraction adv() override { return (v._envs + 1) * Fraction(1, 4); }
QString description(bool showEND = false) override { return optOut(showEND); }
void form(QWidget* parent, QVBoxLayout* layout) override { AllPowers::form(parent, layout);
effect = createComboBox(parent, layout, "Effects?", { "",
"Movement",
"PER Roll for one Sense",
"PER Roll for one Sense Group",
"Characteristic Roll",
"Skill Roll",
"Increase Temperature",
"Decrease Temperature",
"Range Modifier",
"Negative Combat Modifier▲",
"Characteristic Roll and all assoc. Skill Rolls",
"Damage",
"Telekinesis",
"Increate Wind Level",
"Decrease Wind Level"
},
std::mem_fn(&Power::activate));
lasting = createComboBox(parent, layout, "Lasting?", { "", "1 Turn", "1 Minute", "5 Minutes", "20 Minutes",
"1 Hour", "6 Hours", "1 Day", "1 Week",
"1 Month", "1 Season", "1 Year", "5 Years" });
varying = createCheckBox(parent, layout, "Varying Combat Effects");
envs = createComboBox(parent, layout, "Varying Environments?", { "",
"Very Limited Group",
"Limited Group",
"Broad Group"
});
what = createLineEdit(parent, layout, "What Environmets?");
_create = true;
_data = false;
_index = 0;
_layout = layout;
_parent = parent;
for (auto& effect: v._effects) { indexed(effect.which, NoUpdate); ++_index; }
_data = true;
}
Fraction lim() override { return Fraction(0); }
QJsonObject toJson() const override { QJsonObject obj = AllPowers::toJson();
QJsonArray arr;
for (auto& effect: v._effects) {
QJsonObject eff;
eff["which"] = effect.which;
eff["idx"] = effect.idx;
eff["level"] = effect.level;
eff["val"] = effect.val;
arr.append(eff);
}
obj["effects"] = arr;
obj["lasting"] = v._lasting;
obj["varying"] = v._varying;
obj["envs"] = v._envs;
obj["what"] = v._what;
return obj;
}
private:
struct vars {
QList<effects> _effects;
int _lasting = -1;
bool _varying = false;
int _envs = -1;
QString _what = "";
} v;
QVBoxLayout* _layout;
QWidget* _parent;
QComboBox* effect;
QComboBox* lasting;
QCheckBox* varying;
QComboBox* envs;
QLineEdit* what;
void restore() override {
vars s = v;
AllPowers::restore();
for (auto& effect: s._effects) {
int count = effect.widgets.count();
for (int i = 0; i < count; ++i) {
QLineEdit* edit = dynamic_cast<QLineEdit*>(effect.widgets[i]);
if (edit) edit->setText(effect.val);
QComboBox* combo = dynamic_cast<QComboBox*>(effect.widgets[i]);
if (combo) combo->setCurrentIndex(effect.idx);
}
}
lasting->setCurrentIndex(s._lasting);
varying->setChecked(s._varying);
envs->setCurrentIndex(s._envs);
what->setText(s._what);
v = s;
_create = true;
_data = true;
}
void store() override {
AllPowers::store();
for (auto& effect: v._effects) {
int count = effect.widgets.count();
for (int i = 0; i < count - 1; ++i) {
QLineEdit* edit = dynamic_cast<QLineEdit*>(effect.widgets[i]);
if (edit) effect.val = edit->text();
QComboBox* combo = dynamic_cast<QComboBox*>(effect.widgets[i]);
if (combo) effect.idx = combo->currentIndex();
}
}
v._lasting = lasting->currentIndex();
v._varying = varying->isChecked();
v._envs = envs->currentIndex();
v._what = what->text();
}
void deleteEffect(QWidget* w) {
for (auto effect = v._effects.cbegin(); effect != v._effects.cend(); ++effect) {
for (const auto& wgt: effect->widgets) if (w == wgt) {
for (const auto& wgt: effect->widgets) wgt->deleteLater();
v._effects.erase(effect);
return;
}
}
}
effects& findEffect(QWidget* w) {
for (auto& effect: v._effects) {
for (const auto& wgt: effect.widgets) if (w == wgt) return effect;
}
static effects none { -1, -1, -1, { }, "" };
return none;
}
Points points(bool noStore = false) override {
if (!noStore) store();
Points pts = (v._lasting + 1) * 2_cp;
if (v._varying) pts += 10_cp;
for (const auto& effect: v._effects) {
switch (effect.which) {
case 0: break;
case 1: pts = pts + effect.level; break;
case 2: pts = pts + effect.level * 2_cp; break;
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9: pts = pts + effect.level * 3_cp; break;
case 10: pts = pts + effect.level * 4_cp; break;
case 11:
case 12:
case 13:
case 14: pts = pts + effect.level * 5_cp; break;
}
}
return pts;
}
void activate(int pick, int) override {
indexed(pick, true);
}
#ifdef ISHSC
void indexed(int pick, bool) {
#else
void indexed(int pick, bool update = DoUpdate) {
#endif
int idx = _layout->indexOf(lasting);
QList<QWidget*> widgets { };
switch (pick) {
case 0:
break;
case 1: // Movement
if (_create) {
widgets.emplaceBack(createComboBox(_parent, _layout, "Movement Type?", { "",
"Running",
"Swimming",
"Jumping",
"Flight",
"Teleportation",
"Tunneling"
}, idx));
widgets.emplaceBack(createLineEdit(_parent, _layout, "Movement Penalty?", std::mem_fn(&Power::numeric), idx + 1));
if (_data) v._effects.emplaceBack(0, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(0, -1, 0, widgets);
break;
case 2: // PER Roll for one Sense
if (_create) {
widgets.emplaceBack(createComboBox(_parent, _layout, "Sense?", { "",
"Normal Hearing",
"Active Sonar",
"Ultrasonic Perception",
"Mental Awareness",
"Mind Scan",
"Radio Perception",
"Radar",
"Normal Sight",
"Nightvision",
"Infrared Pereception",
"Ultraviolet Perception",
"Spatial Awreness",
"Clairsentience",
"Normal Smell",
"Normal Taste",
"Normal Touch"
}, idx));
widgets.emplaceBack(createLineEdit(_parent, _layout, "PER Roll Penalty?", std::mem_fn(&Power::numeric), idx + 1));
if (_data) v._effects.emplaceBack(1, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(1, -1, 0, widgets);
break;
case 3: // PER Rolll for one Sense Group
if (_create) {
widgets.emplaceBack(createComboBox(_parent, _layout, "Sense Group?", { "",
"Hearing",
"Mental",
"Radio",
"Sight",
"Smell/Taste",
"Touch"
}, idx));
widgets.emplaceBack(createLineEdit(_parent, _layout, "PER Roll Penalty?", std::mem_fn(&Power::numeric), idx + 1));
if (_data) v._effects.emplaceBack(2, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(2, -1, 0, widgets);
break;
case 4: // Characteristic Roll
if (_create) {
widgets.emplaceBack(createComboBox(_parent, _layout, "Charactreristic?", { "",
"STR",
"DEX",
"CON",
"INT",
"EGO",
"PRE"
}, idx));
widgets.emplaceBack(createLineEdit(_parent, _layout, "Characteristic Roll Penalty?", std::mem_fn(&Power::numeric), idx + 1));
if (_data) v._effects.emplaceBack(3, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(3, -1, 0, widgets);
break;
case 5: // Skill Roll
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Skills?", idx));
widgets.emplaceBack(createLineEdit(_parent, _layout, "Skill Roll Penalty?", std::mem_fn(&Power::numeric), idx + 1));
if (_data) v._effects.emplaceBack(4, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(4, -1, 0, widgets);
break;
case 6: // Increase Temperature
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Temperature Levels Increase?", std::mem_fn(&Power::numeric), idx));
if (_data) v._effects.emplaceBack(5, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(5, -1, 0, widgets);
break;
case 7: // Decrease Temperature
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Temperature Levels Decrease?", std::mem_fn(&Power::numeric), idx));
if (_data) v._effects.emplaceBack(6, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(6, -1, 0, widgets);
break;
case 8: // Range Modifier
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Range Modifier Penalty?", std::mem_fn(&Power::numeric), idx));
if (_data) v._effects.emplaceBack(7, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(7, -1, 0, widgets);
break;
case 9: // Negative Combat Modifier▲
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Combat Modifier▲?", idx));
widgets.emplaceBack(createLineEdit(_parent, _layout, "Penalty?", std::mem_fn(&Power::numeric), idx + 1));
if (_data) v._effects.emplaceBack(8, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(8, -1, 0, widgets);
break;
case 10: // Characteristic Roll and all assoc. Skill Rolls
if (_create) {
widgets.emplaceBack(createComboBox(_parent, _layout, "Charactreristic?", { "",
"STR",
"DEX",
"CON",
"INT",
"EGO",
"PRE"
}, idx));
widgets.emplaceBack(createLineEdit(_parent, _layout, "Characteristicc & Skill Roll Penalty?", std::mem_fn(&Power::numeric), idx + 1));
if (_data) v._effects.emplaceBack(9, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(9, -1, 0, widgets);
break;
case 11: // Damage
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Damage Points?", std::mem_fn(&Power::numeric), idx));
if (_data) v._effects.emplaceBack(10, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(10, -1, 0, widgets);
break;
case 12: // Telekinesis
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Telekinetic STR?", std::mem_fn(&Power::numeric), idx));
if (_data) v._effects.emplaceBack(11, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(11, -1, 0, widgets);
break;
case 13: // Increase Wind Level
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Wind Increase?", std::mem_fn(&Power::numeric), idx));
if (_data) v._effects.emplaceBack(12, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(12, -1, 0, widgets);
break;
case 14: // Decrease Wind Level
if (_create) {
widgets.emplaceBack(createLineEdit(_parent, _layout, "Wind Decrease?", std::mem_fn(&Power::numeric), idx));
if (_data) v._effects.emplaceBack(13, -1, 0, widgets);
else v._effects[_index].widgets = widgets;
} else if (_data) v._effects.emplaceBack(13, -1, 0, widgets);
break;
}
#ifndef ISHSC
if (update) PowerDialog::ref().updateForm();
#endif
}
QString describe(const effects& effect) {
if (effect.idx < 0) return "";
QStringList movement { "None",
"Running",
"Swimming",
"Jumping",
"Flight",
"Teleportation",
"Tunneling" };
QStringList sense { "None",
"Normal Hearing",
"Active Sonar",
"Ultrasonic Perception",
"Mental Awareness",
"Mind Scan",
"Radio Perception",
"Radar",
"Normal Sight",
"Nightvision",
"Infrared Pereception",
"Ultraviolet Perception",
"Normal Smell",
"Normal Taste",
"Normal Touch" };
QStringList senseGroup { "None",
"Hearing",
"Mental",
"Radio",
"Sight",
"Smell/Taste",
"Touch" };
QStringList stat { "None",
"STR",
"DEX",
"CON",
"INT",
"EGO",
"PRE" };
switch (effect.which) {
case 0: return QString("-%1m ").arg(effect.level) + movement[effect.idx];
case 1: return QString("-%1 PER Roll w/").arg(effect.level) + sense[effect.idx];
case 2: return QString("-%1 PER Roll w/").arg(effect.level) + senseGroup[effect.idx];
case 3: return QString("-%1 Roll w/").arg(effect.level) + stat[effect.idx];
case 4: return QString("-%1 w/").arg(effect.level) + effect.val;
case 5: return QString("+%1 Temperature Level%2").arg(effect.level).arg((effect.level > 1) ? "s" : "");
case 6: return QString("-%1 Temperature Level%2").arg(effect.level).arg((effect.level > 1) ? "s" : "");
case 7: return QString("+%1 to Range MOD").arg(effect.level);
case 8: return QString("-%1 w/").arg(effect.level) + effect.val + "▲";
case 9: return QString("-%1 Roll w/").arg(effect.level) + stat[effect.idx + 1] + " and Skills";
case 10: return QString("%1 Damage").arg(effect.level);
case 11: return QString("%1 Telekinetic STR").arg(effect.level);
case 12: return QString("+%1 Wind Level%2").arg(effect.level).arg((effect.level > 1) ? "s" : "");
case 13: return QString("-%1 Wind Level%2").arg(effect.level).arg((effect.level > 1) ? "s" : "");
}
return "";
}
QString optOut(bool showEND) {
if (v._effects.isEmpty() || (v._envs > 0 && v._what.isEmpty())) return "<incomplete>";
QString res;
if (showEND && !nickname().isEmpty()) res = nickname() + " " + end() + " ";
res += "Change Environment: ";
QString sep = "";
for (const auto& effect: v._effects) { res += sep + describe(effect); sep = ", "; }
sep = " (";
QStringList lasting { "1 Turn", "1 Minute", "5 Minutes", "20 Minutes",
"1 Hour", "6 Hours", "1 Day", "1 Week",
"1 Month", "1 Season", "1 Year", "5 Years" };
if (v._lasting != -1) { res += sep + "Long Lasting: " + lasting[v._lasting]; sep = "; "; }
if (v._varying) { res += sep + "Varying Combat Effects "; sep = "; "; }
if (v._envs > 0) { res += sep + " Varying Environments (" + v._what + ")"; sep += "; "; }
if (sep == "; ") res += ")";
return res;
}
void numeric(int) override {
QLineEdit* line = dynamic_cast<QLineEdit*>(sender());
QString txt = line->text();
if (!txt.isEmpty() && txt == "0") {
line->undo();
effects& effect = findEffect(line);
if (effect.widgets.count() != 0) {
deleteEffect(line);
_layout->update();
return;
}
}
if (txt.isEmpty() || isNumber(txt)) {
effects& effect = findEffect(line);
effect.level = txt.toInt();
return;
}
line->undo();
}
};
class Entangle: public AllPowers {
public:
Entangle(): AllPowers("Entangle") { }
Entangle(const Entangle& s): AllPowers(s) { }
Entangle(Entangle&& s): AllPowers(s) { }
Entangle(const QJsonObject& json): AllPowers(json) { v._dice = json["dice"].toInt(0);
v._body = json["body"].toInt(0);
v._def = json["def"].toInt(0);
v._dmg = json["dmg"].toInt(0);
v._what = json["what"].toString();
v._senses = json["senses"].toString();
v._groups = json["groups"].toString();
v._foci = json["foci"].toBool(false);
v._one = json["one"].toBool(false);
v._nodef = json["nodef"].toBool(false);
v._set = json["set"].toInt(0);
v._susc = json["susc"].toInt(0);
v._suscTo = json["suscTo"].toString();
v._vuln = json["vuln"].toInt(0);
v._vulnTo = json["vulnTo"].toString();
}
Fraction adv() override { return ((v._dmg == 0) ? Fraction(1, 4) : Fraction(0)) +
((v._dmg == 1) ? Fraction(1, 4) : Fraction(0)) +
((v._dmg == 2) ? Fraction(1, 2) : Fraction(0)) +
((v._dmg == 3) ? Fraction(1) : Fraction(0)); }
QString description(bool showEND = false) override { return optOut(showEND); }
void form(QWidget* parent, QVBoxLayout* layout) override { AllPowers::form(parent, layout);
dice = createLineEdit(parent, layout, "Dice of Entangle?", std::mem_fn(&Power::numeric));
body = createLineEdit(parent, layout, "Additional BODY dice?", std::mem_fn(&Power::numeric));
def = createLineEdit(parent, layout, "Additional Defense?", std::mem_fn(&Power::numeric));
dmg = createComboBox(parent, layout, "Damage Allocation?", { "Entagle Takes Damage And Acts As rDEF For Target",
"Entangle And Target Both Take Damage",
"Entangle Takes No Damage From Certain Attacks",
"Entangle is Transparent To All Attacks",
"Entangle Only Affected By Target"
});
what = createLineEdit(parent, layout, "Effected by What?");
senses = createLineEdit(parent, layout, "Entangle Stops Sense(s)?");
groups = createLineEdit(parent, layout, "Entangle Stops Sense Group(s)?");
foci = createCheckBox(parent, layout, "Character Can Use Foci");
one = createCheckBox(parent, layout, "Entangle Has 1 BODY");
nodef = createCheckBox(parent, layout, "No Defense");
set = createComboBox(parent, layout, "Set Effect?", { "Whole Body",
"Hands Only",
"Feet Only"
});
susc = createComboBox(parent, layout, "Susceptible?", { "Not Susceptible",
"Uncommon",
"Common",
"Very Common"});
suscTo = createLineEdit(parent, layout, "Susceptible To?");
vuln = createComboBox(parent, layout, "Vulnerable?", { "Not Vulnerable",
"Uncommon",
"Common",
"Very Common"});
vulnTo = createLineEdit(parent, layout, "Vulnerable To?");
}
Fraction lim() override { return (v._foci ? Fraction(1) : Fraction(0)) +
(v._one ? Fraction(1, 2) : Fraction(0)) +
(v._nodef ? Fraction(1, Fraction(1, 2)) : Fraction(0)) +
((v._set >= 1) ? Fraction(1) : Fraction(0)) +
((v._susc == 1) ? Fraction(1, 4) : Fraction(0)) +
((v._susc == 2) ? Fraction(1, 2) : Fraction(0)) +
((v._susc == 3) ? Fraction(1) : Fraction(0)) +
((v._vuln == 1) ? Fraction(1, 4) : Fraction(0)) +
((v._vuln == 2) ? Fraction(1, 2) : Fraction(0)) +
((v._vuln == 3) ? Fraction(1) : Fraction(0)); }
Points points(bool noStore = false) override { if (!noStore) store();
return v._dice * 10_cp +
v._body * 5_cp +
((v._def + 1) / 2) * 5_cp +
countCommas(v._senses) * 5_cp +
countCommas(v._groups) * 10_cp; }
void restore() override { vars s = v;
AllPowers::restore();
dice->setText(QString("%1").arg(s._dice));
body->setText(QString("%1").arg(s._body));
def->setText(QString("%1").arg(s._def));
dmg->setCurrentIndex(s._dmg);
what->setText(s._what);
senses->setText(s._senses);
groups->setText(s._groups);
one->setChecked(s._one);
nodef->setChecked(s._nodef);
set->setCurrentIndex(s._set);
susc->setCurrentIndex(s._susc);
suscTo->setText(s._suscTo);
vuln->setCurrentIndex(s._vuln);
vulnTo->setText(s._vulnTo);
v = s;
}
void store() override { AllPowers::store();
v._dice = dice->text().toInt();
v._body = body->text().toInt();
v._def = def->text().toInt();
v._dmg = dmg->currentIndex();
v._what = what->text();
v._senses = senses->text();
v._groups = groups->text();
v._foci = foci->isChecked();
v._one = one->isChecked();
v._nodef = nodef->isChecked();
v._set = set->currentIndex();
v._susc = susc->currentIndex();
v._suscTo = suscTo->text();
v._vuln = vuln->currentIndex();
v._vulnTo = vulnTo->text();
}
QJsonObject toJson() const override { QJsonObject obj = AllPowers::toJson();
obj["dice"] = v._dice;
obj["pded"] = v._body;
obj["def"] = v._def;
obj["dmg"] = v._dmg;
obj["what"] = v._what;
obj["senses"] = v._senses;
obj["groups"] = v._groups;
obj["foci"] = v._foci;
obj["one"] = v._one;
obj["nodef"] = v._nodef;
obj["set"] = v._set;
obj["susc"] = v._susc;
obj["suscTo"] = v._suscTo;
obj["vuln"] = v._vuln;
obj["vulnTo"] = v._vulnTo;
return obj;
}
private:
struct vars {
int _dice = 0;
int _body = 0;
int _def = 0;
int _dmg = -1;
QString _what = "";
QString _senses = "";
QString _groups = "";
bool _foci = false;
bool _one = false;
bool _nodef = false;
int _set = -1;
int _susc = -1;
QString _suscTo = "";
int _vuln = -1;
QString _vulnTo = "";
} v;
QLineEdit* dice;
QLineEdit* body;
QLineEdit* def;
QComboBox* dmg;
QLineEdit* what;
QLineEdit* senses;
QLineEdit* groups;
QCheckBox* foci;
QCheckBox* one;
QCheckBox* nodef;
QComboBox* set;
QComboBox* susc;
QLineEdit* suscTo;
QComboBox* vuln;
QLineEdit* vulnTo;
QString optOut(bool showEND) {
if (v._dice < 1 ||
(v._dmg == 2 && v._what.isEmpty()) ||
(v._susc >= 1 && v._suscTo.isEmpty()) ||
(v._vuln >= 1 && v._vulnTo.isEmpty())) return "<incomplete>";
QString res;
if (showEND && !nickname().isEmpty()) res = nickname() + " " + end() + " ";
res += QString("+%1").arg(v._dice) + "d6 Entangle";
if (v._body > 0) res += " +" + QString("+%1").arg(v._body) + "d6 (Body Only)";
if (v._def > 0) res += " +" + QString("+%1").arg(v._def) + " DEF";
QStringList dmg { "",
"Both Take Damage",
"Takes No Damage From Certain Attacks",
"Transparent To All Attacks",
"Only Affected By Target" };
if (v._dmg > 0) {
res += "; " + dmg[v._dmg];
if (v._dmg == 2) res += " (" + v._what + ")";
}
if (!v._senses.isEmpty()) {
res += "; Blocks " + v._senses;
if (!v._groups.isEmpty()) res += "and " + v._groups;
} else if (!v._groups.isEmpty()) res += "; Blocks " + v._groups;
if (v._foci) res += "; Allows use of Foci";
if (v._one) res += "; 1 BODY";
if (v._nodef) res += "; No Defense";
if (v._set > 0) {
if (v._set == 1) res += "; Only Hands";
else res += "; Only Feet";
}
QStringList common { "", " (Uncommon)", " (Common)", " (Very Common)" };
if (v._susc > 0) res += "; Susceptible to " + v._suscTo + common[v._susc];
if (v._vuln > 0) res += "; Vulnerable to " + v._vulnTo + common[v._vuln];
return res;
}
void numeric(int) override {
QString txt = dice->text();
#ifndef ISHSC
PowerDialog::ref().updateForm();
#endif
if (txt.isEmpty() || isNumber(txt)) return;
dice->undo();
}
};
class Flash: public AllPowers {
public:
Flash(): AllPowers("Flash") { }
Flash(const Flash& s): AllPowers(s) { }
Flash(Flash&& s): AllPowers(s) { }
Flash(const QJsonObject& json): AllPowers(json) { v._dice = json["dice"].toInt(0);
v._tgt = json["tgt"].toString();
v._nonTgt = json["nonTgt"].toString();
v._desolid = json["stun"].toBool(false);
v._indTgt = json["indTgt"].toString();
v._indNonTgt = json["indNonTgt"].toString();
}
virtual Flash& operator=(const Flash& s) {
if (this != &s) {
AllPowers::operator=(s);
v = s.v;
}
return *this;
}
virtual Flash& operator=(Flash&& s) {
AllPowers::operator=(s);
v = s.v;
return *this;
}
Fraction adv() override { return Fraction(0); }
QString description(bool showEND = false) override { return optOut(showEND); }
void form(QWidget* parent, QVBoxLayout* layout) override { AllPowers::form(parent, layout);
dice = createLineEdit(parent, layout, "Dice of Damage?", std::mem_fn(&Power::numeric));
tgt = createLineEdit(parent, layout, "Targeting Sense Groups?");
indTgt = createLineEdit(parent, layout, "Targeting Senses?");
nonTgt = createLineEdit(parent, layout, "Non-Targeting Sense Groups?");
indNonTgt = createLineEdit(parent, layout, "Non-Targeting Senses?");
desolid = createCheckBox(parent, layout, "Does not Effect Desolid");
}
Fraction lim() override { return v._desolid ? Fraction(1, 4) : Fraction(0); }
Points points(bool noStore = false) override { if (!noStore) store();
return v._dice * (!v._tgt.isEmpty() ? 5_cp : 3_cp) +
((countCommas(v._tgt) > 1) ? (countCommas(v._tgt) - 1) * 10_cp : 0_cp) +
((countCommas(v._nonTgt) > 0) ? (countCommas(v._nonTgt) - (v._tgt.isEmpty() ? 1 : 0)) * 5_cp : 0_cp) +
countCommas(v._indTgt) * 5_cp + countCommas(v._indNonTgt) * 3_cp;
}
void restore() override { vars s = v;
AllPowers::restore();
dice->setText(QString("%1").arg(s._dice));
tgt->setText(s._tgt);
nonTgt->setText(s._nonTgt);
desolid->setChecked(s._desolid);
indTgt->setText(s._indTgt);
indNonTgt->setText(s._indNonTgt);
v = s;
}
void store() override { AllPowers::store();
v._dice = dice->text().toInt();
v._tgt = tgt->text();
v._nonTgt = nonTgt->text();
v._desolid = desolid->isChecked();
v._indTgt = indTgt->text();
v._indNonTgt = indNonTgt->text();
}
QJsonObject toJson() const override { QJsonObject obj = AllPowers::toJson();
obj["dice"] = v._dice;
obj["tgt"] = v._tgt;
obj["nonTgt"] = v._nonTgt;
obj["desolid"] = v._desolid;
obj["indTgt"] = v._indTgt;
obj["indNonTgt"] = v._indNonTgt;
return obj;
}
private:
struct vars {
int _dice = 0;
QString _tgt = "";
QString _indTgt = "";
QString _nonTgt = "";
QString _indNonTgt = "";
bool _desolid = false;
} v;
QLineEdit* dice;
QLineEdit* tgt;
QLineEdit* indTgt;
QLineEdit* nonTgt;
QLineEdit* indNonTgt;
QCheckBox* desolid;
QString optOut(bool showEND) {
if (v._dice < 1 || (v._tgt.isEmpty() && v._nonTgt.isEmpty())) return "<incomplete>";
QString res;
if (showEND && !nickname().isEmpty()) res = nickname() + " " + end() + " ";
res += QString("+%1").arg(v._dice) + "d6 Flash vs ";
QString sep = "";
if (!v._tgt.isEmpty()) { res += sep + v._tgt; sep = ", "; }
if (!v._nonTgt.isEmpty()) { res += sep + v._nonTgt; sep = ", "; }
if (!v._indTgt.isEmpty()) { res += sep + v._indTgt; sep = ", "; }
if (!v._indNonTgt.isEmpty()) { res += sep + v._indNonTgt; sep = ", "; }
if (v._desolid) res += "; Does Not Effect Desolid";
return res;
}
void numeric(int) override {
QString txt = dice->text();
#ifndef ISHSC
PowerDialog::ref().updateForm();
#endif
if (txt.isEmpty() || isNumber(txt)) return;
dice->undo();
}
};
class HandToHandAttack: public AllPowers {
public:
HandToHandAttack(): AllPowers("Hand-To-Hand Attack") { }
HandToHandAttack(const HandToHandAttack& s): AllPowers(s) { }
HandToHandAttack(HandToHandAttack&& s): AllPowers(s) { }
HandToHandAttack(const QJsonObject& json): AllPowers(json) { v._dice = json["dice"].toInt(0);
}
virtual HandToHandAttack& operator=(const HandToHandAttack& s) {
if (this != &s) {
AllPowers::operator=(s);
v = s.v;
}
return *this;
}
virtual HandToHandAttack& operator=(HandToHandAttack&& s) {
AllPowers::operator=(s);
v = s.v;
return *this;
}
Fraction adv() override { return Fraction(0); }
QString description(bool showEND = false) override { return optOut(showEND); }
void form(QWidget* parent, QVBoxLayout* layout) override { AllPowers::form(parent, layout);
dice = createLineEdit(parent, layout, "Dice of Damage?", std::mem_fn(&Power::numeric));
}
Fraction lim() override { return Fraction(1, 4); }
Points points(bool noStore = false) override { if (!noStore) store();
return Points(v._dice * 5); }
void restore() override { vars s = v;
AllPowers::restore();
dice->setText(QString("%1").arg(s._dice));
v = s;
}
void store() override { AllPowers::store();
v._dice = dice->text().toInt();
}
QJsonObject toJson() const override { QJsonObject obj = AllPowers::toJson();
obj["dice"] = v._dice;
return obj;
}
private:
struct vars {
int _dice = 0;
} v;
QLineEdit* dice;
QString optOut(bool showEND) {
if (v._dice < 1) return "<incomplete>";
QString res;
if (showEND && !nickname().isEmpty()) res = nickname() + " " + end() + " ";
res += QString("+%1").arg(v._dice) + "d6 HA; Hand-To-Hand Attack";
return res;
}
void numeric(int) override {
QString txt = dice->text();
#ifndef ISHSC
PowerDialog::ref().updateForm();
#endif
if (txt.isEmpty() || isNumber(txt)) return;
dice->undo();
}
};
class KillingAttack: public AllPowers {
public:
KillingAttack(): AllPowers("Killing Attack") { }
KillingAttack(const KillingAttack& s): AllPowers(s) { }
KillingAttack(KillingAttack&& s): AllPowers(s) { }
KillingAttack(const QJsonObject& json): AllPowers(json) { v._dice = json["dice"].toInt(0);
v._range = json["range"].toBool(false);
v._extra = json["extra"].toInt(0);
v._pded = json["pded"].toInt(0);
v._incr = json["incr"].toInt(0);
v._decr = json["decr"].toInt(0);
v._str = json["str"].toBool(false);
}
virtual KillingAttack& operator=(const KillingAttack& s) {
if (this != &s) {
AllPowers::operator=(s);
v = s.v;
}
return *this;
}
virtual KillingAttack& operator=(KillingAttack&& s) {
AllPowers::operator=(s);
v = s.v;
return *this;
}
Fraction adv() override { return v._incr * Fraction(1, 4); }
QString description(bool showEND = false) override { return optOut(showEND); }
void form(QWidget* parent, QVBoxLayout* layout) override { AllPowers::form(parent, layout);
range = createCheckBox(parent, layout, "Ranged");
dice = createLineEdit(parent, layout, "Dice of Damage?", std::mem_fn(&Power::numeric));
extra = createComboBox(parent, layout, "Partial Dice?", { "", "+1", Fraction(1, 2).toString() + "d6" });
pded = createComboBox(parent, layout, "Versus?", { "PD", "ED" });
incr = createLineEdit(parent, layout, "STUN Multiplier Increases?", std::mem_fn(&Power::numeric));
decr = createComboBox(parent, layout, "STUN Multiplier Decreases?", { "None", "1x", "2x" });
str = createCheckBox(parent, layout, "No STR Bonus");
}
Fraction lim() override { return (v._decr + 1) * Fraction(1, 4) + (v._str ? Fraction(1, 2) : Fraction(0)); }
Points points(bool noStore = false) override { if (!noStore) store();
return v._dice * 15 + ((v._extra > -1) ? v._extra * 5_cp : 0_cp); }
void restore() override { vars s = v;
AllPowers::restore();
range->setChecked(s._range);
dice->setText(QString("%1").arg(s._dice));
extra->setCurrentIndex(s._extra);
pded->setCurrentIndex(s._pded);