This repository has been archived by the owner on Apr 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
omae.js
3569 lines (3215 loc) · 169 KB
/
omae.js
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
var priorityA,
priorityB,
priorityC,
priorityD,
priorityE,
metatype,
attribute = 0,
specAttribute = 0,
magres, //what kind of emergence or awakening a character is
skills = 0, //skill points
knowledgepoints = 0, //knowledge skill points
skillgroups = 0, //skill group points
skillgroupmax = 6, //this is the max rating for a skill group
spells = 0, //number of spells one can learn
powerPoints = 0.0, //adept power points
forms = 0, //number of complex forms
nuyen = 0, //money
ess = 6.0,
reachmod = 0, //reachmod for trolls
karma = 25,
//var iniphy=attributes.current.int+attributes.current.rea;
dataP = 0, //data processing, for TM's
knowledgeType, //This holds which knowledge type is selected when submitting a new knowledge skill
focinumber = 0, //number of foci that are bonded
fociRating = 0, //the total rating of the foci
fociMaxRating = attributes.current.mag * 2, //max rating or total foci
maxAvail = 12; //the max availibility at chargen
var knowledgeSkills = [];
var spellType = [
"Combat",
"Detection",
"Health",
"Illusion",
"Manipulation"
]
var spiritType = [
"Air",
"Beasts",
"Blood",
"Guardian",
"Guidance",
"Earth",
"Fire",
"Insect-Caretaker",
"Insect-Nymph",
"Insect-Scout",
"Insect-Soldier",
"Insect-Worker",
"Man",
"Plant",
"Shadow",
"Shedim",
"Task",
"Water"
]
var ritualKeywords = [
"Anchored",
"Adept",
"Blood",
"Contractual",
"Mana",
"Material Link",
"Minion",
"Organic Link",
"Spell",
"Spotter"
];
var inventory = {};
setUpSkills();
$(".a, .b, .c, .d, .e").click( //This controls the Priority table
selectPriority
);
function selectPriority() { //Priority table controls
var classPrior; //this is the class of what was clicked
var priorityL; //Priority Level, holds which priority goes into which level
fnselect($(this));
switch (true) {
case $(this).hasClass('a'):
classPrior = "a";
break;
case $(this).hasClass('b'):
classPrior = "b";
break;
case $(this).hasClass('c'):
classPrior = "c";
break;
case $(this).hasClass('d'):
classPrior = "d";
break;
case $(this).hasClass('e'):
classPrior = "e";
break;
}
var className = $(this).attr("class");
switch (className) {
case 'metatype ' + classPrior + ' selected':
priorityL = "metatype";
break;
case 'attribute ' + classPrior + ' selected':
priorityL = "attribute";
break;
case 'magres ' + classPrior + ' selected':
priorityL = "magres";
break;
case 'skillz ' + classPrior + ' selected':
priorityL = "skillz";
break;
case 'resource ' + classPrior + ' selected':
priorityL = "resource";
break;
case 'prilevel ' + classPrior + ' selected':
priorityL = "prilevel";
break;
default:
priorityL = "prilevel";
break;
}
switch (true) {
case $(this).hasClass('a'):
priorityA = priorityL;
break;
case $(this).hasClass('b'):
priorityB = priorityL;
break;
case $(this).hasClass('c'):
priorityC = priorityL;
break;
case $(this).hasClass('d'):
priorityD = priorityL;
break;
case $(this).hasClass('e'):
priorityE = priorityL;
break;
}
deactivate(priorityL, $(this));
function deactivate(x, y) {
$("." + x).addClass("deact");
y.removeClass("deact");
}
switch (priorityA) {
case "metatype":
activateMT(".human");
activateMT(".elf");
activateMT(".dwarf");
activateMT(".ork");
activateMT(".troll");
break;
case "attribute":
attribute = 24;
pointUpdater(".pnt", attribute);
break;
case "magres":
activateMT(".mage");
activateMT(".techno");
activateMT(".mystic");
deactivateMT(".adept");
deactivateMT(".aspect");
break;
case "skillz":
skillgroups = 10;
skills = 46;
break;
case "resource":
nuyen = 450000;
break;
}
switch (priorityB) {
case "metatype":
activateMT(".human");
activateMT(".elf");
activateMT(".dwarf");
activateMT(".ork");
activateMT(".troll");
break;
case "attribute":
attribute = 20;
pointUpdater(".pnt", attribute);
break;
case "magres":
activateMT(".mage");
activateMT(".techno");
activateMT(".mystic");
activateMT(".adept");
activateMT(".aspect");
break;
case "skillz":
skillgroups = 5;
skills = 36;
break;
case "resource":
nuyen = 275000;
break;
}
switch (priorityC) {
case "metatype":
activateMT(".human");
activateMT(".elf");
activateMT(".dwarf");
activateMT(".ork");
deactivateMT(".troll");
break;
case "attribute":
attribute = 16;
pointUpdater(".pnt", attribute);
break;
case "magres":
activateMT(".mage");
activateMT(".techno");
activateMT(".mystic");
activateMT(".adept");
activateMT(".aspect");
break;
case "skillz":
skillgroups = 2;
skills = 28;
break;
case "resource":
nuyen = 140000;
break;
}
switch (priorityD) {
case "metatype":
activateMT(".human");
activateMT(".elf");
deactivateMT(".dwarf");
deactivateMT(".ork");
deactivateMT(".troll");
break;
case "attribute":
attribute = 14;
pointUpdater(".pnt", attribute);
break;
case "magres":
deactivateMT(".mage");
deactivateMT(".techno");
deactivateMT(".mystic");
activateMT(".adept");
activateMT(".aspect");
break;
case "skillz":
skillgroups = 0;
skills = 22;
break;
case "resource":
nuyen = 50000;
break;
}
switch (priorityE) {
case "metatype":
activateMT(".human");
deactivateMT(".elf");
deactivateMT(".dwarf");
deactivateMT(".ork");
deactivateMT(".troll");
break;
case "attribute":
attribute = 12;
pointUpdater(".pnt", attribute);
break;
case "magres":
deactivateMT(".mage");
deactivateMT(".techno");
deactivateMT(".mystic");
deactivateMT(".adept");
deactivateMT(".aspect");
break;
case "skillz":
skillgroups = 0;
skills = 18;
break;
case "resource":
nuyen = 6000;
break;
}
function activateMT(x) {
$(x).removeClass("deact");
}
function deactivateMT(x) {
$(x).addClass("deact");
}
disUpdater();
}
function fnselect(x) { //fucntion for highlighting what has been selected
x.siblings().removeClass("selected");
x.addClass('selected');
}
$(".human, .elf, .dwarf, .ork, .troll").click( //this part will call the metatype select fuction when a metatype button is clicked
selectMetatype
);
function selectMetatype() { //Metatype controls
if ($(this).hasClass('deact')) { //this will make it so that if the button is deactivated that it won't do anything
return;
} else {
fnselect($(this)); //highlights what's been clicked on
if ($(this).hasClass('human')) { //this stuff sets the metatype attributes and stuff
resetAtt();
metatype = "human";
attributes.current.edg = 2;
attributes.maximum.edgmax = 7;
attributes.minimum.edgmin = 2;
disUpdater();
$("#racial").empty().append($("<p>None<br>Boring</p>"));
switch ("metatype") {
case priorityA:
specAttribute = 9;
break;
case priorityB:
specAttribute = 7;
break;
case priorityC:
specAttribute = 5;
break;
case priorityD:
specAttribute = 3;
break;
case priorityE:
specAttribute = 1;
break;
}
}
if ($(this).hasClass('elf')) {
resetAtt();
metatype = "elf";
attributes.current.agi = 2;
attributes.current.cha = 3;
attributes.maximum.agimax = 7;
attributes.minimum.agimin = 2;
attributes.maximum.chamax = 8;
attributes.minimum.chamin = 3;
disUpdater();
$("#racial").empty().append($("<p>Low-Light Vision</p>"));
switch ("metatype") {
case priorityA:
specAttribute = 8;
break;
case priorityB:
specAttribute = 6;
break;
case priorityC:
specAttribute = 3;
break;
case priorityD:
specAttribute = 0;
break;
}
}
if ($(this).hasClass('dwarf')) {
resetAtt();
metatype = "dwarf";
attributes.current.bod = 3;
attributes.current.str = 3;
attributes.current.wil = 2;
attributes.maximum.bodmax = 8;
attributes.maximum.reamax = 5;
attributes.maximum.strmax = 8;
attributes.maximum.wilmax = 7;
attributes.minimum.bodmin = 3;
attributes.minimum.strmin = 3;
attributes.minimum.wilmin = 2;
disUpdater();
$("#racial").empty().append($("<p>Thermographic Vision<br>+2 Pathogen/Toxic Resist<br>20% Lifestyle increase</p>"));
switch ("metatype") {
case priorityA:
specAttribute = 7;
break;
case priorityB:
specAttribute = 4;
break;
case priorityC:
specAttribute = 1;
break;
}
}
if ($(this).hasClass('ork')) {
resetAtt();
metatype = "ork";
attributes.current.bod = 4;
attributes.current.str = 3;
attributes.maximum.bodmax = 9;
attributes.maximum.strmax = 8;
attributes.maximum.logmax = 5;
attributes.maximum.chamax = 5;
attributes.minimum.bodmin = 4;
attributes.minimum.strmin = 3;
disUpdater();
$("#racial").empty().append($("<p>Low-Light Vision</p>"));
switch ("metatype") {
case priorityA:
specAttribute = 7;
break;
case priorityB:
specAttribute = 4;
break;
case priorityC:
specAttribute = 0;
break;
}
}
if ($(this).hasClass('troll')) {
resetAtt();
metatype = "troll";
attributes.current.bod = 5;
attributes.current.str = 5;
attributes.maximum.bodmax = 10;
attributes.maximum.strmax = 10;
attributes.maximum.agimax = 5;
attributes.maximum.logmax = 5;
attributes.maximum.intmax = 5;
attributes.maximum.chamax = 4;
attributes.minimum.bodmin = 5;
attributes.minimum.strmin = 5;
reachmod = 1;
disUpdater();
$("#racial").empty().append($("<p>Thermographic Vision<br>+1 Reach<br>+1 Dermal Armor<br>100% Lifestyle increase</p>"));
switch ("metatype") {
case priorityA:
specAttribute = 5;
break;
case priorityB:
specAttribute = 0;
break;
}
}
disUpdater();
}
}
function resetAtt() { //reset attribute to default
attributes.current.bod = 1;
attributes.current.agi = 1;
attributes.current.rea = 1;
attributes.current.str = 1;
attributes.current.wil = 1;
attributes.current.log = 1;
attributes.current.int = 1;
attributes.current.cha = 1;
attributes.current.edg = 1;
attributes.minimum.bodmin = 1;
attributes.minimum.agimin = 1;
attributes.minimum.reamin = 1;
attributes.minimum.strmin = 1;
attributes.minimum.wilmin = 1;
attributes.minimum.logmin = 1;
attributes.minimum.intmin = 1;
attributes.minimum.chamin = 1;
attributes.minimum.edgmin = 1;
attributes.maximum.bodmax = 6;
attributes.maximum.agimax = 6;
attributes.maximum.reamax = 6;
attributes.maximum.strmax = 6;
attributes.maximum.wilmax = 6;
attributes.maximum.logmax = 6;
attributes.maximum.intmax = 6;
attributes.maximum.chamax = 6;
attributes.maximum.edgmax = 6;
reachmod = 0;
}
//there are 10 types of people in this world. Those who understand binary, and those who don't
var updaters = { //experimenting on removing functions from the global name space
nuyenUpdater: function() {
$("#nuyen").empty().append($("<strong>" + nuyen + "¥</strong>"));
},
essUpdater: function() {
$("#essencepnt").empty().append($("<strong>" + Math.round(ess * 1000) / 1000 + "</strong>"));
},
magUpdater: function() {
$(".mag" + " .stats").empty().append($("<span>" + Math.floor(attributes.current.mag) + "/" + Math.floor(attributes.maximum.magmax) + "</span>"));
},
resUpdater: function() {
$(".res" + " .stats").empty().append($("<span>" + Math.floor(attributes.current.res) + "/" + Math.floor(attributes.maximum.resmax) + "</span>"));
}
}
disUpdater(); //runs the attribute display funcation on start up
function disUpdater() { //adds the attributes to the attribute table
renderAttStat(attributes.augment.bod, "bod", attributes.current.bod, attributes.maximum.bodmax);
renderAttStat(attributes.augment.agi, "agi", attributes.current.agi, attributes.maximum.agimax);
renderAttStat(attributes.augment.rea, "rea", attributes.current.rea, attributes.maximum.reamax);
renderAttStat(attributes.augment.str, "str", attributes.current.str, attributes.maximum.strmax);
renderAttStat(attributes.augment.wil, "wil", attributes.current.wil, attributes.maximum.wilmax);
renderAttStat(attributes.augment.log, "log", attributes.current.log, attributes.maximum.logmax);
renderAttStat(attributes.augment.int, "int", attributes.current.int, attributes.maximum.intmax);
renderAttStat(attributes.augment.cha, "cha", attributes.current.cha, attributes.maximum.chamax);
renderSpecStat("edg", attributes.current.edg, attributes.maximum.edgmax);
updaters.magUpdater();
updaters.resUpdater();
pointUpdater(".pnt", attribute);
pointUpdater(".spePnt", specAttribute);
attributes.limits.phyLimit = renderLimit(attributes.limitMod.phyLimitMod, "phyLimit", attributes.current.str + attributes.augment.str, attributes.current.bod + attributes.augment.bod, attributes.current.rea + attributes.augment.rea);
attributes.limits.socLimit = renderLimit(attributes.limitMod.socLimitMod, "socLimit", attributes.current.cha, attributes.current.wil, ess);
attributes.limits.menLimit = renderLimit(attributes.limitMod.menLimitMod, "menLimit", attributes.current.log, attributes.current.int, attributes.current.wil);
attributes.initiative.iniphy = initiativeRenderMonkey(attributes.current.rea, "meatini", attributes.initiative.iniphyDice, attributes.augment.rea);
attributes.initiative.iniast = initiativeRenderMonkey(attributes.current.int, "magicini", attributes.initiative.iniastDice, attributes.augment.int);
attributes.initiative.inimat = initiativeRenderMonkey(dataP, "coldmatini", attributes.initiative.inimatcold, 0);
attributes.initiative.inimat = initiativeRenderMonkey(dataP, "hotmatini", attributes.initiative.inimathot, 0);
renderSkills(); //this updates everything that uses a for loop
$("#skillpnt").empty().append($("<strong>" + skills + "/" + skillgroups + "</strong>"));
pointUpdater("#knowpnt", knowledgepoints);
pointUpdater("#powerpnt", powerPoints);
pointUpdater("#spellpnt", spells);
pointUpdater("#formpnt", forms);
pointUpdater("#karmapnt", karma);
updaters.essUpdater();
updaters.nuyenUpdater();
}
function pointUpdater(x, y) {
$(x).empty().append($("<strong>" + y + "</strong>"));
}
function renderAttStat(w, x, y, z) { //this shows the current level of an attribute and the attribute max
var augment = y + w;
$("." + x + " .stats").empty().append($("<span>" + y + "/" + z + "(" + augment + ")" + "</span>"));
}
function renderSpecStat(x, y, z) { //this is for special stats like edge, attributes.current.mag, and attributes.current.res
$("." + x + " .stats").empty().append($("<span>" + y + "/" + z + "</span>"));
}
function initiativeRenderMonkey(x, y, z, w) {
if (magres == "technomancer") {
dataP = attributes.current.log;
}
var ini = attributes.current.int + attributes.augment.int + x + w;
$("." + y).empty().append($("<strong>" + ini + "+" + z + "D6</strong>"));
return ini;
}
function renderLimit(v, w, x, y, z) { //function for showing and calculating limits
var limit = (x * 2 + y + z) / 3;
limit = Math.ceil(limit); //this rounds up
$("." + w).empty().append($("<strong>" + limit + "(" + (limit + v) + ")" + "</strong>"));
return limit;
}
$("#container").on("click", ".incAtt, .decAtt",
changeAtt
);
var phyAttMax = false;
var menAttMax = false;
function changeAtt() { //this function changes the attributes
var className = $(this).attr("class");
switch (className) { //This switch statement is SO LONG!
case 'incAtt Bod':
attributes.current.bod = increasePhy(attributes.current.bod, attributes.maximum.bodmax);
break;
case 'incAtt Agi':
attributes.current.agi = increasePhy(attributes.current.agi, attributes.maximum.agimax);
break;
case 'incAtt Rea':
attributes.current.rea = increasePhy(attributes.current.rea, attributes.maximum.reamax);
break;
case 'incAtt Str':
attributes.current.str = increasePhy(attributes.current.str, attributes.maximum.strmax);
break;
case 'incAtt Wil':
attributes.current.wil = increaseMen(attributes.current.wil, attributes.maximum.wilmax);
break;
case 'incAtt Log':
attributes.current.log = increaseMen(attributes.current.log, attributes.maximum.logmax);
knowingIsHalftheBattle(); //update the number of knowledge skills
break;
case 'incAtt Int':
attributes.current.int = increaseMen(attributes.current.int, attributes.maximum.intmax);
knowingIsHalftheBattle(); //update the number of knowledge skills
break;
case 'incAtt Cha':
attributes.current.cha = increaseMen(attributes.current.cha, attributes.maximum.chamax);
break;
case 'decAtt Bod':
attributes.current.bod = decreasePhy(attributes.current.bod, attributes.minimum.bodmin, attributes.maximum.bodmax);
break;
case 'decAtt Agi':
attributes.current.agi = decreasePhy(attributes.current.agi, attributes.minimum.agimin, attributes.maximum.agimax);
break;
case 'decAtt Rea':
attributes.current.rea = decreasePhy(attributes.current.rea, attributes.minimum.reamin, attributes.maximum.reamax);
break;
case 'decAtt Str':
attributes.current.str = decreasePhy(attributes.current.str, attributes.minimum.strmin, attributes.maximum.strmax);
break;
case 'decAtt Wil':
attributes.current.wil = decreaseMen(attributes.current.wil, attributes.minimum.wilmin, attributes.maximum.wilmax);
break;
case 'decAtt Log':
attributes.current.log = decreaseMen(attributes.current.log, attributes.minimum.logmin, attributes.maximum.logmax);
knowingIsHalftheBattle(); //update the number of knowledge skills
break;
case 'decAtt Int':
attributes.current.int = decreaseMen(attributes.current.int, attributes.minimum.intmin, attributes.maximum.intmax);
knowingIsHalftheBattle(); //update the number of knowledge skills
break;
case 'decAtt Cha':
attributes.current.cha = decreaseMen(attributes.current.cha, attributes.minimum.chamin, attributes.maximum.chamax);
break;
case 'incAtt Edg':
attributes.current.edg = increaseSpec(attributes.current.edg, attributes.maximum.edgmax);
break;
case "incAtt Mag":
if (magres == "adept" && attributes.current.mag < attributes.maximum.magmax) {
powerPoints++;
}
attributes.current.mag = increaseSpec(attributes.current.mag, attributes.maximum.magmax);
fociMaxRating = attributes.current.mag * 2;
break;
case "incAtt Res":
attributes.current.res = increaseSpec(attributes.current.res, attributes.maximum.resmax);
break;
case "decAtt Edg":
attributes.current.edg = decreaseSpec(attributes.current.edg, attributes.minimum.edgmin);
break;
case "decAtt Mag":
if (magres == "adept" && attributes.current.mag > attributes.minimum.magmin) {
powerPoints--;
}
attributes.current.mag = decreaseSpec(attributes.current.mag, attributes.minimum.magmin);
fociMaxRating = attributes.current.mag * 2;
break;
case "decAtt Res":
attributes.current.res = decreaseSpec(attributes.current.res, attributes.minimum.resmin);
break;
case "incAtt bow weaprating": //this increase the bows rating. A strange place to put this...but whatever.
if (weapons.bow.rating < 10) {
weapons.bow.rating++;
bowUpdater();
}
break;
case "decAtt bow weaprating": //this increase the bows rating. A strange place to put this...but whatever.
if (weapons.bow.rating > 0) {
weapons.bow.rating--;
bowUpdater();
}
break;
}
function bowUpdater() {
weapons.bow.damage = weapons.bow.rating + 2;
weapons.bow.ap = Math.ceil(weapons.bow.rating / 4) * -1;
weapons.bow.avail = weapons.bow.rating;
weapons.bow.cost = weapons.bow.rating * 100;
}
if ($(this).closest("skilltitle")) { //if the incAtt or decAtt is in the div skilltitle, then its a skill, so update the active skills
activeSkills = skillUpdater(activeSkills, skills);
}
if ($(this).closest("knowledgeskills")) { //this updates the knowledge skills
knowledgeSkills = skillUpdater(knowledgeSkills, knowledgepoints);
}
function knowingIsHalftheBattle() { //this sets how many knowledge points a character gets
knowledgepoints = (attributes.current.int + attributes.current.log) * 2; //sets the number of knowledge skill points
}
//skillupdater is very poorly written, refactor later!
function skillUpdater(x, y) { //this function gets called by both the active and knowledge skills
for (var skill in x) { //this will increase the skills
if (y > 0) { //if you're out of skill points, don't add skills.
if (x[skill]["rating"] < x[skill]["max"]) { //skill ratings can't be over the max skill
if (className == "incAtt " + [skill]) { //if increase attribute (now poorly named) is not with a skill, then do nothing
if (x == activeSkills) { //if this is an active skill decrease the skill points
skills--;
} else if (x == knowledgeSkills) { //if this is a knowledge skill decrease the knowledge skill points
knowledgepoints--;
}
x[skill]["rating"]++; //incease the rating of the skill by 1
}
}
}
if (x[skill]["rating"] > 0 && className == "decAtt " + [skill]) { //if skill rating is over 0 and decrease Attribute is with the skill then do this stuff
if (x == activeSkills) {
skills++;
} else if (x == knowledgeSkills) {
knowledgepoints++;
}
x[skill]["rating"]--;
} else if ((x[skill]["rating"] === 0) && (x == knowledgeSkills)) { // Removes knowledge skill if at zero and reduced again.
if (className == "decAtt " + [skill]) {
$('.' + [skill]).remove(); // Technically removes table row. Does not delete array entry to avoid index problems.
}
}
}
return x;
}
for (var skill in groupSkills) { //this will increase the skill groups
if (skillgroups > 0 && groupSkills[skill]["rating"] < skillgroupmax && className == "incAtt " + [skill]) {
groupSkills[skill]["rating"]++;
for (var key in groupSkills[skill]["skillsingroup"]) {
var x = groupSkills[skill]["skillsingroup"][key];
activeSkills[x]["rating"] = groupSkills[skill]["rating"];
$(".incAtt" + "." + x).addClass("deact");
$(".decAtt" + "." + x).addClass("deact");
}
skillgroups--;
} else if (groupSkills[skill]["rating"] > 0 && className == "decAtt " + [skill]) {
groupSkills[skill]["rating"]--;
skillgroups++;
for (var key2 in groupSkills[skill]["skillsingroup"]) {
var x2 = groupSkills[skill]["skillsingroup"][key2];
activeSkills[x2]["rating"] = groupSkills[skill]["rating"];
if (groupSkills[skill]["rating"] === 0) {
$(".incAtt" + "." + x2).removeClass("deact");
$(".decAtt" + "." + x2).removeClass("deact");
}
}
}
}
for (var prop in adeptPowers) {
var power = adeptPowers[prop];
if (prop == "improvedreflexes" && power["level"] > 0) { //this will reduce the cost of improved reflexes if it is activated
power["cost"] = 1;
if (power["level"] >= 1 && power["level"] < 3 && powerPoints - power["cost"] >= 0) {
if (className == "incAtt " + prop) {
power["level"]++;
powerPoints = powerPoints - power["cost"];
attributes.initiative.iniphyDice++;
attributes.augment.rea++;
}
}
if (power["level"] > 1) {
if (className == "decAtt " + [prop]) {
power["level"]--;
powerPoints = powerPoints + power["cost"];
attributes.initiative.iniphyDice--;
attributes.augment.rea--;
}
}
} else if (prop == "improvedphysicalattributebody" || prop == "improvedphysicalattributeagility" || prop == "improvedphysicalattributereaction" || prop == "improvedphysicalattributestrength") { //if the power is improve attribute then do this stuff
if (powerPoints - power["cost"] >= 0 && power["level"] < 4 && className == "incAtt " + [prop]) {
power["level"]++;
powerPoints = powerPoints - power["cost"];
addAttMod(power["attmod"]);
}
if (power["level"] > 1 && className == "decAtt " + prop) {
power["level"]--;
powerPoints = powerPoints + power["cost"];
for (var key in power["attmod"]) {
switch (power["attmod"][key]) {
case "body":
attributes.augment.bod = minusAugmentAtt(attributes.augment.bod);
break;
case "reaction":
attributes.augment.rea = minusAugmentAtt(attributes.augment.rea);
break;
case "agility":
attributes.augment.agi = minusAugmentAtt(attributes.augment.agi);
break;
case "strength":
attributes.augment.str = minusAugmentAtt(attributes.augment.str);
break;
}
}
}
} else {
if (powerPoints - power["cost"] >= 0 && power["level"] < attributes.current.mag && className == "incAtt " + [prop]) {
power["level"]++;
powerPoints = powerPoints - power["cost"];
for (var skill in power["skillmod"]) {
addMod(power["skillmod"][skill], power["level"]); //updates mods that power effect
}
}
if (power["level"] > 1 && className == "decAtt " + [prop]) {
power["level"]--;
powerPoints = powerPoints + power["cost"];
for (var skill in power["skillmod"]) {
minusMod(power["skillmod"][skill], power["level"]); //updates mods that power effect
}
}
}
}
for (var item in inventory) { //this will be used to increase and decrease the weapon foci rating and license rating, and now clips too
var itemhold = inventory[item]
if ($(this).parents("#" + item).attr("id") == item) {
if ($(this).attr("class") == item + " incAtt weaponfoci" && fociRating < fociMaxRating && focinumber < attributes.current.mag && itemhold["weaponfoci"] < 3 && nuyen - 7000 > 0 && karma - 3 > 0) {
if (itemhold["weaponfoci"] == 0) {
focinumber++;
}
itemhold["weaponfoci"]++;
inventoryStatUpdater(item, ".focirating.weaponfoci", itemhold["weaponfoci"]);
fociRating++;
nuyen -= 7000;
inventory[item]["cost"] += 7000;
karma -= 3;
} else if ($(this).attr("class") == item + " decAtt weaponfoci" && itemhold["weaponfoci"] > 0) {
itemhold["weaponfoci"]--;
if (itemhold["weaponfoci"] == 0) {
focinumber--;
}
inventoryStatUpdater(item, ".focirating.weaponfoci", itemhold["weaponfoci"]);
fociRating--;
nuyen += 7000;
itemhold["cost"] -= 7000;
karma += 3;
}
if ($(this).attr("class") == item + " incAtt license" && itemhold["license"] < 4 && nuyen - 200 > 0) {
itemhold["license"]++;
inventoryStatUpdater(item, ".licenserating.license", itemhold["license"]);
nuyen -= 200;
itemhold["cost"] += 200;
} else if ($(this).attr("class") == item + " decAtt license" && itemhold["license"] > 0) {
itemhold["license"]--;
inventoryStatUpdater(item, ".licenserating.license", itemhold["license"]);
nuyen += 200;
itemhold["cost"] -= 200;
}
if (itemhold["rating"] > 0) { //if rating 0 its a crossbow.
var arrowPrice = itemhold["rating"] * 2;
var injectPrice = itemhold["rating"] * 20;
} else {
var arrowPrice = 5;
var injectPrice = 50;
}
if (itemhold.name == "shuriken") {
var arrowPrice = 25;
}
if ($(this).attr("class") == item + " incAtt arrow" && nuyen - arrowPrice > 0) {
itemhold["arrow"]++;
inventoryStatUpdater(item, ".arrowNum.arrow", itemhold["arrow"]);
nuyen -= arrowPrice;
itemhold["cost"] += arrowPrice;
} else if ($(this).attr("class") == item + " decAtt arrow" && itemhold["arrow"] > 0) {
itemhold["arrow"]--;
inventoryStatUpdater(item, ".arrowNum.arrow", itemhold["arrow"]);
nuyen += arrowPrice;
itemhold["cost"] -= arrowPrice;
}
if ($(this).attr("class") == item + " incAtt injarrow" && nuyen - injectPrice > 0) {
itemhold["inject"]++;
inventoryStatUpdater(item, ".arrowNum.injarrow", itemhold["inject"]);
nuyen -= injectPrice;
itemhold["cost"] += injectPrice;
} else if ($(this).attr("class") == item + " decAtt injarrow" && itemhold["inject"] > 0) {
itemhold["inject"]--;
inventoryStatUpdater(item, ".arrowNum.injarrow", itemhold["inject"]);
nuyen += injectPrice;
itemhold["cost"] -= injectPrice;
}
if (itemhold.clip == "Clip") {
var clipPrice = 5;
} else {
var clipPrice = 25;
}
if ($(this).attr("class") == item + " incAtt extraclips" && nuyen - clipPrice > 0) {
itemhold["extraclips"]++;
inventoryStatUpdater(item, ".numofclips.extraclips", itemhold["extraclips"]);
nuyen -= clipPrice;
itemhold["cost"] += clipPrice;
} else if ($(this).attr("class") == item + " decAtt extraclips" && itemhold["extraclips"] > 0) {
itemhold["extraclips"]--;
inventoryStatUpdater(item, ".numofclips.extraclips", itemhold["extraclips"]);
nuyen += clipPrice;
itemhold["cost"] -= clipPrice;
}
}
};
function inventoryStatUpdater(x, y, z) { //x=the name of the item, y=the classes to target the table to update the stat. z=the stat to show
$("#" + x + " " + y).empty().append(z);
}
function increasePhy(x, y) { //this shit increases an attribute while decreating the points you can spend
if (phyAttMax == true) {
y--;
}
if (attribute > 0 && x < y) {
x++;
attribute--;
if (x == y) {
phyAttMax = true;
}
}
return x;
}
function increaseMen(x, y) { //this shit increases an attribute while decreating the points you can spend
if (phyAttMax == true) {
y--;
}
if (attribute > 0 && x < y) {
x++;
attribute--;
if (x == y) {
phyAttMax = true; //if i ever need to change this back to mental attrubuteing being difference the variable is menAttMax
}
}
return x;
}
function decreasePhy(x, y, z) { //this shit decreases and attribute while increating the points you can spend
if (x == z) {
phyAttMax = false;
}
if (x > y) {
x--;
attribute++;
}
return x;
}
function decreaseMen(x, y, z) { //this shit decreases and attribute while increating the points you can spend
if (x == z) {
phyAttMax = false;
}
if (x > y) {
x--;
attribute++;
}
return x;
}
function increaseSpec(x, y) { //this is for special attributes, they get their own funcation because they're special
if (specAttribute > 0) {
if (x < y) {
x++;
specAttribute--;
}
}
return x;
}
function decreaseSpec(x, y) { //for when special people make a mistake
if (x > y) {
x--;
specAttribute++;
}
return x;
}
disUpdater(); //this was ment to orignally update the attributes, but is now used for EVERYTHING
}
function addAugmentAtt(x) {
if (x < 4) {
x++;
}
return x;
}
function minusAugmentAtt(x) {
if (x > 0) {
x--;
}
return x;
}
$(".mage, .techno, .mystic, .adept, .aspect").click( //this part will call the attributes.current.mag/attributes.current.res function
selectmagres
);
function selectmagres() { //Magic/Resonance controls
if ($(this).hasClass('deact') || $(this).hasClass('selected')) { //this will make it so that if the button is deactivated that it won't do anything
return;
} else {
fnselect($(this)); //highlights what's been clicked on
if ($(this).hasClass('mage')) { //attributes.current.mag man doing attributes.current.mag stuff