`
for (let i = 0, len = Math.min(powerUps.research.count, 30); i < len; i++) text += ``
text += `${tech.isResearchReality ? "alternate reality" : "research"}
`
} else {
text += ``
}
return text
},
researchAndCancelText(type) {
let text = `
`
if (type === "entanglement") {
text += `entanglement` //
} else if (tech.isJunkResearch && powerUps.research.currentRerollCount < 2) {
text += `` // style = "margin-left: 192px; margin-right: -192px;"
text += `
`
text += ``
text += `${tech.isResearchReality ? "alternate reality" : "research"}
`
} else if (powerUps.research.count > 0) {
text += `` // style = "margin-left: 192px; margin-right: -192px;"
text += `
`
let researchCap = 18
if (tech.isCancelTech && tech.cancelTechCount === 0) researchCap -= 2
if (canvas.width < 1951) researchCap -= 3
if (canvas.width < 1711) researchCap -= 4
for (let i = 0, len = Math.min(powerUps.research.count, researchCap); i < len; i++) {
text += ``
}
text += `${tech.isResearchReality ? "alternate reality" : "research"}
`
} else {
text += `research` //
}
if (tech.isSuperDeterminism) {
text += `cancel`
} else if (tech.isCancelTech && tech.cancelTechCount === 0) {
text += `randomize`
} else if (level.levelsCleared === 0 && localSettings.isTrainingNotAttempted && b.inventory.length === 0) {
text += `cancel` //don't show cancel if on initial level and haven't done tutorial
} else {
text += `cancel`
}
return text + "
"
},
buildColumns(totalChoices, type) {
let width
if (canvas.width < 1710) {
width = "285px"
} else if (canvas.width < 1950) {
width = "340px"
} else {
width = "384px"
}
let text = ""
if (localSettings.isHideImages) {
document.getElementById("choose-grid").style.gridTemplateColumns = width
text += powerUps.researchAndCancelText(type)
} else if (totalChoices === 0) {
document.getElementById("choose-grid").style.gridTemplateColumns = width
text += powerUps.researchAndCancelText(type)
} else if (totalChoices === 1 || canvas.width < 1200) {
document.getElementById("choose-grid").style.gridTemplateColumns = width
text += powerUps.researchAndCancelText(type)
// console.log('hi')
// text += powerUps.cancelText(type)
// text += powerUps.researchText(type)
} else if (totalChoices === 2) {
document.getElementById("choose-grid").style.gridTemplateColumns = `repeat(2, ${width})`
text += powerUps.researchText(type)
text += powerUps.cancelText(type)
} else {
document.getElementById("choose-grid").style.gridTemplateColumns = `repeat(3, ${width})`
text += ""
text += powerUps.researchText(type)
text += powerUps.cancelText(type)
}
return text
},
hideStyle: `style="height:auto; border: none; background-color: transparent;"`,
gunText(choose, click) {
const style = localSettings.isHideImages ? powerUps.hideStyle : `style="background-image: url('img/gun/${b.guns[choose].name}.webp');"`
return `
`
},
gun: {
name: "gun",
color: "#26a",
size() {
return 35;
},
effect() {
if (m.alive) {
let options = [];
for (let i = 0; i < b.guns.length; i++) {
if (!b.guns[i].have) options.push(i);
}
// console.log(options.length)
if (options.length > 0 || !tech.isSuperDeterminism) {
let totalChoices = 2 + tech.extraChoices + 3 * (m.fieldMode === 8)
if (tech.isCancelTech && tech.cancelTechCount === 1) {
totalChoices *= 3
tech.cancelTechCount++
}
if (tech.isDeterminism) totalChoices = 1
totalChoices = Math.min(options.length, totalChoices)
function removeOption(index) {
for (let i = 0; i < options.length; i++) {
if (options[i] === index) {
options.splice(i, 1) //remove a previous choice from option pool
return
}
}
}
//check for guns that were a choice last time and remove them
for (let i = 0; i < b.guns.length; i++) {
if (options.length - 1 < totalChoices) break //you have to repeat choices if there are not enough choices left to display
if (b.guns[i].isRecentlyShown) removeOption(i)
}
for (let i = 0; i < b.guns.length; i++) b.guns[i].isRecentlyShown = false //reset recently shown back to zero
// if (options.length > 0) {
let text = powerUps.buildColumns(totalChoices, "gun")
for (let i = 0; i < totalChoices; i++) {
const choose = options[Math.floor(Math.seededRandom(0, options.length))] //pick an element from the array of options
// text += `
${b.guns[choose].name}
${b.guns[choose].description}
`
text += powerUps.gunText(choose, `powerUps.choose('gun',${choose})`)
b.guns[choose].isRecentlyShown = true
removeOption(choose)
if (options.length < 1) break
}
if (tech.isExtraBotOption) {
const botTech = [] //make an array of bot options
for (let i = 0, len = tech.tech.length; i < len; i++) {
if (tech.tech[i].isBotTech && tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed()) botTech.push(i)
}
if (botTech.length > 0) { //pick random bot tech
const choose = botTech[Math.floor(Math.random() * botTech.length)];
const techCountText = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count + 1}x)` : "";
const style = localSettings.isHideImages ? powerUps.hideStyle : `style="background-image: url('img/${tech.tech[choose].name}.webp');"`
text += `
`
}
}
if (tech.isOneGun && b.inventory.length > 0) text += `
replaces your current gun
`
document.getElementById("choose-grid").innerHTML = text
powerUps.showDraft();
}
// }
}
},
},
field: {
name: "field",
color: "#0cf",
size() {
return 45;
},
effect() {
if (m.alive) {
let options = [];
for (let i = 1; i < m.fieldUpgrades.length; i++) { //skip field emitter
if (i !== m.fieldMode) options.push(i);
}
let totalChoices = 2 + tech.extraChoices + 3 * (m.fieldMode === 8)
if (tech.isCancelTech && tech.cancelTechCount === 1) {
totalChoices *= 3
tech.cancelTechCount++
}
if (tech.isDeterminism) totalChoices = 1
totalChoices = Math.min(options.length, totalChoices)
function removeOption(index) {
for (let i = 0; i < options.length; i++) {
if (options[i] === index) {
options.splice(i, 1) //remove a previous choice from option pool
return
}
}
}
//check for fields that were a choice last time and remove them
for (let i = 0; i < m.fieldUpgrades.length; i++) {
if (options.length - 1 < totalChoices) break //you have to repeat choices if there are not enough choices left to display
if (m.fieldUpgrades[i].isRecentlyShown) removeOption(i)
}
for (let i = 0; i < m.fieldUpgrades.length; i++) m.fieldUpgrades[i].isRecentlyShown = false //reset recently shown back to zero
if (options.length > 0 || tech.isExtraBotOption) {
let text = powerUps.buildColumns(totalChoices, "field")
for (let i = 0; i < totalChoices; i++) {
const choose = options[Math.floor(Math.seededRandom(0, options.length))] //pick an element from the array of options
//text += `
${m.fieldUpgrades[choose].name}
${m.fieldUpgrades[choose].description}
` //default
text += powerUps.fieldText(choose, `powerUps.choose('field',${choose})`)
m.fieldUpgrades[choose].isRecentlyShown = true
removeOption(choose)
if (options.length < 1) break
}
if (tech.isExtraBotOption) {
const botTech = [] //make an array of bot options
for (let i = 0, len = tech.tech.length; i < len; i++) {
if (tech.tech[i].isBotTech && tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed()) botTech.push(i)
}
if (botTech.length > 0) { //pick random bot tech
const choose = botTech[Math.floor(Math.random() * botTech.length)];
const techCountText = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count + 1}x)` : "";
const style = localSettings.isHideImages ? powerUps.hideStyle : `style="background-image: url('img/${tech.tech[choose].name}.webp');"`
text += `
`
}
}
document.getElementById("choose-grid").innerHTML = text
powerUps.showDraft();
}
}
},
},
tech: {
name: "tech",
color: "hsl(246,100%,77%)", //"#a8f",
size() {
return 42;
},
effect() {
if (m.alive) {
// powerUps.animatePowerUpGrab('hsla(246, 100%, 77%,0.5)')
let options = []; //generate all options
optionLengthNoDuplicates = 0
for (let i = 0; i < tech.tech.length; i++) {
if (tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed() && !tech.tech[i].isBanished) {
if (tech.tech[i].frequency > 0) optionLengthNoDuplicates++
for (let j = 0, len = tech.tech[i].frequency; j < len; j++) options.push(i);
}
}
function removeOption(index) {
for (let i = options.length - 1; i > -1; i--) {
if (index === options[i]) {
options.splice(i, 1) //remove all copies of that option form the options array (some tech are in the options array multiple times because of frequency)
optionLengthNoDuplicates--
}
if (options.length < 1) return;
}
}
//set total choices
let totalChoices = 3 + tech.extraChoices + 3 * (m.fieldMode === 8)
if (tech.isCancelTech && tech.cancelTechCount === 1) {
totalChoices *= 3
tech.cancelTechCount++
}
if (tech.isDeterminism) totalChoices = 1
totalChoices = Math.min(options.length, totalChoices)
if (optionLengthNoDuplicates < totalChoices + 1) { //if not enough options for all the choices
totalChoices = optionLengthNoDuplicates
if (tech.isBanish) { //when you run out of options eject banish
for (let i = 0, len = tech.tech.length; i < len; i++) {
if (tech.tech[i].name === "decoherence") powerUps.ejectTech(i, true)
}
simulation.makeTextLog(`decoherence tech ejected`)
simulation.makeTextLog(`options reset`)
}
}
if (tech.tooManyTechChoices) {
tech.tooManyTechChoices = false
totalChoices = optionLengthNoDuplicates
}
if (optionLengthNoDuplicates > totalChoices) { //check for tech that were a choice last time and remove them
for (let i = 0; i < tech.tech.length; i++) {
if (optionLengthNoDuplicates > totalChoices) {
if (tech.tech[i].isRecentlyShown) removeOption(i)
} else {
break //you have to repeat choices if there are not enough choices left to display
}
}
}
for (let i = 0; i < tech.tech.length; i++) tech.tech[i].isRecentlyShown = false //reset recently shown back to zero
if (options.length > 0) {
let text = powerUps.buildColumns(totalChoices, "tech")
for (let i = 0; i < totalChoices; i++) {
if (options.length < 1) break
const choose = options[Math.floor(Math.seededRandom(0, options.length))] //pick an element from the array of options
if (tech.isBanish) {
tech.tech[choose].isBanished = true
if (i === 0) simulation.makeTextLog(`options.length = ${optionLengthNoDuplicates} //tech removed from pool by decoherence`)
}
removeOption(choose) //move from future options pool to avoid repeats on this selection
tech.tech[choose].isRecentlyShown = true //this flag prevents this option from being shown the next time you pick up a tech power up
if (Math.random() < tech.junkChance) { // choose is set to a random JUNK tech
const list = []
for (let i = 0; i < tech.tech.length; i++) {
if (tech.tech[i].isJunk) list.push(i)
}
chooseJUNK = list[Math.floor(Math.random() * list.length)]
text += powerUps.junkTechText(chooseJUNK, `powerUps.choose('tech',${chooseJUNK})`)
} else {
if (tech.tech[choose].isFieldTech) {
text += powerUps.fieldTechText(choose, `powerUps.choose('tech',${choose})`)
} else if (tech.tech[choose].isGunTech) {
text += powerUps.gunTechText(choose, `powerUps.choose('tech',${choose})`)
} else if (tech.tech[choose].isJunk) {
text += powerUps.junkTechText(choose, `powerUps.choose('tech',${choose})`)
} else if (tech.tech[choose].isSkin) {
text += powerUps.skinTechText(choose, `powerUps.choose('tech',${choose})`)
} else if (tech.tech[choose].isInstant) {
text += powerUps.instantTechText(choose, `powerUps.choose('tech',${choose})`)
} else { //normal tech
text += powerUps.techText(choose, `powerUps.choose('tech',${choose})`)
}
if (options.length < 1) break
}
}
if (tech.isExtraBotOption) {
const botTech = [] //make an array of bot options
for (let i = 0, len = tech.tech.length; i < len; i++) {
if (tech.tech[i].isBotTech && tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed() && !tech.tech[i].isRecentlyShown) botTech.push(i)
}
if (botTech.length > 0) { //pick random bot tech
// const choose = botTech[Math.floor(Math.random() * botTech.length)];
// const isCount = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count+1}x)` : "";
// text += `
`
}
}
}
if (tech.isExtraGunField) {
if (Math.random() > 0.5 && b.inventory.length < b.guns.length) {
let gunOptions = [];
for (let i = 0; i < b.guns.length; i++) {
if (!b.guns[i].have) gunOptions.push(i);
}
const pick = gunOptions[Math.floor(Math.seededRandom(0, gunOptions.length))] //pick an element from the array of options
// text += `
${b.guns[pick].name}
${b.guns[pick].description}
`
text += powerUps.gunText(pick, `powerUps.choose('gun',${pick})`)
} else {
let fieldOptions = [];
for (let i = 1; i < m.fieldUpgrades.length; i++) { //skip field emitter
if (i !== m.fieldMode) fieldOptions.push(i);
}
const pick = fieldOptions[Math.floor(Math.seededRandom(0, fieldOptions.length))] //pick an element from the array of options
// text += `
${m.fieldUpgrades[pick].name}
${m.fieldUpgrades[pick].description}
`
text += powerUps.fieldText(pick, `powerUps.choose('field',${pick})`)
}
}
if (tech.isBrainstorm && !tech.isBrainstormActive && !simulation.isChoosing) {
tech.isBrainstormActive = true
let count = 1
let timeStart = performance.now()
const cycle = (timestamp) => {
// if (timeStart === undefined) timeStart = timestamp
// console.log(timestamp, timeStart)
if (timestamp - timeStart > tech.brainStormDelay * count && simulation.isChoosing) {
count++
powerUps.tech.effect();
document.getElementById("choose-grid").style.pointerEvents = "auto"; //turn off the normal 500ms delay
document.body.style.cursor = "auto";
document.getElementById("choose-grid").style.transitionDuration = "0s";
}
if (count < 10 && simulation.isChoosing) {
requestAnimationFrame(cycle);
} else {
tech.isBrainstormActive = false
}
}
requestAnimationFrame(cycle);
}
document.getElementById("choose-grid").innerHTML = text
powerUps.showDraft();
}
}
},
},
entanglement: {
name: "entanglement",
color: "#fff", //"hsl(248,100%,65%)",
size() {
return 40
},
effect() {
if (m.alive && localSettings.entanglement) {
// let text = ""
// document.getElementById("choose-grid").style.gridTemplateColumns = "384px 384px 384px"
let text = powerUps.buildColumns(3, "entanglement")
// text += powerUps.researchText('tech')
// text += ""
// text += "
entanglement
"
// text += `
cancel
` //powerUps.cancelText('tech')
if (localSettings.entanglement.fieldIndex && localSettings.entanglement.fieldIndex !== m.fieldMode) {
const choose = localSettings.entanglement.fieldIndex //add field
text += powerUps.fieldText(choose, `powerUps.choose('field',${choose})`)
}
for (let i = 0; i < localSettings.entanglement.gunIndexes.length; i++) { //add guns
const choose = localSettings.entanglement.gunIndexes[i]
//check if you always have this gun
let alreadyHasGun = false
for (let j = 0; j < b.inventory.length; j++) {
if (b.inventory[j] === choose) alreadyHasGun = true
}
// text += `
${b.guns[gun].name}
${b.guns[gun].description}
`
if (!alreadyHasGun) text += powerUps.gunText(choose, `powerUps.choose('gun',${choose})`)
}
for (let i = 0; i < localSettings.entanglement.techIndexes.length; i++) { //add tech
let found = false;
let choose = undefined
console.log(localSettings.entanglement.techIndexes[i])
for (let j = 0; j < tech.tech.length; j++) {
if (localSettings.entanglement.techIndexes[i] === tech.tech[j].name) {
choose = j;
found = true;
break;
}
}
// let choose = localSettings.entanglement.techIndexes[i]
console.log(choose)
if (found && tech.tech[choose]) {
const isCount = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count + 1}x)` : "";
if (choose === null || tech.tech[choose].count + 1 > tech.tech[choose].maxCount || !tech.tech[choose].allowed()) {
// text += `
${tech.tech[choose].name} - incoherent
`
text += powerUps.incoherentTechText(choose)
} else {
if (tech.tech[choose].isFieldTech) {
text += powerUps.fieldTechText(choose, `powerUps.choose('tech',${choose})`)
} else if (tech.tech[choose].isGunTech) {
text += powerUps.gunTechText(choose, `powerUps.choose('tech',${choose})`)
} else if (tech.tech[choose].isLore) {
text += `