Sfoglia il codice sorgente

Add 10x click powerup

tags/v0.0.7
Fen Dweller 6 anni fa
parent
commit
bf854e7c23
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: E80B35A6F11C3656
2 ha cambiato i file con 33 aggiunte e 30 eliminazioni
  1. +9
    -0
      constants.js
  2. +24
    -30
      gorge.js

+ 9
- 0
constants.js Vedi File

@@ -1225,6 +1225,15 @@ const powerups = {
popup: (self, e) => {
clickPopup("VROOM!", "gulp", [e.clientX, e.clientY]);
}
},
"click": {
name: "Chaos Click",
description: "Ten times the clicking!",
icon: "fa-cursor",
duration: 10000,
prereqs: state => true,
effect: state => state.clickPowers.clickMultiplier *= 10,
popup: (self, e) => clickPopup("CLICK TIME!!", "gulp", [e.clientX, e.clientY])
}
}



+ 24
- 30
gorge.js Vedi File

@@ -15,6 +15,12 @@ let updateRate = 60;
const currentProductivity = {};
const contributions = {};

const clickPowers = {
clickBonus: 0,
clickMultiplier: 1,
clickVictim: "micro"
}

let clickBonus = 0;
let clickVictim = "micro";

@@ -25,6 +31,14 @@ let shiftHeld = false;

let mouseTarget = undefined;

const state = {
ownedUpgrades: ownedUpgrades,
resources: resources,
currentProductivity: currentProductivity,
belongings: belongings,
clickPowers: clickPowers
};

const numberModes = {
words: {
name: "Words",
@@ -82,7 +96,6 @@ function tickPowerups(delta) {
}

function addPowerup(key, powerup) {
console.log(key, powerup)
// powerup already exists
if (activePowerups[key].life > 0) {
activePowerups[key].life += powerup.duration;
@@ -166,7 +179,6 @@ function addCost(cost1, cost2) {
}

function scaleCost(cost, scale) {
if (typeof(scale) != "number") console.log(scale)
return Object.keys(resourceTypes).reduce((o, k) => {o[k] *= scale; return o;}, cost);
}

@@ -204,13 +216,11 @@ function buyBuilding(type, e) {
}

updateProductivity();
updateClickBonus();

}

function updateAll() {
updateProductivity();
updateClickBonus();
updateClickVictim();
updateOptions();
}
@@ -239,21 +249,19 @@ function updateDisplay() {
function updateProductivity() {
Object.assign(currentProductivity, calculateProductivity());


// maybe this should go somewhere else - it also does clicking...
updateClickPowers();

Object.entries(activePowerups).forEach(([key, entry]) => {
if (entry.life > 0) {
const powerup = entry.powerup;

const state = {
ownedUpgrades: ownedUpgrades,
resources: resources,
currentProductivity: currentProductivity,
belongings: belongings
};
powerup.effect(state);
}
});

}

function addResources(delta) {
@@ -407,8 +415,9 @@ function displayUpgrades(owned) {
}
}

function updateClickBonus() {
function updateClickPowers() {
let bonus = 0;
clickPowers.clickMultiplier = 1;

for (let effect of effects["click"]) {
if (ownedUpgrades[effect.parent]) {
@@ -416,13 +425,13 @@ function updateClickBonus() {
}
}

clickBonus = bonus;
clickPowers.clickBonus = bonus;
}

function updateClickVictim() {
for (let effect of effects["click-victim"]) {
if (ownedUpgrades[effect.parent]) {
clickVictim = effect.id;
clickPowers.clickVictim = effect.id;
document.querySelector("#tasty-micro").innerText = "Eat " + buildings[effect.id].name;
}
}
@@ -448,12 +457,11 @@ function buyUpgrade(id, e) {
clickPopup(text, "upgrade", [e.clientX, e.clientY]);

updateProductivity();
updateClickBonus();
updateClickVictim();
}

function eatPrey() {
const add = buildings[clickVictim]["prod"].food * 10 + clickBonus;
const add = clickPowers.clickMultiplier * (buildings[clickPowers.clickVictim]["prod"].food * 10 + clickPowers.clickBonus);
resources.food += add;
return add;
}
@@ -947,13 +955,6 @@ function clickPopup(text, type, location) {
}

function doNews() {
const state = {
ownedUpgrades: ownedUpgrades,
resources: resources,
currentProductivity: currentProductivity,
belongings: belongings
};

let options = [];
news.forEach(entry => {
if (entry.condition(state)) {
@@ -1005,13 +1006,6 @@ function doPowerup() {

const choices = [];

const state = {
ownedUpgrades: ownedUpgrades,
resources: resources,
currentProductivity: currentProductivity,
belongings: belongings
};

Object.entries(powerups).forEach(([key, val]) => {
if (val.prereqs(state))
choices.push(key);


Loading…
Annulla
Salva