Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AroriaNetwork
GitHub Repository: AroriaNetwork/3kho-backup
Path: blob/main/projects/n-gon/js/powerup.js
1834 views
1
let powerUp=[];const powerUps={ejectGraphic(e="68, 102, 119"){simulation.drawList.push({x:m.pos.x,y:m.pos.y,radius:100,color:`rgba(${e}, 0.8)`,time:4}),simulation.drawList.push({x:m.pos.x,y:m.pos.y,radius:75,color:`rgba(${e}, 0.6)`,time:8}),simulation.drawList.push({x:m.pos.x,y:m.pos.y,radius:50,color:`rgba(${e}, 0.3)`,time:12}),simulation.drawList.push({x:m.pos.x,y:m.pos.y,radius:25,color:`rgba(${e}, 0.15)`,time:16})},orb:{research(e=1){switch(e){case 1:return'<div class="research-circle"></div> ';case 2:return'<span style="position:relative;">\n <div class="research-circle" style="position:absolute; top:0; left:0;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:7px;"></div>\n </span> &nbsp; &nbsp; &nbsp; &nbsp;';case 3:return'<span style="position:relative;">\n <div class="research-circle" style="position:absolute; top:0; left:0;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:8px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:16px;"></div>\n </span> &nbsp; &nbsp; &nbsp; &nbsp; &thinsp; ';case 4:return'<span style="position:relative;">\n <div class="research-circle" style="position:absolute; top:0; left:0;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:8px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:16px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:24px;"></div>\n </span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ';case 5:return'<span style="position:relative;">\n <div class="research-circle" style="position:absolute; top:0; left:0;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:8px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:16px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:24px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:32px;"></div>\n </span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ';case 6:return'<span style="position:relative;">\n <div class="research-circle" style="position:absolute; top:0; left:0;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:8px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:16px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:24px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:32px;"></div>\n <div class="research-circle" style="position:absolute; top:0; left:40px;"></div>\n </span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '}let s='<span style="position:relative;">';for(let t=0;t<e;t++)s+=`<div class="research-circle" style="position:absolute; top:0; left:${8*t}px;"></div>`;s+="</span> &nbsp; &nbsp; ";for(let t=0;t<e;t++)s+="&nbsp; ";return s},ammo(e=1){if(1===e)return'<div class="ammo-circle"></div>';let s='<span style="position:relative;">';for(let t=0;t<e;t++)s+=`<div class="ammo-circle" style="position:absolute; top:1.5px; left:${8*t}px;"></div>`;s+="</span> &nbsp; &nbsp; ";for(let t=0;t<e;t++)s+="&nbsp; ";return s},heal(e=1){if(1===e)return'<div class="heal-circle"></div>';let s='<span style="position:relative;">';for(let t=0;t<e;t++)s+=`<div class="heal-circle" style="position:absolute; top:1px; left:${10*t}px;"></div>`;s+="</span> &nbsp; &nbsp; ";for(let t=0;t<e;t++)s+="&nbsp; ";return s},tech:(e=1)=>'<div class="tech-circle"></div>'},totalPowerUps:0,lastTechIndex:null,do(){},setDupChance(){tech.duplicationChance()>0||tech.isAnthropicTech?(tech.isPowerUpsVanish?powerUps.do=powerUps.doDuplicatesVanish:tech.isPowerUpsAttract?powerUps.do=powerUps.doAttractDuplicates:powerUps.do=powerUps.doDuplicates,tech.maxDuplicationEvent()):tech.isPowerUpsAttract?powerUps.do=powerUps.doAttract:powerUps.do=powerUps.doDefault},doDefault(){ctx.globalAlpha=.4*Math.sin(.15*m.cycle)+.6;for(let e=0,s=powerUp.length;e<s;++e)ctx.beginPath(),ctx.arc(powerUp[e].position.x,powerUp[e].position.y,powerUp[e].size,0,2*Math.PI),ctx.fillStyle=powerUp[e].color,ctx.fill();ctx.globalAlpha=1},doAttract(){powerUps.doDefault();for(let e=0,s=powerUp.length;e<s;++e){const s=Vector.mult(Vector.normalise(Vector.sub(m.pos,powerUp[e].position)),.0015*powerUp[e].mass);powerUp[e].force.x+=s.x,powerUp[e].force.y=s.y-simulation.g}},doAttractDuplicates(){powerUps.doDuplicates()},doDuplicates(){ctx.globalAlpha=.4*Math.sin(.15*m.cycle)+.6;for(let e=0,s=powerUp.length;e<s;++e)ctx.beginPath(),ctx.arc(powerUp[e].position.x,powerUp[e].position.y,powerUp[e].size,0,2*Math.PI),ctx.fillStyle=powerUp[e].color,ctx.fill();ctx.globalAlpha=1;for(let e=0,s=powerUp.length;e<s;++e)if(powerUp[e].isDuplicated&&Math.random()<.1){const s=5+powerUp[e].size/5;let t=Vector.rotate({x:s,y:s},2*Math.PI*Math.random()),o={x:powerUp[e].position.x+t.x,y:powerUp[e].position.y+t.y};ctx.beginPath(),ctx.moveTo(o.x,o.y);for(let e=0;e<6;e++)t=Vector.rotate(t,3*(Math.random()-.5)),o=Vector.add(o,t),ctx.lineTo(o.x,o.y);ctx.lineWidth=.5+2*Math.random(),ctx.strokeStyle="#000",ctx.stroke()}},doDuplicatesVanish(){for(let e=0,s=powerUp.length;e<s;++e)if(powerUp[e].isDuplicated&&Math.random()<.004){b.explosion(powerUp[e].position,150+(10+3*Math.random())*powerUp[e].size),Matter.Composite.remove(engine.world,powerUp[e]),powerUp.splice(e,1);break}ctx.globalAlpha=.4*Math.sin(.25*m.cycle)+.6;for(let e=0,s=powerUp.length;e<s;++e)ctx.beginPath(),ctx.arc(powerUp[e].position.x,powerUp[e].position.y,powerUp[e].size,0,2*Math.PI),ctx.fillStyle=powerUp[e].color,ctx.fill();ctx.globalAlpha=1;for(let e=0,s=powerUp.length;e<s;++e)if(powerUp[e].isDuplicated&&Math.random()<.3){const s=5+powerUp[e].size/5;let t=Vector.rotate({x:s,y:s},2*Math.PI*Math.random()),o={x:powerUp[e].position.x+t.x,y:powerUp[e].position.y+t.y};ctx.beginPath(),ctx.moveTo(o.x,o.y);for(let e=0;e<6;e++)t=Vector.rotate(t,3*(Math.random()-.5)),o=Vector.add(o,t),ctx.lineTo(o.x,o.y);ctx.lineWidth=.5+2*Math.random(),ctx.strokeStyle="#000",ctx.stroke()}},choose(e,s){if("gun"===e){b.giveGuns(s);let e=`b.giveGuns("<span class='color-text'>${b.guns[s].name}</span>")`;1===b.inventory.length&&(e+="<br>input.key.gun<span class='color-symbol'>:</span> [\"<span class='color-text'>MouseLeft</span>\"]"),2===b.inventory.length&&(e+=`\n <br>input.key.nextGun<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.nextGun}</span>","<span class='color-text'>MouseWheel</span>"]\n <br>input.key.previousGun<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.previousGun}</span>","<span class='color-text'>MouseWheel</span>"]`),simulation.makeTextLog(e)}else"field"===e?m.setField(s):"tech"===e&&(setTimeout((()=>{powerUps.lastTechIndex=s}),10),simulation.makeTextLog(`<span class='color-var'>tech</span>.giveTech("<span class='color-text'>${tech.tech[s].name}</span>")`),tech.giveTech(s));powerUps.endDraft(e)},showDraft(){document.getElementById("choose-background").style.visibility="visible",document.getElementById("choose-background").style.opacity="0.6",document.getElementById("choose-grid").style.transitionDuration="0.25s",document.getElementById("choose-grid").style.visibility="visible",document.getElementById("choose-grid").style.opacity="1",document.getElementById("choose-grid").style.pointerEvents="none",setTimeout((()=>{document.getElementById("choose-grid").style.pointerEvents="auto",document.body.style.cursor="auto",document.getElementById("choose-grid").style.transitionDuration="0s"}),500),simulation.paused=!0,simulation.isChoosing=!0,build.pauseGrid(!0)},endDraft(e,s=!1){if(s){if(tech.isCancelDuplication&&(tech.cancelCount++,tech.maxDuplicationEvent(),simulation.makeTextLog("tech.duplicationChance() <span class='color-symbol'>+=</span> 0.043"),simulation.circleFlare(.043)),tech.isCancelRerolls)for(let e=0,s=5+5*Math.random();e<s;e++){let e=m.health<.25&&!tech.isEnergyHealth||tech.isEnergyNoAmmo?"heal":"ammo";Math.random()<.36?e="heal":Math.random()<.4&&!tech.isSuperDeterminism&&(e="research"),powerUps.spawn(m.pos.x+40*(Math.random()-.5),m.pos.y+40*(Math.random()-.5),e,!1)}if(tech.isBanish&&"tech"===e){const e=tech.isDeterminism?1:3+2*tech.isExtraChoice;for(let s=0;s<e;s++){const e=powerUps.tech.choiceLog.length-s-1;void 0!==powerUps.tech.choiceLog[e]&&(tech.tech[powerUps.tech.choiceLog[e]].isBanished=!0)}simulation.makeTextLog(`powerUps.tech.length: ${Math.max(0,powerUps.tech.lastTotalChoices-e)}`)}}if(tech.isAnsatz&&0===powerUps.research.count)for(let e=0;e<2;e++)powerUps.spawn(m.pos.x+40*(Math.random()-.5),m.pos.y+40*(Math.random()-.5),"research",!1);document.getElementById("choose-grid").style.visibility="hidden",document.getElementById("choose-grid").style.opacity="0",document.getElementById("choose-background").style.visibility="hidden",document.getElementById("choose-background").style.opacity="0",document.body.style.cursor="none",simulation.paused=!1,simulation.isChoosing=!1,m.immuneCycle<m.cycle+15&&(m.immuneCycle=m.cycle+15),build.unPauseGrid(),requestAnimationFrame(cycle),m.holdingTarget&&m.drop()},research:{count:0,name:"research",color:"#f7b",size:()=>20,effect(){powerUps.research.changeRerolls(1)},changeRerolls(e){if(0!==e&&(powerUps.research.count+=e,powerUps.research.count<0?powerUps.research.count=0:simulation.makeTextLog(`powerUps.research.count <span class='color-symbol'>+=</span> ${e}`)),tech.isRerollBots){let e=0;for(const s=2+Math.floor(.1666*b.totalBots());powerUps.research.count>s-1;powerUps.research.count-=s)e+=500,setTimeout((()=>{if(b.randomBot(),tech.renormalization)for(let e=0;e<s;e++)Math.random()<.4&&(m.fieldCDcycle=m.cycle+20,powerUps.spawn(m.pos.x+100*(Math.random()-.5),m.pos.y+100*(Math.random()-.5),"research"))}),e)}if(tech.isDeathAvoid&&document.getElementById("tech-anthropic")&&(document.getElementById("tech-anthropic").innerHTML=`-${powerUps.research.count}`),tech.renormalization&&Math.random()<.4&&e<0)for(let s=0,t=-e;s<t;s++)powerUps.spawn(m.pos.x,m.pos.y,"research");tech.isRerollHaste&&(0===powerUps.research.count?(tech.researchHaste=.66,b.setFireCD()):(tech.researchHaste=1,b.setFireCD()))},currentRerollCount:0,use(e){if(tech.isJunkResearch&&powerUps.research.currentRerollCount<3?tech.addJunkTechToPool(.01*tech.junkResearchNumber):powerUps.research.changeRerolls(-1),powerUps.research.currentRerollCount++,tech.isBanish&&"tech"===e){const e=tech.isDeterminism?1:3+2*tech.isExtraChoice;for(let s=0;s<e;s++){const e=powerUps.tech.choiceLog.length-s-1;void 0!==powerUps.tech.choiceLog[e]&&(tech.tech[powerUps.tech.choiceLog[e]].isBanished=!0)}simulation.makeTextLog(`powerUps.tech.length: ${Math.max(0,powerUps.tech.lastTotalChoices-e)}`)}tech.isResearchReality&&(m.switchWorlds(),simulation.trails(),simulation.makeTextLog(`simulation.amplitude <span class='color-symbol'>=</span> ${Math.random()}`)),powerUps[e].effect()}},heal:{name:"heal",color:"#0eb",size:()=>40*simulation.healScale**.25*Math.sqrt(tech.largerHeals)*Math.sqrt(.1+.5*Math.random()),calculateHeal:e=>tech.largerHeals*(e/40/Math.sqrt(tech.largerHeals)/simulation.healScale**.25)**2,effect(){if(!tech.isEnergyHealth&&m.alive&&!tech.isNoHeals){const e=powerUps.heal.calculateHeal(this.size);if(e>0){const s=m.health+e*simulation.healScale-m.maxHealth,t=Math.min(m.maxHealth-m.health,e)*simulation.healScale;if(m.addHealth(e),simulation.makeTextLog(`<span class='color-var'>m</span>.health <span class='color-symbol'>+=</span> ${t.toFixed(3)}`),tech.isOverHeal&&s>0){const e=.7*s;m.damage(e),simulation.makeTextLog(`<span class='color-var'>m</span>.health <span class='color-symbol'>-=</span> ${e.toFixed(3)}`),simulation.drawList.push({x:m.pos.x,y:m.pos.y,radius:500*e*simulation.healScale,color:simulation.mobDmgColor,time:simulation.drawTime}),tech.extraMaxHealth+=e*simulation.healScale,m.setMaxHealth()}}}tech.healGiveMaxEnergy&&(tech.healMaxEnergyBonus+=.07,m.setMaxEnergy())},spawn(e,s,t){powerUps.directSpawn(e,s,"heal",!1,null,t),Math.random()<tech.duplicationChance()&&(powerUps.directSpawn(e,s,"heal",!1,null,t),powerUp[powerUp.length-1].isDuplicated=!0)}},ammo:{name:"ammo",color:"#467",size:()=>17,effect(){if(b.inventory.length>0){if(tech.isAmmoForGun&&b.activeGun){const e=b.guns[b.activeGun];if(e.ammo!==1/0)if(tech.ammoCap){const s=Math.ceil(.7*e.ammoPack*tech.ammoCap);e.ammo=s}else{const s=Math.ceil((.7*Math.random()+.7*Math.random())*e.ammoPack);e.ammo+=s}}else for(let e=0,s=b.inventory.length;e<s;e++){const s=b.guns[b.inventory[e]];if(s.ammo!==1/0)if(tech.ammoCap){const e=Math.ceil(.45*s.ammoPack*tech.ammoCap);s.ammo=e}else{const e=Math.ceil((.45*Math.random()+.45*Math.random())*s.ammoPack);s.ammo+=e}}simulation.updateGunHUD()}}},field:{name:"field",color:"#0cf",size:()=>45,pick(e,s=-1,t=-1,o=-1,i=-1){let c=[];for(let r=1;r<e.length;r++)r!==m.fieldMode&&r!==s&&r!==t&&r!==o&&r!==i&&c.push(r);const r=tech.isDeterminism?1:3+2*tech.isExtraChoice;if(powerUps.field.choiceLog.length>r||powerUps.field.choiceLog.length===r)for(let e=0;e<r;e++)if(c.length>r)for(let s=0,t=c.length;s<t;s++)if(powerUps.field.choiceLog[powerUps.field.choiceLog.length-1-e]===c[s]){c.splice(s,1);break}if(c.length>0)return c[Math.floor(Math.random()*c.length)]},choiceLog:[],effect(){let e=powerUps.field.pick(m.fieldUpgrades),s=-1,t=-1;if(e>-1){let o="";if(tech.isSuperDeterminism||(o+="<div class='cancel' onclick='powerUps.endDraft(\"field\",true)'>✕</div>"),o+="<h3 style = 'color:#fff; text-align:left; margin: 0px;'>field</h3>",o+=`<div class="choose-grid-module" onclick="powerUps.choose('field',${e})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${m.fieldUpgrades[e].name}</div> ${m.fieldUpgrades[e].description}</div>`,tech.isDeterminism||(s=powerUps.field.pick(m.fieldUpgrades,e),s>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('field',${s})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${m.fieldUpgrades[s].name}</div> ${m.fieldUpgrades[s].description}</div>`),t=powerUps.field.pick(m.fieldUpgrades,e,s),t>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('field',${t})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${m.fieldUpgrades[t].name}</div> ${m.fieldUpgrades[t].description}</div>`)),tech.isExtraChoice){let i=powerUps.field.pick(m.fieldUpgrades,e,s,t);i>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('field',${i})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${m.fieldUpgrades[i].name}</div> ${m.fieldUpgrades[i].description}</div>`);let c=powerUps.field.pick(m.fieldUpgrades,e,s,t,i);c>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('field',${c})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${m.fieldUpgrades[c].name}</div> ${m.fieldUpgrades[c].description}</div>`),powerUps.field.choiceLog.push(i),powerUps.field.choiceLog.push(c)}if(powerUps.field.choiceLog.push(e),powerUps.field.choiceLog.push(s),powerUps.field.choiceLog.push(t),tech.isJunkResearch&&powerUps.research.currentRerollCount<3){tech.junkResearchNumber=Math.floor(4*Math.random()),o+='<div class="choose-grid-module" onclick="powerUps.research.use(\'field\')"><div class="grid-title"> <span style="position:relative;">';for(let e=0;e<tech.junkResearchNumber;e++)o+=`<div class="circle-grid junk" style="position:absolute; top:0; left:${15*e}px ;opacity:0.8; border: 1px #fff solid;"></div>`;o+="</span>&nbsp; <span class='research-select'>pseudoscience</span></div></div>"}else if(powerUps.research.count){o+='<div class="choose-grid-module" onclick="powerUps.research.use(\'field\')"><div class="grid-title"> <span style="position:relative;">';for(let e=0,s=Math.min(powerUps.research.count,30);e<s;e++)o+=`<div class="circle-grid research" style="position:absolute; top:0; left:${(18-.3*s)*e}px ;opacity:0.8; border: 1px #fff solid;"></div>`;o+=`</span>&nbsp; <span class='research-select'>${tech.isResearchReality?"<span class='alt'>alternate reality</span>":"research"}</span></div></div>`}document.getElementById("choose-grid").innerHTML=o,powerUps.showDraft()}}},tech:{name:"tech",color:"hsl(246,100%,77%)",size:()=>42,choiceLog:[],lastTotalChoices:0,effect(){if(m.alive){function e(e=-1,t=-1,o=-1,i=-1){let c=[];for(let s=0;s<tech.tech.length;s++)if(tech.tech[s].count<tech.tech[s].maxCount&&s!==e&&s!==t&&s!==o&&s!==i&&tech.tech[s].allowed()&&!tech.tech[s].isBanished)for(let e=0,t=tech.tech[s].frequency;e<t;e++)c.push(s);powerUps.tech.lastTotalChoices=c.length;const r=tech.isDeterminism?1:3+2*tech.isExtraChoice;if(powerUps.tech.choiceLog.length>r||powerUps.tech.choiceLog.length===r)for(let e=0;e<r;e++)if(c.length>r)for(let s=0,t=c.length;s<t;s++)if(powerUps.tech.choiceLog[powerUps.tech.choiceLog.length-1-e]===c[s]){c.splice(s,1);break}if(c.length>0){const e=c[Math.floor(Math.random()*c.length)],t=tech.tech[e].count>0?`(${tech.tech[e].count+1}x)`:"";return tech.tech[e].isFieldTech?s+=`<div class="choose-grid-module" onclick="powerUps.choose('tech',${e})"><div class="grid-title">\n <span style="position:relative;">\n <div class="circle-grid tech" style="position:absolute; top:0; left:0;opacity:0.8;"></div>\n <div class="circle-grid field" style="position:absolute; top:0; left:10px;opacity:0.65;"></div>\n </span>\n &nbsp; &nbsp; &nbsp; &nbsp; ${tech.tech[e].name} ${t}</div>${tech.tech[e].descriptionFunction?tech.tech[e].descriptionFunction():tech.tech[e].description}</div></div>`:tech.tech[e].isGunTech?s+=`<div class="choose-grid-module" onclick="powerUps.choose('tech',${e})"><div class="grid-title">\n <span style="position:relative;">\n <div class="circle-grid tech" style="position:absolute; top:0; left:0;opacity:0.8;"></div>\n <div class="circle-grid gun" style="position:absolute; top:0; left:10px; opacity:0.65;"></div>\n </span>\n &nbsp; &nbsp; &nbsp; &nbsp; ${tech.tech[e].name} ${t}</div>${tech.tech[e].descriptionFunction?tech.tech[e].descriptionFunction():tech.tech[e].description}</div></div>`:tech.tech[e].isLore?s+=`<div class="choose-grid-module" onclick="powerUps.choose('tech',${e})"><div class="grid-title lore-text"><div class="circle-grid lore"></div> &nbsp; ${tech.tech[e].name} ${t}</div>${tech.tech[e].descriptionFunction?tech.tech[e].descriptionFunction():tech.tech[e].description}</div>`:tech.tech[e].isJunk?s+=`<div class="choose-grid-module" onclick="powerUps.choose('tech',${e})"><div class="grid-title"><div class="circle-grid junk"></div> &nbsp; ${tech.tech[e].name} ${t}</div>${tech.tech[e].descriptionFunction?tech.tech[e].descriptionFunction():tech.tech[e].description}</div>`:s+=`<div class="choose-grid-module" onclick="powerUps.choose('tech',${e})"><div class="grid-title"><div class="circle-grid tech"></div> &nbsp; ${tech.tech[e].name} ${t}</div>${tech.tech[e].descriptionFunction?tech.tech[e].descriptionFunction():tech.tech[e].description}</div>`,e}}let s="";tech.isSuperDeterminism||(s+="<div class='cancel' onclick='powerUps.endDraft(\"tech\",true)'>✕</div>"),s+="<h3 style = 'color:#fff; text-align:left; margin: 0px;'>tech</h3>";let t=e(),o=-1,i=-1;if(t>-1){if(tech.isDeterminism||(o=e(t),i=e(t,o)),tech.isExtraChoice){let s=e(t,o,i),c=e(t,o,i,s);powerUps.tech.choiceLog.push(s),powerUps.tech.choiceLog.push(c)}if(powerUps.tech.choiceLog.push(t),powerUps.tech.choiceLog.push(o),powerUps.tech.choiceLog.push(i),tech.isExtraGunField)if(Math.random()>.5&&b.inventory.length<b.guns.length){let e=powerUps.gun.pick(b.guns);powerUps.gun.choiceLog.push(e),s+=`<div class="choose-grid-module" onclick="powerUps.choose('gun',${e})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[e].name}</div> ${b.guns[e].description}</div>`}else{let e=powerUps.field.pick(m.fieldUpgrades);powerUps.field.choiceLog.push(e),s+=`<div class="choose-grid-module" onclick="powerUps.choose('field',${e})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${m.fieldUpgrades[e].name}</div> ${m.fieldUpgrades[e].description}</div>`}if(tech.isBrainstorm&&!tech.isBrainstormActive&&!simulation.isChoosing){tech.isBrainstormActive=!0;let e=0;requestAnimationFrame((function s(){e++,e<600&&simulation.isChoosing?(e%tech.brainStormDelay||(powerUps.tech.effect(),document.getElementById("choose-grid").style.pointerEvents="auto",document.body.style.cursor="auto",document.getElementById("choose-grid").style.transitionDuration="0s"),requestAnimationFrame(s)):tech.isBrainstormActive=!1}))}if(tech.isJunkResearch&&powerUps.research.currentRerollCount<3){tech.junkResearchNumber=Math.floor(5*Math.random()),s+='<div class="choose-grid-module" onclick="powerUps.research.use(\'tech\')"><div class="grid-title"> <span style="position:relative;">';for(let e=0;e<tech.junkResearchNumber;e++)s+=`<div class="circle-grid junk" style="position:absolute; top:0; left:${15*e}px ;opacity:0.8; border: 1px #fff solid;"></div>`;s+="</span>&nbsp; <span class='research-select'>pseudoscience</span></div></div>"}else if(powerUps.research.count){s+='<div class="choose-grid-module" onclick="powerUps.research.use(\'tech\')"><div class="grid-title"> <span style="position:relative;">';for(let e=0,t=Math.min(powerUps.research.count,30);e<t;e++)s+=`<div class="circle-grid research" style="position:absolute; top:0; left:${(18-.3*t)*e}px;opacity:0.8; border: 1px #fff solid;"></div>`;s+=`</span>&nbsp; <span class='research-select'>${tech.isResearchReality?"<span class='alt'>alternate reality</span>":"research"}</span></div></div>`}document.getElementById("choose-grid").innerHTML=s,powerUps.showDraft()}else if(tech.isBanish){for(let e=0,s=tech.tech.length;e<s;e++)"decoherence"===tech.tech[e].name&&powerUps.ejectTech(e);powerUps.endDraft("tech")}}}},gun:{name:"gun",color:"#26a",size:()=>35,pick(e,s=-1,t=-1,o=-1,i=-1){let c=[];for(let r=0;r<e.length;r++)e[r].have||r===s||r===t||r===o||r===i||c.push(r);const r=tech.isDeterminism?1:3+2*tech.isExtraChoice;if(powerUps.gun.choiceLog.length>r||powerUps.gun.choiceLog.length===r)for(let e=0;e<r;e++)if(c.length>r)for(let s=0,t=c.length;s<t;s++)if(powerUps.gun.choiceLog[powerUps.gun.choiceLog.length-1-e]===c[s]){c.splice(s,1);break}if(c.length>0)return c[Math.floor(Math.random()*c.length)]},choiceLog:[],effect(){let e=powerUps.gun.pick(b.guns),s=-1,t=-1;if(e>-1){let o="";if(tech.isSuperDeterminism||(o+="<div class='cancel' onclick='powerUps.endDraft(\"gun\",true)'>✕</div>"),o+="<h3 style = 'color:#fff; text-align:left; margin: 0px;'>gun</h3>",o+=`<div class="choose-grid-module" onclick="powerUps.choose('gun',${e})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[e].name}</div> ${b.guns[e].description}</div>`,tech.isDeterminism||(s=powerUps.gun.pick(b.guns,e),s>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('gun',${s})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[s].name}</div> ${b.guns[s].description}</div>`),t=powerUps.gun.pick(b.guns,e,s),t>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('gun',${t})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[t].name}</div> ${b.guns[t].description}</div>`)),tech.isExtraChoice){let i=powerUps.gun.pick(b.guns,e,s,t);i>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('gun',${i})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[i].name}</div> ${b.guns[i].description}</div>`);let c=powerUps.gun.pick(b.guns,e,s,t,i);c>-1&&(o+=`<div class="choose-grid-module" onclick="powerUps.choose('gun',${c})">\n <div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[c].name}</div> ${b.guns[c].description}</div>`),powerUps.gun.choiceLog.push(i),powerUps.gun.choiceLog.push(c)}if(powerUps.gun.choiceLog.push(e),powerUps.gun.choiceLog.push(s),powerUps.gun.choiceLog.push(t),tech.isJunkResearch&&powerUps.research.currentRerollCount<3){tech.junkResearchNumber=Math.floor(5*Math.random()),o+='<div class="choose-grid-module" onclick="powerUps.research.use(\'gun\')"><div class="grid-title"> <span style="position:relative;">';for(let e=0;e<tech.junkResearchNumber;e++)o+=`<div class="circle-grid junk" style="position:absolute; top:0; left:${15*e}px ;opacity:0.8; border: 1px #fff solid;"></div>`;o+="</span>&nbsp; <span class='research-select'>pseudoscience</span></div></div>"}else if(powerUps.research.count){o+='<div class="choose-grid-module" onclick="powerUps.research.use(\'gun\')"><div class="grid-title"> <span style="position:relative;">';for(let e=0,s=Math.min(powerUps.research.count,30);e<s;e++)o+=`<div class="circle-grid research" style="position:absolute; top:0; left:${(18-.3*s)*e}px ;opacity:0.8; border: 1px #fff solid;"></div>`;o+=`</span>&nbsp; <span class='research-select'>${tech.isResearchReality?"<span class='alt'>alternate reality</span>":"research"}</span></div></div>`}tech.isOneGun&&b.inventory.length>0&&(o+='<div style = "color: #f24">replaces your current gun</div>'),document.getElementById("choose-grid").innerHTML=o,powerUps.showDraft()}}},onPickUp(e){powerUps.research.currentRerollCount=0,tech.isTechDamage&&"tech"===e.name&&m.damage(.11),tech.isMassEnergy&&(m.energy+=2),tech.isMineDrop&&bullet.length<150&&(tech.isLaserMine&&input.down?b.laserMine(e.position):b.mine(e.position,{x:0,y:0},0)),tech.isRelay&&(tech.isFlipFlopOn?(tech.isFlipFlopOn=!1,document.getElementById("tech-switch")&&(document.getElementById("tech-switch").innerHTML=" = <strong>OFF</strong>"),m.eyeFillColor="transparent"):(tech.isFlipFlopOn=!0,document.getElementById("tech-switch")&&(document.getElementById("tech-switch").innerHTML=" = <strong>ON</strong>"),m.eyeFillColor=m.fieldMeterColor))},spawnRandomPowerUp(e,s){Math.random()*Math.random()-.3>Math.sqrt(m.health)&&!tech.isEnergyHealth||Math.random()<.04?powerUps.spawn(e,s,"heal"):Math.random()<.15&&b.inventory.length>0?powerUps.spawn(e,s,"ammo"):Math.random()<7e-4*(3-b.inventory.length)?powerUps.spawn(e,s,"gun"):Math.random()<.005*(10-level.levelsCleared)?powerUps.spawn(e,s,"tech"):Math.random()<.0015&&powerUps.spawn(e,s,"field")},randomPowerUpCounter:0,spawnBossPowerUp(e,s){if("final"!==level.levels[level.onLevel]){function t(t){Math.random()*t<powerUps.randomPowerUpCounter?(powerUps.randomPowerUpCounter=0,Math.random()<.97?powerUps.spawn(e,s,"tech"):powerUps.spawn(e,s,"gun")):m.health<.65&&!tech.isEnergyHealth?(powerUps.spawn(e,s,"heal"),powerUps.spawn(e,s,"heal")):(powerUps.spawn(e,s,"ammo"),powerUps.spawn(e,s,"ammo"))}0===m.fieldMode?powerUps.spawn(e,s,"field"):(powerUps.randomPowerUpCounter++,t(.1*Math.max(level.levelsCleared,10))),powerUps.randomPowerUpCounter+=.6,t(.1*Math.max(level.levelsCleared,6))}},chooseRandomPowerUp(e,s){Math.random()<.5?powerUps.spawn(e,s,"heal",!1):powerUps.spawn(e,s,"ammo",!1)},addResearchToLevel(){if(mob.length&&Math.random()<.8){const e=Math.floor(Math.random()*mob.length);powerUps.spawn(mob[e].position.x,mob[e].position.y,"research")}},spawnStartingPowerUps(e,s){if(level.levelsCleared<4)if(level.levelsCleared>1&&powerUps.spawn(e,s,"tech"),0===b.inventory.length)powerUps.spawn(e,s,"gun",!1);else if(0===tech.totalCount)powerUps.spawn(e,s,"tech",!1);else if(1===b.inventory.length)if(Math.random()<.4)powerUps.spawn(e,s,"gun",!1);else for(let t=0;t<5;t++)powerUps.spawn(e,s,"ammo",!1);else for(let t=0;t<4;t++)powerUps.spawnRandomPowerUp(e,s);else for(let t=0;t<3;t++)powerUps.spawnRandomPowerUp(e,s)},ejectTech(e="random"){if("random"===e){const s=[];for(let e=0;e<tech.tech.length;e++)tech.tech[e].count>0&&!tech.tech[e].isNonRefundable&&s.push(e);if(0===s.length)for(let e=0;e<tech.tech.length;e++)tech.tech[e].count>0&&s.push(e);if(s.length){e=s[Math.floor(Math.random()*s.length)],simulation.makeTextLog(`<span class='color-var'>tech</span>.remove("<span class='color-text'>${tech.tech[e].name}</span>")`);for(let s=0;s<tech.tech[e].count;s++)powerUps.directSpawn(m.pos.x,m.pos.y,"tech"),powerUp[powerUp.length-1].isDuplicated=!0;return tech.tech[e].remove(),tech.tech[e].count=0,tech.tech[e].isLost=!0,simulation.updateTechHUD(),m.fieldCDcycle=m.cycle+30,!0}return!1}if(tech.tech[e].count){simulation.makeTextLog(`<span class='color-var'>tech</span>.remove("<span class='color-text'>${tech.tech[e].name}</span>")`);for(let s=0;s<tech.tech[e].count;s++)powerUps.directSpawn(m.pos.x,m.pos.y,"tech"),powerUp[powerUp.length-1].isDuplicated=!0;return tech.tech[e].remove(),tech.tech[e].count=0,tech.tech[e].isLost=!0,simulation.updateTechHUD(),m.fieldCDcycle=m.cycle+30,!0}return!1},directSpawn(e,s,t,o=!0,i=null,c=powerUps[t].size()){let r=powerUp.length;t=powerUps[t],powerUp[r]=Matter.Bodies.polygon(e,s,0,c,{density:.001,frictionAir:.03,restitution:.85,inertia:1/0,collisionFilter:{group:0,category:cat.powerUp,mask:cat.map|cat.powerUp},color:t.color,effect:t.effect,name:t.name,size:c}),i&&(powerUp[r].mode=i),o&&Matter.Body.setVelocity(powerUp[r],{x:15*(Math.random()-.5),y:-9*Math.random()-3}),Composite.add(engine.world,powerUp[r])},spawn(e,s,t,o=!0,i=null,c=powerUps[t].size()){tech.isSuperDeterminism&&"research"===t||tech.isEnergyNoAmmo&&"ammo"===t||simulation.isNoPowerUps||(powerUps.directSpawn(e,s,t,o,i,c),Math.random()<tech.duplicationChance()&&(powerUps.directSpawn(e,s,t,o,i,c),powerUp[powerUp.length-1].isDuplicated=!0))}};
2
3