This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
playground:playground [2017/10/30 22:17] – curufea | playground:playground [2023/05/11 01:48] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PlayGround ====== | ====== PlayGround ====== | ||
- | < | ||
- | / | ||
- | # / | ||
- | / | ||
- | </ | ||
- | | ||
- | | ||
- | < | ||
- | <div class=" | ||
- | < | ||
- | </ | ||
- | |||
- | <form class=" | ||
- | <div class=" | ||
- | <label class=" | ||
- | <div class=" | ||
- | <select class=" | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | <div class=" | ||
- | <label class=" | ||
- | <div class=" | ||
- | <select class=" | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | <div class=" | ||
- | <label class=" | ||
- | <div class=" | ||
- | <select class=" | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | <div class=" | ||
- | <div class=" | ||
- | < | ||
- | </ | ||
- | </ | ||
- | |||
- | <div class=" | ||
- | <div class=" | ||
- | <button class=" | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | |||
- | <div id=" | ||
- | |||
- | </ | ||
- | </ | ||
- | |||
- | <JS> | ||
- | // Mission Difficulty Tables | ||
- | const MD0 = {" | ||
- | const MD1 = {" | ||
- | const MD2 = {" | ||
- | const MD3 = {" | ||
- | const MD4 = {" | ||
- | const MD5 = {" | ||
- | const MD6 = {" | ||
- | const MD7 = {" | ||
- | const MD8 = {" | ||
- | const MD9 = {" | ||
- | const MD10 = {" | ||
- | |||
- | // Athletics Tables | ||
- | const ATH1 = {" | ||
- | " | ||
- | " | ||
- | const ATH2 = {" | ||
- | " | ||
- | " | ||
- | const ATH3 = {" | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | const ATH4 = {" | ||
- | " | ||
- | | ||
- | // Profession Kits | ||
- | const MARINE_KITS = [" | ||
- | const SCI_KITS = [" | ||
- | const ENG_KITS = [" | ||
- | const PILOT_KITS = [" | ||
- | const GRENADES = ["Frag Grenade", | ||
- | |||
- | const SPECIES = {" | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | |||
- | const CORE_PROFESSIONS = [" | ||
- | |||
- | class Character { | ||
- | constructor(species, | ||
- | 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===" | ||
- | this.skills=[skills[0], | ||
- | this.label=" | ||
- | } | ||
- | else if (profession===" | ||
- | this.skills=[skills[0], | ||
- | this.label=" | ||
- | } | ||
- | else if (profession===" | ||
- | this.skills=[skills[0], | ||
- | this.label=" | ||
- | } | ||
- | else if (profession===" | ||
- | this.skills=[skills[0], | ||
- | this.label=" | ||
- | } | ||
- | |||
- | 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(" | ||
- | this.wearing_armor=true; | ||
- | } | ||
- | // add shield if enough hands and athletics | ||
- | if (parseInt(this.hands)> | ||
- | ath=ath-1 | ||
- | this.equipment.push(" | ||
- | } | ||
- | | ||
- | // Stuff for silicoids | ||
- | if (this.species===" | ||
- | this.equipment.push(" | ||
- | this.equipment.push(" | ||
- | } | ||
- | | ||
- | 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(" | ||
- | if (this.profession == " | ||
- | kit = MARINE_KITS; | ||
- | if (index !== -1){ | ||
- | this.equipment[index]=" | ||
- | } | ||
- | } | ||
- | else if (this.profession==" | ||
- | kit = ENG_KITS; | ||
- | if (index !== -1){ | ||
- | this.equipment[index]=" | ||
- | } | ||
- | } | ||
- | else if (this.profession==" | ||
- | kit = PILOT_KITS; | ||
- | if (index !== -1){ | ||
- | this.equipment[index]=" | ||
- | } | ||
- | } | ||
- | else if (this.profession==" | ||
- | kit = SCI_KITS; | ||
- | if (index !== -1){ | ||
- | this.equipment[index]=" | ||
- | } | ||
- | } | ||
- | | ||
- | // Replace kits with profession specific items | ||
- | var num_kits=0; | ||
- | for (var i=0; i< | ||
- | if (this.equipment[i]==" | ||
- | num_kits++; | ||
- | } | ||
- | if (num_kits > 0){ | ||
- | for (var i=0; i< | ||
- | if (i<3) | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | else if (i==3){ | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | this.equipment.push(kit[4]); | ||
- | } | ||
- | else{ | ||
- | this.equipment.splice(this.equipment.indexOf(" | ||
- | this.equipment = this.equipment.concat(GRENADES); | ||
- | } | ||
- | | ||
- | } | ||
- | } | ||
- | | ||
- | // Replace ' | ||
- | // TODO: Allow grenade selection by user | ||
- | while (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | } | ||
- | while (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]); | ||
- | } | ||
- | while (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]); | ||
- | this.equipment.push(GRENADES[Math.floor(Math.random() * GRENADES.length)]); | ||
- | } | ||
- | while (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | 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==" | ||
- | this.equipment.push(" | ||
- | if (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | else if (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | else if (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | else if (this.equipment.indexOf(" | ||
- | this.equipment[this.equipment.indexOf(" | ||
- | } | ||
- | |||
- | // Modify stats to account for skill chips and cyber gear | ||
- | if (this.equipment.indexOf(" | ||
- | this.move = this.move+1; | ||
- | if (this.equipment.indexOf(" | ||
- | this.hands = this.hands+1; | ||
- | if (this.equipment.indexOf(" | ||
- | this.carry = this.carry+10; | ||
- | if (this.equipment.indexOf(" | ||
- | this.skills[1]= this.skills[1]+1; | ||
- | if (this.equipment.indexOf(" | ||
- | this.skills[2]= this.skills[2]+1; | ||
- | if (this.equipment.indexOf(" | ||
- | this.skills[3]= this.skills[3]+1; | ||
- | if (this.equipment.indexOf(" | ||
- | this.skills[4]= this.skills[4]+1; | ||
- | if (this.equipment.indexOf(" | ||
- | 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 = '< | ||
- | '< | ||
- | '< | ||
- | '< | ||
- | '< | ||
- | '</ | ||
- | '< | ||
- | sheet += '< | ||
- | '< | ||
- | '< | ||
- | '< | ||
- | '< | ||
- | '< | ||
- | '</ | ||
- | sheet+='< | ||
- | '< | ||
- | '< | ||
- | +'</ | ||
- | '< | ||
- | '< | ||
- | +'</ | ||
- | '< | ||
- | '< | ||
- | +'</ | ||
- | '< | ||
- | '< | ||
- | +'</ | ||
- | '< | ||
- | '< | ||
- | +'</ | ||
- | '</ | ||
- | sheet+='< | ||
- | | ||
- | sheet += '< | ||
- | for (var item in this.equipment){ | ||
- | if (this.equipment[item] >1 ) | ||
- | sheet+=item + ' x ' + this.equipment[item] +', '; | ||
- | else | ||
- | sheet+=item + ', '; | ||
- | }; | ||
- | sheet = sheet.slice(0, | ||
- | |||
- | sheet+='</ | ||
- | return sheet; | ||
- | }; | ||
- | }; | ||
- | |||
- | function shuffle(array) { | ||
- | var m = array.length, | ||
- | while (m > 0) | ||
- | { | ||
- | i = Math.floor(Math.random() * m--); | ||
- | t = array[m]; | ||
- | array[m] = array[i]; | ||
- | array[i] = t; | ||
- | } | ||
- | return array; | ||
- | }; | ||
- | |||
- | function die_roll(){ | ||
- | return (Math.floor(Math.random() * 6) + 1) + (Math.floor(Math.random() * 6) + 1); | ||
- | }; | ||
- | |||
- | $('# | ||
- | // Get the values in the form fields | ||
- | var md = document.getElementById(" | ||
- | var players = document.getElementById(" | ||
- | var species = document.getElementById(" | ||
- | var random_species = $('# | ||
- | var enemy_skills = []; | ||
- | | ||
- | // Roll 2d6 | ||
- | var roll = die_roll(); | ||
- | roll = roll.toString(); | ||
- | | ||
- | // Apply roll to the appropriate Mission Difficulty table to get enemy stats | ||
- | switch(md){ | ||
- | case " | ||
- | enemy_skills = MD0[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD1[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD2[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD3[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD4[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD5[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD6[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD7[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD8[roll]; | ||
- | break; | ||
- | case " | ||
- | enemy_skills = MD9[roll]; | ||
- | break; | ||
- | case " | ||
- | 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); | ||
- | if (i%4==0) | ||
- | shuffle(profession_tracker); | ||
- | enemies_list.push(new Character(species, | ||
- | } | ||
- | $("# | ||
- | var result = ''; | ||
- | for (var j=0; j< | ||
- | //Build rows | ||
- | if (j%3==0) | ||
- | result+='< | ||
- | | ||
- | result += '< | ||
- | result += enemies_list[j].print((j+1).toString())+'</ | ||
- | | ||
- | if (j%3==2) | ||
- | result+='</ | ||
- | } | ||
- | | ||
- | $("# | ||
- | return false; | ||
- | |||
- | |||
- | }); | ||
- | |||
- | $(document).on(' | ||
- | var skill = $(this).data(' | ||
- | var value = $(this).data(' | ||
- | var enemy = $(this).data(' | ||
- | $("# | ||
- | var r = die_roll() + parseInt(value) | ||
- | |||
- | var result = ' | ||
- | $("# | ||
- | return false; | ||
- | |||
- | }); | ||
- | |||
- | </JS> |