Переглянути джерело

Add prerequisites to powerups. Create a template for "free X" powerups. Add free bus

The "free X" powerups now only appear if you have at least one of the item, and also stop appearing once you have 100
tags/v0.0.6
Fen Dweller 6 роки тому
джерело
коміт
83e78b60af
Не вдалося знайти GPG ключ що відповідає даному підпису Ідентифікатор GPG ключа: E80B35A6F11C3656
2 змінених файлів з 39 додано та 18 видалено
  1. +30
    -10
      constants.js
  2. +9
    -8
      gorge.js

+ 30
- 10
constants.js Переглянути файл

@@ -302,7 +302,9 @@ function createTemplateUpgrades() {
createHelperUpgrades();
createClickVictimUpgrades();
createPowerupFreqUpgrades();
createFreeBuildingPowerups();
deepFreeze(upgrades);
deepFreeze(powerups);
}

const prodUpgradeCounts = [1, 5, 10, 25, 50, 75, 100];
@@ -1198,27 +1200,19 @@ const powerups = {
name: "Free Food",
description: "Tasty!",
icon: "fa-drumstick-bite",
prereqs: state => true,
effect: state => state.resources.food += state.currentProductivity.food * 60,
popup: (self, e) => {
clickPopup("GULP!", "gulp", [e.clientX, e.clientY]);
clickPopup("+60 seconds of food", "food", [e.clientX, e.clientY]);
}
},
"free-car": {
name: "Free Car",
description: "It's FREE!",
icon: "fa-car",
effect: state => state.belongings.car.count += 1,
popup: (self, e) => {
clickPopup("CAR!", "gulp", [e.clientX, e.clientY]);
clickPopup("+1 car", "food", [e.clientX, e.clientY]);
}
},
"double": {
name: "Double Dip",
description: "Doubled productivity!",
icon: "fa-cogs",
duration: 10000,
prereqs: state => true,
effect: state => state.currentProductivity.food *= 2,
popup: (self, e) => {
clickPopup("VROOM!", "gulp", [e.clientX, e.clientY]);
@@ -1226,6 +1220,32 @@ const powerups = {
}
}

function createFreeBuildingPowerups() {
const prefix = "free-";
Object.entries(freeBuildingPowerupText).forEach(([building, text]) => {
const key = prefix + building;

powerups[key] = {
name: text.name,
description: text.desc,
icon: buildings[building].icon,
prereqs: state => state.belongings[building].count > 0 && state.belongings[building].count < 100,
effect: state => state.belongings[building].count += 1,
popup: (self, e) => clickPopup("+1 " + buildings[building].name, "food", [e.clientX, e.clientY])
}
});
}

const freeBuildingPowerupText = {
car: {
name: "Free Car",
desc: "It's FREE!"
},
bus: {
name: "Deserted Bus",
desc: "Just kidding. It's full of people."
}
}
deepFreeze(prodUpgradeText);
deepFreeze(prodAllUpgradeText);
deepFreeze(clickUpgradeText);


+ 9
- 8
gorge.js Переглянути файл

@@ -984,8 +984,16 @@ function doPowerup() {

const choices = [];

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

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

const choice = Math.floor(Math.random() * choices.length);
@@ -1015,13 +1023,6 @@ function doPowerup() {
doPowerup();
}, delay);

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

button.addEventListener("mousedown", e => {
if (powerup.duration !== undefined) {
addPowerup(powerup);


Завантаження…
Відмінити
Зберегти