-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
549 lines (497 loc) · 26.8 KB
/
Copy pathindex.html
File metadata and controls
549 lines (497 loc) · 26.8 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
<!DOCTYPE html>
<!---
This is a random enemy generator for the board game
battlestations second edition. It was created based on the request by the author in
the rule book on page 160.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
see <http://www.gnu.org/licenses/>
Author: starchildren
Date: 2017-09-24
-->
<html lang="en">
<head>
<title>Battlestations Enemy Manager</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<style>
.custombtn{
border:0px solid transparent;
margin-left: 0;
}
.row{
margin: 0px;
}
</style>
</head>
<body>
<div class="container-fluid" style="margin-top:10px; margin-bottom:10px">
<div class="row">
<div class="col-sm-6">
<h1>Battlestations Enemy Manager</h1>
</div>
<div class="col-sm-6" style="font-size:small; margin-top:10px">
To roll dice for enemies, click on a skill. </br>
For professional re-rolls, click on a single die.
</div>
</div>
</div>
<div class="container-fluid" style="margin-bottom:10px">
<form class="form-inline">
<label class="form-control-label mr-sm-2 mb-0" for="md">Mission Difficulty</label>
<select class="form-control mr-sm-2 mb-0" id="md">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
<label class="form-control-label mr-sm-2 mb-0" for="players">Number of Players</label>
<select class="form-control mr-sm-2 mb-0" id="players">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
<label class="form-control-label mr-sm-2 mb-0" for="species">Enemy Species</label>
<select class="form-control mr-sm-2 mb-0" id="species">
<option>Bot</option>
<option>Blootian</option>
<option>Canosian</option>
<option>Diploid</option>
<option>Fungaloid</option>
<option>Human</option>
<option>Kerbite</option>
<option>Silicoid</option>
<option>Tentac</option>
<option>Trundlian</option>
<option>Vomeg</option>
<option>Whistler</option>
<option>Xeloxian</option>
<option>Zoallan</option>
<option>Avianoid</option>
<option>Cheetahoid</option>
<option>Crocodillian</option>
<option>Elephantoid</option>
<option>Felinoids</option>
<option>Gorilloids</option>
<option>Lupinoids</option>
<option>Lapinoid</option>
<option>Rhinoceroid</option>
<option>Reptilianoid</option>
<option>Testudinoid</option>
<option>Ursinoid</option>
</select>
<div class="form-check mr-sm-2 mb-0">
<label><input type="checkbox" value="" id="random_species"> Pick Random Species?</label>
</div>
<div class="mr-sm-2 mb-0">
<button class="btn btn-secondary" id="submit">Submit</button>
</div>
</form>
</div>
<div id="enemiesDiv" class="container-fluid" style="margin-bottom:10px">
</div>
<script>
// Mission Difficulty Tables
const MD0 = {"2":[1,2,0], "3":[1,2,0], "4":[1,2,0], "5":[1,2,0], "6":[1,2,0], "7":[1,2,0], "8":[1,2,0], "9":[1,2,0], "10":[1,2,0], "11":[1,2,0], "12":[1,2,0]};
const MD1 = {"2":[1,2,1], "3":[1,2,1], "4":[1,2,1], "5":[1,3,0], "6":[1,3,0], "7":[1,3,0], "8":[1,3,0], "9":[2,2,0], "10":[2,2,0], "11":[2,2,0], "12":[2,2,0]};
const MD2 = {"2":[1,3,1], "3":[1,2,2], "4":[2,3,1], "5":[1,4,1], "6":[1,3,2], "7":[2,4,1], "8":[2,3,2], "9":[1,4,2], "10":[1,5,1], "11":[3,4,1], "12":[2,4,2]};
const MD3 = {"2":[2,5,1], "3":[2,3,3], "4":[1,5,2], "5":[3,4,2], "6":[1,4,3], "7":[3,5,1], "8":[1,6,1], "9":[2,5,2], "10":[2,4,3], "11":[2,6,1], "12":[3,5,2]};
const MD4 = {"2":[2,4,4], "3":[1,6,3], "4":[1,5,4], "5":[4,6,1], "6":[3,6,2], "7":[3,5,3], "8":[2,6,3], "9":[3,7,1], "10":[3,4,4], "11":[2,7,2], "12":[4,6,2]};
const MD5 = {"2":[4,5,3], "3":[1,7,3], "4":[3,6,3], "5":[4,7,1], "6":[2,5,4], "7":[2,8,1], "8":[2,7,3], "9":[4,6,3], "10":[2,6,4], "11":[4,7,2], "12":[2,8,2]};
const MD6 = {"2":[4,5,4], "3":[3,7,3], "4":[3,6,4], "5":[1,9,1], "6":[3,8,2], "7":[4,8,1], "8":[1,7,4], "9":[2,9,1], "10":[2,8,3], "11":[2,7,4], "12":[4,6,4]};
const MD7 = {"2":[4,8,2], "3":[3,9,1], "4":[2,6,5], "5":[3,7,4], "6":[4,9,1], "7":[4,7,4], "8":[1,7,5], "9":[2,9,3], "10":[4,6,5], "11":[3,8,4], "12":[3,7,5]};
const MD8 = {"2":[1,8,5], "3":[4,7,5], "4":[3,8,5], "5":[2,7,6], "6":[4,9,4], "7":[4,8,5], "8":[2,9,5], "9":[4,7,6], "10":[3,8,6], "11":[1,9,6], "12":[3,9,6]};
const MD9 = {"2":[2,8,7], "3":[4,9,6], "4":[3,8,7], "5":[4,8,7], "6":[2,9,7], "7":[3,8,8], "8":[4,8,8], "9":[5,8,7], "10":[4,9,7], "11":[5,8,8], "12":[2,9,8]};
const MD10 = {"2":[3,9,8], "3":[3,9,9], "4":[4,9,8], "5":[4,9,9], "6":[5,9,7], "7":[5,9,8], "8":[5,9,9], "9":[6,9,6], "10":[6,9,7], "11":[6,9,8], "12":[6,9,9]};
// Athletics Tables
const ATH1 = {"2":["Sonic Beam","Kit","g"],"3":["Needler","Kit"],"4":["Slug Gun","Kit"],"5":["Ion Bore","g"],
"6":["Disintegrator","Scope"],"7":["Blaster","Kit","g"],"8":["Laser", "Kit"],"9":["Nerve Disruptor","Kit"],
"10":["Particle Gun","Kit"],"11":["Voltrex"],"12":["Plasma Pistol","gggg"]};
const ATH2 = {"2":["Knife","Stun","Kit"],"3":["Sword","ggg"],"4":["Kit","Flyntlock","Flyntlock","EMP Grenade"],
"5":["VibraKnife","Kit","g"],"6":["Phase Pick"],"7":["Butt","Kit","g"],"8":["Energy Blade","gg"],
"9":["Plasma Dagger","Kit"],"10":["Arc Laser","ggg"],"11":["EMP pistol"],"12":["Lightning Rod","Kit"]};
const ATH3 = {"2":["MedJack","Aggro","Charme","Detox ","Dull","Equilout","FlyBoy","Numb ","Patches ","Roid","Stim","StunGone ","SupSci","TecKnow"],
"3":["Skeletal Enhancement","Slug Machine Gun"],"4":["Cyberfoot","Pro Chip"],
"5":["Cybergyros"],"6":["Cyberhand", "Pro Chip"],"7":["Autonurse","Pro Chip","gg"],
"8":["Athletics Skill Chip", "Combat Skill Chip", "Science Skill Chip", "Engineering Skill Chip", "Piloting Skill Chip", "MagBoots"],
"9":["Cyberhook","Pro Chip"],"10":["Kit","Pro Chip","Satchel Charge"],
"11":["Skeletal Enhancement","Plasma Projector"],"12":["Butt","Kit"]};
const ATH4 = {"2":["Kit","Kit"],"3":["Kit","Kit"],"4":["Kit","Kit"],"5":["Kit","Kit"],"6":["Kit","Kit"],"7":["Kit","Kit"],
"8":["Kit","Kit"],"9":["Kit","Kit"],"10":["Kit","Kit"],"11":["Kit","Kit"],"12":["Kit","Kit"]};
// Profession Kits
const MARINE_KITS = ["Vibraknife","MedKit","JetPack","EVA","WristComp"];
const SCI_KITS = ["MedKit","JetPack","ToolKit","EVA","WristComp"];
const ENG_KITS = ["ToolKit","JetPack","MedKit","EVA","WristComp"];
const PILOT_KITS = ["JetPack","ToolKit","MedKit","EVA","WristComp"];
const GRENADES = ["Frag Grenade", "Energy Grenade", "EMP Grenade", "Stun Grenade", "Fritzer Grenade"];
const SPECIES = {"Bot":[4,8,1,4,0],"Blootian":[0,7,5,6,0],"Canosian":[8,8,9999,5,0],"Diploid":[4,8,2,3,1], "Fungaloid":[8,9,2,4,0],"Human":[5,8,2,5,1],"Kerbite":[5,9,5,6,1],
"Silicoid":[9,7,1,4,0], "Tentac":[6,9,9999,6,0],"Trundlian":[0,8,7,2,0],"Vomeg":[7,7,3,5,1],"Whistler":[9,7,4,5,0],
"Xeloxian":[5,8,6,2,1],"Zoallan":[4,9,3,7,0],"Avianoid":[3,9,2,4,0],"Cheetahoid":[4,8,2,9,1],
"Crocodillian":[5,7,2,5,0],"Elephantoid":[8,5,3,5,0],"Felinoid":[6,8,2,6,1],"Gorilloid":[6,7,4,2,1],
"Lupinoid":[5,8,2,6,1],"Lapinoid":[3,9,2,7,1],"Rhinoceroid":[7,6,2,6,0],"Reptilianoid":[4,8,2,5,0],
"Testudinoid":[3,8,2,4,0],"Ursinoid":[8,7,2,5,0]};
const CORE_PROFESSIONS = ["Marine", "Scientist", "Engineer", "Pilot"];
class Character {
constructor(species, base_stats, rank, profession, skills){
this.species = species;
this.hp_base = base_stats[0];
this.target_number=base_stats[1];
this.hands = base_stats[2];
this.move = base_stats[3];
this.can_wear_armor = base_stats[4]
this.wearing_armor=false;
this.rank = rank;
this.profession=profession;
if (profession==="Marine"){
this.skills=[skills[0],skills[1],skills[2],skills[2],skills[2]];
this.label="badge-danger";
}
else if (profession==="Engineer"){
this.skills=[skills[0],skills[2],skills[1],skills[2],skills[2]];
this.label="badge-primary";
}
else if (profession==="Pilot"){
this.skills=[skills[0],skills[2],skills[2],skills[1],skills[2]];
this.label="badge-warning";
}
else if (profession==="Scientist"){
this.skills=[skills[0],skills[2],skills[2],skills[2],skills[1]];
this.label="badge-success";
}
this.carry = skills[0]*10;
this.equipment = [];
var ath = parseInt(skills[0]);
// if can wear armor, add it and reduce athletics for rolls
if (ath>1 && this.can_wear_armor){
ath=ath-1
this.equipment.push("Armor");
this.wearing_armor=true;
}
// add shield if enough hands and athletics
if (parseInt(this.hands)>2 && parseInt(skills[0])>2){
ath=ath-1
this.equipment.push("Shield");
}
// Stuff for silicoids
if (this.species==="Silicoid"){
this.equipment.push("Butt");
this.equipment.push("Jet Pack");
}
for (var i=0; i<ath; i ++){
var r = (Math.floor(Math.random() * 6) + 1) + (Math.floor(Math.random() * 6) + 1);
r = r.toString();
if (i==0){
this.equipment = this.equipment.concat(ATH1[r]);
}
else if (i==1){
this.equipment = this.equipment.concat(ATH2[r]);
}
else if (i==2){
this.equipment = this.equipment.concat(ATH3[r]);
}
else{
this.equipment = this.equipment.concat(ATH4[r]);
}
}
var kit = [];
// Select correct kit tables and swap out pro chips
var index = this.equipment.indexOf("Pro Chip");
if (this.profession == "Marine"){
kit = MARINE_KITS;
if (index !== -1){
this.equipment[index]="Combat Skill Chip";
}
}
else if (this.profession=="Engineer"){
kit = ENG_KITS;
if (index !== -1){
this.equipment[index]="Engineering Skill Chip";
}
}
else if (this.profession=="Pilot"){
kit = PILOT_KITS;
if (index !== -1){
this.equipment[index]="Piloting Skill Chip";
}
}
else if (this.profession=="Scientist"){
kit = SCI_KITS;
if (index !== -1){
this.equipment[index]="Science Skill Chip";
}
}
// Replace kits with profession specific items
var num_kits=0;
for (var i=0; i<this.equipment.length; i++){
if (this.equipment[i]=="Kit")
num_kits++;
}
if (num_kits > 0){
for (var i=0; i<num_kits; i++){
if (i<3)
this.equipment[this.equipment.indexOf("Kit")] = kit[i];
else if (i==3){
this.equipment[this.equipment.indexOf("Kit")] = kit[i];
this.equipment.push(kit[4]);
}
else{
this.equipment.splice(this.equipment.indexOf("Kit"),1);
this.equipment = this.equipment.concat(GRENADES);
}
}
}
// Replace 'g' with random grenades
// TODO: Allow grenade selection by user
while (this.equipment.indexOf("g")!==-1){
this.equipment[this.equipment.indexOf("g")] = GRENADES[Math.floor(Math.random() * GRENADES.length)];
}
while (this.equipment.indexOf("gg")!==-1){
this.equipment[this.equipment.indexOf("gg")] = GRENADES[Math.floor(Math.random() * GRENADES.length)];
this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]);
}
while (this.equipment.indexOf("ggg")!==-1){
this.equipment[this.equipment.indexOf("ggg")] = GRENADES[Math.floor(Math.random() * GRENADES.length)];
this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]);
this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]);
}
while (this.equipment.indexOf("gggg")!==-1){
this.equipment[this.equipment.indexOf("gggg")] = GRENADES[Math.floor(Math.random() * GRENADES.length)];
this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]);
this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]);
this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]);
}
// Niche case of a crew not having a medkit
if (this.profession=="Scientist" && this.equipment.indexOf("MedKit")==-1){
this.equipment.push("MedKit");
if (this.equipment.indexOf("Ion Bore")!==-1)
this.equipment[this.equipment.indexOf("Ion Bore")]="Blaster";
else if (this.equipment.indexOf("Disintegrator")!==-1)
this.equipment[this.equipment.indexOf("Disintegrator")]="Blaster";
else if (this.equipment.indexOf("Voltrex")!==-1)
this.equipment[this.equipment.indexOf("Voltrex")]="Blaster";
else if (this.equipment.indexOf("Plasma Pistol")!==-1)
this.equipment[this.equipment.indexOf("Plasma Pistol")]="Blaster";
}
// Modify stats to account for skill chips and cyber gear
if (this.equipment.indexOf("Cyberfoot")!==-1)
this.move = this.move+1;
if (this.equipment.indexOf("Cyberhand")!==-1)
this.hands = this.hands+1;
if (this.equipment.indexOf("Skeletal Enhancement")!==-1)
this.carry = this.carry+10;
if (this.equipment.indexOf("Combat Skill Chip")!==-1)
this.skills[1]= this.skills[1]+1;
if (this.equipment.indexOf("Engineering Skill Chip")!==-1)
this.skills[2]= this.skills[2]+1;
if (this.equipment.indexOf("Piloting Skill Chip")!==-1)
this.skills[3]= this.skills[3]+1;
if (this.equipment.indexOf("Science Skill Chip")!==-1)
this.skills[4]= this.skills[4]+1;
if (this.equipment.indexOf("Athletics Skill Chip")!==-1){
this.skills[0]= this.skills[0]+1;
this.carry = this.carry+10;
}
var count = {};
this.equipment.forEach(function(i) { count[i] = (count[i]||0)+1; });
this.equipment = count;
this.max_hp = this.hp_base+this.skills[0]+parseInt(this.rank);
};
print(enemy_number){
var sheet = '<div class="row">'+
'<div class="col-sm-6">'+
'<div class="row"><div class="col-sm-12">Enemy #'+enemy_number+'</div></div>'+
'<div class="row"><div class="col-sm-12"><span class="badge '+this.label+'">'+this.profession+'</span></div></div>'+
'<div class="row"><div class="col-sm-12">Species: '+this.species+'</div></div>'+
'</div>'+
'<div class="col-sm-6 mr-auto" id="enemy'+enemy_number+'">Click a skill to roll 2d6</div></div>';
sheet += '<div class="row">'+
'<div class="col-sm-2 text-center"><span class="badge badge-secondary">HP</span></br>'+ this.max_hp +'</div>' +
'<div class="col-sm-2 text-center"><span class="badge badge-secondary">Move</span></br>'+ this.move +'</div>'+
'<div class="col-sm-2 text-center"><span class="badge badge-secondary">Hands</span></br>'+ this.hands +'</div>'+
'<div class="col-sm-2 text-center"><span class="badge badge-secondary">Tgt</span></br>'+ this.target_number +'</div>'+
'<div class="col-sm-2 text-center"><span class="badge badge-secondary">Carry</span></br>'+ this.carry +'</div>'+
'</div>';
sheet+='<div class="row">'+
'<div class="col-sm-2 text-center rollskill" data-num="'+enemy_number+'" data-skill="Ath" data-val="'+this.skills[0]+'">'+
'<button class="custombtn btn-default"><span class="badge badge-secondary">Ath</span></br>'+ this.skills[0]+'</button>'
+'</div>'+
'<div class="col-sm-2 text-center rollskill" data-num="'+enemy_number+'" data-skill="Com" data-val="'+this.skills[1]+'">'+
'<button class="custombtn btn-default"><span class="badge badge-secondary">Com</span></br>'+ this.skills[1]+'</button>'
+'</div>'+
'<div class="col-sm-2 text-center rollskill" data-num="'+enemy_number+'" data-skill="Eng" data-val="'+this.skills[2]+'">'+
'<button class="custombtn btn-default"><span class="badge badge-secondary">Eng</span></br>'+ this.skills[2]+'</button>'
+'</div>'+
'<div class="col-sm-2 text-center rollskill" data-num="'+enemy_number+'" data-skill="Pil" data-val="'+this.skills[3]+'">'+
'<button class="custombtn btn-default"><span class="badge badge-secondary">Pil</span></br>'+ this.skills[3]+'</button>'
+'</div>'+
'<div class="col-sm-2 text-center rollskill" data-num="'+enemy_number+'" data-skill="Sci" data-val="'+this.skills[4]+'">'+
'<button class="custombtn btn-default"><span class="badge badge-secondary">Sci</span></br>'+ this.skills[4]+'</button>'
+'</div>'+
'</div>'
sheet+='<div class="row"><div class="col-sm-3 text-center"><span class="badge badge-secondary">Equipment</span></div></div>';
sheet += '<div class="row"><div class="col-sm-12">';
for (var item in this.equipment){
if (this.equipment[item] >1 )
sheet+=item + ' x ' + this.equipment[item] +', ';
else
sheet+=item + ', ';
};
sheet = sheet.slice(0,-2);
sheet+='</div></div>';
return sheet;
};
};
function shuffle(array) {
var m = array.length, t, i;
while (m > 0)
{
i = Math.floor(Math.random() * m--);
t = array[m];
array[m] = array[i];
array[i] = t;
}
return array;
};
function die_roll(num_dice){
var d = []
for (var i=0; i< num_dice; i++){
d.push(Math.floor(Math.random() * 6) + 1);
}
return d;
};
$('#submit').on('click',function(){
// Get the values in the form fields
var md = document.getElementById("md").value;
var players = document.getElementById("players").value;
var species = document.getElementById("species").value;
var random_species = $('#random_species').is(':checked');
var enemy_skills = [];
// Roll 2d6
var roll = die_roll(2);
roll = (roll[0] + roll[1]).toString();
// Apply roll to the appropriate Mission Difficulty table to get enemy stats
switch(md){
case "0":
enemy_skills = MD0[roll];
break;
case "1":
enemy_skills = MD1[roll];
break;
case "2":
enemy_skills = MD2[roll];
break;
case "3":
enemy_skills = MD3[roll];
break;
case "4":
enemy_skills = MD4[roll];
break;
case "5":
enemy_skills = MD5[roll];
break;
case "6":
enemy_skills = MD6[roll];
break;
case "7":
enemy_skills = MD7[roll];
break;
case "8":
enemy_skills = MD8[roll];
break;
case "9":
enemy_skills = MD9[roll];
break;
case "10":
enemy_skills = MD10[roll];
}
// If picking a random species, select one from const dictionary
if (random_species){
var rando = Object.keys(SPECIES);
var key = Math.floor(Math.random() * rando.length);
species = rando[key];
}
var profession_tracker = CORE_PROFESSIONS.slice();
shuffle(profession_tracker);
var enemies_list = []
for (var i=0; i< parseInt(players); i++){
if (i%4==0)
shuffle(profession_tracker);
enemies_list.push(new Character(species,SPECIES[species],md,profession_tracker[i%4],enemy_skills));
}
$("#enemiesDiv").empty();
var result = '';
for (var j=0; j<enemies_list.length;j++){
//Build rows
if (j%3==0)
result+='<div class="row" style="margin-top:10px">';
result += '<div class="col-sm-4" style="border: 1px solid black">';
result += enemies_list[j].print((j+1).toString())+'</div>';
if (j%3==2)
result+='</div>';
}
$("#enemiesDiv").append(result);
return false;
});
$(document).on('click', '.rollskill', function(){
var skill = $(this).data('skill');
var value = $(this).data('val');
var enemy_number = $(this).data('num');
$("#enemy"+enemy_number).empty();
var roll = die_roll(2);
var total = roll[0] + roll[1] + parseInt(value);
var result = '<div class="row"><div class="col-sm-12">Rolled: '+skill+'</div></div>'+
'<div class="row">'+
'<div class="col-sm-1 text-center" style="font-size:small">skill</br><div class="text-center" id="'+enemy_number+'skill" data-val="'+value+'" style="font-size:large">'+value+'</div></div>'+
'<div class="col-sm-1 text-center" style="font-size:small"></br>+</div>'+
'<div class="col-sm-1 text-center" style="font-size:small">d1</br><div class="rolldie text-center" id="'+enemy_number+'die1" data-val="'+roll[0].toString()+'" style="font-size:large"><button class="custombtn btn-default">'+roll[0].toString()+'</button></div></div>'+
'<div class="col-sm-1 text-center" style="font-size:small"></br>+</div>'+
'<div class="col-sm-1 text-center" style="font-size:small">d2</br><div class="rolldie text-center" id="'+enemy_number+'die2" data-val="'+roll[1].toString()+'" style="font-size:large"><button class="custombtn btn-default">'+roll[1].toString()+'</button></div></div>'+
'<div class="col-sm-1 text-center" style="font-size:small"></br>=</div>'+
'<div class="col-sm-1 text-center" id="'+enemy_number+'total" style="font-size:x-large">'+total.toString()+'</div>'+
'</div>'
$("#enemy"+enemy_number).append(result);
return false;
});
$(document).on('click', '.rolldie', function(event){
var die = $(this).attr('id');
enemy_number = die.charAt(0);
var otherdie ='';
if(die.substr(1,)==="die1")
otherdie="#"+enemy_number+"die2";
else otherdie="#"+enemy_number+"die1";
die = "#"+die;
$(die).empty();
var roll = die_roll(1);
$(die).data('val', roll[0].toString());
$(die).append('<button class="custombtn btn-default">'+roll[0].toString()+'</button>');
$("#"+enemy_number+"total").empty();
$("#"+enemy_number+"total").append( (parseInt($("#"+enemy_number+"skill").data('val')) + parseInt($(otherdie).data('val')) + roll[0]).toString() );
return false;
});
</script>
</body>
</html>