forked from HeyOmae/Omae
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgear.js
1285 lines (1131 loc) · 60.4 KB
/
gear.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
function setupGear() {
$(".melee.label").appendTo($(".meleeweapon")); //this labels the melee weapons, but I have a function that does this, so i'm stupid for not using that function
//this pulls the weapons stats from the weapons object to populate the page
for (var item in weapons) {
var itemhold = weapons[item];
switch (itemhold.category) {
case "blades":
case "clubs":
case "unarmedcombat":
case "exoticmeleeweapon":
//this one populates the melee weapons
$(".meleeweapon." + itemhold.category).after("<tr id='" + item + "'><td class='weapact " + item + " button'><strong>+</strong></td><td class='weapname " + item + "'>" + itemhold["name"] + "</td><td class='accuracy " + item + "'>" + itemhold["accuracy"] + "(" + (itemhold["accuracy"] + itemhold["accmod"]) + ")" + "</td><td class='reach " + item + "'>" + itemhold["reach"] + "(" + (itemhold["reach"] + reachmod) + ")" + "</td><td class='damage " + item + "'>" + (itemhold["stat"] + itemhold["damage"]) + "(" + (itemhold["stat"] + itemhold["damage"] + itemhold["dvmod"]) + ")" + itemhold["damtype"] + " " + itemhold["element"] + "</td><td class='ap " + item + "'>" + itemhold["ap"] + "</td><td class='avail " + item + "'>" + itemhold["avail"] + " " + itemhold["restrict"] + "</td><td class='cost " + item + "'>" + itemhold["cost"] + "¥" + "</td><td>" + itemhold.ref.book + " p" + itemhold.ref.page + "</td></tr>");
break;
case "bow":
case "crossbow":
case "throwingweapons":
//this one populates the projectiles
$(".projectiles." + itemhold.category).after("<tr id='" + item + "'><td class='weapact " + item + " button'><strong>+</strong></td><td class='incAtt " + item + " weaprating'>+</td><td class='weaprating " + item + " weapratingnum'>" + itemhold["rating"] + "</td><td class='decAtt " + item + " weaprating'>-</td><td class='weap accuracy " + item + "'>" + itemhold["arruracy"] + "</td><td class='weap damage " + item + "'>" + itemhold["damage"] + "</td><td class='weap ap " + item + "'>" + itemhold["ap"] + "</td><td class='weap avail " + item + "'>" + itemhold["avail"] + "</td><td class='weap cost " + item + "'>" + itemhold["cost"] + "</td><td>" + itemhold.ref.book + " p" + itemhold.ref.page + "</td></tr>");
break;
default:
//firearms
$(".firearms." + itemhold.category).after("<tr id='" + item + "'><td class='weapact " + item + " button'><strong>+</strong></td><td class='weapname " + item + "'>" + itemhold["name"] + "</td><td class='accuracy " + item + "'>" + itemhold["accuracy"] + "(" + (itemhold["accuracy"] + itemhold["accmod"]) + ")" + "</td><td class='damage " + item + "'>" + itemhold["damage"] + "(" + (itemhold["damage"] + itemhold["dvmod"]) + ")" + itemhold["damtype"] + " " + itemhold["element"] + "</td><td class='ap " + item + "'>" + itemhold["ap"] + "</td><td class='modes " + item + "'></td><td class='RC " + item + "'>" + itemhold["rc"] + "</td><td class='ammo " + item + " clip'>" + itemhold["ammo"] + " " + itemhold["clip"] + "</td><td class='avail " + item + "'>" + itemhold["avail"] + " " + itemhold["restrict"] + "</td><td class='cost " + item + "'>" + itemhold["cost"] + "¥" + "</td></tr>");
break;
}
var modeCount = 0;
for (var firemode in itemhold.mode) {
var modeContainer = $(".modes." + item);
if (modeCount > 0) {
modeContainer.append(", ");
}
modeContainer.append(itemhold.mode[firemode]);
modeCount++;
}
for (var diffAmmo in itemhold["altammo"]) {
switch (diffAmmo) {
case "ammo":
$("." + diffAmmo + "." + item).append("/" + itemhold["altammo"][diffAmmo]);
break;
case "clip":
$("." + diffAmmo + "." + item).append(" " + itemhold["altammo"][diffAmmo]);
break;
}
}
if (itemhold["avail"] > maxAvail) {
$(".weapact." + item).addClass("deact").empty().append("<span>-</span>");
}
}
$(".projectiles.crossbow,#shuriken").find(".weaprating").remove(); //this removes the rating information for the crossbows, because crossbows don't have ratings
}
function setupAmmo() {
//adding ammo details below
$(".ammo.label").appendTo(".ammunition");
for (var ammo in ammunition) {
var ammotype = ammunition[ammo];
switch (ammotype["class"]) {
case "taserammo":
case "specialammo":
case "cannonammo":
abnormalAmmo(ammotype, ammo);
break;
case "grenades":
explosivesAmmo("grenadeammo", ammotype);
break;
case "rockets":
explosivesAmmo("rocketammo", ammotype);
break;
case "none":
$(".standard.ammunition").after("<tr class='" + ammo + "'><td class='buyammo button'><strong>+</strong></td><td class='amountofammo'>0</td><td class='sellammo button'><em>-</em></td><td class='ammoname'>" + ammotype["name"] + "</td><td class='dammod'>" + ammotype["dammod"] + " " + ammotype["typemod"] + " " + ammotype["elemod"] + "</td><td class='apmod'>" + ammotype["apmod"] + "</td><td class='avail'>" + ammotype["avail"] + " " + ammotype["restrict"] + "</td><td class='cost'>" + ammotype["cost"] + "¥</td><td class='blast'></td></tr>");
break;
}
if (ammotype["avail"] > maxAvail) {
$("." + ammo + " .button").addClass("deact");
}
}
function explosivesAmmo(catalog, type) {
$("." + catalog).after("<tr class='ammo'><td class='buygrenades button'><strong>+</strong></td><td class='amountofammo'>0</td><td class='sellgrenades button'><em>-</em></td><td class='grenadesname'>" + type["name"] + "</td><td class='grenadesdammod'>" + type["dammod"] + " " + type["typemod"] + " " + type["elemod"] + "</td><td class='apmod'>" + type["apmod"] + "</td><td class='avail'>" + type["avail"] + " " + type["restrict"] + "</td><td class='cost'>" + type["cost"] + "¥</td><td class='blast'>" + type["blast"] + "</td></tr>");
}
function abnormalAmmo(x, y) {
$("." + x["class"]).after("<tr class='ammo'><td class='buyammo button'><strong>+</strong></td><td class='amountofammo'>0</td><td class='sellammo button'><em>-</em></td><td class='ammoname'>" + x["name"] + "</td><td class='dammod'>" + x["dammod"] + x["typemod"] + " " + x["elemod"] + "</td><td class='apmod'>" + x["apmod"] + "</td><td class='avail'>" + x["avail"] + " " + x["restrict"] + "</td><td class='cost'>" + x["cost"] + "¥</td><td class='blast'></td></tr>");
}
$(".gas .grenadesname").empty().append("<select class='toxicgas'></select>");
for (var dose in toxin) {
if (toxin[dose]["avail"] <= maxAvail) {
$(".toxicgas").append("<option value='" + dose + "'>" + toxin[dose]["name"] + "</option>")
}
}
$(".holdoutammo .tracer, .lightammo .tracer, .heavyammo .tracer, .sniperammo .tracer, .shotgunammo .tracer").remove();
for (var bomb in explosives) {
$("." + bomb + ".explosives").after("<tr class='" + bomb + "'><td class='buybomb button'><strong>+</strong></td><td class='bombup button'>+</td><td class='explosiverating'>" + explosives[bomb].rating + "</td><td class='bombdown button'>-</td><td>" + explosives[bomb]["avail"] + " " + explosives[bomb]["restrict"] + "</td><td class='bombbond'>" + explosives[bomb]["cost"] + "¥</td></tr>");
}
$(".detonator").after("<tr><td class='buyDet button'>+</td><td class='caps'>0</td><td class='sellDet button'>-</td><td>" + detonator.avail + " " + detonator.restrict + "</td><td>" + detonator.cost + "¥</td></tr>");
$(".commercial .bombup,.commercial .bombdown, .plastic .buybomb").addClass("deact");
$(".plastic .buybomb").empty().append("-");
}
function setupElectronics() {
for (var devicename in electronics) { //this populates the electronic devices
var device = electronics[devicename];
switch (device.type) {
case "commlink":
$("#links").after("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + device["model"] + "</td><td>" + device["device"] + "</td><td>" + device["avail"] + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "deck":
$("#decks").after("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + device["model"] + "</td><td>" + device["device"] + "</td><td>" + device["array"] + "</td><td>" + device["programs"] + "</td><td>" + device["avail"] + " " + device["restrict"] + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "rcc":
$("#consoles").after("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + device["model"] + "</td><td>" + device["device"] + "</td><td>" + device["dataprocess"] + "</td><td>" + device["firewall"] + "</td><td>" + device["avail"] + " " + device["restrict"] + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "accessory":
$("#eccessories").append("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + device["name"] + "</td><td>" + device["device"] + "</td><td>" + device["avail"] + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "rfid":
$('#rfid').append("<tr class='" + devicename + "'><td class='buyUp button'><strong>+</strong></td><td class='numrfid'>0</td><td class='sellDown button'><em>-</em></td><td>" + device["name"] + "</td><td>" + device["device"] + "</td><td>" + device["avail"] + " " + device.restrict + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "credsticks":
$('#credsticks').append("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + device["name"] + "</td><td>" + device["maxvalue"] + "</td><td>" + device["avail"] + " " + device.restrict + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "identification":
$('#identification').append("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td class='ratingUp button'>+</td><td class='commrating'>1</td><td class='ratingDown button'>-</td><td>" + device["name"] + " <input type='text' class='fakename' placeholder='For?'>" + "</td><td class='avail'>" + device["avail"] + " " + device.restrict + "</td><td class='price'>" + device["cost"] + "¥</td></tr>");
break;
case "tools":
$('#tools').append("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + "<input type='text' class='toolname' placeholder='Skill name'> " + device["name"] + "</td><td>" + device["avail"] + " " + device.restrict + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "restraints":
$('#restraints').append("<tr class='" + devicename + "'><td class='buyUp button'><strong>+</strong></td><td class='numrfid'>0<td class='sellDown'><em>-</em></td></td><td>" + device["name"] + "</td><td>" + device.armor + "</td><td>" + device.structure + "</td><td>" + device["avail"] + " " + device.restrict + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "chemicals":
$('#chemicals').append("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + device["name"] + "</td><td>" + device["avail"] + " " + device.restrict + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "grapplegungear":
$('#grapplegungear').append("<tr class='" + devicename + "'><td class='buydevice button'><strong>+</strong></td><td>" + device["name"] + "</td><td>" + device["avail"] + " " + device.restrict + "</td><td>" + device["cost"] + "¥</td></tr>");
break;
case "grapplerope":
case "docwagon":
case "reagents":
bulkBuyGear(device, devicename);
break;
case "communications":
case "optics":
case "audio":
case "securitydevice":
case "bnegear":
case "survivalgear":
case "biotech":
case "slappatches":
case "enchantingfoci":
case "metamagicfoci":
case "powerfoci":
case "magicallodgematerials":
ratingGear(device, devicename);
break;
case "qifoci":
ratingGear(device, devicename);
$("#" + device.type + " ." + devicename + " .name").after("<td class='adeptPowers'><select></select></td>");
for (var power in adeptPowers) {
$("#" + device.type + " ." + devicename + " .adeptPowers select").append("<option value='" + power + "'>" + adeptPowers[power]["name"] + "</option>");
}
break;
case "spellfoci":
ratingGear(device, devicename);
$("#" + device.type + " ." + devicename + " .name").after("<td class='magicType'><select></select></td>");
if (devicename != "ritualspellcastingfocus") {
for (var spellCat in spellType) {
$("#" + device.type + " ." + devicename + " .magicType select").append("<option value='" + spellType[spellCat] + "'>" + spellType[spellCat] + "</option>");
}
} else {
for (var spellCat in ritualKeywords) {
$("#" + device.type + " ." + devicename + " .magicType select").append("<option value='" + ritualKeywords[spellCat] + "'>" + ritualKeywords[spellCat] + "</option>");
}
}
break;
case "spiritfoci":
ratingGear(device, devicename);
$("#" + device.type + " ." + devicename + " .name").after("<td class='magicType'><select></select></td>");
for (var spirit in spiritType) {
$("#" + device.type + " ." + devicename + " .magicType select").append("<option value='" + spiritType[spirit] + "'>" + spiritType[spirit] + "</option>");
}
break;
}
if (device["avail"] > maxAvail) {
$("." + devicename + " .buydevice").addClass("deact").empty().append("-");
}
if (typeof device.rating === "undefined") {
$("." + devicename + " .commrating").empty().append("n/a");
}
if (typeof device.availx === "undefined") {
$("." + devicename + " .ratingUp,." + devicename + " .ratingDown").addClass("deact");
}
}
}
function setupArmor() {
for (var type in armor) {
$("#clotharmor #bodyarmor tbody").append("<tr class='" + type + "'><td class='buyarmor button'><strong>+</strong></td><td>" + armor[type]["name"] + "</td><td>" + armor[type]["armor"] + "</td><td>" + armor[type]["avail"] + " " + armor[type]["restrict"] + "</td><td>" + armor[type]["cost"] + "¥</td></tr>");
if (armor[type]["avail"] > maxAvail) {
$("." + type + " .buyarmor").addClass("deact").empty().append("-");
}
}
}
function ratingGear(device, deviceName) {
$('#' + device.type).append("<tr class='" + deviceName + "'><td class='buydevice button'><strong>+</strong></td><td class='ratingUp button'>+</td><td class='commrating'>" + device.rating + "</td><td class='ratingDown button'>-</td><td class='name'>" + device.name + "</td><td class='avail'>" + device.avail + " " + device.restrict + "</td><td class='price'>" + device.cost + "¥</td></tr>");
}
function bulkBuyGear(device, deviceName) { //x=device, y=devicename
$('#' + device.type).append("<tr class='" + deviceName + "'><td class='buyUp button'><strong>+</strong></td><td class='numrfid'>0</td><td class='sellDown button'><em>-</em></td><td>" + device.name + "</td><td>" + device.avail + " " + device.restrict + "</td><td>" + device.cost + "¥</td></tr>");
}
function buyWeapon() {
if ($(this).hasClass("deact")) {
return;
}
var itemhold = weapons[$(this).parent().attr("id")];
var item = $(this).parent().attr("id");
var itemNum = item + invNum;
var gotMoney = nuyen - itemhold["cost"] > 0;
inventory[itemNum] = {}; //this creates a blank object for the weapon's stats to be added too
for (var key in itemhold) {
if (key == "mods") { //when we get to the key called mods in the weapon, do this
inventory[itemNum][key] = {}; //make a blank key for the mod
for (var subkey in itemhold[key]) { //this creates a section for the mods for each instance of a gun, so gun instances don't end up sharing all the same mods
inventory[itemNum][key][subkey] = itemhold[key][subkey];
}
} else {
inventory[itemNum][key] = itemhold[key];
}
}
inventory[itemNum]["active"] = true;
if ($(this).closest(".meleeweapon").hasClass("meleeweapon") && gotMoney) {
$("#" + item).after("<tr id='" + itemNum + "'><td class='sell button'><em>-</em></td><td>" + itemhold["name"] + "</td><td class='inventory " + item + itemNum + "' colspan=5></td><td class='custWeapPrice'>" + itemhold["cost"] + "¥</td></tr>");
if (attributes.current.mag > 0) {
inventory[itemNum]["weaponfoci"] = 0;
$("<td>Weapon Focus</td><td class='" + itemNum + " incAtt weaponfoci'>+</td><td class='focirating weaponfoci'>0</td><td class='" + itemNum + " decAtt weaponfoci'>-</td>").appendTo($(".inventory." + item + itemNum));
}
buyingItem(itemhold);
}
if ($(this).hasClass("bow") && gotMoney) { //buying bows
addingArrows(7, "#bow", item, itemNum, "Arrows");
buyingItem(itemhold);
}
if ($(this).closest(".crossbow").hasClass("crossbow") && gotMoney) { //buying crossbows
addingArrows(4, "#" + item, item, itemNum, "Bolts");
buyingItem(itemhold);
}
if ($(this).hasClass("shuriken") && gotMoney) { //buying throwing weapons
inventory[itemNum]["arrow"] = 1;
$("#shuriken").after("<tr id='" + itemNum + "'><td class='sell button'><em>-</em></td><td class='inventory " + item + itemNum + "' colspan=4></td><td class='custWeapPrice'></td></tr>");
$(".inventory." + item + itemNum).append("<td>Shuriken/Throwing Knives</td><td class='" + itemNum + " incAtt arrow'>+</td><td class='arrowNum arrow'>1</td><td class='" + itemNum + " decAtt arrow'>-</td>");
buyingItem(itemhold);
}
licenseDP(itemNum, item, itemhold, ""); //adds license and dice pool
if ($(this).closest(".firearms").hasClass("firearms") && gotMoney) { //this adds firearms
$("#" + item).after("<tr id='" + itemNum + "' class='invName'><td class='sell button'><em>-</em></td><td class='inventory " + item + itemNum + "' colspan=8></td><td class='custWeapPrice'></td></tr>");
buyingItem(itemhold); //this takes money out of the nuyen, so buys the item
$(".inventory." + item + itemNum).append("<tr class='mounts'></tr>"); //this adds the area for the gun mounts
var acctarget = ".inventory." + item + itemNum + " .mounts";
$(acctarget).append("<tr><td>Top</td><td>Barrel</td><td>Under</td></tr>");
$(acctarget).append("<tr><td class='topmount " + itemNum + "'>n/a</td><td class='barrelmount " + itemNum + "'>n/a</td><td class='underbarrel " + itemNum + "'>n/a</td></tr>");
topMount(item, itemNum);
barrelMount(item, itemNum);
bottomMount(item, itemNum);
holsterAddOn(itemhold, itemNum, item);
$(".inventory." + item + itemNum).append("<tr class='accessories'></tr>"); //this is where nonmount accessories go
acctarget = ".inventory." + item + itemNum + " .accessories"; //makes targetting accessories eaiser
$(acctarget).append("<tr class='nonmounts " + itemNum + "'></tr>"); //puting a row in a row breaks the normal table
var nonmount = ".nonmounts." + itemNum;
if (itemhold.avail + 2 <= maxAvail || itemhold.mods.internalsmart == "Smartgun") { //adding a internal smartgun increaes avail, this doesn't go over 12
$(nonmount).append("<td>Internal Smartgun</td><td class='smartgun " + itemNum + " button'>+</td>");
}
if (itemhold.mods.internalsmart == "Smartgun") { //if the gun already has an internal smartgun system, this prevents people from adding another one
$(".smartgun." + itemNum).addClass("deact active").empty().append("-");
}
var skillcheck = itemhold.skill;
if (itemhold.category == "assaultrifles" || skillcheck == "longarms" || skillcheck == "heavyweapons") { //add shockpad to some guns
$(nonmount).append("<td>Shock Pad</td><td class='shockpad " + itemNum + " button'>+</td>");
}
if (itemhold.damtype == "Grenade" || itemhold.damtype == "Missile") { //adds airburst link to explosive weapons
$(nonmount).append("<td>Airburst Link</td><td class='airburstlink " + itemNum + " button'>+</td>");
}
if (itemhold.mods.integral != "n/a") { //adds accessories that are already built in to the smartgun
$(nonmount).append("<td>Integral</td><td class='integral " + itemNum + " active' colspan=2>" + itemhold["mods"]["integral"] + "</td>")
}
$(nonmount).after("<table><tr class='options'></tr></table>"); //adds a new table so that the clip and fake licenses don't get all stretched out
if (itemhold.clip == "Clip") { //adds spare clips
addClips(itemNum, item, "Clips");
} else if (itemhold.clip == "Detachable Cylinder" || itemhold.clip == "Cylinder") { //add speed loader for revolvers
addClips(itemNum, item, "Speed Loader");
}
licenseDP(itemNum, item, itemhold, " .options"); //add license and dicepool
$(".inventory." + item + itemNum + " .options .labelDP").before("<td>Acc</td><td class='acc " + itemNum + "'>" + itemhold.accuracy + "(" + (itemhold.accuracy + itemhold.accmod) + ")" + "</td><td>RC</td><td class='rc " + itemNum + "'>" + itemhold.rc + Math.ceil((attributes.current.str / 3) + 1) + "(" + (itemhold.rc + itemhold.rcmod + Math.ceil((attributes.current.str / 3) + 1)) + ")" + "</td>");
$(".inventory." + item + itemNum + " .options").append("<td>Avail</td><td class='avail " + itemNum + "'>" + itemhold.avail + " " + itemhold.restrict + "</td>");
}
invNum++;
displayUpdater();
}
//@TODO - rename parameters
function addClips(x, y, z) {
inventory[itemNum]["extraclips"] = 0;
$("<td>" + z + "</td><td class='" + x + " incAtt extraclips'>+</td><td class='numofclips extraclips'>0</td><td class='" + x + " decAtt extraclips'>-</td>").appendTo($(".inventory." + y + x + " .options"));
}
function holsterAddOn(itemHold, itemNum, item) { //x=itemhold, y=itemNum,z=item
var check = itemHold["category"];
if (check == "lightpistols" || check == "tasers" || check == "holdouts") { //checks to see if small arms to use arm sldder
makeHolster(itemNum, item);
$(".holster." + itemNum).append("<td class='concealableholster " + itemNum + " button'>Concealable Holster</td><td class='hiddenarmslide " + itemNum + " button'>Hidden Arm Slide</td><td class='quickdrawholster " + itemNum + " button'>Quick-draw Holster</td>");
}
if (check == "heavypistols" || check == "machinepistols") { //checks to see if larger small arms that can use holsters that are not arm slider
makeHolster(itemNum, item);
$(".holster." + itemNum).append("<td class='concealableholster " + itemNum + " button'>Concealable Holster</td><td class='quickdrawholster " + itemNum + " button'>Quick-draw Holster</td>");
}
}
//@TODO - rename parameters
function makeHolster(y, z) { //adds the stuff to make the holsters
$(".inventory." + z + y).append("<tr class='holsters " + y + "'></tr>");
$(".holsters." + y).append("<tr class='holster " + y + "'><td>Holster</td></tr>");
}
//@TODO - rename parameters
function licenseDP(x, y, z, l) {
if (z["restrict"] == "Restricted") { //if restricted add the ability to buy a fake license
inventory[x]["license"] = 0;
$("<td>Fake License</td><td class='" + x + " incAtt license'>+</td><td class='licenserating license'>0</td><td class='" + x + " decAtt license'>-</td>").appendTo($(".inventory." + y + x + l));
}
$("<td class='labelDP'>DP</td><td class='weaponDP'>" + (activeSkills[inventory[x]["skill"]]["rating"] + activeSkills[inventory[x]["skill"]]["stat"] + activeSkills[inventory[x]["skill"]]["mod"]) + "</td>").appendTo($(".inventory." + y + x + l));
}
//@TODO - rename parameters
function topMount(x, y) {
if (weapons[x]["mods"]["top"] == "empty") {
$(".topmount." + y).empty().append("<select><option value='empty'>Empty</option><option value='Laser Sight'>Laser Sight</option><option value='Imaging Scope'>Imaging Scope</option><option value='Periscope'>Periscope</option><option value='Smartgun'>Smartgun</option></select>");
}
}
//@TODO - rename parameters
function barrelMount(x, y) {
if (weapons[x]["mods"]["barrel"] == "empty") {
$(".barrelmount." + y).empty().append("<select><option value='empty'>Empty</option><option value='Gas Vent 1'>Gas Vent System 1</option><option value='Gas Vent 2'>Gas Vent System 2</option><option value='Gas Vent 3'>Gas Vent System 3</option><option value='Silencer'>Silencer</option></select>");
}
}
//@TODO - rename parameters
function bottomMount(x, y) {
if (weapons[x]["mods"]["under"] == "empty") {
$(".underbarrel." + y).empty().append("<select><option value='empty'>Empty</option><option value='Laser Sight'>Laser Sight</option><option value='Bipod'>Bipod</option><option value='Smart Firing Platform'>Smart Firing Platform</option><option value='Smartgun'>Smartgun</option><option value='Tripod'>Tripod</option></select>");
if (weapons[x]["skill"] == "heavyweapons" || weapons[x]["category"] == "assaultrifles") {
$(".underbarrel." + y + " select").append("<option value='Gyro Mount'>Gyro Mount</option>");
}
}
}
function addingArrows(columns, target, weapon, weaponNumber, projectile) {
inventory[weaponNumber]["arrow"] = 0;
inventory[weaponNumber]["inject"] = 0;
$(target).after("<tr id='" + weaponNumber + "'><td class='sell button'><em>-</em></td><td class='inventory " + weapon + weaponNumber + "' colspan=" + columns + "></td><td class='custWeapPrice'></td></tr>");
$(".inventory." + weapon + weaponNumber).append("<td>" + projectile + "</td><td class='" + weaponNumber + " incAtt arrow'>+</td><td class='arrowNum arrow'>0</td><td class='" + weaponNumber + " decAtt arrow'>-</td><td>Injection " + z + "</td><td class='" + weaponNumber + " incAtt injarrow'>+</td><td class='arrowNum injarrow'>0</td><td class='" + weaponNumber + " decAtt injarrow'>-</td>");
}
function buyingItem(itemhold) {
nuyen -= itemhold["cost"];
}
function sellWeapon() {
var item = $(this).parent().attr("id");
nuyen += inventory[item]["cost"];
inventory[item]["active"] = false;
fociRating -= inventory[item]["weaponfoci"];
if (inventory[item]["weaponfoci"] > 0) {
karma += inventory[item]["weaponfoci"] * 3;
focinumber--;
fociRating -= inventory[item]["weaponfoci"];
pointUpdater("#karmapnt", karma);
}
$(this).parent().remove();
delete inventory[item];
nuyenUpdater();
}
function settingWeapon() { //this will change the weapon mounts and the nuyen
var item = $(this).closest(".invName").attr("id");
var itemmod = inventory[item]["mods"];
var itemhold = inventory[item];
itemmod.top = mountCheck($(".topmount." + item + " select").val(), itemmod.top, itemmod.under);
itemmod.barrel = mountCheck($(".barrelmount." + item + " select").val(), itemmod.barrel);
itemmod.under = mountCheck($(".underbarrel." + item + " select").val(), itemmod.under, itemmod.top);
//@TODO - rename parameters
//@TODO - move outside of parent function
function mountCheck(x, y, z) {
if (x != y) { //reset stats below
price = gunModPricing(y); //the price of the old mod
nuyen += price; //returns money of the old mod
inventory[item]["cost"] -= price; //takes out of the price of the old mod
itemhold["rc"] -= addingRecoil(y); //takes away the recoil of the old mod
itemhold["rcmod"] -= moddingRecoil(y); //takes away the recoil mod of the old mod
itemhold["accmod"] -= addingAccuracy(y, z);
//set new stats below
price = gunModPricing(x); //sets the new price
nuyen -= price; //reduces the nuyen by the price of the new mod
inventory[item]["cost"] += price; //adds the price of the new mod to the gun's price
itemhold["rc"] += addingRecoil(x); //sets the new recoil
itemhold["rcmod"] += moddingRecoil(x); //sets the new recoil mod
itemhold["accmod"] += addingAccuracy(x, z);
}
return x;
}
displayUpdater();
}
//@TODO - rename parameters
function addingAccuracy(x, z) {
if (x == "Smartgun" || z == "Smartgun" || itemmod["internalsmart"] == "Smartgun") { //this figures out of accuracy bonus
y = 2;
} else if (x == "Laser Sight" || z == "Laser Sight" || itemmod["integral"].indexOf("Laser Sight") !== -1) {
y = 1;
} else {
y = 0;
}
return y;
}
//@TODO - rename parameters
function moddingRecoil(x) {
if (x == "Tripod" || x == "Gyro Mount") {
y = 6;
} else if (x == "Bipod") {
y = 2;
} else {
y = 0;
}
return y;
}
//@TODO - rename parameters
function addingRecoil(x) {
if (x == "Gas Vent 3" || itemmod["integral"].indexOf("Gas Vent 3") !== -1) { //gas vents apparently determine the natural recoil
y = 3;
} else if (x == "Gas Vent 2" || itemmod["integral"].indexOf("Gas Vent 2") !== -1) {
y = 2;
} else if (x == "Gas Vent 1" || itemmod["integral"].indexOf("Gas Vent 1") !== -1) {
y = 1;
} else {
y = 0;
}
return y;
}
function gunModPricing(mod) { //this is the price of all the mods
var price;
switch (mod) {
default: price = 0;
break;
case "Laser Sight":
price = 125;
break;
case "Imaging Scope":
price = 300;
break;
case "Periscope":
price = 70;
break;
case "Smartgun":
price = 200;
break;
case "Gas Vent 1":
price = 200;
break;
case "Gas Vent 2":
price = 400;
break;
case "Gas Vent 3":
price = 600;
break;
case "Silencer":
price = 500;
break;
case "Bipod":
price = 200;
break;
case "Gyro Mount":
price = 1400;
break;
case "Smart Firing Platform":
price = 2500;
break;
case "Tripod":
price = 500;
break;
}
return price;
}
function smartlink() {
if ($(this).hasClass("deact")) {
return;
}
var item = $(this).closest(".invName").attr("id");
var itemmod = inventory[item]["mods"];
var itemhold = inventory[item];
if ($(this).hasClass("active")) {
$(this).removeClass("active");
itemmod["internalsmart"] = "empty";
if (itemmod.top == "Smartgun" || itemmod.under == "Smartgun") { //this figures out of accuracy bonus
itemhold["accmod"] -= 0;
} else if (itemmod.top == "Laser Sight" || itemmod.under == "Laser Sight" || itemmod["integral"].indexOf("Laser Sight") !== -1) {
itemhold["accmod"] -= 1;
} else {
itemhold["accmod"] -= 2;
}
for (var key in weapons) {
if (weapons[key]["name"] == itemhold["name"]) {
nuyen += weapons[key]["cost"];
itemhold["cost"] -= weapons[key]["cost"];
itemhold["avail"] -= 2;
if (weapons[key]["restrict"] == " ") {
itemhold["restrict"] = " ";
}
}
}
} else {
$(this).addClass("active");
itemmod["internalsmart"] = "Smartgun";
if (itemmod.top == "Smartgun" || itemmod.under == "Smartgun") { //this figures out of accuracy bonus
itemhold["accmod"] += 0;
} else if (itemmod.top == "Laser Sight" || itemmod.under == "Laser Sight" || itemmod["integral"].indexOf("Laser Sight") !== -1) {
itemhold["accmod"] += 1;
} else {
itemhold["accmod"] += 2;
}
for (var key in weapons) {
if (weapons[key]["name"] == itemhold["name"]) {
nuyen -= weapons[key]["cost"];
itemhold["cost"] += weapons[key]["cost"];
itemhold["avail"] += 2;
if (itemhold["restrict"] == " ") {
itemhold["restrict"] = "Restricted";
}
}
}
}
displayUpdater();
}
function shockPadding() {
if ($(this).hasClass("deact")) {
return;
}
var item = $(this).closest(".invName").attr("id");
var itemmod = inventory[item]["mods"];
var itemhold = inventory[item];
if ($(this).hasClass("active")) {
$(this).removeClass("active");
itemmod["shockpad"] = "empty";
itemhold["rc"]--;
nuyen += 50;
itemhold["cost"] -= 50;
} else {
$(this).addClass("active");
itemmod["shockpad"] = "Shock Pad";
itemhold["rc"]++;
nuyen -= 50;
itemhold["cost"] += 50;
}
displayUpdater();
}
//@TODO - rename function
function airBurstLink() {
if ($(this).hasClass("deact")) {
return;
}
var item = $(this).closest(".invName").attr("id");
var itemmod = inventory[item]["mods"];
var itemhold = inventory[item];
if ($(this).hasClass("active")) {
$(this).removeClass("active");
itemmod["airburstlink"] = false;
nuyen += 600;
itemhold["cost"] -= 600;
} else {
$(this).addClass("active");
itemmod["airburstlink"] = true;
nuyen -= 600;
itemhold["cost"] += 600;
}
displayUpdater();
}
function holsters() { //this creates and manages the background stuff for the holsters of a gun
var item = $(this).closest(".invName").attr("id");
var itemmod = inventory[item]["mods"];
var itemhold = inventory[item];
if ($(this).hasClass("active")) {
$(this).removeClass("active");
if ($(this).hasClass("concealableholster")) {
itemmod["concealableholster"] = false;
nuyen += 150;
itemhold["cost"] -= 150;
} else if ($(this).hasClass("hiddenarmslide")) {
itemmod["hiddenarmslide"] = false;
nuyen += 350;
itemhold["cost"] -= 350;
} else if ($(this).hasClass("quickdrawholster")) {
itemmod["quickdrawholster"] = false;
nuyen += 175;
itemhold["cost"] -= 175;
}
} else {
$(this).addClass("active");
if ($(this).hasClass("concealableholster")) {
itemmod["concealableholster"] = true;
nuyen -= 150;
itemhold["cost"] += 150;
} else if ($(this).hasClass("hiddenarmslide")) {
itemmod["hiddenarmslide"] = true;
nuyen -= 350;
itemhold["cost"] += 350;
} else if ($(this).hasClass("quickdrawholster")) {
itemmod["quickdrawholster"] = true;
nuyen -= 175;
itemhold["cost"] += 175;
}
}
displayUpdater();
}
function buyingAmmo() {
var ammo = $(this).parent().attr("class");
var gunclass = $(this).closest(".ammunition").attr("id");
if ($(this).parent().hasClass("gas")) {
gasname = $("select.toxicgas").val();
gas = toxin[gasname];
if (typeof ammunition[gasname] === 'undefined') {
ammunition[gasname] = {
name: gas["name"],
ammo: 0,
class: "grenades",
dammod: gas["power"],
typemod: gas["effect"],
elemod: "",
apmod: 0,
blast: "10m Radius",
avail: gas["avail"] + 2,
restrict: gas["restrict"],
cost: gas["cost"] + 40
};
z = ammunition[gasname];
$(".gas").after("<tr class='" + gasname + "'><td class='buygrenades button'>+</td><td class='amountofammo'>0</td><td class='sellgrenades button'>-</td><td class='grenadesname'>" + z["name"] + "</td><td class='grenadesdammod'>" + z["dammod"] + " " + z["typemod"] + " " + z["elemod"] + "</td><td class='apmod'>" + z["apmod"] + "</td><td class='blast'>" + z["blast"] + "</td><td class='avail'>" + z["avail"] + " " + z["restrict"] + "</td><td class='cost'>" + z["cost"] + "¥</td></tr>");
}
return;
}
if (typeof inventory[gunclass + ammo] === 'undefined') {
inventory[gunclass + ammo] = {};
for (var key in ammunition[ammo]) {
inventory[gunclass + ammo][key] = ammunition[ammo][key];
}
}
var invammo = inventory[gunclass + ammo];
inventory[gunclass + ammo]["class"] = gunclass;
if (nuyen - inventory[gunclass + ammo]["cost"] > 0 && $(this).hasClass("buyammo")) {
addAmmo($(this), gunclass + ammo, 10, invammo);
} else if (inventory[gunclass + ammo]["ammo"] > 0 && $(this).hasClass("sellammo")) {
subAmmo($(this), gunclass + ammo, 10, invammo);
} else if (nuyen - inventory[gunclass + ammo]["cost"] > 0 && $(this).hasClass("buygrenades")) {
addAmmo($(this), gunclass + ammo, 1, invammo);
} else if (inventory[gunclass + ammo]["ammo"] > 0 && $(this).hasClass("sellgrenades")) {
subAmmo($(this), gunclass + ammo, 1, invammo);
}
nuyenUpdater();
}
//@TODO - rename parameters
function addAmmo(w, x, y) { //w=this, x=name of ammo in inventory, y=amount of ammo bought at a time
inventory[x]["ammo"] += y;
nuyen -= inventory[x]["cost"];
$(w.next(".amountofammo")).empty().append(inventory[x]["ammo"]);
}
//@TODO - rename parameters
function subAmmo(w, x, y) { //w=this, x=name of ammo in inventory, y=amount of ammo bought at a time
inventory[x]["ammo"] -= y;
nuyen += inventory[x]["cost"];
$(w.prev(".amountofammo")).empty().append(inventory[x]["ammo"]);
}
function toxicgas() {
gasGrenade($(this).val());
}
//@TODO - rename parameter
function gasGrenade(x) {
$(".gas .grenadesdammod").empty().append(toxin[x]["power"] + " " + toxin[x]["effect"]);
$(".gas .avail").empty().append((toxin[x]["avail"] + 2) + " " + toxin[x]["restrict"]);
$(".gas .cost").empty().append((toxin[x]["cost"] + 40) + "¥");
}
//@TODO - rename function
function kaboom() {
if ($(this).hasClass("deact")) {
return;
}
var bomb = $(this).parent().attr("class");
if ($(this).hasClass("bombup") && explosives[bomb]["rating"] < 25) {
explosives[bomb]["rating"]++;
bombupdate(bomb);
} else if ($(this).hasClass("bombdown") && explosives[bomb]["rating"] > 6) {
explosives[bomb]["rating"]--;
bombupdate(bomb);
}
//@TODO - move function outside of function
//@TODO - rename parameter
function bombupdate(x) {
$("." + x + " .explosiverating").empty().append(explosives[x]["rating"]);
explosives[x]["cost"] = explosives[x]["rating"] * 100;
$("." + x + " .bombbond").empty().append(explosives[x]["cost"] + "¥");
}
}
//@TODO - rename function
function bombsaway() {
var bomb = $(this).parent().attr("class");
if ($(this).hasClass("buybomb") && nuyen - explosives[bomb]["cost"] > 0) {
inventory[bomb + invNum] = {};
bombname = bomb + invNum;
for (var key in explosives[bomb]) {
inventory[bombname][key] = explosives[bomb][key];
}
inventory[bombname]["kg"] = 1;
$("." + bomb + ".explosives").append("<tr class='" + bombname + "'><td class='sellbomb button'><em>-<em></td><td class='inventory' colspan=4></td><td class='bombprice'>" + inventory[bombname]["cost"] + "¥</td></tr>");
$("." + bombname + " .inventory").append("<td>Rating</td><td>" + inventory[bombname]["rating"] + "</td><td>Kilograms</td><td class='kgup button'>+</td><td class='kg'>" + inventory[bombname]["kg"] + "</td><td class='kgdown button'>-</td>");
invNum++;
nuyen -= inventory[bombname]["cost"];
} else if ($(this).hasClass("sellbomb")) {
$("." + bomb).remove();
nuyen += inventory[bomb]["cost"];
delete inventory[bomb];
}
nuyenUpdater();
}
//@TODO - rename function
function fatboy() {
var bomb = $(this).parent().parent().attr("class");
if ($(this).hasClass("kgup") && nuyen - inventory[bomb]["rating"] * 100 >= 0) {
inventory[bomb]["kg"]++;
bombupdate(bomb);
if (inventory[bomb]["name"] == "Commercial") {
nuyen -= 100;
} else {
nuyen -= inventory[bomb]["rating"] * 100;
}
} else if ($(this).hasClass("kgdown") && inventory[bomb]["kg"] > 0) {
inventory[bomb]["kg"]--;
bombupdate(bomb);
if (inventory[bomb]["name"] == "Commercial") {
nuyen += 100
} else {
nuyen += inventory[bomb]["rating"] * 100;
}
}
nuyenUpdater();
//@TODO - move outside of function
//@TODO - rename parameter
function bombupdate(x) {
$("." + x + " .kg").empty().append(inventory[x]["kg"]);
if (inventory[x]["name"] == "Commercial") {
inventory[x]["cost"] = inventory[x]["kg"] * 100;
} else {
inventory[x]["cost"] = inventory[x]["kg"] * (inventory[x]["rating"] * 100);
}
$("." + x + " .bombprice").empty().append(inventory[x]["cost"] + "¥");
}
}
function buyDetonator() {
if (typeof inventory["detonator"] === 'undefined') {
inventory["detonator"] = {};
for (var key in detonator) {
inventory["detonator"][key] = detonator[key];
}
}
if ($(this).hasClass("buyDet") && nuyen - inventory["detonator"]["cost"] > 0) {
inventory["detonator"]["amount"]++;
nuyen -= inventory["detonator"]["cost"];
} else if ($(this).hasClass("sellDet") && inventory["detonator"]["amount"] > 0) {
inventory["detonator"]["amount"]--;
nuyen += inventory["detonator"]["cost"];
}
$(".caps").empty().append(inventory["detonator"]["amount"]);
nuyenUpdater();
}
//@TODO - rename function
function sponge() {
var armtype = $(this).parent().attr("class");
if (nuyen - armor[armtype]["cost"] < 0 || $(this).hasClass("deact")) {
return;
}
inventory[armtype + invNum] = {};
for (var key in armor[armtype]) {
inventory[armtype + invNum][key] = armor[armtype][key];
}
$("." + armtype).after("<tr class='" + armtype + invNum + "'><td class='sellarmor button'><em>-</em></td><td class='armormods' colspan=3></td><td class='armorcost'>" + inventory[armtype + invNum]["cost"] + "¥</td></tr>");
inventory[armtype + invNum]["mods"] = {}; //create emtpy mods section for intentory armor
for (var mods in armormods) { //this will add the mods
inventory[armtype + invNum]["mods"][mods] = {}; //this will add the name of the mods
for (var modstats in armormods[mods]) {
inventory[armtype + invNum]["mods"][mods][modstats] = armormods[mods][modstats]; //this adds all the stats for each mod
}
if (typeof armormods[mods]["rating"] !== "undefined") { //this is for mods that don't have ratings
$("." + armtype + invNum + " .armormods").append("<tr class='" + mods + "'><td>" + inventory[armtype + invNum]["mods"][mods]["name"] + "</td><td class='armmodup button'>+</td><td class='armmodrating'>0</td><td class='armmoddown button'>-</td><td>Capacity</td><td class='armorcap'>" + inventory[armtype + invNum]["mods"][mods]["capacity"] + "</td></tr>");
} else if (typeof armor[armtype]["helm"] === "undefined" && mods == "chemicalseal") { //this checks to see if the armor has a helm
//do nothing
} else { //this adds all other mods
modnorating(armtype + invNum, mods)
}
}
if (inventory[armtype + invNum]["helm"] == false) { //if the armor supports a helm, add it to the mods
$("." + armtype + invNum + " .armormods").append("<tr class='helm'><td>Helmet</td><td class='buyhelmmod button' colspan=3><strong>+</strong></td></tr>");
}
nuyen -= armor[armtype]["cost"];
invNum++;
nuyenUpdater();
//@TODO - move function
//@TODO - rename parameters
function modnorating(x, y) {
$("." + x + " .armormods").append("<tr class='" + y + "'><td>" + inventory[armtype + invNum]["mods"][y]["name"] + "</td><td class='buyarmmod button' colspan=3><strong>+</strong></td><td>Capacity</td><td>" + inventory[armtype + invNum]["mods"][y]["capacity"] + "</td></tr>");
}
}
function clearArmor() {
var armtype = $(this).parent().attr("class");
nuyen += inventory[armtype]["cost"];
$("." + armtype).remove();
delete inventory[armtype];
nuyenUpdater();
}
function armorModding() {
mod = $(this).parent().attr("class");
item = $(this).parent().parent().parent().attr("class");
invmod = inventory[item]["mods"][mod];
var legit = nuyen - invmod["cost"] > 0;
if ($(this).hasClass("armmodup") && invmod["rating"] < 6 && inventory[item]["capacity"] < inventory[item]["armor"] && legit) {
invmod["rating"]++;
inventory[item]["capacity"]++;
nuyen -= invmod["cost"];
inventory[item]["cost"] += invmod["cost"];
modUpdater(item, mod, invmod);
} else if ($(this).hasClass("armmoddown") && invmod["rating"] > 0) {
invmod["rating"]--;
inventory[item]["capacity"]--;
nuyen += invmod["cost"];
inventory[item]["cost"] -= invmod["cost"];
modUpdater(item, mod, invmod);
} else if ($(this).hasClass("buyarmmod") && invmod["active"] == false && invmod["capacity"] + inventory[item]["capacity"] <= inventory[item]["armor"] && legit) {
inventory[item]["capacity"] += invmod["capacity"];
nuyen -= invmod["cost"];
inventory[item]["cost"] += invmod["cost"];
invmod["active"] = true;
sellSign($(this));
costUpdater(item);
if (mod == "chemicalseal" && inventory[item]["helm"] == false) {
turnonhelm(item, $("." + item + " .buyhelmmod"));
}
} else if ($(this).hasClass("buyarmmod") && invmod["active"] == true) {
inventory[item]["capacity"] -= invmod["capacity"];
nuyen += invmod["cost"];
inventory[item]["cost"] -= invmod["cost"];
invmod["active"] = false;
buySign($(this));
costUpdater(item);
}
nuyenUpdater();
function modUpdater(x, y, z) {
$("." + x + " ." + y + " .armmodrating, ." + x + " ." + y + " .armorcap").empty().append(z["rating"]);
costUpdater(x);
}
}
function helmup() {
item = $(this).parent().parent().parent().attr("class");
if (inventory[item]["helm"] == false && nuyen - inventory[item]["helmmod"]["cost"] > 0) {
turnonhelm(item, $(this));
} else {
buySign($(this));
inventory[item]["helm"] = false;
nuyen += inventory[item]["helmmod"]["cost"];
inventory[item]["cost"] -= inventory[item]["helmmod"]["cost"];
costUpdater(item);
if (inventory[item]["mods"]["chemicalseal"]["active"] == true) {
invmod = inventory[item]["mods"]["chemicalseal"];
inventory[item]["capacity"] -= invmod["capacity"];
nuyen += invmod["cost"];
inventory[item]["cost"] -= invmod["cost"];
invmod["active"] = false;
buySign($("." + item + " .chemicalseal .buyarmmod"));
costUpdater(item);
}
}
nuyenUpdater();
}
function turnonhelm(item, x) {
sellSign(x);
inventory[item]["helm"] = true;
nuyen -= inventory[item]["helmmod"]["cost"];
inventory[item]["cost"] += inventory[item]["helmmod"]["cost"];
costUpdater(item);