made draft mode default, bug fixes
This commit is contained in:
@@ -85,12 +85,6 @@
|
|||||||
<text x="10" y="30">custom</text>
|
<text x="10" y="30">custom</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
<svg class="SVG-button" id="draft-button" width="80" height="40">
|
|
||||||
<title>When you gain a new a power up choose between 3 random options.</title>
|
|
||||||
<g stroke='none' fill='#333' stroke-width="2" font-size="28px" font-family="Arial, sans-serif">
|
|
||||||
<text x="10" y="30">draft</text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
<div id="settings">
|
<div id="settings">
|
||||||
<details>
|
<details>
|
||||||
<summary>settings</summary>
|
<summary>settings</summary>
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ const b = {
|
|||||||
game.replaceTextLog = true;
|
game.replaceTextLog = true;
|
||||||
game.makeTextLog("<div style='font-size:140%;'>NO AMMO</div> <p style='font-size:90%;'><strong>Q</strong>, <strong>E</strong>, and <strong>mouse wheel</strong> change weapons</p>", 200);
|
game.makeTextLog("<div style='font-size:140%;'>NO AMMO</div> <p style='font-size:90%;'><strong>Q</strong>, <strong>E</strong>, and <strong>mouse wheel</strong> change weapons</p>", 200);
|
||||||
}
|
}
|
||||||
if (mech.isHolding) {
|
if (mech.holdingTarget) {
|
||||||
mech.drop();
|
mech.drop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1761,7 +1761,7 @@ const b = {
|
|||||||
//use energy to explode
|
//use energy to explode
|
||||||
const energy = mech.fieldMeter * 0.25
|
const energy = mech.fieldMeter * 0.25
|
||||||
mech.fieldMeter -= energy
|
mech.fieldMeter -= energy
|
||||||
if (best.who) b.explosion(path[1], 1200 * energy)
|
if (best.who) b.explosion(path[1], 1000 * energy)
|
||||||
mech.fireCDcycle = mech.cycle + Math.floor(65 * b.modFireRate); // cool down
|
mech.fireCDcycle = mech.cycle + Math.floor(65 * b.modFireRate); // cool down
|
||||||
|
|
||||||
//draw laser beam
|
//draw laser beam
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ const game = {
|
|||||||
accelScale: null, //set in levels.setDifficulty
|
accelScale: null, //set in levels.setDifficulty
|
||||||
CDScale: null, //set in levels.setDifficulty
|
CDScale: null, //set in levels.setDifficulty
|
||||||
lookFreqScale: null, //set in levels.setDifficulty
|
lookFreqScale: null, //set in levels.setDifficulty
|
||||||
isDraftMode: false,
|
|
||||||
// dropFPS(cap = 40, time = 15) {
|
// dropFPS(cap = 40, time = 15) {
|
||||||
// game.fpsCap = cap
|
// game.fpsCap = cap
|
||||||
// game.fpsInterval = 1000 / game.fpsCap;
|
// game.fpsInterval = 1000 / game.fpsCap;
|
||||||
@@ -501,7 +500,6 @@ const game = {
|
|||||||
document.getElementById("choose-grid").style.display = "none"
|
document.getElementById("choose-grid").style.display = "none"
|
||||||
document.getElementById("controls").style.display = "inline";
|
document.getElementById("controls").style.display = "inline";
|
||||||
document.getElementById("build-button").style.display = "inline"
|
document.getElementById("build-button").style.display = "inline"
|
||||||
document.getElementById("draft-button").style.display = "inline"
|
|
||||||
isShowingBuilds = false
|
isShowingBuilds = false
|
||||||
document.getElementById("settings").style.display = "inline";
|
document.getElementById("settings").style.display = "inline";
|
||||||
document.getElementById("splash").style.display = "inline";
|
document.getElementById("splash").style.display = "inline";
|
||||||
@@ -520,7 +518,6 @@ const game = {
|
|||||||
document.getElementById("controls").style.display = "none";
|
document.getElementById("controls").style.display = "none";
|
||||||
document.getElementById("settings").style.display = "none";
|
document.getElementById("settings").style.display = "none";
|
||||||
document.getElementById("build-button").style.display = "none";
|
document.getElementById("build-button").style.display = "none";
|
||||||
document.getElementById("draft-button").style.display = "none"
|
|
||||||
document.getElementById("splash").onclick = null; //removes the onclick effect so the function only runs once
|
document.getElementById("splash").onclick = null; //removes the onclick effect so the function only runs once
|
||||||
document.getElementById("splash").style.display = "none"; //hides the element that spawned the function
|
document.getElementById("splash").style.display = "none"; //hides the element that spawned the function
|
||||||
document.getElementById("dmg").style.display = "inline";
|
document.getElementById("dmg").style.display = "inline";
|
||||||
|
|||||||
11
js/index.js
11
js/index.js
@@ -2,8 +2,6 @@
|
|||||||
/* TODO: *******************************************
|
/* TODO: *******************************************
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
||||||
make draft mode default and add in negative mods
|
|
||||||
|
|
||||||
field: catch mobs in your field and make them into guardian bullets
|
field: catch mobs in your field and make them into guardian bullets
|
||||||
|
|
||||||
negative mod effect ideas
|
negative mod effect ideas
|
||||||
@@ -11,6 +9,8 @@ negative mod effect ideas
|
|||||||
-fire rate
|
-fire rate
|
||||||
-slow life decay
|
-slow life decay
|
||||||
|
|
||||||
|
mod: gain an extra choice of power ups
|
||||||
|
|
||||||
mod: if you fire when out of ammo you gain 1 ammo pack at the cost of
|
mod: if you fire when out of ammo you gain 1 ammo pack at the cost of
|
||||||
10% max health
|
10% max health
|
||||||
20% of your current health
|
20% of your current health
|
||||||
@@ -104,12 +104,6 @@ const cat = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("draft-button").addEventListener("click", () => {
|
|
||||||
game.isDraftMode = true;
|
|
||||||
game.startGame();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
//build build grid display
|
//build build grid display
|
||||||
const build = {
|
const build = {
|
||||||
isShowingBuilds: false,
|
isShowingBuilds: false,
|
||||||
@@ -163,7 +157,6 @@ const build = {
|
|||||||
|
|
||||||
document.getElementById("build-button").addEventListener("click", () => {
|
document.getElementById("build-button").addEventListener("click", () => {
|
||||||
document.getElementById("build-button").style.display = "none";
|
document.getElementById("build-button").style.display = "none";
|
||||||
document.getElementById("draft-button").style.display = "none";
|
|
||||||
const el = document.getElementById("build-grid")
|
const el = document.getElementById("build-grid")
|
||||||
if (build.isShowingBuilds) {
|
if (build.isShowingBuilds) {
|
||||||
el.style.display = "none"
|
el.style.display = "none"
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ const level = {
|
|||||||
//******************************************************************************************************************
|
//******************************************************************************************************************
|
||||||
testingMap() {
|
testingMap() {
|
||||||
//start with all guns
|
//start with all guns
|
||||||
|
level.difficultyIncrease(8)
|
||||||
game.zoomScale = 1400 //1400 is normal
|
game.zoomScale = 1400 //1400 is normal
|
||||||
spawn.setSpawnList();
|
spawn.setSpawnList();
|
||||||
mech.setPosToSpawn(-75, -60); //normal spawn
|
mech.setPosToSpawn(-75, -60); //normal spawn
|
||||||
@@ -117,11 +118,11 @@ const level = {
|
|||||||
// powerUps.spawn(450, -400, "mod", false, 6);
|
// powerUps.spawn(450, -400, "mod", false, 6);
|
||||||
// powerUps.spawn(450, -400, "mod", false);
|
// powerUps.spawn(450, -400, "mod", false);
|
||||||
// spawn.bodyRect(-45, -100, 40, 50);
|
// spawn.bodyRect(-45, -100, 40, 50);
|
||||||
spawn.groupBoss(800, -1050);
|
// spawn.groupBoss(800, -1050);
|
||||||
spawn.shooter(400, -1050);
|
spawn.spinner(400, -1050);
|
||||||
spawn.shooter(1200, -1050);
|
spawn.spinner(1200, -1050);
|
||||||
// spawn.groupBoss(-600, -550);
|
// spawn.groupBoss(-600, -550);
|
||||||
spawn.hopper(800, -150);
|
spawn.spinner(800, -150);
|
||||||
// spawn.beamer(800, -150);
|
// spawn.beamer(800, -150);
|
||||||
// spawn.grower(800, -250);
|
// spawn.grower(800, -250);
|
||||||
// spawn.blinker(800, -250, 40);
|
// spawn.blinker(800, -250, 40);
|
||||||
|
|||||||
44
js/player.js
44
js/player.js
@@ -687,7 +687,7 @@ const mech = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
drop() {
|
drop() {
|
||||||
if (mech.isHolding) {
|
if (mech.isHolding && mech.holdingTarget) {
|
||||||
mech.isHolding = false;
|
mech.isHolding = false;
|
||||||
mech.definePlayerMass()
|
mech.definePlayerMass()
|
||||||
mech.holdingTarget.collisionFilter.category = cat.body;
|
mech.holdingTarget.collisionFilter.category = cat.body;
|
||||||
@@ -735,6 +735,7 @@ const mech = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
holding() {
|
holding() {
|
||||||
|
// if (mech.holdingTarget) {
|
||||||
mech.fieldMeter -= mech.fieldRegen;
|
mech.fieldMeter -= mech.fieldRegen;
|
||||||
if (mech.fieldMeter < 0) mech.fieldMeter = 0;
|
if (mech.fieldMeter < 0) mech.fieldMeter = 0;
|
||||||
Matter.Body.setPosition(mech.holdingTarget, {
|
Matter.Body.setPosition(mech.holdingTarget, {
|
||||||
@@ -743,32 +744,35 @@ const mech = {
|
|||||||
});
|
});
|
||||||
Matter.Body.setVelocity(mech.holdingTarget, player.velocity);
|
Matter.Body.setVelocity(mech.holdingTarget, player.velocity);
|
||||||
Matter.Body.rotate(mech.holdingTarget, 0.01 / mech.holdingTarget.mass); //gently spin the block
|
Matter.Body.rotate(mech.holdingTarget, 0.01 / mech.holdingTarget.mass); //gently spin the block
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
throw () {
|
throw () {
|
||||||
if ((keys[32] || game.mouseDownRight)) {
|
if ((keys[32] || game.mouseDownRight)) {
|
||||||
if (mech.fieldMeter > 0.0007) {
|
if (mech.fieldMeter > 0.0007) {
|
||||||
mech.fieldMeter -= 0.0007;
|
if (mech.holdingTarget) {
|
||||||
mech.throwCharge += mech.throwChargeRate;;
|
mech.fieldMeter -= 0.0007;
|
||||||
//draw charge
|
mech.throwCharge += mech.throwChargeRate;;
|
||||||
const x = mech.pos.x + 15 * Math.cos(mech.angle);
|
//draw charge
|
||||||
const y = mech.pos.y + 15 * Math.sin(mech.angle);
|
const x = mech.pos.x + 15 * Math.cos(mech.angle);
|
||||||
const len = mech.holdingTarget.vertices.length - 1;
|
const y = mech.pos.y + 15 * Math.sin(mech.angle);
|
||||||
const edge = mech.throwCharge * mech.throwCharge * 0.02;
|
const len = mech.holdingTarget.vertices.length - 1;
|
||||||
const grd = ctx.createRadialGradient(x, y, edge, x, y, edge + 5);
|
const edge = mech.throwCharge * mech.throwCharge * 0.02;
|
||||||
grd.addColorStop(0, "rgba(255,50,150,0.3)");
|
const grd = ctx.createRadialGradient(x, y, edge, x, y, edge + 5);
|
||||||
grd.addColorStop(1, "transparent");
|
grd.addColorStop(0, "rgba(255,50,150,0.3)");
|
||||||
ctx.fillStyle = grd;
|
grd.addColorStop(1, "transparent");
|
||||||
ctx.beginPath();
|
ctx.fillStyle = grd;
|
||||||
ctx.moveTo(x, y);
|
|
||||||
ctx.lineTo(mech.holdingTarget.vertices[len].x, mech.holdingTarget.vertices[len].y);
|
|
||||||
ctx.lineTo(mech.holdingTarget.vertices[0].x, mech.holdingTarget.vertices[0].y);
|
|
||||||
ctx.fill();
|
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(x, y);
|
ctx.moveTo(x, y);
|
||||||
ctx.lineTo(mech.holdingTarget.vertices[i].x, mech.holdingTarget.vertices[i].y);
|
ctx.lineTo(mech.holdingTarget.vertices[len].x, mech.holdingTarget.vertices[len].y);
|
||||||
ctx.lineTo(mech.holdingTarget.vertices[i + 1].x, mech.holdingTarget.vertices[i + 1].y);
|
ctx.lineTo(mech.holdingTarget.vertices[0].x, mech.holdingTarget.vertices[0].y);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x, y);
|
||||||
|
ctx.lineTo(mech.holdingTarget.vertices[i].x, mech.holdingTarget.vertices[i].y);
|
||||||
|
ctx.lineTo(mech.holdingTarget.vertices[i + 1].x, mech.holdingTarget.vertices[i + 1].y);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mech.drop()
|
mech.drop()
|
||||||
|
|||||||
185
js/powerups.js
185
js/powerups.js
@@ -43,7 +43,7 @@ const powerUps = {
|
|||||||
heal = Math.min(mech.maxHealth - mech.health, heal)
|
heal = Math.min(mech.maxHealth - mech.health, heal)
|
||||||
if (b.isModRecursiveHealing) heal *= 2
|
if (b.isModRecursiveHealing) heal *= 2
|
||||||
mech.addHealth(heal);
|
mech.addHealth(heal);
|
||||||
if (heal > 0) game.makeTextLog("<div class='circle heal'></div> <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300)
|
if (heal > 0) game.makeTextLog("<div class='circle heal'></div> <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (heal * game.healScale * 100).toFixed(0) + "%</span>", 300)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ammo: {
|
ammo: {
|
||||||
@@ -91,54 +91,27 @@ const powerUps = {
|
|||||||
return 45;
|
return 45;
|
||||||
},
|
},
|
||||||
effect() {
|
effect() {
|
||||||
if (game.isDraftMode) {
|
function doNotHave(who, skip1 = -1, skip2 = -1) {
|
||||||
function doNotHave(who, skip1 = -1, skip2 = -1) {
|
let options = [];
|
||||||
let options = [];
|
for (let i = 1; i < who.length; i++) {
|
||||||
for (let i = 1; i < who.length; i++) {
|
if (i !== mech.fieldMode && i !== skip1 && i !== skip2) options.push(i);
|
||||||
if (i !== mech.fieldMode && i !== skip1 && i !== skip2) options.push(i);
|
|
||||||
}
|
|
||||||
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
|
|
||||||
}
|
}
|
||||||
|
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
|
||||||
|
}
|
||||||
|
|
||||||
let choice1 = doNotHave(mech.fieldUpgrades)
|
let choice1 = doNotHave(mech.fieldUpgrades)
|
||||||
let choice2 = doNotHave(mech.fieldUpgrades, choice1)
|
let choice2 = doNotHave(mech.fieldUpgrades, choice1)
|
||||||
let choice3 = doNotHave(mech.fieldUpgrades, choice1, choice2)
|
let choice3 = doNotHave(mech.fieldUpgrades, choice1, choice2)
|
||||||
if (choice1 > -1) {
|
if (choice1 > -1) {
|
||||||
let text = `<h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a field</h3>`
|
let text = `<h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a field</h3>`
|
||||||
text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice1})"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[choice1].name}</div> ${mech.fieldUpgrades[choice1].description}</div>`
|
text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice1})"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[choice1].name}</div> ${mech.fieldUpgrades[choice1].description}</div>`
|
||||||
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice2})"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[choice2].name}</div> ${mech.fieldUpgrades[choice2].description}</div>`
|
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice2})"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[choice2].name}</div> ${mech.fieldUpgrades[choice2].description}</div>`
|
||||||
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice3})"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[choice3].name}</div> ${mech.fieldUpgrades[choice3].description}</div>`
|
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice3})"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[choice3].name}</div> ${mech.fieldUpgrades[choice3].description}</div>`
|
||||||
// text += `<div style = 'color:#fff'>${game.SVGrightMouse} activate the shield with the right mouse<br>fields shield you from damage <br>and let you pick up and throw blocks</div>`
|
// text += `<div style = 'color:#fff'>${game.SVGrightMouse} activate the shield with the right mouse<br>fields shield you from damage <br>and let you pick up and throw blocks</div>`
|
||||||
document.getElementById("choose-grid").innerHTML = text
|
document.getElementById("choose-grid").innerHTML = text
|
||||||
powerUps.showDraft();
|
powerUps.showDraft();
|
||||||
} else {
|
|
||||||
powerUps.giveRandomAmmo()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const previousMode = mech.fieldMode
|
powerUps.giveRandomAmmo()
|
||||||
if (this.mode) { //this.mode is set if the power up has been ejected from player
|
|
||||||
// mech.fieldUpgrades[this.mode].effect(); //set a predetermined power up
|
|
||||||
mech.setField(this.mode)
|
|
||||||
} else { //choose a random mode that you don't already have
|
|
||||||
availableModes = []
|
|
||||||
for (let i = 1; i < mech.fieldUpgrades.length; i++) { //start on 1 to skip the default field
|
|
||||||
if (i !== previousMode) {
|
|
||||||
availableModes.push(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const mode = availableModes[Math.floor(Math.random() * availableModes.length)]
|
|
||||||
mech.setField(mode)
|
|
||||||
}
|
|
||||||
game.replaceTextLog = true;
|
|
||||||
game.makeTextLog(`${game.SVGrightMouse}<strong style='font-size:30px;'> ${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'></span><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 600);
|
|
||||||
game.replaceTextLog = false;
|
|
||||||
//pop the old field out in case player wants to swap back
|
|
||||||
if (previousMode !== 0) {
|
|
||||||
mech.fieldCDcycle = mech.cycle + 40; //trigger fieldCD to stop power up grab automatic pick up of spawn
|
|
||||||
setTimeout(function () {
|
|
||||||
powerUps.spawn(mech.pos.x, mech.pos.y - 15, "field", false, previousMode);
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -149,43 +122,26 @@ const powerUps = {
|
|||||||
return 42;
|
return 42;
|
||||||
},
|
},
|
||||||
effect() {
|
effect() {
|
||||||
if (game.isDraftMode) {
|
function doNotHave(who, skip1 = -1, skip2 = -1) {
|
||||||
function doNotHave(who, skip1 = -1, skip2 = -1) {
|
|
||||||
let options = [];
|
|
||||||
for (let i = 0; i < who.length; i++) {
|
|
||||||
if (!who[i].have && i !== skip1 && i !== skip2) options.push(i);
|
|
||||||
}
|
|
||||||
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
|
|
||||||
}
|
|
||||||
|
|
||||||
let choice1 = doNotHave(b.mods)
|
|
||||||
let choice2 = doNotHave(b.mods, choice1)
|
|
||||||
let choice3 = doNotHave(b.mods, choice1, choice2)
|
|
||||||
if (choice1 > -1) {
|
|
||||||
let text = "<h3 style = 'color:#fff; text-align:center; margin: 0px;'>choose a mod</h3>"
|
|
||||||
text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice1})"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[choice1].name}</div> ${b.mods[choice1].description}</div>`
|
|
||||||
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice2})"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[choice2].name}</div> ${b.mods[choice2].description}</div>`
|
|
||||||
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice3})"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[choice3].name}</div> ${b.mods[choice3].description}</div>`
|
|
||||||
document.getElementById("choose-grid").innerHTML = text
|
|
||||||
powerUps.showDraft();
|
|
||||||
} else {
|
|
||||||
powerUps.giveRandomAmmo()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//find what mods I don't have
|
|
||||||
let options = [];
|
let options = [];
|
||||||
for (let i = 0; i < b.mods.length; i++) {
|
for (let i = 0; i < who.length; i++) {
|
||||||
if (!b.mods[i].have) options.push(i);
|
if (!who[i].have && i !== skip1 && i !== skip2) options.push(i);
|
||||||
}
|
}
|
||||||
|
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
|
||||||
|
}
|
||||||
|
|
||||||
// give a random mod from the mods I don 't have
|
let choice1 = doNotHave(b.mods)
|
||||||
if (options.length > 0) {
|
let choice2 = doNotHave(b.mods, choice1)
|
||||||
let newMod = options[Math.floor(Math.random() * options.length)]
|
let choice3 = doNotHave(b.mods, choice1, choice2)
|
||||||
b.giveMod(newMod)
|
if (choice1 > -1) {
|
||||||
game.replaceTextLog = true;
|
let text = "<h3 style = 'color:#fff; text-align:center; margin: 0px;'>choose a mod</h3>"
|
||||||
game.makeTextLog(`<div class="circle mod"></div> <strong style='font-size:30px;'>${b.mods[newMod].name}</strong><br><br> ${b.mods[newMod].description}`, 1000);
|
text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice1})"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[choice1].name}</div> ${b.mods[choice1].description}</div>`
|
||||||
game.replaceTextLog = false;
|
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice2})"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[choice2].name}</div> ${b.mods[choice2].description}</div>`
|
||||||
}
|
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice3})"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[choice3].name}</div> ${b.mods[choice3].description}</div>`
|
||||||
|
document.getElementById("choose-grid").innerHTML = text
|
||||||
|
powerUps.showDraft();
|
||||||
|
} else {
|
||||||
|
powerUps.giveRandomAmmo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -196,58 +152,27 @@ const powerUps = {
|
|||||||
return 35;
|
return 35;
|
||||||
},
|
},
|
||||||
effect() {
|
effect() {
|
||||||
if (game.isDraftMode) {
|
function doNotHave(who, skip1 = -1, skip2 = -1) {
|
||||||
|
|
||||||
function doNotHave(who, skip1 = -1, skip2 = -1) {
|
|
||||||
let options = [];
|
|
||||||
for (let i = 0; i < who.length; i++) {
|
|
||||||
if (!who[i].have && i !== skip1 && i !== skip2) options.push(i);
|
|
||||||
}
|
|
||||||
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
|
|
||||||
}
|
|
||||||
|
|
||||||
let choice1 = doNotHave(b.guns)
|
|
||||||
let choice2 = doNotHave(b.guns, choice1)
|
|
||||||
let choice3 = doNotHave(b.guns, choice1, choice2)
|
|
||||||
|
|
||||||
if (choice1 > -1) {
|
|
||||||
let text = "<h3 style = 'color:#fff; text-align:center; margin: 0px;'>choose a gun</h3>"
|
|
||||||
text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice1})"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[choice1].name}</div> ${b.guns[choice1].description}</div>`
|
|
||||||
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice2})"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[choice2].name}</div> ${b.guns[choice2].description}</div>`
|
|
||||||
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice3})"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[choice3].name}</div> ${b.guns[choice3].description}</div>`
|
|
||||||
document.getElementById("choose-grid").innerHTML = text
|
|
||||||
powerUps.showDraft();
|
|
||||||
} else {
|
|
||||||
powerUps.giveRandomAmmo()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//find what guns I don't have
|
|
||||||
let options = [];
|
let options = [];
|
||||||
if (b.activeGun === null && game.difficulty < 3) {
|
for (let i = 0; i < who.length; i++) {
|
||||||
//choose the first gun to be one that is good for the early game
|
if (!who[i].have && i !== skip1 && i !== skip2) options.push(i);
|
||||||
for (let i = 0; i < b.guns.length; ++i) {
|
|
||||||
if (!b.guns[i].have && b.guns[i].isStarterGun) options.push(i);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//choose a gun you don't have
|
|
||||||
for (let i = 0; i < b.guns.length; ++i) {
|
|
||||||
if (!b.guns[i].have) options.push(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//give player a gun they don't already have if possible
|
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
|
||||||
game.replaceTextLog = true;
|
}
|
||||||
if (options.length > 0) {
|
|
||||||
let newGun = options[Math.floor(Math.random() * options.length)];
|
let choice1 = doNotHave(b.guns)
|
||||||
if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
|
let choice2 = doNotHave(b.guns, choice1)
|
||||||
b.guns[newGun].have = true;
|
let choice3 = doNotHave(b.guns, choice1, choice2)
|
||||||
b.inventory.push(newGun);
|
|
||||||
b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2;
|
if (choice1 > -1) {
|
||||||
game.makeGunHUD();
|
let text = "<h3 style = 'color:#fff; text-align:center; margin: 0px;'>choose a gun</h3>"
|
||||||
game.makeTextLog(`${game.SVGleftMouse} <strong style='font-size:30px;'>${b.guns[newGun].name}</strong><br><br>${b.guns[newGun].description}`, 900);
|
text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice1})"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[choice1].name}</div> ${b.guns[choice1].description}</div>`
|
||||||
} else {
|
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice2})"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[choice2].name}</div> ${b.guns[choice2].description}</div>`
|
||||||
powerUps.giveRandomAmmo()
|
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice3})"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[choice3].name}</div> ${b.guns[choice3].description}</div>`
|
||||||
}
|
document.getElementById("choose-grid").innerHTML = text
|
||||||
game.replaceTextLog = false
|
powerUps.showDraft();
|
||||||
|
} else {
|
||||||
|
powerUps.giveRandomAmmo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user