-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStarship.html
More file actions
929 lines (846 loc) · 39.9 KB
/
Starship.html
File metadata and controls
929 lines (846 loc) · 39.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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
<!doctype html>
<html>
<style>
html {
background-color: black;
color : white;
}
div{
color: white;
}
th {
font-size: 120%;
background-color: orange;
}
th.headsection {
background-color: black;
}
td.section {
background-color: black;
min-width: 25em;
}
td.headsection {
background-color: black;
}
td {
background-color: purple;
}
td.buttonSection {
min-width: 3em;
max-width: 3em
}
th.orangeBar {
column-span: 5
}
textarea {
min-height:6em;
min-width: 25em;
}
</style>
<head>
<title>Starship Character Sheet</title>
</head>
<body>
<div>
<H2>Starship Character Sheet</H2>
<p>
<input value="New Ship", id="newButton", type="button">
<input value="Load Ship", id="loadButton", type="button">
</p>
<p>
<input type="file", id="loadFile", hidden=true>
</p>
<p>
<input value="Import Ship", id="importButton", type="button", hidden=true>
<input value="Cancel", id="cancelButton", type="button", hidden=true>
</p>
</div>
<div id="charSheet" hidden=true>
<table>
<tr>
<td>Ship Name</td>
<td id="shipNameTd">
<input id="shipName" value="Ship Name" type=text>
</td>
<td id=shipNameTextTd hidden=true></td>
<td id="setNameButtonTd" hidden = true>
<input id="setNameButton" value="Set Name" type=button>
</td>
</tr>
<tr>
<td>Ship Class</td>
<td id="shipClassTd">
<select id="shipClass">
<option value="Akira">Akira</option>
<option value="Constellation">Constellation</option>
<option value="Constitution">Constitution</option>
<option value="Defiant">Defiant</option>
<option value="Excelsior">Excelsior</option>
<option value="Galaxy">Galaxy</option>
<option value="Intrepid">Intrepid</option>
<option value="Miranda">Miranda</option>
<option value="Nova">Nova</option>
</select>
</td>
<td id=shipClassTextTd hidden=true></td>
<td id="setClassButtonTd" hidden=false>
<input type=button id="setClassButton" value="Choose Class">
</td>
</tr>
<tr>
<td>Mission Profile</td>
<td id="missionProfileSelectTd" hidden=true>
<select id="missionProfile">
<option value="Strategic and Diplomatic Operations">Strategic and Diplomatic Operations</option>
<option value="Pathfinder and Reconnaissance Operations">Pathfinder and Reconnaissance Operations</option>
<option value="Technical Testbed">Technical Testbed</option>
<option value="Tactical Operations">Tactical Operations</option>
<option value="Scientific and Survey Operations">Scientific and Survey Operations</option>
<option value="Crisis and Emergency Response">Crisis and Emergency Response</option>
<option value="Multirole Explorer">Multirole Explorer</option>
</select>
</td>
<td id="missionProfileTextTd" hidden=true></td>
<td id="missionProfileButtonTd" hidden=true>
<input type="button" id="missionProfileButton" value="Set Mission Profile" disabled=true>
</td>
</tr>
</table>
<table>
<tr>
<th></th>
<th class = "headsection">Systems</th>
<th class="headsection"></th>
<th colspan="3"></th>
</tr>
<tr>
<td class="headsection"></td>
<td>Comms</td>
<td id="commsTd">0</td>
<td id="commsUpButtontd" hidden="true">
<input id="commsUpButton" type=button value="+">
</td>
<td id="commsDownButtontd" hidden="true">
<input id="commsDownButton" type=button value="-">
</td>
<td class="section"></td>
</tr>
<tr>
<td class="headsection"></td>
<td>Engines</td>
<td id="enginesTd">0</td>
<td id="engineUpButtontd" hidden="true">
<input id="engineUpButton" type=button value="+">
</td>
<td id="engineDownButtontd" hidden="true">
<input id="engineDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Structure</td>
<td id="structureTd">0</td>
<td id="strucUpButtontd" hidden="true">
<input id="strucUpButton" type=button value="+">
</td>
<td id="strucDownButtontd" hidden="true">
<input id="strucDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Computers</td>
<td id="computersTd">0</td>
<td id="compUpButtontd" hidden="true">
<input id="compUpButton" type=button value="+">
</td>
<td id="compDownButtontd" hidden="true">
<input id="compDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Sensors</td>
<td id="sensorsTd">0</td>
<td id="sensUpButtontd" hidden="true">
<input id="sensUpButton" type=button value="+">
</td>
<td id="sensDownButtontd" hidden="true">
<input id="sensDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Weapons</td>
<td id="weaponsTd">0</td>
<td id="weapUpButtontd" hidden="true">
<input id="weapUpButton" type=button value="+">
</td>
<td id="weapDownButtontd" hidden="true">
<input id="weapDownButton" type=button value="-">
</td>
</tr>
<tr>
<th></th>
<th class = "headsection">Departments</th>
<th class="headsection"></th>
<th colspan="3"></th>
</tr>
<tr>
<td class="headsection"></td>
<td>Command</td>
<td id="commandTd">0</td>
<td id="cmdUpButtontd" hidden="true">
<input id="cmdUpButton" type=button value="+">
</td>
<td id="cmdDownButtontd" hidden="true">
<input id="cmdDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Security</td>
<td id="securityTd">0</td>
<td id="secUpButtontd" hidden="true">
<input id="secUpButton" type=button value="+">
</td>
<td id="secDownButtontd" hidden="true">
<input id="secDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Science</td>
<td id="scienceTd">0</td>
<td id="sciUpButtontd" hidden="true">
<input id="sciUpButton" type=button value="+">
</td>
<td id="sciDownButtontd" hidden="true">
<input id="sciDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Conn</td>
<td id="connTd">0</td>
<td id="connUpButtontd" hidden="true">
<input id="connUpButton" type=button value="+">
</td>
<td id="connDownButtontd" hidden="true">
<input id="connDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Engineering</td>
<td id="engineeringTd">0</td>
<td id="engUpButtontd" hidden="true">
<input id="engUpButton" type=button value="+">
</td>
<td id="engDownButtontd" hidden="true">
<input id="engDownButton" type=button value="-">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td>Medicine</td>
<td id="medicineTd">0</td>
<td id="medUpButtontd" hidden="true">
<input id="medUpButton" type=button value="+">
</td>
<td id="medDownButtontd" hidden="true">
<input id="medDownButton" type=button value="-">
</td>
</tr>
</table>
<table>
<tr>
<th></th>
<th class = "headsection">Talents</th>
<th class="orangeBar" colspan="5"></th>
</tr>
<tr id=talentRow hidden=true>
<td class = "headsection" colspan="4">
<select id=talentField></select>
<input type=button id="talentButton" value="Add Talent to List">
</td>
<td class="headsection"></td>
</tr>
<tr id="profileTalentTr" hidden = true>
<td class="headsection"></td>
<td class="headsection" colspan="2">
<select id=profileTalentSelect></select>
</td>
<td class="headsection">
<input id=profileTalentButton type="button" value="Choose">
</td>
<td class="headsection"></td>
</tr>
<tr>
<td class="headsection"></td>
<td class = "headsection" colspan="2">
<textarea id="talentDisplay" readonly></textarea>
</td>
</tr>
<tr>
<th></th>
<th class = "headsection" width="5em">Traits</th>
<th class="orangeBar" colspan="5"></th>
</tr>
<tr id=traitRow hidden=true>
<td class="headsection"></td>
<td class = "headsection" colspan="4">
<input type=text id="traitField">
<input type=button id="traitButton" value="Add Trait to List">
</td>
<td class="headsection"></td>
</tr>
<tr>
<td class="headsection"></td>
<td class = "headsection" colspan="2">
<textarea id="traitDisplay" readonly ></textarea>
</td>
<td class="section"></td>
</tr>
<tr>
<th></th>
<th class = "headsection">Weapons</th>
<th class="orangeBar" colspan="6"></th>
</tr>
<tr id=weaponRow hidden=true>
<td class="headsection"></td>
<td class = "headsection">
<select id="typeSelect">
<option>Phaser</option>
<option>Disruptor</option>
<option>Phased Polaron Beam</option>
</select>
</td>
<td class = "headsection">
<select id="deliverySelect">
<option>Cannons</option>
<option>Banks</option>
<option>Arrays</option>
</select>
</td>
<td class = "headsection">
<input type=button id="weaponButton" value="Add Weapon">
</td>
<td class="section"></td>
</tr>
<tr id=torpedoRow hidden=true>
<td class="headsection"></td>
<td class = "headsection">
<select id="torpedoSelect">
<option>Photon Torpedo</option>
<option>Quantum Torpedo</option>
<option>Plasma Torpedo</option>
</select>
</td>
<td class = "headsection">
<input type=button id="torpedoButton" value="Add Torpedo">
</td>
</tr>
<tr>
<td class="headsection"></td>
<td class = "headsection" colspan="2">
<textarea id="weaponDisplay" readonly></textarea>
</td>
</tr>
</table>
<input id="editButton" type=button value=Edit>
<input value="Download", id="downloadButton", type="button">
<input value="Cancel", id="cancelNewButton", type="button">
</div>
<script>
/*
TO DO LIST:
Better implementation than textarea for display of traits weapons and talents Unordered List? embedded table with highlighted rows? CSS rule to turn off bullets
Would like to be able to remove entries from the above by clicking them and then clicking a remove button multiselect/combo box
Weapon damages should adjust when Security score changes
Edit button triggers editable on Name, Class and Profile
Add nonship building fields (power, shields, etc)
Add picture of ships when Class is selected
Clicking on talent explains what it does
Admin tab? Allow DM to add traits and talents? Would need to track as part of the ship, possibly a separate save file... Might be something to modify if I ever add a backend/serverside element to this for tracking ships in the cloud. appstate
Need to find out how to change the filetype on the output file from txt to JSON or something
*/
var ship = {
name:"",
class:"",
scale:0,
//systems[comms, engines, structure, computers, sensors, weapons]
systems:[0,0,0,0,0,0],
//departments[command, security, science, conn, engineering, medicine]
departments:[0,0,0,0,0,0],
weaponry:"",
talents:"",
traits:"",
profileVals:[0,0,0,0,0,0],
missionProfile:""
};
let editFlag = false;
let newFlag = false;
let starDate = 2371;
let inserviceDate = 2017;
let numRefits = 0;
let buttons = [commsUpButtontd, commsDownButtontd, engineUpButtontd, engineDownButtontd, strucUpButtontd, strucDownButtontd, compUpButtontd, compDownButtontd, sensUpButtontd, sensDownButtontd, weapUpButtontd, weapDownButtontd, cmdUpButtontd, cmdDownButtontd, connUpButtontd, connDownButtontd, secUpButtontd, secDownButtontd, engUpButtontd, engDownButtontd, sciUpButtontd, sciDownButtontd, medUpButtontd, medDownButtontd, traitRow, talentRow, weaponRow, torpedoRow];
let profiles = {
"Strategic and Diplomatic Operations":[3,2,2,1,2,2],
"Pathfinder and Reconnaissance Operations":[2,2,2,3,2,1],
"Technical Testbed":[1,2,2,2,3,2],
"Tactical Operations":[2,3,1,2,2,2],
"Scientific and Survey Operations":[2,1,3,2,2,2],
"Crisis and Emergency Response":[2,2,2,2,1,3],
"Multirole Explorer":[2,2,2,2,2,2]
};
let talentChoices = ["Ablative Armor", "Advanced Research Facilities", "Advanced Sensor Suites", "Advanced Shields", "Advanced Sickbay", "Backup EPS Conduits", "Command Ship", "Diplomatic Suites", "Electronic Warfare Systems", "Emergency Medical Hologram", "Extensive Shuttlebays", "Fast Targeting Systems", "High Resolution Sensors", "Improved Damage Control", "Improved Hull Integrity", "Improved Impulse Drive", "Improved Power Systems", "Improved Reaction Control System", "Improved Shield Recharge", "Improved Warp Drive", "Modular Laboratories", " Quantum Torpedoes", "Rapid-Fire Torpedo Launcher", "Redundant Systems", "Rugged Design", "Saucer Separation", "Secondary Reactors"];
let profilesChoices = {
"Strategic and Diplomatic Operations":`<option>Command Ship</option>\n<option>Diplomatic Suites</option>\n<option>Electronic Warfare Systems</option>\n<option>Extensive Shuttlebays</option>`,
"Pathfinder and Reconnaissance Operations":`<option>Improved Reaction Control System</option>\n<option>Improved Warp Drive</option>\n<option>Rugged Design</option>`,
"Technical Testbed":`<option>Advanced Shields</option>\n<option>Backup EPS Conduits</option>\n<option>High Resolution Sensors</option>\n<option>Improved Power Systems</option>\n<option>Improved Warp Drive</option>`,
"Tactical Operations":`<option>Ablative Armor</option>\n<option>Fast Targeting Systems</option>\n<option>Improved Damage Control</option>\n<option>Quantum Torpedoes</option>\n<option>Improved Impulse Drive</option>`,
"Scientific and Survey Operations":`<option>Advanced Research Facilities</option>\n<option>Advanced Sensor Suites</option>\n<option>High Resolution Sensors</option>\n<option>Modular Laboratories</option>`,
"Crisis and Emergency Response":`<option>Advanced Sickbay</option>\n<option>Emergency Medical Hologram</option>\n<option>Extensive Shuttlebays</option>\n<option>Modular Laboratories</option>`,
"Multirole Explorer":`<option>Improved Hull Integrity</option>\n<option>Improved Power Systems</option>\n<option>Rugged Design</option>\n<option>Redundant Systems</option>\n<option>Secondary Reactors</option>`
};
let weapQual = {
"Photon Torpedo":"High Yield",
"Quantum Torpedo":"Calibration, High Yield",
"Plasma Torpedo":"Calibration",
"Phaser":"Versatile 2",
"Disruptor":"Vicious 1",
"Phased Polaron Beam": "",
};
let weapDamage = {
"Cannons":2,
"Banks":1,
"Arrays":0,
"Photon Torpedo":3,
"Quantum Torpedo":4,
"Plasma Torpedo":3
};
let weapRange = {
"Cannons":"Close",
"Banks": "Medium",
"Arrays": "Medium"
};
function download(filename, text) {
console.log("download fired");
let element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
function loadHandler() {
console.log("loadHandler fired");
newButton.hidden = true;
loadFile.hidden = false;
importButton.hidden = false;
loadButton.hidden = true;
cancelButton.hidden = false;
newFlag = false;
}
function newHandler() {
console.log("newHandler fired");
newButton.hidden = true;
loadButton.hidden = true;
loadFile.hidden = true;
importButton.hidden = true;
cancelButton.hidden = true;
charSheet.hidden = false;
missionProfileSelectTd.hidden = false;
missionProfileButtonTd.hidden = false;
missionProfileTextTd.hidden = true;
missionProfileButton.disabled = true;
setClassButtonTd.hidden=false;
setNameButtonTd.hidden=false;
newFlag = true;
}
function cancelHandler() {
console.log("cancelHandler fired");
newButton.hidden = false;
loadButton.hidden = false;
loadFile.hidden = true;
importButton.hidden = true;
shipClassTd.hidden = false;
shipClassTextTd.hidden = true;
shipNameTextTd.hidden = true;
shipNameTd.hidden = false;
cancelButton.hidden = true;
charSheet.hidden = true;
profileTalentTr.hidden = true;
ship.name = "";
ship.class = "";
ship.scale = 0;
ship.weaponry = "";
ship.talents = "";
ship.traits = "";
for(let i = 0; i < 6; i++){
ship.systems[i] = 0;
ship.departments[i] = 0;
}
shipClass.value = "Akira";
missionProfile.value = "Strategic and Diplomatic Operations";
updateStats();
talentDisplay.value = "";
if(editFlag){
editHandler();
}
}
function downloadHandler() {
console.log("downloadHandler fired");
let jsonShip = JSON.stringify(ship);
download(ship.name, jsonShip);
}
function importHandler() {
console.log("importHandler fired");
var files = document.getElementById('loadFile').files;
console.log(files);
if (files.length <= 0) {
return false;
}
var fr = new FileReader();
fr.onload = function(e) {
console.log(e);
var myship = JSON.parse(e.target.result);
ship.name = myship.name;
ship.class = myship.class;
ship.scale = myship.scale;
ship.weaponry = myship.weaponry;
ship.talents = myship.talents;
ship.traits = myship.traits;
ship.missionProfile = myship.missionProfile;
for(let i = 0; i < 6; i++){
ship.systems[i] = myship.systems[i];
ship.departments[i] = myship.departments[i];
}
updateStats();
shipNameTd.hidden = true;
setNameButtonTd.hidden = true;
shipNameTextTd.textContent = ship.name;
shipNameTextTd.hidden = false;
shipClassTd.hidden = true;
setClassButtonTd.hidden = true;
shipClassTextTd.textContent = ship.class;
shipClassTextTd.hidden = false;
missionProfileSelectTd.hidden = true;
missionProfileTextTd.textContent = ship.missionProfile;
missionProfileTextTd.hidden = false;
missionProfileButtonTd.hidden = true;
};
fr.readAsText(files.item(0));
loadFile.hidden = true;
importButton.hidden = true;
cancelButton.hidden = true;
charSheet.hidden = false;
}
function editHandler() {
console.log("editHandler fired");
for(let btn in buttons){
buttons[btn].hidden = editFlag;
}
editFlag = !editFlag;
}
function systIncrease(statID,stat){
return function() {
console.log(ship.systems[stat]);
if(ship.systems[stat]<11){
ship.systems[stat]++;
} else if(ship.systems[stat] === 11 && !twelveExists()){
ship.systems[stat]++;
} else {
alert("Only one system may be at 12, and 12 is the max for any one system");
}
console.log(ship.systems[stat]);
//statID.textContent = String(ship.systems[stat]);
updateStats();
};
}
function systDecrease(statID,stat){
return function() {
console.log(ship.systems[stat]);
if(ship.systems[stat] > 0){
ship.systems[stat]--;
}
console.log(ship.systems[stat]);
//statID.textContent = String(ship.systems[stat]);
updateStats();
};
}
function deptIncrease(statID,stat){
return function() {
console.log(ship.departments[stat]);
if(ship.departments[stat]<12){
ship.departments[stat]++;
}
console.log(ship.departments[stat]);
//statID.textContent = String(ship.departments[stat]);
updateStats();
};
}
function deptDecrease(statID,stat){
return function() {
console.log(ship.departments[stat]);
if(ship.departments[stat] > 0){
ship.departments[stat]--;
}
console.log(ship.departments[stat]);
//statID.textContent = String(ship.departments[stat]);
updateStats();
};
}
function setClassHandler() {
console.log("setClassHandler fired");
shipClassTd.hidden = true;
setClassButtonTd.hidden = true;
let newClass = shipClass.value;
ship.class = newClass;
shipClassTextTd.textContent = ship.class;
shipClassTextTd.hidden = false;
switch(ship.class){
case "Akira":
ship.scale = 5;
ship.systems = [9,10,11,9,9,11];
ship.departments = [0,2,0,0,0,1];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Arrays\t ${damage} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 4)\n`;
ship.talents = "Ablative Armor\nExtensive Shuttlebays\nRapid Fire Torpedo Launcher\n";
inserviceDate = 2368;
break;
case "Constellation":
ship.scale = 4;
ship.systems = [8,9,8,7,9,9];
ship.departments = [0,1,0,1,1,0];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Banks\t ${damage + 1} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 2)\n`;
ship.talents = "Improved Warp Drive\nExtensive Shuttlebays\n";
inserviceDate = 2285;
break;
case "Constitution":
ship.scale = 4;
ship.systems = [7,8,8,7,8,8];
ship.departments = [1,1,1,0,0,0];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Banks\t ${damage + 1} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 3)\n`;
ship.talents = "Rugged Design\nModular Laboratories\n";
inserviceDate = 2243;
break;
case "Defiant":
ship.scale = 3;
ship.systems = [9,10,8,9,9,13];
ship.departments = [0,2,0,1,0,0];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Arrays\t ${damage} \u25B5\t${weapQual["Phaser"]}\nPhaser Cannon\t ${damage + 2} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nQuantum Torpedo\t ${ship.departments[1] + 4} \u25B5 Vicious 1\t${weapQual["Quantum Torpedo"]}\nTractor Beam(Strength 2)\n`;
ship.talents = "Ablative Armor\nQuantum Torpedoes\n";
inserviceDate = 2371;
break;
case "Excelsior":
ship.scale = 5;
ship.systems = [8,9,9,8,8,9];
ship.departments = [1,0,0,0,2,0];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Banks\t ${damage + 1} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 4)\n";
ship.talents = "improved Impulse Drive\nSecondary Reactors\n`;
inserviceDate = 2285;
break;
case "Galaxy":
ship.scale = 6;
ship.systems = [9,10,10,10,9,10];
ship.departments = [1,0,1,0,0,1];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Arrays\t ${damage} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 5)\n`;
ship.talents = "Saucer Separation\nModular Laboratories\nRedundant Systems\n";
inserviceDate = 2359;
break;
case "Intrepid":
ship.scale = 4;
ship.systems = [10,11,8,11,10,9];
ship.departments = [0,0,2,1,0,0];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Arrays\t ${damage} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 3)\n`;
ship.talents = "Improved Warp Drive\nAdvanced Sensor Suites\nEmergency Medical Hologram\n";
inserviceDate = 2371;
break;
case "Miranda":
ship.scale = 4;
ship.systems = [8,8,8,8,9,9];
ship.departments = [1,0,1,1,0,0];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Banks\t ${damage + 1} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedo\t ${ship.departments[1] + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 3)\n`;
ship.talents = "Extensive Shuttlebays\n";
inserviceDate = 2274;
break;
case "Nova":
ship.scale = 3;
ship.systems = [10,9,8,10,10,8];
ship.departments = [0,0,2,0,1,0];
ship.traits = "Federation Ship\n";
damage = ship.scale + ship.departments[1];
ship.weaponry = `Phaser Arrays\t ${damage} \u25B5\t${weapQual["Phaser"]}\nPhoton Torpedoes\t ${ship.departments + 3} \u25B5\t${weapQual["Photon Torpedo"]}\nTractor Beam(Strength 2)\n`;
ship.talents = "Advanced Sensors\n";
inserviceDate = 2368;
break;
}
missionProfileButton.disabled = false;
updateStats();
}
function setNameHandler() {
console.log("setNameHandler fired");
shipNameTd.hidden = true;
setNameButtonTd.hidden = true;
let newName = shipName.value;
console.log(newName);
ship.name = String(newName);
shipNameTextTd.textContent = ship.name;
shipNameTextTd.hidden = false;
}
function talentHandler() {
console.log("talentHandler fired");
if(!ship.talents.includes(talentField.value)){
ship.talents += talentField.value + "\n";
}
console.log(ship.talents)
talentDisplay.value = ship.talents;
}
function traitHandler() {
console.log("traitHandler fired");
if(traitField.value != ""){
if(!ship.traits.includes(traitField.value)){
ship.traits += traitField.value + "\n";
}
}
console.log(ship.traits)
traitField.value = "";
traitDisplay.value = ship.traits;
}
function weaponHandler() {
console.log("weaponHandler fired");
let damage = ship.scale + ship.departments[1] + weapDamage[deliverySelect.value];
if(!ship.weaponry.includes(typeSelect.value + " " + deliverySelect.value)){
ship.weaponry += typeSelect.value + " " + deliverySelect.value + "\t" + damage + "\u25B5" + weapQual[typeSelect.value] + "\n";
}
console.log(ship.weaponry)
weaponDisplay.value = ship.weaponry;
}
function torpedoHandler() {
console.log("torpedoHandler fired");
let damage = ship.departments[1] + weapDamage[torpedoSelect.value];
if(!ship.weaponry.includes(torpedoSelect.value)){
ship.weaponry += torpedoSelect.value + "\t" + damage + "\u25B5" + weapQual[torpedoSelect.value] + "\n";
}
console.log(ship.weaponry)
weaponDisplay.value = ship.weaponry;
}
function missionProfileHandler() {
console.log("missionProfileHandler fired");
missionProfileSelectTd.hidden = true;
ship.missionProfile = missionProfile.value;
missionProfileTextTd.textContent = ship.missionProfile;
missionProfileTextTd.hidden = false;
missionProfileButtonTd.hidden = true;
profileTalentTr.hidden = false;
for(let i = 0; i < ship.departments.length; i++){
ship.departments[i] += profiles[missionProfile.value][i];
}
profileTalentSelect.innerHTML = profilesChoices[missionProfile.value];
updateStats();
}
function profileTalentHandler() {
console.log("profileTalentHandler fired");
profileTalentTr.hidden = true;
ship.talents += profileTalentSelect.value + "\n"
updateStats();
}
function updateStats() {
console.log("updateStats fired");
commsTd.textContent = String(ship.systems[0]);
enginesTd.textContent = String(ship.systems[1]);
structureTd.textContent = String(ship.systems[2]);
computersTd.textContent = String(ship.systems[3]);
sensorsTd.textContent = String(ship.systems[4]);
weaponsTd.textContent = String(ship.systems[5]);
commandTd.textContent = String(ship.departments[0]);
securityTd.textContent = String(ship.departments[1]);
scienceTd.textContent = String(ship.departments[2]);
connTd.textContent = String(ship.departments[3]);
engineeringTd.textContent = String(ship.departments[4]);
medicineTd.textContent = String(ship.departments[5]);
traitDisplay.value = ship.traits;
talentDisplay.value = ship.talents;
weaponDisplay.value = ship.weaponry;
}
function twelveExists() {
console.log("twelveExists fired");
for(let i = 0; i < ship.systems.length; i++){
if(ship.systems[i] >= 12){
updateStats();
return true;
}
}
return false;
}
function calcRefits() {
return (starDate - inserviceDate)/10;
}
loadButton.addEventListener("click", loadHandler);
newButton.addEventListener("click", newHandler);
downloadButton.addEventListener("click", downloadHandler);
cancelButton.addEventListener("click", cancelHandler);
importButton.addEventListener("click", importHandler);
editButton.addEventListener("click", editHandler);
//add event listeners to Systems section
commsUpButton.addEventListener("click", systIncrease("commsTd", 0));
commsDownButton.addEventListener("click", systDecrease("commsTd", 0));
engineUpButton.addEventListener("click", systIncrease("enginesTd", 1));
engineDownButton.addEventListener("click", systDecrease("enginesTd", 1));
strucUpButton.addEventListener("click", systIncrease("structureTd", 2));
strucDownButton.addEventListener("click", systDecrease("structureTd", 2));
compUpButton.addEventListener("click", systIncrease("computersTd", 3));
compDownButton.addEventListener("click", systDecrease("computersTd", 3));
sensUpButton.addEventListener("click", systIncrease("sensorsTd", 4));
sensDownButton.addEventListener("click", systDecrease("sensorsTd", 4));
weapUpButton.addEventListener("click", systIncrease("weaponsTd", 5));
weapDownButton.addEventListener("click", systDecrease("weaponsTd", 5));
//add event listeners to Departments section
cmdUpButton.addEventListener("click", deptIncrease("commandTd", 0));
cmdDownButton.addEventListener("click", deptDecrease("commandTd", 0));
secUpButton.addEventListener("click", deptIncrease("securityTd", 1));
secDownButton.addEventListener("click", deptDecrease("securityTd", 1));
sciUpButton.addEventListener("click", deptIncrease("scienceTd", 2));
sciDownButton.addEventListener("click", deptDecrease("scienceTd", 2));
connUpButton.addEventListener("click", deptIncrease("connTd", 3));
connDownButton.addEventListener("click", deptDecrease("connTd", 3));
engUpButton.addEventListener("click", deptIncrease("engineeringTd", 4));
engDownButton.addEventListener("click", deptDecrease("engineeringTd", 4));
medUpButton.addEventListener("click", deptIncrease("medicineTd", 5));
medDownButton.addEventListener("click", deptDecrease("medicineTd", 5));
setClassButton.addEventListener("click", setClassHandler);
setNameButton.addEventListener("click", setNameHandler);
cancelNewButton.addEventListener("click", cancelHandler);
talentButton.addEventListener("click", talentHandler);
traitButton.addEventListener("click", traitHandler);
weaponButton.addEventListener("click", weaponHandler);
torpedoButton.addEventListener("click", torpedoHandler);
missionProfileButton.addEventListener("click", missionProfileHandler);
profileTalentButton.addEventListener("click", profileTalentHandler);
console.log("EventListeners loaded");
let talentFill = "";
for(i in talentChoices){
talentFill += `<option>${talentChoices[i]}</option>\n`;
}
talentField.innerHTML = talentFill;
</script>
</body>
</html>