From 51a7b3bd770af1e6080a74f0926d2150986b3a76 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 28 Apr 2018 20:41:52 -0400 Subject: [PATCH 01/58] Improved Challenges system --- game.js | 163 ++++++++++++--- js/buildings.js | 33 +-- js/calendar.js | 44 ++-- js/challenges.js | 527 +++++++++++++++++++++++++++++++++++++++++------ js/prestige.js | 24 ++- js/religion.js | 36 +++- js/resources.js | 120 ++++++++--- js/science.js | 23 +-- js/space.js | 20 +- js/time.js | 44 ++-- js/toolbar.js | 6 +- js/village.js | 67 ++++-- res/i18n/en.json | 17 +- 13 files changed, 871 insertions(+), 253 deletions(-) diff --git a/game.js b/game.js index 22b2674bd3..077423e45e 100644 --- a/game.js +++ b/game.js @@ -985,10 +985,11 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { //on a side note, I hate those flags. Could we use gamePage.opts = []/{}; ? karmaKittens: 0, //counter for karmic reincarnation karmaZebras: 0, + karmaZebrasReserve: 0, deadKittens: 0, ironWill: true, //true if player has no kittens or housing buildings - saveVersion: 15, + saveVersion: 16, //FINALLY opts: null, @@ -1129,6 +1130,10 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.timeTab = new classes.tab.TimeTab({name:$I("tab.name.time"), id:"Time"}, this); this.timeTab.visible = false; this.addTab(this.timeTab); + + this.challengesTab = new classes.tab.ChallengesTab({name:$I("tab.name.challenges"), id:"Challenges"}, this); + this.challengesTab.visible = false; + this.addTab(this.challengesTab); this.achievementTab = new com.nuclearunicorn.game.ui.tab.AchTab({name:$I("tab.name.achievements"), id:"Achievements"}, this); this.achievementTab.visible = false; @@ -1282,6 +1287,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.colorScheme = ""; this.karmaKittens = 0; this.karmaZebras = 0; + this.karmaZebrasReserve = 0; this.ironWill = true; this.deadKittens = 0; this.cheatMode = false; @@ -1337,7 +1343,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var saveData = { saveVersion: this.saveVersion, resources: this.resPool.filterMetadata( - this.resPool.resources, ["name", "value", "unlocked", "isHidden"] + this.resPool.resources, ["name", "value", "reserveValue", "unlocked", "isHidden"] ) }; @@ -1358,6 +1364,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { colorScheme: this.colorScheme, karmaKittens: this.karmaKittens, karmaZebras: this.karmaZebras, + karmaZebrasReserve: this.karmaZebrasReserve, ironWill : this.ironWill, deadKittens: this.deadKittens, cheatMode: this.cheatMode, @@ -1483,6 +1490,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.karmaKittens = (data.karmaKittens !== undefined) ? data.karmaKittens : 0; this.karmaZebras = (data.karmaZebras !== undefined) ? data.karmaZebras : 0; + this.karmaZebrasReserve = (data.karmaZebrasReserve !== undefined) ? data.karmaZebrasReserve : 0; this.deadKittens = (data.deadKittens !== undefined) ? data.deadKittens : 0; this.ironWill = (data.ironWill !== undefined) ? data.ironWill : true; this.useWorkers = (data.useWorkers !== undefined) ? data.useWorkers : false; @@ -1512,9 +1520,10 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.statsTab.visible = (this.karmaKittens > 0 || this.science.get("math").researched); this.diplomacyTab.visible = (this.diplomacy.hasUnlockedRaces()); - this.religionTab.visible = (this.resPool.get("faith").value > 0 || this.challenges.currentChallenge == "atheism" && this.bld.get("ziggurat").val > 0); + this.religionTab.visible = (this.resPool.get("faith").value > 0 || this.challenges.getChallenge("atheism").on && this.bld.get("ziggurat").val > 0); this.spaceTab.visible = (this.science.get("rocketry").researched); this.timeTab.visible = (this.science.get("calendar").researched || this.time.getVSU("usedCryochambers").val > 0); + this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched; this.ui.load(); @@ -1951,6 +1960,40 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { save.saveVersion = 15; } + + if (save.saveVersion == 15) { + if (save.challenges && save.challenges.challenges) { + for (var i = 0; i < save.challenges.challenges.length; i++) { + if (save.challenges.challenges[i].name == save.challenges.currentChallenge) { + save.challenges.challenges[i].on = 1; + save.challenges.challenges[i].rewardable = true; + } + + save.challenges.challenges[i].researched = save.challenges.challenges[i].researched ? 1 : 0; + } + + if (save.challenges.currentChallenge) { + save.challenges.conditions = []; + var chrono = {}; + chrono.name = "disableChrono"; + chrono.on = 1; + chrono.rewardable = true; + chrono.resets = 0; + save.challenges.conditions.push(chrono); + } + } + + if (save.resources) { + for (var i = 0; i < save.resources.length; i++) + { + // Give the benefit of the doubt + save.resources[i].reserveValue = save.resources[i].value; + save.resources[i].value = 0; + } + } + + save.saveVersion = 16; + } return save; @@ -2044,8 +2087,24 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (!season){ var season = this.calendar.getCurSeason(); } - var weatherMod = this.calendar.getWeatherMod(); - weatherMod = (season.modifiers[res.name] + weatherMod); + if (this.challenges.getChallenge("winterIsComing").on) + { + var weatherMod = (this.challenges.getChallengePenalty("winterIsComing"), (this.calendar.weather || "normal") + "Mod"); + } + else + { + var reward = 1; + if (this.calendar.weather == "warm") + { + reward = this.challenges.getChallengeReward("winterIsComing"); + } + if (this.calendar.weather == "cold") + { + reward = 1 / this.challenges.getChallengeReward("winterIsComing"); + } + var weatherMod = this.calendar.getWeatherMod(); + weatherMod = Math.floor((((season.modifiers[res.name] - 1) * reward + 1) + weatherMod) * 100) / 100; + } if (weatherMod < -0.95){ weatherMod = -0.95; } @@ -2086,7 +2145,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { // *PARAGON BONUS var paragonProductionRatio = this.prestige.getParagonProductionRatio(); - if (resName == "catnip" && this.challenges.currentChallenge == "winterIsComing") { + if (resName == "catnip" && this.challenges.getChallenge("winterIsComing").on) { paragonProductionRatio = 0; //winter has come } @@ -2124,7 +2183,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } // +*FAITH BONUS - perTick *= 1 + (this.religion.getProductionBonus() / 100); + perTick *= 1 + (this.religion.getProductionBonus() / 100 * (resName == "faith" ? this.challenges.getChallengeReward("atheism") : 1)); //+COSMIC RADIATION if (!this.opts.disableCMBR && res.name != "coal") { @@ -2162,7 +2221,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { resConsumption *= 1 + this.getEffect(res.name + "DemandRatio"); if (res.name == "catnip" && this.village.sim.kittens.length > 0 && this.village.happiness > 1) { var hapinnessConsumption = Math.max(this.village.happiness - 1, 0); - if (this.challenges.currentChallenge == "anarchy") { + if (this.challenges.getChallenge("anarchy").on) { resConsumption += resConsumption * hapinnessConsumption * (1 + this.getEffect(res.name + "DemandWorkerRatioGlobal")); } else { resConsumption += resConsumption * hapinnessConsumption * (1 + this.getEffect(res.name + "DemandWorkerRatioGlobal")) * (1 - this.village.getFreeKittens() / this.village.sim.kittens.length); @@ -2233,8 +2292,24 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (!season){ var season = this.calendar.getCurSeason(); } - var weatherMod = this.calendar.getWeatherMod(); - weatherMod = (season.modifiers[res.name] + weatherMod); + if (this.challenges.getChallenge("winterIsComing").on) + { + var weatherMod = (this.challenges.getChallengePenalty("winterIsComing"), (this.calendar.weather || "normal") + "Mod"); + } + else + { + var reward = 1; + if (this.calendar.weather == "warm") + { + reward = this.challenges.getChallengeReward("winterIsComing"); + } + if (this.calendar.weather == "cold") + { + reward = 1 / this.challenges.getChallengeReward("winterIsComing"); + } + var weatherMod = this.calendar.getWeatherMod(); + weatherMod = Math.floor((((season.modifiers[res.name] - 1) * reward + 1) + weatherMod) * 100) / 100; + } if (weatherMod < -0.95){ weatherMod = -0.95; } @@ -2303,7 +2378,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { // *PARAGON BONUS var paragonProductionRatio = this.prestige.getParagonProductionRatio(); - if (resName == "catnip" && this.challenges.currentChallenge == "winterIsComing") { + if (resName == "catnip" && this.challenges.getChallenge("winterIsComing").on) { paragonProductionRatio = 0; //winter has come } @@ -2469,7 +2544,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { resConsumption *= 1 + this.getEffect(res.name + "DemandRatio"); if (res.name == "catnip" && this.village.sim.kittens.length > 0 && this.village.happiness > 1) { var hapinnessConsumption = Math.max(this.village.happiness - 1, 0); - if (this.challenges.currentChallenge == "anarchy") { + if (this.challenges.getChallenge("anarchy").on) { resConsumption += resConsumption * hapinnessConsumption * (1 + this.getEffect(res.name + "DemandWorkerRatioGlobal")); } else { resConsumption += resConsumption * hapinnessConsumption * (1 + this.getEffect(res.name + "DemandWorkerRatioGlobal")) * (1 - this.village.getFreeKittens() / this.village.sim.kittens.length); @@ -2596,6 +2671,14 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { */ updateModel: function(){ + if (!this.challenges.getCondition("disableMisc").on) + { + this.karmaZebras += this.karmaZebrasReserve; + this.karmaZebrasReserve = 0; + this.resPool.get("zebras").maxValue = this.karmaZebras ? this.karmaZebras + 1 : 0; + this.resPool.get("zebras").value += this.resPool.get("zebras").reserveValue; + this.resPool.get("zebras").reserveValue = 0; + } this.resPool.update(); this.bld.update(); @@ -2614,6 +2697,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.religion.update(); this.space.update(); this.challenges.update(); + this.prestige.update(); /*for (i in this.managers){ if (this.managers[i].update){ @@ -3106,9 +3190,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (!confirmed) { return; } - if (game.challenges.currentChallenge == "atheism" && game.time.getVSU("cryochambers").on > 0) { - game.challenges.getChallenge("atheism").researched = true; - + if (game.challenges.getChallenge("atheism").on && game.time.getVSU("cryochambers").on > 0) { if (game.ironWill){ game.achievements.unlockHat("ivoryTowerHat"); } @@ -3117,7 +3199,6 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { game.achievements.unlockHat("fezHat"); } - game.challenges.currentChallenge = null; game.resetAutomatic(); }); }, @@ -3225,7 +3306,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var paragonPoints = 0; if (kittens > 70){ - paragonPoints = (kittens - 70); + paragonPoints = (kittens - 70) * (1 + this.resPool.get("apotheosis").value / 10); } var addRes = { @@ -3341,7 +3422,12 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (value > 0){ var newRes = this.resPool.createResource(res.name); - newRes.value = value; + if (res.maxValue || (this.challenges.getCondition("disableChrono").on && !res.persists)) { + newRes.reserveValue = (this.challenges.getCondition("disableChrono").on ? res.reserveValue : 0) + value; + } + else { + newRes.value = value; + } newResources.push(newRes); } } @@ -3364,15 +3450,39 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } } - if (newKittens.length > 0) { - var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on"]); + if (this.challenges.getCondition("disableChrono").on) + { + for (var i = 0; i < this.village.sim.reserveKittens.length; i++) + { + newKittens.push(this.village.sim.reserveKittens[i]); + } + } + + if (!this.challenges.getCondition("disableChrono").on) { + var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on", "reserve"]); usedCryochambers_reset[0]["val"] = newKittens.length; usedCryochambers_reset[0]["on"] = newKittens.length; + usedCryochambers_reset[0]["reserve"] = 0; } else { - var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on"]); + var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on", "reserve"]); usedCryochambers_reset[0]["val"] = 0; usedCryochambers_reset[0]["on"] = 0; + usedCryochambers_reset[0]["reserve"] += newKittens.length; + } + + for (var i = 0; i < this.challenges.challenges.length; i++) { + if (this.challenges.challenges[i].on && this.challenges.getCondition("disableChrono").on) { + this.challenges.challenges[i].rewardable = true; + } } + + for (var i = 0; i < this.challenges.conditions.length; i++) { + if (this.challenges.conditions[i].on) { + this.challenges.conditions[i].rewardable = true; + this.challenges.conditions[i].resets += 1; + } + } + var saveData = { saveVersion: this.saveVersion, @@ -3381,7 +3491,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { buildings: [], challenges: { challenges: this.challenges.challenges, - currentChallenge: this.challenges.currentChallenge + conditions: this.challenges.conditions }, diplomacy: { races: [] @@ -3410,7 +3520,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { timestamp: Date.now() }, village :{ - kittens: newKittens, + kittens: this.challenges.getCondition("disableChrono").on ? [] : newKittens, + reserveKittens: this.challenges.getCondition("disableChrono").on ? newKittens : [], jobs: [] }, achievements: lsData.achievements, @@ -3418,7 +3529,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { statsCurrent: statsCurrent }; - if (anachronomancy.researched){ + if (anachronomancy.researched && !this.challenges.getCondition("disableChrono").on){ saveData.science.techs.push(this.science.get("chronophysics")); } LCstorage["com.nuclearunicorn.kittengame.savedata"] = JSON.stringify(saveData); @@ -3466,6 +3577,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { return this.statsTab; case "time": return this.timeTab; + case "challenges": + return this.challengesTab; } }, @@ -3543,7 +3656,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { newUnlock.unlockable = true; } else if (type == "stages") { newUnlock.stages[unlockId.stage].stageUnlocked = true; - } else if (type == "jobs" && unlockId == "priest" && this.challenges.currentChallenge == "atheism") { + } else if (type == "jobs" && unlockId == "priest" && this.challenges.getChallenge("atheism").on) { // do nothing } else { if (!newUnlock){ diff --git a/js/buildings.js b/js/buildings.js index ba7b254cec..6b0d55633e 100644 --- a/js/buildings.js +++ b/js/buildings.js @@ -179,8 +179,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan //probably not the best place to handle this mechanics //----------- move to separate part? ----------- - if ((effectName == "productionRatio" || effectName == "magnetoRatio") - && (game.resPool.energyCons > game.resPool.energyProd)){ + if (effectName == "productionRatio" || effectName == "magnetoRatio"){ effect *= game.resPool.getEnergyDelta(); } @@ -356,9 +355,9 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }; effects.energyProduction *= 1 + game.getEffect("solarFarmRatio"); if (game.calendar.season == 3) { - effects.energyProduction *= 0.75; + effects.energyProduction *= (1 - (0.25 / this.game.challenges.getChallengeReward("winterIsComing"))); } else if (game.calendar.season == 1) { - effects.energyProduction /= 0.75; + effects.energyProduction /= (1 - (0.25 / this.game.challenges.getChallengeReward("winterIsComing"))); } stageMeta.effects = effects; } @@ -576,9 +575,6 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan var energyCons = 0; if (game.workshop.get("biofuel").researched){ energyCons = 1; - if (game.challenges.currentChallenge == "energy") { - energyCons *= 2; - } self.togglable = true; } self.effects["energyConsumption"] = energyCons; @@ -878,9 +874,6 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }, calculateEffects: function(self, game) { self.effects["energyConsumption"] = 1; - if (game.challenges.currentChallenge == "energy") { - self.effects["energyConsumption"] *= 2; - } }, lackResConvert: false, action: function(self, game){ @@ -1136,9 +1129,6 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan if (game.workshop.get("pumpjack").researched){ effects["energyConsumption"] = 1; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } self.togglable = true; } @@ -1189,9 +1179,6 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan } effects["energyConsumption"] = 2; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } if (game.workshop.get("neuralNetworks").researched){ } @@ -1267,9 +1254,6 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }, calculateEffects: function(self, game){ self.effects["energyConsumption"] = 2; - if (game.challenges.currentChallenge == "energy") { - self.effects["energyConsumption"] *= 2; - } self.effects["scienceMax"] = 0; if (game.workshop.get("lhc").researched){ @@ -1474,7 +1458,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan "cultureMax" : 0 }, calculateEffects: function(self, game) { - if (game.challenges.currentChallenge != "atheism") { + if (!game.challenges.getChallenge("atheism")) { var effects = { "culturePerTickBase" : 0.05, "faithPerTickBase" : 0.005, @@ -1510,7 +1494,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan "faithMax": 0 }, calculateEffects: function(self, game){ - if (game.challenges.currentChallenge != "atheism") { + if (!game.challenges.getChallenge("atheism").on) { var effects = { "culturePerTickBase" : 0.1, "faithPerTickBase" : 0, @@ -1627,9 +1611,6 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }, calculateEffects: function(self, game) { self.effects["energyConsumption"] = 20; - if (game.challenges.currentChallenge == "energy") { - self.effects["energyConsumption"] *= 2; - } self.effects["temporalFluxProduction"] = game.getEffect("temporalFluxProductionChronosphere"); } },{ @@ -1652,10 +1633,6 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan action: function(self, game){ self.effects["energyConsumption"] = 2 * ( 1 + 0.75 * self.on); - if (game.challenges.currentChallenge == "energy") { - self.effects["energyConsumption"] *= 2; - } - var gflops = game.resPool.get("gflops"); gflops.value += self.effects["gflopsPerTickBase"] * self.on; diff --git a/js/calendar.js b/js/calendar.js index 0c4f581001..c4f0f705e3 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -378,7 +378,7 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { if (this.season >= this.seasons.length) { this.season = 0; - if (!(this.game.challenges.currentChallenge == "1000Years" && this.year >= 500)) { + if (!(this.game.challenges.getChallenge("1000Years").on && this.year >= 500)) { this.year += 1; } newyear = true; @@ -740,7 +740,7 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { //==================== other calendar stuff ======================== //cap years skipped in 1000 years - if (this.game.challenges.currentChallenge == "1000Years" && this.year + yearsOffset > 500){ + if (this.game.challenges.getChallenge("1000Years").on && this.year + yearsOffset > 500){ yearsOffset = Math.max(500 - this.year, 0); } @@ -759,16 +759,34 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { onNewSeason: function(){ this.eventChance = 0; - if (this.game.rand(100) < 35 && this.year > 3){ - var warmChance = 50; - if (this.game.challenges.getChallenge("winterIsComing").researched){ - warmChance += 15; + if (this.year > 3){ + if (this.game.challenges.getChallenge("winterIsComing").on) + { + var warmChance = this.game.challenges.getChallengePenalty("winterIsComing", "warmRate"); + var coldChance = this.game.challenges.getChallengePenalty("winterIsComing", "coldRate"); + } + else + { + var warmChance = 175; + var coldChance = 175; + if (this.season == 3 && this.game.challenges.getChallenge("winterIsComing").researched && !this.game.challenges.getCondition("disableRewards").on){ + coldChance = 0; + } } - if (this.game.rand(100) < warmChance){ - this.weather = "warm"; - } else { - this.weather = "cold"; + var rand = this.game.rand(1000); + + if (rand < warmChance) + { + this.weather = "warm" + } + else if (rand < warmChance + coldChance) + { + this.weather = "cold" + } + else + { + this.weather = null; } }else{ this.weather = null; @@ -917,7 +935,7 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { }, getCurSeason: function(){ - if (this.game.challenges.currentChallenge == "winterIsComing"){ + if (this.game.challenges.getChallenge("winterIsComing").on){ return this.seasons[3]; //eternal winter } return this.seasons[this.season]; @@ -925,7 +943,7 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { getCurSeasonTitle: function(){ var title = this.getCurSeason().title; - if (this.game.challenges.currentChallenge == "winterIsComing"){ + if (this.game.challenges.getChallenge("winterIsComing").on){ var numeral = ''; switch(this.season){ case 0: @@ -948,7 +966,7 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { getCurSeasonTitleShorten: function(){ var title = this.getCurSeason().shortTitle; - if (this.game.challenges.currentChallenge == "winterIsComing"){ + if (this.game.challenges.getChallenge("winterIsComing").on){ var numeral = ''; switch(this.season){ case 0: diff --git a/js/challenges.js b/js/challenges.js index c21186c04d..0effb952c0 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -6,67 +6,165 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa this.setEffectsCachedExisting(); }, - currentChallenge: null, - challenges:[ { name: "ironWill", label: $I("challendge.ironWill.label"), description: $I("challendge.ironWill.desc"), effectDesc: $I("challendge.ironWill.effect.desc"), - researched: false, - unlocked: true + researched: 0, + unlocked: true, + togglableOnOff: true, + val: 1 },{ name: "winterIsComing", label: $I("challendge.winterIsComing.label"), description: $I("challendge.winterIsComing.desc"), effectDesc: $I("challendge.winterIsComing.effect.desc"), - researched: false, - unlocked: true + difficulty: 1, + researched: 0, + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + rewarded: false },{ name: "anarchy", label: $I("challendge.anarchy.label"), description: $I("challendge.anarchy.desc"), effectDesc: $I("challendge.anarchy.effect.desc"), - researched: false, - unlocked: true + difficulty: 5, + researched: 0, + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + rewarded: false },{ name: "energy", label: $I("challendge.energy.label"), description: $I("challendge.energy.desc"), effectDesc: $I("challendge.energy.effect.desc"), - researched: false, - unlocked: false + difficulty: 10, + researched: 0, + unlocked: false, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + rewarded: false },{ name: "atheism", label: $I("challendge.atheism.label"), description: $I("challendge.atheism.desc"), effectDesc: $I("challendge.atheism.effect.desc"), - researched: false, - unlocked: false + difficulty: 15, + researched: 0, + unlocked: false, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + rewarded: false },{ name: "1000Years", label: $I("challendge.1000Years.label"), description: $I("challendge.1000Years.desc"), effectDesc: $I("challendge.1000Years.effect.desc"), - researched: false, - unlocked: false + difficulty: 3, + researched: 0, + unlocked: false, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + rewarded: false + }], + + conditions:[ + { + name: "disableChrono", + label: $I("challendge.condition.disableChrono.label"), + description: $I("challendge.condition.disableChrono.desc"), + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + resets: 0 + },{ + name: "disableMetaResources", + label: $I("challendge.condition.disableMetaResources.label"), + description: $I("challendge.condition.disableMetaResources.desc"), + bonus: 5, + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + resets: 0 + },{ + name: "disableMetaTechs", + label: $I("challendge.condition.disableMetaTechs.label"), + description: $I("challendge.condition.disableMetaTechs.desc"), + bonus: 10, + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + resets: 0 + },{ + name: "disableApo", + label: $I("challendge.condition.disableApo.label"), + description: $I("challendge.condition.disableApo.desc"), + bonus: 20, + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + resets: 0 + },{ + name: "disableRewards", + label: $I("challendge.condition.disableRewards.label"), + description: $I("challendge.condition.disableRewards.desc"), + bonus: 3, + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + resets: 0 + },{ + name: "disableMisc", + label: $I("challendge.condition.disableMisc.label"), + description: $I("challendge.condition.disableMisc.desc"), + unlocked: true, + togglableOnOff: true, + val: 1, + on: 0, + rewardable: false, + resets: 0 }], game: null, + rewarded: false, resetState: function(){ for (var i = 0; i < this.challenges.length; i++){ var challenge = this.challenges[i]; challenge.enabled = false; } - this.currentChallenge = null; }, save: function(saveData){ saveData.challenges = { - challenges: this.filterMetadata(this.challenges, ["name", "researched", "unlocked"]), - currentChallenge: this.currentChallenge + rewarded: this.rewarded, + challenges: this.filterMetadata(this.challenges, ["name", "researched", "unlocked", "on", "rewardable", "rewarded"]), + conditions: this.filterMetadata(this.conditions, ["name", "on", "rewardable", "resets"]) }; }, @@ -77,10 +175,13 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa var self = this; - this.loadMetadata(this.challenges, saveData.challenges.challenges); + this.rewarded = saveData.challenges.rewarded; - if (saveData.challenges.currentChallenge){ - this.currentChallenge = saveData.challenges.currentChallenge; + this.loadMetadata(this.challenges, saveData.challenges.challenges); + + if (saveData.challenges.conditions) + { + this.loadMetadata(this.conditions, saveData.challenges.conditions); } }, @@ -90,7 +191,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa if (this.game.resPool.energyProd != 0 || this.game.resPool.energyCons != 0) { this.getChallenge("energy").unlocked = true; } - } else if (this.currentChallenge == "energy") { + } else if (this.getChallenge("energy").on) { if ( (this.game.bld.get("pasture").val > 0 && this.game.bld.get("pasture").stage == 1) && (this.game.bld.get("aqueduct").val > 0 && this.game.bld.get("aqueduct").stage == 1) && @@ -104,18 +205,59 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa ) { this.researchChallenge("energy"); } - } else if (this.currentChallenge == "anarchy") { + } + + if (this.getChallenge("anarchy").on) { if (this.game.bld.get("aiCore").val > 0){ this.researchChallenge("anarchy"); } } // winterIsComing - if (this.currentChallenge == "winterIsComing") { + if (this.getChallenge("winterIsComing").on) { if (this.game.space.getPlanet("helios").reached){ this.researchChallenge("winterIsComing"); } } + + if (this.getChallenge("atheism").on && this.game.time.getVSU("cryochambers").on > 0) { + this.researchChallenge("atheism"); + } + + if (game.challenges.getChallenge("1000Years").on && this.game.calendar.year >= 1000) { + game.challenges.researchChallenge("1000Years"); + } + + var noChallenge = true; + + for (var i = 0; i < this.challenges.length; i++) { + if (this.challenges[i].on) { + noChallenge = false; + } + } + + if (noChallenge && this.getCondition("disableChrono").on && this.game.space.getPlanet("moon").unlocked) + { + this.researchChallenge(); + } + + for (var i = 0; i < this.challenges.length; i++) { + if (!this.challenges[i].on || !this.getCondition("disableChrono").on) { + this.challenges[i].rewardable = false; + } + } + + for (var i = 0; i < this.conditions.length; i++) { + if (!this.conditions[i].on) { + this.conditions[i].rewardable = false; + this.conditions[i].resets = 0; + + if (this.conditions[i].name == "disableMetaResources") + { + this.getCondition("disableMetaTechs").resets = 0; + } + } + } }, @@ -123,12 +265,148 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa getChallenge: function(name){ return this.getMeta(name, this.challenges); }, + + getCondition: function(name){ + return this.getMeta(name, this.conditions); + }, researchChallenge: function(challenge) { - if (challenge == this.currentChallenge){ - this.getChallenge(challenge).researched = true; - this.currentChallenge = null; - this.game.msg($I("challendge.btn.log.message.on.complete", [this.getChallenge(challenge).label])); + var apotheosis = 0; + if (challenge){ + if (this.getChallenge(challenge).rewardable && !this.getChallenge(challenge).rewarded){ + this.getChallenge(challenge).researched += 1; + this.getChallenge(challenge).rewarded = true; + this.game.msg($I("challendge.btn.log.message.on.complete", [this.getChallenge(challenge).label])); + + if (challenge == "winterIsComing"){ + this.game.resPool.get("void").reserveValue += 1000; + } + + if (challenge == "anarchy"){ + this.game.resPool.get("relic").reserveValue += 10000; + } + + if (challenge == "energy"){ + this.game.resPool.get("antimatter").reserveValue += 5000; + } + + if (challenge == "atheism"){ + this.game.resPool.get("faith").reserveValue += 1000000; + } + + if (challenge == "1000Years"){ + this.game.resPool.get("timeCrystal").reserveValue += 20000; + } + + var challengeTotal = 0; + var challengeNumber = 0; + for (var i = 0; i < this.challenges.length; i++) { + if (this.challenges[i].rewardable) { + challengeNumber += 1; + challengeTotal += Math.pow(this.challenges[i].difficulty, 2) + } + } + + apotheosis += Math.sqrt(challengeTotal) / challengeNumber; + } + } + + if (!this.rewarded) + { + apotheosis += 1; + this.rewarded = true; + } + var conditionTotal = 0; + for (var i = 0; i < this.conditions.length; i++) { + if (this.conditions[i].on && this.conditions[i].bonus) { + conditionTotal += Math.pow(this.conditions[i].bonus, 2); + } + } + + apotheosis *= Math.sqrt(conditionTotal); + + if (apotheosis) + { + this.game.resPool.addRes("apotheosis", Math.floor(apotheosis), true); + } + }, + + getChallengePenalty: function(name, type){ + var researched = this.getChallenge(name).researched; + var on = this.getChallenge(name).on; + + if (name == "winterIsComing") + { + if (type == "warmRate") + { + return Math.floor(175 - this.game.getHyperbolicEffect(researched * 10, 175)); + } + else if (type == "coldRate") + { + return Math.ceil(175 + this.game.getHyperbolicEffect(researched * 50, 825)); + } + else if (type == "warmMod") + { + return (1 - Math.ceil(60 + this.game.getHyperbolicEffect(researched, 40)) / 100); + } + else if (type == "normalMod") + { + return (1 - Math.ceil(75 + this.game.getHyperbolicEffect(researched, 25)) / 100); + } + else if (type == "coldMod") + { + return (1 - Math.ceil(90 + this.game.getHyperbolicEffect(researched, 10)) / 100); + } + } + else if (name == "anarchy") + { + return (Math.floor(50 + this.game.getHyperbolicEffect(researched * 5, 50)) / 100); + } + else if (!on) + { + return 1; + } + else if (name == "energy") + { + return (2 + researched * 0.1); + } + else if (name == "atheism") + { + return (1 + researched * 0.2); + } + else if (name == "1000Years") + { + return (1 + researched * 0.5); + } + }, + + getChallengeReward: function(name, type){ + if (this.getChallenge(name).on || this.getCondition("disableRewards").on) + { + return 1; + } + + var researched = this.getChallenge(name).researched; + + if (name == "winterIsComing") + { + return 1 + this.game.getHyperbolicEffect(researched * 0.1, 1); + } + else if (name == "anarchy") + { + return 1 + this.game.getHyperbolicEffect(researched * 0.5, 4); + } + else if (name == "energy") + { + return 1 + this.game.getHyperbolicEffect(researched * 0.1, 1); + } + else if (name == "atheism") + { + return 1 + this.game.getHyperbolicEffect(researched * 0.25, 5); + } + else if (name == "1000Years") + { + return 1 - this.game.getHyperbolicEffect(researched * 0.1, 1); } } }); @@ -154,10 +432,8 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui getName: function(model){ var meta = model.metadata; - if (meta.name == this.game.challenges.currentChallenge) { - return $I("challendge.btn.name.current", [meta.label]); - } else if (meta.researched){ - return $I("challendge.btn.name.complete", [meta.label]); + if (meta.researched){ + return meta.label + "(" + meta.researched + ")"; } else { return meta.label; } @@ -172,40 +448,133 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui }, buyItem: function(model, event, callback) { - if (model.metadata.name != this.game.challenges.currentChallenge && (model.enabled || this.game.devMode)) { - //if (confirm("Are you sure you want to start this challenge by resetting the game ?")) { - this.game.ui.confirm($I("challendge.btn.confirmation.dlg.title"), $I("challendge.btn.confirmation.dlg.text"), function (confirmed) { - if (!confirmed) { - callback(false); - return; - } + } +}); - // Set the challenge for after reset - if (model.metadata.name == "ironWill") { - this.game.challenges.currentChallenge = null; - } else { - this.game.challenges.currentChallenge = model.metadata.name; - } - // Reset with any benefit of chronosphere (ressource, kittens, etc...) - this.game.bld.get("chronosphere").val = 0; - this.game.bld.get("chronosphere").on = 0; - this.game.time.getVSU("cryochambers").val = 0; - this.game.time.getVSU("cryochambers").on = 0; - this.game.resetAutomatic(); - callback(true); - }); - } else { - callback(false); - return; - } +dojo.declare("classes.ui.ConditionBtnController", com.nuclearunicorn.game.ui.BuildingBtnController, { + + getMetadata: function(model){ + if (!model.metaCached){ + model.metaCached = this.game.challenges.getCondition(model.options.id); + } + return model.metaCached; + }, + + getDescription: function(model) { + return model.metadata.description; + }, + + getName: function(model){ + return model.metadata.label; + }, + + updateVisible: function(model){ + model.visible = model.metadata.unlocked; + }, + + getPrices: function(model) { + return $.extend(true, [], model.metadata.prices); // Create a new array to keep original values }, - updateEnabled: function(model){ + buyItem: function(model, event, callback) { + }, + + handleTogglableOnOffClick: function(model) { + var on = model.metadata.on; + this.inherited(arguments); - if (model.metadata.researched){ - model.enabled = false; + + if (!on && model.metadata.on) + { + if (model.metadata.name == "disableMetaResources") + { + var metaRes = ["karma", "paragon", "burnedParagon", "apotheosis"] + for (var i = 0; i < metaRes.length; i++) + { + var res = this.game.resPool.get(metaRes[i]); + res.reserveValue = res.value; + res.value = 0; + } + + if (this.game.challenges.getCondition("disableMetaTechs").on) + { + for (var i = 0; i < this.game.prestige.perks.length; i++) + { + var perk = this.game.prestige.perks[i]; + + if (perk.defaultUnlocked) + { + perk.unlocked = true; + } + } + } + } + + if (model.metadata.name == "disableMetaTechs") + { + for (var i = 0; i < this.game.prestige.perks.length; i++) + { + var perk = this.game.prestige.perks[i]; + perk.reserve = perk.researched; + perk.unlocked = false; + perk.researched = false; + + if (this.game.challenges.getCondition("disableMetaResources").on && perk.defaultUnlocked) + { + perk.unlocked = true; + } + } + } + + if (model.metadata.name == "disableApo") + { + this.game.religion.faithRatioReserve = this.game.religion.faithRatio; + this.game.religion.faithRatio = 0; + this.game.religion.tcratioReserve = this.game.religion.tcratio; + this.game.religion.tcratio = 0; + this.game.religion.tclevel = this.game.religion.getTranscendenceLevel(); + + for (var i = 0; i < this.game.religion.transcendenceUpgrades.length; i++) + { + this.game.religion.transcendenceUpgrades[i].reserve += this.game.religion.transcendenceUpgrades[i].val; + this.game.religion.transcendenceUpgrades[i].val = 0; + this.game.religion.transcendenceUpgrades[i].on = 0; + } + } + + if (model.metadata.name == "disableMisc") + { + var bls = this.game.resPool.get("sorrow"); + bls.reserveValue = bls.value; + bls.value = 0; + + this.game.karmaZebrasReserve = this.game.karmaZebras; + this.game.karmaZebras = 0; + this.game.resPool.get("zebras").maxValue = 0; + this.game.resPool.get("zebras").reserveValue = this.game.resPool.get("zebras").value; + this.game.resPool.get("zebras").value = 0; + } } - } + + if (on && !model.metadata.on) + { + if (model.metadata.name == "disableMetaResources") + { + if (this.game.challenges.getCondition("disableMetaTechs").on) + { + for (var i = 0; i < this.game.prestige.perks.length; i++) + { + var perk = this.game.prestige.perks[i]; + + if (perk.defaultUnlocked) + { + perk.unlocked = false; + } + } + } + } + } + }, }); dojo.declare("classes.ui.ChallengePanel", com.nuclearunicorn.game.ui.Panel, { @@ -228,3 +597,41 @@ dojo.declare("classes.ui.ChallengePanel", com.nuclearunicorn.game.ui.Panel, { } }); + +dojo.declare("classes.ui.ConditionPanel", com.nuclearunicorn.game.ui.Panel, { + + game: null, + + constructor: function(){ + }, + + render: function(container){ + var content = this.inherited(arguments); + var self = this; + var controller = new classes.ui.ConditionBtnController(self.game); + dojo.forEach(this.game.challenges.conditions, function(condition, i){ + var button = new com.nuclearunicorn.game.ui.BuildingBtn({id: condition.name, controller: controller}, self.game); + button.render(content); + self.addChild(button); + }); + + } + +}); + +dojo.declare("classes.tab.ChallengesTab", com.nuclearunicorn.game.ui.tab, { + render: function(container){ + this.challengesPanel = new classes.ui.ChallengePanel($I("challendge.panel.label"), this.game.challenges); + this.challengesPanel.game = this.game; + this.challengesPanel.render(container); + + this.conditionsPanel = new classes.ui.ConditionPanel($I("challendge.condition.panel.label"), this.game.challenges); + this.conditionsPanel.game = this.game; + this.conditionsPanel.render(container); + }, + + update: function(){ + this.challengesPanel.update(); + this.conditionsPanel.update(); + } +}); diff --git a/js/prestige.js b/js/prestige.js index 419754a7a6..ec747b0615 100644 --- a/js/prestige.js +++ b/js/prestige.js @@ -429,7 +429,7 @@ dojo.declare("classes.managers.PrestigeManager", com.nuclearunicorn.core.TabMana save: function(saveData){ saveData.prestige = { - perks: this.filterMetadata(this.perks, ["name", "unlocked", "researched"]) + perks: this.filterMetadata(this.perks, ["name", "unlocked", "researched", "reserve"]) }; }, @@ -451,7 +451,27 @@ dojo.declare("classes.managers.PrestigeManager", com.nuclearunicorn.core.TabMana }, update: function(){ - + if (!this.game.challenges.getCondition("disableMetaTechs").on) + { + for (var i = 0; i < this.perks.length; i++) + { + if (this.perks[i].reserve) + { + if (this.perks[i].researched) + { + for (var j = 0; j < this.perks[i].prices.length; j++) + { + this.game.resPool.addResEvent(this.perks[i].prices[j].name, this.perks[i].prices[j].val); + } + } + + this.perks[i].unlocked = true; + this.perks[i].researched = true; + this.game.unlock(this.perks[i].unlocks); + this.perks[i].reserve = false; + } + } + } }, getPerk: function(name){ diff --git a/js/religion.js b/js/religion.js index d9fefa0f1d..719a41c85f 100644 --- a/js/religion.js +++ b/js/religion.js @@ -9,6 +9,8 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana faithRatio : 0, tcratio: 0, corruption: 0, + faithRatioReserve: 0, + tcratioReserve: 0, alicornCounter: 0, @@ -25,6 +27,8 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana this.corruption = 0; this.faithRatio = 0; this.tcratio = 0; + this.faithRatioReserve = 0; + this.tcratioReserve = 0; for (var i = 0; i < this.zigguratUpgrades.length; i++){ var zu = this.zigguratUpgrades[i]; @@ -50,9 +54,11 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana corruption: this.corruption, faithRatio: this.faithRatio, tcratio: this.tcratio, + faithRatioReserve: this.faithRatioReserve, + tcratioReserve: this.tcratioReserve, zu: this.filterMetadata(this.zigguratUpgrades, ["name", "val", "on", "unlocked"]), ru: this.filterMetadata(this.religionUpgrades, ["name", "val", "on"]), - tu: this.filterMetadata(this.transcendenceUpgrades, ["name", "val", "on", "unlocked"]) + tu: this.filterMetadata(this.transcendenceUpgrades, ["name", "val", "on", "unlocked", "reserve"]), }; }, @@ -65,6 +71,8 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana this.corruption = saveData.religion.corruption || 0; this.faithRatio = saveData.religion.faithRatio || 0; this.tcratio = saveData.religion.tcratio || 0; + this.faithRatioReserve = saveData.religion.faithRatioReserve || 0; + this.tcratioReserve = saveData.religion.tcratioReserve || 0; this.loadMetadata(this.zigguratUpgrades, saveData.religion.zu); this.loadMetadata(this.religionUpgrades, saveData.religion.ru); this.loadMetadata(this.transcendenceUpgrades, saveData.religion.tu); @@ -80,7 +88,23 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana }, update: function(){ - if (this.game.resPool.get("faith").value > 0 || this.game.challenges.currentChallenge == "atheism" && this.game.bld.get("ziggurat").val > 0){ + if (!this.game.challenges.getCondition("disableApo").on) + { + this.faithRatio += this.faithRatioReserve; + this.faithRatioReserve = 0; + this.tcratio += this.tcratioReserve; + this.tcratioReserve = 0; + this.tclevel = this.getTranscendenceLevel(); + + for (var i = 0; i < this.transcendenceUpgrades.length; i++) + { + this.transcendenceUpgrades[i].val += this.transcendenceUpgrades[i].reserve; + this.transcendenceUpgrades[i].on += this.transcendenceUpgrades[i].reserve; + this.transcendenceUpgrades[i].reserve = 0; + } + } + + if (this.game.resPool.get("faith").value > 0 || this.game.challenges.getChallenge("atheism").on && this.game.bld.get("ziggurat").val > 0){ this.game.religionTab.visible = true; } @@ -672,7 +696,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana getProductionBonus: function(){ var rate = this.getRU("solarRevolution").on ? this.game.getTriValue(this.faith, 1000) : 0; //Solar Revolution capped to 1000% so it doesn't become game-breaking - var atheismBonus = this.game.challenges.getChallenge("atheism").researched ? this.getTranscendenceLevel() * 0.1 : 0; + var atheismBonus = (this.game.challenges.getChallenge("atheism").researched && !this.game.challenges.getCondition("disableRewards").on) ? this.getTranscendenceLevel() * 0.1 : 0; var blackObeliskBonus = this.getTranscendenceLevel() * this.getTU("blackObelisk").val * 0.005; rate = this.game.getHyperbolicEffect(rate, 1000) * (1 + atheismBonus + blackObeliskBonus); return rate; @@ -1287,7 +1311,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.ReligionTab", com.nuclearunicorn.ga var sacrificeAlicornsBtn = classes.ui.religion.SacrificeBtn({ name: $I("religion.sacrificeAlicornsBtn.label"), description: $I("religion.sacrificeAlicornsBtn.desc"), - prices: [{ name: "alicorn", val: 25}], + prices: [{ name: "alicorn", val: 25 * game.challenges.getChallengePenalty("atheism")}], controller: new classes.ui.religion.SacrificeAlicornsBtnController(game) }, game); sacrificeAlicornsBtn.render(content); @@ -1331,7 +1355,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.ReligionTab", com.nuclearunicorn.ga } } //eo zg upgrades - if (game.challenges.currentChallenge != "atheism") { + if (!game.challenges.getChallenge("atheism").on) { //------------------- religion ------------------- var religionPanel = new com.nuclearunicorn.game.ui.Panel($I("religion.panel.orderOfTheSun.label"), game.religion); var content = religionPanel.render(container); @@ -1424,7 +1448,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.ReligionTab", com.nuclearunicorn.ga this.refineTCBtn.update(); } - if (this.game.challenges.currentChallenge != "atheism") { + if (!this.game.challenges.getChallenge("atheism").on) { if (this.praiseBtn){ this.praiseBtn.update(); } diff --git a/js/resources.js b/js/resources.js index 25924324f2..5dbe0eac3a 100644 --- a/js/resources.js +++ b/js/resources.js @@ -152,7 +152,8 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana title: $I("resources.zebras.title"), type : "common", transient: true, - visible: true + visible: true, + hideReserve: true },{ name : "starchart", title: $I("resources.starchart.title"), @@ -248,21 +249,32 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana name : "karma", title: $I("resources.karma.title"), type : "rare", - visible: true + visible: true, + hideReserve: true },{ name : "paragon", title: $I("resources.paragon.title"), type : "common", visible: true, color: "#6141CD", - persists: true + persists: true, + hideReserve: true },{ name : "burnedParagon", title : $I("resources.burnedParagon.title"), type : "common", visible: true, color: "#493099", - persists: true + persists: true, + hideReserve: true + },{ + name : "apotheosis", + title : $I("resources.apotheosis.title"), + type : "common", + visible: true, + color: "#7950FF", + persists: true, + hideReserve: true },{ name : "timeCrystal", title: $I("resources.timeCrystal.title"), @@ -471,6 +483,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana for (var i = 0; i< this.resourceData.length; i++){ var res = dojo.clone(this.resourceData[i]); res.value = 0; + res.reserveValue = 0; res.unlocked = false; if (res.name == "oil" || res.name == "kerosene" || @@ -501,6 +514,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var res = { name: name, value: 0, + reserveValue: 0, //whether resource was marked by user as hidden or visible isHidden: false, @@ -510,29 +524,40 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana return res; }, - addRes: function(res, addedValue, event, preventLimitCheck) { - if (this.game.calendar.day < 0 && !event || addedValue == 0) { + addRes: function(res, addedValue, event) { + if (this.game.calendar.day < 0 && !event) { return 0; } var prevValue = res.value || 0; - if(res.maxValue) { - //if already overcap, allow to remain that way unless removing resources. - if(res.value > res.maxValue) { - if(addedValue < 0 ) { - res.value += addedValue; - } - } else { - res.value += addedValue; - if(res.value > res.maxValue && !preventLimitCheck) { + res.value += addedValue; + if(res.maxValue && res.value > res.maxValue) { + res.value = res.maxValue; + } + + if (res.name == "karma" || res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") + { + if (!this.game.challenges.getCondition("disableMetaResources").on && res.reserveValue) + { + res.value += res.reserveValue; + res.reserveValue = 0; + } + } + else + { + if (!this.game.challenges.getCondition("disableChrono").on && res.reserveValue && (!res.maxValue || res.value < res.maxValue)) { + if (res.maxValue && res.reserveValue > res.maxValue) { + res.reserveValue -= (res.maxValue - res.value); res.value = res.maxValue; } + else { + res.value += res.reserveValue; + res.reserveValue = 0; + } } - } else { - res.value += addedValue; } - + if (res.name == "void") { // Always an integer res.value = Math.floor(res.value); } @@ -597,12 +622,17 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana * Iterates resources and updates their values with per tick increment */ update: function(){ - var game = this.game; for (var i in this.resources){ var res = this.resources[i]; if (res.name == "sorrow"){ + if (!this.game.challenges.getCondition("disableMisc").on) + { + res.value += res.reserveValue; + res.reserveValue = 0; + } + res.maxValue = 12 + (game.getEffect("blsLimit") || 0); res.value = res.value > res.maxValue ? res.maxValue : res.value; continue; @@ -636,7 +666,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana //-------- this.energyProd = game.getEffect("energyProduction") * (1 + game.getEffect("energyProductionRatio")); - this.energyCons = game.getEffect("energyConsumption"); + this.energyCons = game.getEffect("energyConsumption") * this.game.challenges.getChallengePenalty("energy") / this.game.challenges.getChallengeReward("energy"); }, @@ -730,6 +760,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana for (var i = 0; i < this.resources.length; i++){ var res = this.resources[i]; res.value = 0; + res.reserveValue = 0; res.maxValue = 0; res.perTickCached = 0; res.unlocked = false; @@ -816,18 +847,20 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana }, getEnergyDelta: function(){ - if (this.energyCons == 0) { - return 0; - } else { - var delta = this.energyProd / this.energyCons; - if (delta < 0.25){ - delta = 0.25; - } - if (this.game.challenges.getChallenge("energy").researched == true) { - delta = 1 - (1 - delta) / 2; - } - return delta; + if (this.energyProd == 0 && this.energyCons == 0){ + return 1; + } + var delta = this.energyProd / (this.energyCons ? this.energyCons : 1); + if (delta < 0.25){ + delta = 0.25; + } + if (delta > 4){ + delta = 4; + } + if ((this.game.challenges.getChallenge("energy").on || !this.game.challenges.getChallenge("energy") || this.game.challenges.getCondition("disableRewards").on) && delta > 1) { + delta = 1; } + return delta; }, getVoidQuantity: function() { @@ -957,6 +990,10 @@ dojo.declare("com.nuclearunicorn.game.ui.GenericResourceTable", null, { var tdAmt = dojo.create("td", {className: "resAmount"}, tr); tdAmt.textContent = this.game.getDisplayValueExt(res.value); + // ---------------- reserve ---------------------- + var tdReserve = dojo.create("td", {className: "resAmountReserve"}, tr); + tdReserve.textContent = !this.game.challenges.getCondition("disableChrono").on && !res.hideReserve && res.reserveValue ? "+" + this.game.getDisplayValueExt(res.reserveValue) : ""; + // ---------------- max ---------------------- var tdMax = dojo.create("td", { className: "maxRes" }, tr); tdMax.textContent = this.game.getDisplayValueExt(res.maxValueUI); @@ -972,6 +1009,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GenericResourceTable", null, { resRef: res, rowRef: tr, resAmt : tdAmt, + resReserve: tdReserve, resMax : tdMax, resTick: tdPerTick, resWMod: tdWeatherMod @@ -1036,6 +1074,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GenericResourceTable", null, { row.resAmt.className = className; } + row.resReserve.textContent = !this.game.challenges.getCondition("disableChrono").on && !res.hideReserve && res.reserveValue ? "+" + this.game.getDisplayValueExt(res.reserveValue) : ""; + var maxResValue = res.maxValue ? "/" + this.game.getDisplayValueExt(res.maxValue) : ""; row.resMax.textContent = maxResValue; @@ -1057,7 +1097,23 @@ dojo.declare("com.nuclearunicorn.game.ui.GenericResourceTable", null, { var season = this.game.calendar.getCurSeason(); if (season.modifiers[res.name] && perTick != 0 ){ - var modifier = (season.modifiers[res.name] + this.game.calendar.getWeatherMod() - 1)*100; + if (this.game.challenges.getChallenge("winterIsComing").on) + { + var modifier = (this.game.challenges.getChallengePenalty("winterIsComing"), (this.game.calendar.weather || "normal") + "Mod"); + } + else + { + var reward = 1; + if (this.game.calendar.weather == "warm") + { + reward = this.game.challenges.getChallengeReward("winterIsComing"); + } + if (this.game.calendar.weather == "cold") + { + reward = 1 / this.game.challenges.getChallengeReward("winterIsComing"); + } + var modifier = Math.floor(((season.modifiers[res.name] - 1) * reward + this.game.calendar.getWeatherMod())*100); + } row.resWMod.textContent = modifier ? "[" + (modifier > 0 ? "+" : "") + modifier.toFixed() + "%]" : ""; if (modifier > 0){ diff --git a/js/science.js b/js/science.js index 8113812860..ff83e5f66e 100644 --- a/js/science.js +++ b/js/science.js @@ -982,31 +982,22 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.Library", com.nuclearunicorn.game.u this.metaphysicsPanel = metaphysicsPanel; } - //---------- challenges ------------ - this.challengesPanel = null; - - //TODO: use better update/render logic like in Time tab - var showChallenges = this.game.prestige.getPerk("adjustmentBureau").researched; - if (showChallenges){ - var challengesPanel = new classes.ui.ChallengePanel($I("challendge.panel.label"), this.game.challenges); - challengesPanel.game = this.game; - - var content = challengesPanel.render(tabContainer); - this.challengesPanel = challengesPanel; - } - this.update(); }, update: function(){ this.inherited(arguments); + if (!this.game.science.get("chronophysics").researched && this.game.prestige.getPerk("anachronomancy").researched && !this.game.challenges.getCondition("disableChrono").on) + { + var chronophysics = this.game.science.get("chronophysics"); + chronophysics.researched = true; + this.game.unlock(chronophysics.unlocks); + } + if (this.metaphysicsPanel){ this.metaphysicsPanel.update(); } - if (this.challengesPanel){ - this.challengesPanel.update(); - } }, constructor: function(tabName, game){ diff --git a/js/space.js b/js/space.js index 91648af48e..260579d3c4 100644 --- a/js/space.js +++ b/js/space.js @@ -263,9 +263,6 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager } else { self.effects["energyConsumption"] = 1; - if (game.challenges.currentChallenge == "energy") { - self.effects["energyConsumption"] *= 2; - } } } },{ @@ -292,9 +289,6 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "scienceRatio": 0.5 }; effects["energyConsumption"] = 10; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } self.effects = effects; }, breakIronWill: true @@ -328,9 +322,6 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "unobtainiumPerTickSpace": 0.007 * (1+ game.getEffect("lunarOutpostRatio")) }; effects["energyConsumption"] = 5; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } self.effects = effects; }, lackResConvert: false, @@ -384,9 +375,6 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "energyConsumption" : 0 }; effects["energyConsumption"] = game.workshop.get("amBases").researched ? 5 : 10; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } if (game.workshop.get("aiBases").researched){ for (var key in effects){ @@ -511,9 +499,6 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "spaceRatio": 0.02 }; effects["energyConsumption"] = 20; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } self.effects = effects; } }] @@ -562,9 +547,6 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "energyConsumption" : 50 * (1+ game.space.getBuilding("heatsink").val * 0.01) }; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } self.effects = effects; } },{ @@ -872,7 +854,7 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager if (!building.effects){ return 0; } else { - var spaceRatio = (effectName == "spaceRatio" && game.resPool.energyCons > game.resPool.energyProd) ? game.resPool.getEnergyDelta() : 1; + var spaceRatio = (effectName == "spaceRatio") ? game.resPool.getEnergyDelta() : 1; return building.effects[effectName] * building.on * spaceRatio; } }}); diff --git a/js/time.js b/js/time.js index f152d068f0..5e2865bef6 100644 --- a/js/time.js +++ b/js/time.js @@ -26,7 +26,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, flux: this.flux, heat: this.heat, cfu: this.filterMetadata(this.chronoforgeUpgrades, ["name", "val", "on", "heat", "isAutomationEnabled"]), - vsu: this.filterMetadata(this.voidspaceUpgrades, ["name", "val", "on"]) + vsu: this.filterMetadata(this.voidspaceUpgrades, ["name", "val", "on", "reserve"]) }; }, @@ -101,6 +101,13 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, }, update: function(){ + if (!this.game.challenges.getCondition("disableChrono").on && this.getVSU("usedCryochambers").reserve) + { + var cryochambers = this.getVSU("usedCryochambers"); + cryochambers.val += cryochambers.reserve; + cryochambers.reserve = 0; + } + if (this.isAccelerated && this.game.resPool.get("temporalFlux").value > 0){ this.game.resPool.addResEvent("temporalFlux", -1); } @@ -165,8 +172,6 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, this.game.resPool.update(); this.game.updateResources(); // Since workshop requires some resource and we don't want exhaust all resources during workshop so we need a way to consume them. - // Idea: relax resource limits temporaraly, load the resource and do workshop, after that enforce limits again. - var currentLimits = {}; var i, res; // calculate resource offsets @@ -177,13 +182,9 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, } //NB: don't forget to update resources before calling in redshift if (res.perTickCached) { - if (res.maxValue) { - currentLimits[res.name] = Math.max(res.value, res.maxValue); - } - //console.log("Adjusting resource", res.name, "delta",res.perTickCached, "max value", res.maxValue, "days offset", daysOffset); //console.log("resource before adjustment:", res.value); - this.game.resPool.addRes(res, res.perTickCached * this.game.rate * daysOffset, false/*event?*/, true/*preventLimitCheck*/); + this.game.resPool.addRes(res, res.perTickCached * this.game.rate * daysOffset, false/*event?*/); //console.log("resource after adjustment:", res.value); } @@ -197,19 +198,6 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, this.game.space.fastforward(this.game.rate * daysOffset); this.game.religion.fastforward(this.game.rate * daysOffset); - // enforce limits - for (i in this.game.resPool.resources){ - res = this.game.resPool.resources[i]; - if (!res.maxValue) { - continue; - } - var limit = currentLimits[res.name]; - if (!limit){ - continue; - } - res.value = Math.min(limit, res.value); - } - if (daysOffset > 3) { this.game.msg($I("time.redshift", [daysOffset]) + (numberEvents ? $I("time.redshift.ext",[numberEvents]) : "")); } @@ -387,9 +375,6 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, "temporalParadoxDay": 1 + game.getEffect("temporalParadoxDayBonus") }; effects["energyConsumption"] = 15; - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } self.effects = effects; }, unlocks: { @@ -484,9 +469,6 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, game.time.flux += amt; game.challenges.getChallenge("1000Years").unlocked = true; - if (game.challenges.currentChallenge == "1000Years" && cal.year >= 1000) { - game.challenges.researchChallenge("1000Years"); - } }, unlockAll: function(){ @@ -635,6 +617,8 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u if (this.game.time.heat > heatMax) { price["val"] *= (1 + (this.game.time.heat - heatMax) * 0.01); //1% per excessive heat unit } + + price["val"] *= this.game.challenges.getChallengePenalty("1000Years") * this.game.challenges.getChallengeReward("1000Years"); } } @@ -648,7 +632,7 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u var impedance = this.game.getEffect("timeImpedance") * (1+ this.game.getEffect("timeRatio")); var heatMax = this.game.getEffect("heatMax"); - var heatFactor = this.game.challenges.getChallenge("1000Years").researched ? 5 : 10; + var heatFactor = (this.game.challenges.getChallenge("1000Years").researched && !this.game.challenges.getCondition("disableRewards").on) ? 5 : 10; for (var k = 0; k < amt; k++) { for (var i = 0; i < prices_cloned.length; i++) { @@ -662,6 +646,8 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u if ((this.game.time.heat + k * heatFactor) > heatMax) { priceLoop *= (1 + (this.game.time.heat + k * heatFactor - heatMax) * 0.01); //1% per excessive heat unit } + + price["val"] *= this.game.challenges.getChallengePenalty("1000Years") * this.game.challenges.getChallengeReward("1000Years"); pricesTotal += priceLoop; } } @@ -702,7 +688,7 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u doShatter: function(model, amt){ - var factor = this.game.challenges.getChallenge("1000Years").researched ? 5 : 10; + var factor = (this.game.challenges.getChallenge("1000Years").researched && !this.game.challenges.getCondition("disableRewards").on) ? 5 : 10; this.game.time.heat += amt*factor; this.game.time.shatter(amt); diff --git a/js/toolbar.js b/js/toolbar.js index de6f8cb3d8..642f5b8ac5 100644 --- a/js/toolbar.js +++ b/js/toolbar.js @@ -185,6 +185,10 @@ dojo.declare("classes.ui.toolbar.ToolbarEnergy", classes.ui.ToolbarIcon, { var delta = this.game.resPool.getEnergyDelta(); var penalty = energy >= 0 ? "" :"

Production bonuses cuts: -" + Math.floor( (1-delta) * 100) + "%"; + if (!this.game.challenges.getChallenge("energy").on && this.game.challenges.getChallenge("energy").researched && !this.game.challenges.getCondition("disableRewards").on && energy > 0) + { + penalty = "

Production bonuses gains: +" + Math.floor( (delta-1) * 100) + "%"; + } return "Production: " + this.game.getDisplayValueExt(resPool.energyProd, true, false) + "Wt" + "
Consumption: -" + this.game.getDisplayValueExt(resPool.energyCons) + "Wt" + penalty; @@ -229,4 +233,4 @@ dojo.declare("classes.ui.toolbar.ToolbarDonations", classes.ui.ToolbarIcon, { return "Magic kitten level: " + tier + "
"; } -}); \ No newline at end of file +}); diff --git a/js/village.js b/js/village.js index 6ebd9bf146..5f7d27eb64 100644 --- a/js/village.js +++ b/js/village.js @@ -155,28 +155,29 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag var leaderTrait = this.leader.trait["name"]; if (leaderTrait == trait) { var burnedParagonRatio = 1 + this.game.prestige.getBurnedParagonRatio(); + var reward = (this.game.challenges.getChallenge("anarchy").researched && !this.game.challenges.getCondition("disableRewards").on) ? Math.sqrt(this.leader.rank) : 1; // Modify the defautlObject depends on trait switch (trait) { case "engineer": // Crafting bonus - defaultObject = 0.05 * burnedParagonRatio; + defaultObject = 0.05 * burnedParagonRatio * reward; break; case "merchant": // Trading bonus - defaultObject = 0.030 * burnedParagonRatio; + defaultObject = 0.030 * burnedParagonRatio * reward; break; case "manager": // Hunting bonus - defaultObject = 0.5 * burnedParagonRatio; + defaultObject = 0.5 * burnedParagonRatio * reward; break; case "scientist": // Science prices bonus for (var i = 0; i < defaultObject.length; i++) { if (defaultObject[i].name == "science") { - defaultObject[i].val -= defaultObject[i].val * this.game.getHyperbolicEffect(0.05 * burnedParagonRatio, 1.0); //5% before BP + defaultObject[i].val -= defaultObject[i].val * this.game.getHyperbolicEffect(0.05 * burnedParagonRatio * reward, 1.0); //5% before BP } } break; case "wise": // Religion bonus for (var i = 0; i < defaultObject.length; i++) { if (defaultObject[i].name == "faith" || defaultObject[i].name == "gold") { - defaultObject[i].val -= defaultObject[i].val * this.game.getHyperbolicEffect(0.09 + 0.01 * burnedParagonRatio, 1.0); //10% before BP + defaultObject[i].val -= defaultObject[i].val * this.game.getHyperbolicEffect(0.09 + 0.01 * burnedParagonRatio * reward, 1.0); //10% before BP } } break; @@ -271,7 +272,7 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag var resDiff = catnipVal + catnipPerTick; if (this.sim.getKittens() > 0){ - if (resDiff < 0 || this.game.challenges.currentChallenge == "winterIsComing" && this.sim.getKittens() > this.sim.maxKittens && this.game.calendar.weather == "cold") { + if (resDiff < 0 || this.game.challenges.getChallenge("winterIsComing").on && this.sim.getKittens() > this.sim.maxKittens && this.game.calendar.weather == "cold") { var starvedKittens = Math.abs(Math.round(resDiff)); if (starvedKittens > 1){ @@ -345,9 +346,9 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag isFreeKittens: function(){ var FreeKittens = this.getFreeKittens(); - if(this.game.challenges.currentChallenge == "anarchy") { + if(this.game.challenges.getChallenge("anarchy").on) { var kittens = this.getKittens(); - return FreeKittens != Math.floor(this.getKittens() / 2); + return FreeKittens != Math.floor(this.getKittens() * this.game.challenges.getChallengePenalty("anarchy")); } else { return FreeKittens != 0; } @@ -521,6 +522,7 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag save: function(saveData){ saveData.village = { kittens : this.sim.kittens, + reserveKittens: this.sim.reserveKittens, maxKittens: this.maxKittens, jobs: this.filterMetadata(this.jobs, ["name", "unlocked", "value"]) }; @@ -529,12 +531,17 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag load: function(saveData){ if (saveData.village){ var kittens = saveData.village.kittens; + var reserveKittens = saveData.village.reserveKittens; //quick legacy hack, remove in future if (!kittens.length) { kittens = []; } + if (!reserveKittens || !reserveKittens.length) { + reserveKittens = []; + } this.sim.kittens = []; + this.sim.reserveKittens = []; for (var i = kittens.length - 1; i >= 0; i--) { var kitten = kittens[i]; @@ -551,6 +558,15 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag this.sim.kittens.unshift(newKitten); } + + for (var i = reserveKittens.length - 1; i >= 0; i--) { + var reserveKitten = reserveKittens[i]; + + var newKitten = new com.nuclearunicorn.game.village.Kitten(); + newKitten.load(reserveKitten); + + this.sim.reserveKittens.unshift(newKitten); + } this.maxKittens = saveData.village.maxKittens; this.loadMetadata(this.jobs, saveData.village.jobs); @@ -888,6 +904,7 @@ dojo.declare("com.nuclearunicorn.game.village.Kitten", null, { dojo.declare("com.nuclearunicorn.game.village.KittenSim", null, { kittens: null, + reserveKittens: null, game: null, @@ -908,6 +925,16 @@ dojo.declare("com.nuclearunicorn.game.village.KittenSim", null, { if (!times) { times = 1; } + + if (!this.game.challenges.getCondition("disableChrono").on && this.reserveKittens) + { + for (var i = 0; i < this.reserveKittens.length; i++) + { + this.kittens.push(this.reserveKittens[i]); + } + + this.reserveKittens = []; + } if (this.kittens.length < this.maxKittens) { //Don't do maths if Maxed. this.nextKittenProgress += times * kittensPerTick; @@ -951,7 +978,7 @@ dojo.declare("com.nuclearunicorn.game.village.KittenSim", null, { kitten.trait = kitten.traits[kitten.rand(kitten.traits.length)]; } - if (kitten.job && game.calendar.day >= 0 && game.challenges.currentChallenge != "anarchy"){ + if (kitten.job && game.calendar.day >= 0 && !game.challenges.getChallenge("anarchy").on){ //Initialisation of job's skill if (!kitten.skills[kitten.job]){ kitten.skills[kitten.job] = 0; @@ -1448,7 +1475,7 @@ dojo.declare("classes.ui.village.Census", null, { //-------------------------------------------------------------------------------------- this.governmentDiv = null; - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { this.renderGovernment(container); } //-------------------------------------------- @@ -1520,7 +1547,7 @@ dojo.declare("classes.ui.village.Census", null, { } }, div); - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { var leaderHref = dojo.create("a", { href: "#", innerHTML: "", style: { @@ -1538,7 +1565,7 @@ dojo.declare("classes.ui.village.Census", null, { } }, linksDiv); - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { var senatorHref = dojo.create("a", { href: "#", innerHTML: $I("village.btn.senator"), style: { @@ -1555,7 +1582,7 @@ dojo.declare("classes.ui.village.Census", null, { }, this.game, i)); - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { dojo.connect(leaderHref, "onclick", this, dojo.partial(function(census, i, event){ event.preventDefault(); var game = census.game; @@ -1573,7 +1600,7 @@ dojo.declare("classes.ui.village.Census", null, { } //rankExp - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { dojo.connect(senatorHref, "onclick", this, dojo.partial(function(census, i, event){ event.preventDefault(); @@ -1775,7 +1802,7 @@ dojo.declare("classes.ui.village.Census", null, { //TODO: promote leader link var govInfo = this.getGovernmentInfo(); - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { this.leaderDiv.innerHTML = "" + $I("village.census.lbl.leader") + ": " + govInfo.leaderInfo; } @@ -1792,7 +1819,7 @@ dojo.declare("classes.ui.village.Census", null, { } else { dojo.style(record.unassignHref, "display", "none"); } - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { dojo.style(record.senatorHref, "display", "none"); } @@ -1809,7 +1836,7 @@ dojo.declare("classes.ui.village.Census", null, { var skillInfo = this.getSkillInfo(kitten); record.content.innerHTML += skillInfo; - if (this.game.challenges.currentChallenge != "anarchy") { + if (!this.game.challenges.getChallenge("anarchy").on) { record.leaderHref.innerHTML = kitten.isLeader ? "★" : "☆"; //star-shaped link to reduce visual noise } @@ -2070,7 +2097,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.Village", com.nuclearunicorn.game.u }), controller: new classes.village.ui.VillageButtonController(this.game, { updateVisible: function (model) { - model.visible = this.game.village.leader != undefined && this.game.workshop.get("register").researched && this.game.challenges.currentChallenge != "anarchy"; + model.visible = this.game.village.leader != undefined && this.game.workshop.get("register").researched && !this.game.challenges.getChallenge("anarchy").on; } }) }, this.game); @@ -2086,7 +2113,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.Village", com.nuclearunicorn.game.u }), controller: new classes.village.ui.VillageButtonController(this.game, { updateVisible: function (model) { - model.visible = this.game.village.leader != undefined && this.game.workshop.get("register").researched && this.game.challenges.currentChallenge != "anarchy"; + model.visible = this.game.village.leader != undefined && this.game.workshop.get("register").researched && !this.game.challenges.getChallenge("anarchy").on; } }) }, this.game); @@ -2292,7 +2319,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.Village", com.nuclearunicorn.game.u case value < 9000: return 1.50; default: - return 1.75; + return 1.75 * this.game.challenges.getChallengeReward("anarchy"); } }, diff --git a/res/i18n/en.json b/res/i18n/en.json index 4a2f327f38..bad447518b 100644 --- a/res/i18n/en.json +++ b/res/i18n/en.json @@ -253,8 +253,6 @@ "challendge.btn.confirmation.dlg.title": "Challenge confirmation", "challendge.btn.desc": "
Gain: {0}

Your game will be reset in order to enable this challenge. {1}", "challendge.btn.log.message.on.complete": "Congratulations! You complete the challenge {0}.", - "challendge.btn.name.complete": "{0} (Complete)", - "challendge.btn.name.current": "{0} (Current)", "challendge.energy.desc": "Restart the game with consumption of energy multiply by 2.

Goal: Unlock all energy production buildings and build at least one of them.", "challendge.energy.effect.desc": "Production bonuses cuts caused by negative energy are divided by 2.", "challendge.energy.label": "Energy", @@ -265,6 +263,19 @@ "challendge.winterIsComing.effect.desc": "Warm seasons are more likely, and cold seasons are less likely.", "challendge.winterIsComing.label": "Winter Has Come", "challendge.panel.label": "Challenges", + "challendge.condition.panel.label": "Conditions", + "challendge.condition.disableChrono.label": "No Chronospheres", + "challendge.condition.disableChrono.desc": "Benefits from Anachronomancy, Chronospheres, and Cryochambers will not be available on reset until this is re-enabled. Must be enabled to get challenge rewards.", + "challendge.condition.disableMetaResources.label": "No Metaphysics Resources", + "challendge.condition.disableMetaResources.desc": "Karma, Paragon, Burned Paragon, and Apotheosis will be reset until this is re-enabled. Increases challenge rewards.", + "challendge.condition.disableMetaTechs.label": "No Metaphysics Techs", + "challendge.condition.disableMetaTechs.desc": "Metaphysics Techs will be reset until this is re-enabled. Increases challenge rewards.", + "challendge.condition.disableApo.label": "No Apocrypha", + "challendge.condition.disableApo.desc": "Apocrypha, Transcendence Tiers, and Cryptotheology Upgrades will be reset until this is re-enabled. Increases challenge rewards.", + "challendge.condition.disableRewards.label": "No Challenge Rewards", + "challendge.condition.disableRewards.desc": "All Challenge Rewards effects will be disabled until this is re-enabled. Challenges still grant rewards. Increases challenge rewards.", + "challendge.condition.disableMisc.label": "No Miscellaneous", + "challendge.condition.disableMisc.desc": "BLS and Iron Will Zebras will be reset until this is re-enabled. Does NOT increase challenge rewards.", "space.centaurusSystemMission.desc": "Centaurus System is a warm faraway star system.", "space.centaurusSystemMission.label": "Centaurus System Mission", @@ -961,6 +972,7 @@ "resources.karma.title": "karma", "resources.paragon.title": "paragon", "resources.burnedParagon.title": "burned paragon", + "resources.apotheosis.title": "apotheosis", "resources.timeCrystal.title": "time crystal", "resources.sorrow.title": "sorrow", "resources.relic.title": "relic", @@ -1325,6 +1337,7 @@ "tab.name.religion": "Religion", "tab.name.space": "Space", "tab.name.time": "Time", + "tab.name.challenges": "Challenges", "tab.name.stats": "Stats", "tab.name.achievements": "Achievements", "menu.save": "Save", From 8f72d32828f7ceaae8905fdafd7c187fbd422f2d Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 26 May 2018 16:15:02 -0400 Subject: [PATCH 02/58] Address some comments --- game.js | 44 +++++++------------------------------------- js/challenges.js | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/game.js b/game.js index 077423e45e..077eeefe73 100644 --- a/game.js +++ b/game.js @@ -2087,24 +2087,9 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (!season){ var season = this.calendar.getCurSeason(); } - if (this.challenges.getChallenge("winterIsComing").on) - { - var weatherMod = (this.challenges.getChallengePenalty("winterIsComing"), (this.calendar.weather || "normal") + "Mod"); - } - else - { - var reward = 1; - if (this.calendar.weather == "warm") - { - reward = this.challenges.getChallengeReward("winterIsComing"); - } - if (this.calendar.weather == "cold") - { - reward = 1 / this.challenges.getChallengeReward("winterIsComing"); - } - var weatherMod = this.calendar.getWeatherMod(); - weatherMod = Math.floor((((season.modifiers[res.name] - 1) * reward + 1) + weatherMod) * 100) / 100; - } + + var weatherMod = this.challenges.getWeatherMod(season, res); + if (weatherMod < -0.95){ weatherMod = -0.95; } @@ -2292,24 +2277,9 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (!season){ var season = this.calendar.getCurSeason(); } - if (this.challenges.getChallenge("winterIsComing").on) - { - var weatherMod = (this.challenges.getChallengePenalty("winterIsComing"), (this.calendar.weather || "normal") + "Mod"); - } - else - { - var reward = 1; - if (this.calendar.weather == "warm") - { - reward = this.challenges.getChallengeReward("winterIsComing"); - } - if (this.calendar.weather == "cold") - { - reward = 1 / this.challenges.getChallengeReward("winterIsComing"); - } - var weatherMod = this.calendar.getWeatherMod(); - weatherMod = Math.floor((((season.modifiers[res.name] - 1) * reward + 1) + weatherMod) * 100) / 100; - } + + var weatherMod = this.challenges.getWeatherMod(season, res); + if (weatherMod < -0.95){ weatherMod = -0.95; } @@ -3306,7 +3276,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var paragonPoints = 0; if (kittens > 70){ - paragonPoints = (kittens - 70) * (1 + this.resPool.get("apotheosis").value / 10); + paragonPoints = (kittens - 70) * (1 + this.challenges.getParagonBonus()); } var addRes = { diff --git a/js/challenges.js b/js/challenges.js index 0effb952c0..bb45c9b1c3 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -408,6 +408,31 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa { return 1 - this.game.getHyperbolicEffect(researched * 0.1, 1); } + }, + + getWeatherMod: function(season, res){ + if (this.getChallenge("winterIsComing").on) + { + return this.getChallengePenalty("winterIsComing", (this.game.calendar.weather || "normal") + "Mod"); + } + else + { + var reward = 1; + if (this.game.calendar.weather == "warm") + { + reward = this.getChallengeReward("winterIsComing"); + } + if (this.game.calendar.weather == "cold") + { + reward = 1 / this.getChallengeReward("winterIsComing"); + } + var weatherMod = this.game.calendar.getWeatherMod(); + return Math.floor((((season.modifiers[res.name] - 1) * reward + 1) + weatherMod) * 100) / 100; + } + }, + + getParagonBonus: function(){ + return this.game.resPool.get("apotheosis").value / 10; } }); From 089f6f76146741ba2ab19e1e85ffce1dfbd5accc Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 26 May 2018 16:15:39 -0400 Subject: [PATCH 03/58] Balance change --- js/challenges.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/challenges.js b/js/challenges.js index bb45c9b1c3..640458ca3e 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -432,7 +432,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa }, getParagonBonus: function(){ - return this.game.resPool.get("apotheosis").value / 10; + return this.game.resPool.get("apotheosis").value / 100; } }); From 370740f0f06e566a836d4f98b3a1091a4056f270 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 26 May 2018 16:21:14 -0400 Subject: [PATCH 04/58] Forgot this bit before, adding it now --- js/challenges.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/challenges.js b/js/challenges.js index 640458ca3e..a5ffe773e4 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -319,7 +319,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa var conditionTotal = 0; for (var i = 0; i < this.conditions.length; i++) { if (this.conditions[i].on && this.conditions[i].bonus) { - conditionTotal += Math.pow(this.conditions[i].bonus, 2); + conditionTotal += Math.pow(this.conditions[i].bonus * (1 - this.game.getHyperBolicEffect(this.conditions[i].resets / 10, 1)), 2); } } From 92acbe10fd127a2aa575cb90e0ac92fc34e2adf4 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 26 May 2018 23:21:07 -0400 Subject: [PATCH 05/58] Fix migration bug --- game.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/game.js b/game.js index 077eeefe73..f499684da0 100644 --- a/game.js +++ b/game.js @@ -990,6 +990,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { ironWill: true, //true if player has no kittens or housing buildings saveVersion: 16, + migrateRes: false, //FINALLY opts: null, @@ -1480,6 +1481,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { // Calculate effects (needs to be done after all managers are loaded) this.calculateAllEffects(); + this.updateCaches(); if (saveData && saveData.game){ var data = saveData.game; @@ -1665,6 +1667,13 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.msg($I("save.import.msg")); this.render(); + + //hack + if (this.migrateRes) + { + this.challenges.getCondition("disableChrono").on = 1; + this.challenges.getCondition("disableChrono").rewardable = true; + } callback(); } catch (e) { @@ -1973,13 +1982,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } if (save.challenges.currentChallenge) { - save.challenges.conditions = []; - var chrono = {}; - chrono.name = "disableChrono"; - chrono.on = 1; - chrono.rewardable = true; - chrono.resets = 0; - save.challenges.conditions.push(chrono); + //hack; Can't turn on disableChrono here because it messes up overcap resource migration + this.migrateRes = true; } } From 69a16768107cfcca9d70c74ee8afddadb47f780e Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 26 May 2018 23:44:07 -0400 Subject: [PATCH 06/58] Move fix to load --- game.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/game.js b/game.js index f499684da0..0dcc996c89 100644 --- a/game.js +++ b/game.js @@ -1528,6 +1528,14 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched; this.ui.load(); + this.render(); + + //hack + if (this.migrateRes) + { + this.challenges.getCondition("disableChrono").on = 1; + this.challenges.getCondition("disableChrono").rewardable = true; + } return success; }, @@ -1666,15 +1674,6 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.load(); this.msg($I("save.import.msg")); - this.render(); - - //hack - if (this.migrateRes) - { - this.challenges.getCondition("disableChrono").on = 1; - this.challenges.getCondition("disableChrono").rewardable = true; - } - callback(); } catch (e) { console.log("Couldn't import the save of the game:"+e.stack); From cb32b60fcd9cf5debf7e9e0ae77cf87bff1f3817 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 27 May 2018 00:35:54 -0400 Subject: [PATCH 07/58] Fix bug --- js/religion.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/religion.js b/js/religion.js index 719a41c85f..080ed694af 100644 --- a/js/religion.js +++ b/js/religion.js @@ -98,8 +98,8 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana for (var i = 0; i < this.transcendenceUpgrades.length; i++) { - this.transcendenceUpgrades[i].val += this.transcendenceUpgrades[i].reserve; - this.transcendenceUpgrades[i].on += this.transcendenceUpgrades[i].reserve; + this.transcendenceUpgrades[i].val += this.transcendenceUpgrades[i].reserve || 0; + this.transcendenceUpgrades[i].on += this.transcendenceUpgrades[i].reserve || 0; this.transcendenceUpgrades[i].reserve = 0; } } From 2e6a752c121693c4ca9bd85af627d3015583c0a3 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Mon, 3 Sep 2018 13:29:45 -0400 Subject: [PATCH 08/58] Fixes --- js/challenges.js | 18 ++++++++++++++++-- js/time.js | 1 - 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/js/challenges.js b/js/challenges.js index a5ffe773e4..ee3b89b105 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -156,7 +156,12 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa resetState: function(){ for (var i = 0; i < this.challenges.length; i++){ var challenge = this.challenges[i]; - challenge.enabled = false; + challenge.on = 0; + } + + for (var i = 0; i < this.conditions.length; i++){ + var condition = this.conditions[i]; + condition.on = 0; } }, @@ -291,7 +296,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa } if (challenge == "atheism"){ - this.game.resPool.get("faith").reserveValue += 1000000; + this.game.religion.faithRatio += 1; } if (challenge == "1000Years"){ @@ -473,6 +478,15 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui }, buyItem: function(model, event, callback) { + }, + + handleTogglableOnOffClick: function(model) { + this.inherited(arguments); + + if (model.metadata.name == "atheism") + { + this.game.upgrade({buildings: ["temple"]}); + } } }); diff --git a/js/time.js b/js/time.js index 5e2865bef6..4c4f9ee43d 100644 --- a/js/time.js +++ b/js/time.js @@ -68,7 +68,6 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, // Update temporalFluxMax from values loaded this.game.updateCaches(); - this.game.resPool.update(); var temporalAccelerator = this.getCFU("temporalAccelerator"); var energyRatio = 1 + (temporalAccelerator.val * temporalAccelerator.effects["timeRatio"]); From 7b054b8028ea1795ad1610a3ed6c02cadb60e9fd Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 19 Apr 2019 22:06:43 -0400 Subject: [PATCH 09/58] fix stupid mistake --- js/resources.js | 1 - js/time.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/js/resources.js b/js/resources.js index 915f46c759..459582e92a 100644 --- a/js/resources.js +++ b/js/resources.js @@ -695,7 +695,6 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana //console.log("resource after adjustment:", res.value); } } - return limits; }, //Hack to reach the maxValue in resTable diff --git a/js/time.js b/js/time.js index ac50604d74..1281eb4e44 100644 --- a/js/time.js +++ b/js/time.js @@ -164,7 +164,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, //populate cached per tickValues this.game.resPool.update(); this.game.updateResources(); - var resourceLimits = this.game.resPool.fastforward(daysOffset); + this.game.resPool.fastforward(daysOffset); var numberEvents = this.game.calendar.fastForward(daysOffset); this.game.bld.fastforward(daysOffset); From bd491eca7d7114fb73f7e96679a9d5d0597625f2 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 20 Apr 2019 00:03:36 -0400 Subject: [PATCH 10/58] New loading approach (still doesn't quite work) --- game.js | 31 ++++++++----------- js/resources.js | 81 +++++++++++++++++++++++++++++++++---------------- js/time.js | 5 ++- 3 files changed, 71 insertions(+), 46 deletions(-) diff --git a/game.js b/game.js index 77ee7fe783..137b63a002 100644 --- a/game.js +++ b/game.js @@ -1003,7 +1003,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { ironWill: true, //true if player has no kittens or housing buildings saveVersion: 16, - migrateRes: false, + loading: false, //FINALLY opts: null, @@ -1465,6 +1465,9 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.updateOptionsUI(); return; } + + this.loading = true; + var success = true; try { @@ -1555,14 +1558,13 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.ui.load(); this.render(); - - //hack - if (this.migrateRes) - { - this.challenges.getCondition("disableChrono").on = 1; - this.challenges.getCondition("disableChrono").rewardable = true; - } + for (var i in this.resPool.resources) { + var res = this.resPool.resources[i]; + this.resPool.handleLimits(res); + } + this.loading = false; + return success; }, @@ -2007,20 +2009,11 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } if (save.challenges.currentChallenge) { - //hack; Can't turn on disableChrono here because it messes up overcap resource migration - this.migrateRes = true; + this.challenges.getCondition("disableChrono").on = 1; + this.challenges.getCondition("disableChrono").rewardable = true; } } - if (save.resources) { - for (var i = 0; i < save.resources.length; i++) - { - // Give the benefit of the doubt - save.resources[i].reserveValue = save.resources[i].value; - save.resources[i].value = 0; - } - } - save.saveVersion = 16; } diff --git a/js/resources.js b/js/resources.js index 459582e92a..3f02148ed5 100644 --- a/js/resources.js +++ b/js/resources.js @@ -537,6 +537,38 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana return res; }, + handleLimits: function(res) { + if(res.maxValue && res.value > res.maxValue) { + if (this.game.loading) { + // Give the benefit of the doubt + res.reserveValue = res.value - res.maxValue; + } + res.value = res.maxValue; + } + + if (res.name == "karma" || res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") + { + if ((this.game.loading || !this.game.challenges.getCondition("disableMetaResources").on) && res.reserveValue) + { + res.value += res.reserveValue; + res.reserveValue = 0; + } + } + else + { + if ((this.game.loading || !this.game.challenges.getCondition("disableChrono").on) && res.reserveValue && (!res.maxValue || res.value < res.maxValue)) { + if (res.maxValue && res.reserveValue > res.maxValue) { + res.reserveValue -= (res.maxValue - res.value); + res.value = res.maxValue; + } + else { + res.value += res.reserveValue; + res.reserveValue = 0; + } + } + } + }, + addRes: function(res, addedValue, event) { if (this.game.calendar.day < 0 && !event) { return 0; @@ -545,32 +577,11 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var prevValue = res.value || 0; res.value += addedValue; - if(res.maxValue && res.value > res.maxValue) { - res.value = res.maxValue; - } - - if (res.name == "karma" || res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") - { - if (!this.game.challenges.getCondition("disableMetaResources").on && res.reserveValue) - { - res.value += res.reserveValue; - res.reserveValue = 0; - } - } - else - { - if (!this.game.challenges.getCondition("disableChrono").on && res.reserveValue && (!res.maxValue || res.value < res.maxValue)) { - if (res.maxValue && res.reserveValue > res.maxValue) { - res.reserveValue -= (res.maxValue - res.value); - res.value = res.maxValue; - } - else { - res.value += res.reserveValue; - res.reserveValue = 0; - } - } + + if(this.game.loading) { + this.handleLimits(res); } - + if (res.name == "void") { // Always an integer res.value = Math.floor(res.value); } @@ -686,17 +697,35 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana //NB: don't forget to update resources before calling in redshift fastforward: function(daysOffset) { // Since workshop requires some resource and we don't want exhaust all resources during workshop so we need a way to consume them. + // Idea: relax resource limits temporarily, load the resource and do workshop, after that enforce limits again. + var limits = {}; for (var i in this.resources) { var res = this.resources[i]; if (res.perTickCached && !(res.name == "catnip" && res.perTickCached < 0)) { + if (res.maxValue) { + limits[res.name] = Math.max(res.value, res.maxValue); + } //console.log("Adjusting resource", res.name, "delta",res.perTickCached, "max value", res.maxValue, "days offset", daysOffset); //console.log("resource before adjustment:", res.value); - this.addRes(res, res.perTickCached * daysOffset * this.game.calendar.ticksPerDay, false/*event?*/); + this.addRes(res, res.perTickCached * daysOffset * this.game.calendar.ticksPerDay, false/*event?*/, true/*preventLimitCheck*/); //console.log("resource after adjustment:", res.value); } } + return limits; }, + enforceLimits: function(limits) { + for (var i in this.resources) { + var res = this.resources[i]; + if (res.maxValue) { + var limit = limits[res.name]; + if (limit) { + res.value = Math.min(res.value, limit); + } + } + } + }, + //Hack to reach the maxValue in resTable //AB: Questionable resConsHackForResTable: function() { diff --git a/js/time.js b/js/time.js index 1281eb4e44..8242467cbb 100644 --- a/js/time.js +++ b/js/time.js @@ -68,6 +68,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, // Update temporalFluxMax from values loaded this.game.updateCaches(); + this.game.resPool.update(); var temporalAccelerator = this.getCFU("temporalAccelerator"); var energyRatio = 1 + (temporalAccelerator.val * temporalAccelerator.effects["timeRatio"]); @@ -164,7 +165,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, //populate cached per tickValues this.game.resPool.update(); this.game.updateResources(); - this.game.resPool.fastforward(daysOffset); + var resourceLimits = this.game.resPool.fastforward(daysOffset); var numberEvents = this.game.calendar.fastForward(daysOffset); this.game.bld.fastforward(daysOffset); @@ -173,6 +174,8 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, this.game.space.fastforward(daysOffset); this.game.religion.fastforward(daysOffset); + this.game.resPool.enforceLimits(resourceLimits); + if (daysOffset > 3) { this.game.msg($I("time.redshift", [daysOffset]) + (numberEvents ? $I("time.redshift.ext",[numberEvents]) : "")); } From 8f4ed14aeca1a8e8b7e02afdadf8bb8819d34eef Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 20 Apr 2019 13:13:20 -0400 Subject: [PATCH 11/58] Only put overcap in reserve when migrating --- game.js | 5 ++++- js/resources.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/game.js b/game.js index 137b63a002..5287977af8 100644 --- a/game.js +++ b/game.js @@ -1004,6 +1004,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { saveVersion: 16, loading: false, + migrating: false, //FINALLY opts: null, @@ -1559,11 +1560,12 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.ui.load(); this.render(); + this.loading = false; for (var i in this.resPool.resources) { var res = this.resPool.resources[i]; this.resPool.handleLimits(res); } - this.loading = false; + this.migrating = false; return success; }, @@ -2015,6 +2017,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } save.saveVersion = 16; + this.migrating = true; } return save; diff --git a/js/resources.js b/js/resources.js index 3f02148ed5..e5501f2020 100644 --- a/js/resources.js +++ b/js/resources.js @@ -539,7 +539,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana handleLimits: function(res) { if(res.maxValue && res.value > res.maxValue) { - if (this.game.loading) { + if (this.game.migrating) { // Give the benefit of the doubt res.reserveValue = res.value - res.maxValue; } From 0266fc5347f97dca03eb9d3f2ada0cdc9aa8b592 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Tue, 30 Apr 2019 23:53:11 -0400 Subject: [PATCH 12/58] fixes --- game.js | 19 ++++++++++++++++--- js/resources.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/game.js b/game.js index 5287977af8..0fa69a1d18 100644 --- a/game.js +++ b/game.js @@ -1557,8 +1557,18 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.timeTab.visible = (this.science.get("calendar").researched || this.time.getVSU("usedCryochambers").val > 0); this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched; - this.ui.load(); - this.render(); + for (var i in this.resPool.resources) { + var res = this.resPool.resources[i]; + var maxValue = this.getEffect(res.name + "Max") || 0; + + maxValue = this.resPool.addResMaxRatios(res, maxValue); + + if (maxValue < 0 ){ + maxValue = 0; + } + + res.maxValue = maxValue; + } this.loading = false; for (var i in this.resPool.resources) { @@ -1566,7 +1576,10 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.resPool.handleLimits(res); } this.migrating = false; - + + this.ui.load(); + this.render(); + return success; }, diff --git a/js/resources.js b/js/resources.js index e5501f2020..6f7a09c8f6 100644 --- a/js/resources.js +++ b/js/resources.js @@ -578,7 +578,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana res.value += addedValue; - if(this.game.loading) { + if(!this.game.loading) { this.handleLimits(res); } From 9044393d707b4122646442ac63cea8edb4b65575 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 4 May 2019 22:48:40 -0400 Subject: [PATCH 13/58] Loading/migrating finally works?! --- game.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ js/resources.js | 2 +- js/time.js | 10 +++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/game.js b/game.js index 0fa69a1d18..c61c7cddf0 100644 --- a/game.js +++ b/game.js @@ -1557,6 +1557,53 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.timeTab.visible = (this.science.get("calendar").researched || this.time.getVSU("usedCryochambers").val > 0); this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched; + //copied from workshop.js, very bad + //when that code gets moved somewhere better call it here + var scienceMaxBuilding = this.bld.getEffect("scienceMax"), + scienceMaxCompendiaCap = this.bld.getEffect("scienceMaxCompendia"), + compendiaScienceMax = Math.floor(this.resPool.get("compedium").value * 10); + + //iw compedia cap is set to 1000% instead of 100% + var iwScienceCapRatio = this.ironWill ? 10 : 1; + + var blackLibrary = this.religion.getTU("blackLibrary"); + if (this.prestige.getPerk("codexLeviathanianus").researched){ + var ttBoostRatio = ( + 0.05 * ( + 1 + + blackLibrary.val * ( + blackLibrary.effects["compendiaTTBoostRatio"] + + this.getEffect("blackLibraryBonus") ) + ) + ); + iwScienceCapRatio *= (1 + ttBoostRatio * this.religion.getTranscendenceLevel()); + } + + if (compendiaScienceMax > (scienceMaxBuilding * iwScienceCapRatio + scienceMaxCompendiaCap)){ + compendiaScienceMax = (scienceMaxBuilding * iwScienceCapRatio + scienceMaxCompendiaCap); + } + + this.workshop.effectsBase["scienceMax"] = compendiaScienceMax; + var cultureBonusRaw = Math.floor(this.resPool.get("manuscript").value); + this.workshop.effectsBase["cultureMax"] = this.getTriValue(cultureBonusRaw, 0.01); + this.workshop.effectsBase["oilMax"] = Math.floor(this.resPool.get("tanker").value * 500); + + this.updateCaches(); + + this.bld.get("pasture").action(this.bld.get("pasture"), this); + this.bld.get("oilWell").action(this.bld.get("oilWell"), this); + this.bld.get("reactor").action(this.bld.get("reactor"), this); + + this.resPool.energyProd = this.getEffect("energyProduction") * (1 + game.getEffect("energyProductionRatio")); + this.resPool.energyCons = this.getEffect("energyConsumption") * this.challenges.getChallengePenalty("energy") / this.challenges.getChallengeReward("energy"); + + + this.bld.get("observatory").action(this.bld.get("observatory"), this); + this.bld.get("amphitheatre").action(this.bld.get("amphitheatre"), this); + this.space.getBuilding("spaceBeacon").action(this.space.getBuilding("spaceBeacon"), this); + + this.updateCaches(); + for (var i in this.resPool.resources) { var res = this.resPool.resources[i]; var maxValue = this.getEffect(res.name + "Max") || 0; diff --git a/js/resources.js b/js/resources.js index 6f7a09c8f6..1da638e7dd 100644 --- a/js/resources.js +++ b/js/resources.js @@ -578,7 +578,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana res.value += addedValue; - if(!this.game.loading) { + if(!this.game.loading || res.name == "temporalFlux") { this.handleLimits(res); } diff --git a/js/time.js b/js/time.js index 8242467cbb..9fcc0bfbd0 100644 --- a/js/time.js +++ b/js/time.js @@ -68,7 +68,15 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, // Update temporalFluxMax from values loaded this.game.updateCaches(); - this.game.resPool.update(); + var res = this.game.resPool.get("temporalFlux"); + var maxValue = this.game.getEffect("temporalFluxMax") || 0; + maxValue = this.game.resPool.addResMaxRatios(res, maxValue); + + if (maxValue < 0 ) { + maxValue = 0; + } + + res.maxValue = maxValue; var temporalAccelerator = this.getCFU("temporalAccelerator"); var energyRatio = 1 + (temporalAccelerator.val * temporalAccelerator.effects["timeRatio"]); From 8da6b3fae408412efa30d53be6946213ce6672c4 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 4 May 2019 23:23:38 -0400 Subject: [PATCH 14/58] Fix merge bug --- js/village.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/village.js b/js/village.js index c1993a8b96..ccb5dfdfce 100644 --- a/js/village.js +++ b/js/village.js @@ -554,7 +554,7 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag saveData.village = { kittens : kittens, - reserveKittens: reserveKittens, + reserveKittens: this.sim.reserveKittens, maxKittens: this.maxKittens, jobs: this.filterMetadata(this.jobs, ["name", "unlocked", "value"]), map : this.map.villageData From d116ae23a702bc06d3fa59746b088d1080483762 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 5 May 2019 00:18:21 -0400 Subject: [PATCH 15/58] Fix apotheosis reward --- js/challenges.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/challenges.js b/js/challenges.js index 78f73bf81b..a161db0202 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -319,7 +319,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa apotheosis += 1; this.rewarded = true; } - var conditionTotal = 0; + var conditionTotal = 1; for (var i = 0; i < this.conditions.length; i++) { if (this.conditions[i].on && this.conditions[i].bonus) { conditionTotal += Math.pow(this.conditions[i].bonus * (1 - this.game.getHyperBolicEffect(this.conditions[i].resets / 10, 1)), 2); @@ -330,7 +330,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa if (apotheosis) { - this.game.resPool.addRes("apotheosis", Math.floor(apotheosis), true); + this.game.resPool.addRes(this.game.resPool.get("apotheosis"), Math.floor(apotheosis), true); } }, From a575830509ed72675f863f4aeb4e8aff7c75d995 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 5 May 2019 00:58:00 -0400 Subject: [PATCH 16/58] Fix reserve issues --- js/jsx/left.jsx.js | 3 ++- js/resources.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/jsx/left.jsx.js b/js/jsx/left.jsx.js index a35750160e..957471544e 100644 --- a/js/jsx/left.jsx.js +++ b/js/jsx/left.jsx.js @@ -15,6 +15,7 @@ WResourceRow = React.createClass({ var isEqual = oldRes.value == newRes.value && + oldRes.reserveValue == newRes.value && oldRes.maxValue == newRes.maxValue && oldRes.perTickCached == newRes.perTickCached && this.props.isEditMode == nextProp.isEditMode && @@ -165,7 +166,7 @@ WResourceRow = React.createClass({ res.title || res.name ), $r("div", {className:"res-cell " + resAmtClassName + specialClass}, game.getDisplayValueExt(res.value)), - $r("div", {className:"res-cell " + resAmtClassName + specialClass + " reserve"}, game.challenges.getCondition("disableChrono").on && !res.hideReserve && res.reserveValue ? "+" + game.getDisplayValueExt(res.reserveValue) : ""), + $r("div", {className:"res-cell " + resAmtClassName + specialClass + " reserve"}, !game.challenges.getCondition("disableChrono").on && !res.hideReserve && res.reserveValue ? "+" + game.getDisplayValueExt(res.reserveValue) : ""), $r("div", {className:"res-cell maxRes"}, res.maxValue ? "/" + game.getDisplayValueExt(res.maxValue) : "" ), diff --git a/js/resources.js b/js/resources.js index 1da638e7dd..4bc65c8a7c 100644 --- a/js/resources.js +++ b/js/resources.js @@ -545,7 +545,8 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana } res.value = res.maxValue; } - + }, + handleReserve: function(res) { if (res.name == "karma" || res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") { if ((this.game.loading || !this.game.challenges.getCondition("disableMetaResources").on) && res.reserveValue) @@ -557,7 +558,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana else { if ((this.game.loading || !this.game.challenges.getCondition("disableChrono").on) && res.reserveValue && (!res.maxValue || res.value < res.maxValue)) { - if (res.maxValue && res.reserveValue > res.maxValue) { + if (res.maxValue && res.value + res.reserveValue > res.maxValue) { res.reserveValue -= (res.maxValue - res.value); res.value = res.maxValue; } @@ -684,6 +685,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var resPerTick = game.getResourcePerTick(res.name, false); this.addResPerTick(res.name, resPerTick); + this.handleReserve(res); } game.updateKarma(); From 6b2444c7933672673ff71c562398299d1910c988 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 5 May 2019 01:31:31 -0400 Subject: [PATCH 17/58] More fixes --- game.js | 2 +- js/challenges.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/game.js b/game.js index 69004fcb09..d81590e4f0 100644 --- a/game.js +++ b/game.js @@ -1560,7 +1560,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.religionTab.visible = (this.resPool.get("faith").value > 0 || this.challenges.getChallenge("atheism").on && this.bld.get("ziggurat").val > 0); this.spaceTab.visible = (this.science.get("rocketry").researched); this.timeTab.visible = (this.science.get("calendar").researched || this.time.getVSU("usedCryochambers").val > 0); - this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched; + this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched || this.prestige.getPerk("adjustmentBureau").reserve; //copied from workshop.js, very bad //when that code gets moved somewhere better call it here diff --git a/js/challenges.js b/js/challenges.js index a161db0202..d7632caa42 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -322,7 +322,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa var conditionTotal = 1; for (var i = 0; i < this.conditions.length; i++) { if (this.conditions[i].on && this.conditions[i].bonus) { - conditionTotal += Math.pow(this.conditions[i].bonus * (1 - this.game.getHyperBolicEffect(this.conditions[i].resets / 10, 1)), 2); + conditionTotal += Math.pow(this.conditions[i].bonus * (1 - this.game.getHyperbolicEffect(this.conditions[i].resets / 10, 1)), 2); } } From 53bc10b2755dc6fd8ea326a6cbb9b63313b8c486 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Wed, 15 May 2019 04:45:21 -0400 Subject: [PATCH 18/58] Fix karma disappearing on reset, energy bonus applying before challenge finished --- js/resources.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/resources.js b/js/resources.js index 4bc65c8a7c..bbcdf2ee33 100644 --- a/js/resources.js +++ b/js/resources.js @@ -571,7 +571,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana }, addRes: function(res, addedValue, event) { - if (this.game.calendar.day < 0 && !event) { + if (this.game.calendar.day < 0 && !event || addedValue == 0) { return 0; } @@ -916,7 +916,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana if (delta > 4){ delta = 4; } - if ((this.game.challenges.getChallenge("energy").on || !this.game.challenges.getChallenge("energy") || this.game.challenges.getCondition("disableRewards").on) && delta > 1) { + if ((this.game.challenges.getChallenge("energy").on || !this.game.challenges.getChallenge("energy").researched || this.game.challenges.getCondition("disableRewards").on) && delta > 1) { delta = 1; } return delta; From 16d259b8c4f5408d0054d0fd0da2d5e45a761c15 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Wed, 15 May 2019 04:48:50 -0400 Subject: [PATCH 19/58] Fix syntax error --- js/buildings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/buildings.js b/js/buildings.js index fb213bce35..a014ea2ff0 100644 --- a/js/buildings.js +++ b/js/buildings.js @@ -359,9 +359,9 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }; effects["energyProduction"] *= 1 + game.getEffect("solarFarmRatio"); if (game.calendar.season == 3) { - effects["energyProduction"] *= (1 - (0.25 / this.game.challenges.getChallengeReward("winterIsComing"))); + effects["energyProduction"] *= (1 - (0.25 / game.challenges.getChallengeReward("winterIsComing"))); } else if (game.calendar.season == 1) { - effects["energyProduction"] /= (1 - (0.25 / this.game.challenges.getChallengeReward("winterIsComing"))); + effects["energyProduction"] /= (1 - (0.25 / game.challenges.getChallengeReward("winterIsComing"))); } stageMeta.effects = effects; } From e7ce72d89af800c54dce9d138ab21deb163073a5 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Wed, 15 May 2019 18:43:45 -0400 Subject: [PATCH 20/58] Fix inverted logic --- js/village.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/village.js b/js/village.js index ccb5dfdfce..ed6dabde5c 100644 --- a/js/village.js +++ b/js/village.js @@ -1902,7 +1902,7 @@ dojo.declare("classes.ui.village.Census", null, { } }, linksDiv); - /*if (this.game.challenges.getChallenge("anarchy").on) { + /*if (!this.game.challenges.getChallenge("anarchy").on) { var senatorHref = dojo.create("a", { href: "#", innerHTML: $I("village.btn.senator"), style: { @@ -1937,7 +1937,7 @@ dojo.declare("classes.ui.village.Census", null, { } //rankExp - /*if (this.game.challenges.getChallenge("anarchy").on) { + /*if (!this.game.challenges.getChallenge("anarchy").on) { dojo.connect(senatorHref, "onclick", this, dojo.partial(function(census, i, event){ event.preventDefault(); @@ -2156,7 +2156,7 @@ dojo.declare("classes.ui.village.Census", null, { } else { dojo.style(record.unassignHref, "display", "none"); } - /*if (this.game.challenges.getChallenge("anarchy").on) { + /*if (!this.game.challenges.getChallenge("anarchy").on) { dojo.style(record.senatorHref, "display", "none"); }*/ @@ -2453,7 +2453,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.Village", com.nuclearunicorn.game.u }), controller: new classes.village.ui.VillageButtonController(this.game, { updateVisible: function (model) { - model.visible = this.game.village.leader !== undefined && this.game.workshop.get("register").researched && this.game.challenges.getChallenge("anarchy").on; + model.visible = this.game.village.leader !== undefined && this.game.workshop.get("register").researched && !this.game.challenges.getChallenge("anarchy").on; } }) }, this.game); From 360b1de46e8edb8d121cc0dc3a2dd9cd9776af32 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Thu, 16 May 2019 00:28:21 -0400 Subject: [PATCH 21/58] Allow waiting until reset to apply challenges/conditions --- game.js | 2 + js/challenges.js | 284 +++++++++++++++++++++++++++++++---------------- res/i18n/en.json | 3 + 3 files changed, 195 insertions(+), 94 deletions(-) diff --git a/game.js b/game.js index d81590e4f0..e79de44f4b 100644 --- a/game.js +++ b/game.js @@ -3399,6 +3399,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { }, _resetInternal: function(){ + this.challenges.applyPending(); + var kittens = this.resPool.get("kittens").value; var karmaKittens = this.karmaKittens; if (kittens > 35){ diff --git a/js/challenges.js b/js/challenges.js index d7632caa42..aefc25a1bf 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -27,6 +27,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, rewarded: false },{ @@ -40,6 +41,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, rewarded: false },{ @@ -53,6 +55,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, rewarded: false },{ @@ -66,6 +69,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, rewarded: false },{ @@ -79,6 +83,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, rewarded: false }], @@ -92,6 +97,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, resets: 0 },{ @@ -103,6 +109,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, resets: 0 },{ @@ -114,6 +121,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, resets: 0 },{ @@ -125,6 +133,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, resets: 0 },{ @@ -136,6 +145,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, resets: 0 },{ @@ -146,6 +156,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa togglableOnOff: true, val: 1, on: 0, + pending: false, rewardable: false, resets: 0 }], @@ -168,8 +179,8 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa save: function(saveData){ saveData.challenges = { rewarded: this.rewarded, - challenges: this.filterMetadata(this.challenges, ["name", "researched", "unlocked", "on", "rewardable", "rewarded"]), - conditions: this.filterMetadata(this.conditions, ["name", "on", "rewardable", "resets"]) + challenges: this.filterMetadata(this.challenges, ["name", "researched", "unlocked", "on", "pending", "rewardable", "rewarded"]), + conditions: this.filterMetadata(this.conditions, ["name", "on", "pending", "rewardable", "resets"]) }; }, @@ -412,6 +423,125 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa return 1 - this.game.getHyperbolicEffect(researched * 0.1, 1); } }, + + handleChallengeToggle: function(name, on) { + if (name == "atheism") + { + this.game.upgrade({buildings: ["temple"]}); + } + }, + + handleConditionToggle: function(name, on) { + if (on) + { + if (name == "disableMetaResources") + { + var metaRes = ["karma", "paragon", "burnedParagon", "apotheosis"] + for (var i = 0; i < metaRes.length; i++) + { + var res = this.game.resPool.get(metaRes[i]); + res.reserveValue = res.value; + res.value = 0; + } + + if (getCondition("disableMetaTechs").on) + { + for (var i = 0; i < this.game.prestige.perks.length; i++) + { + var perk = this.game.prestige.perks[i]; + + if (perk.defaultUnlocked) + { + perk.unlocked = true; + } + } + } + } + + if (name == "disableMetaTechs") + { + for (var i = 0; i < this.game.prestige.perks.length; i++) + { + var perk = this.game.prestige.perks[i]; + perk.reserve = perk.researched; + perk.unlocked = false; + perk.researched = false; + + if (getCondition("disableMetaResources").on && perk.defaultUnlocked) + { + perk.unlocked = true; + } + } + } + + if (name == "disableApo") + { + this.game.religion.faithRatioReserve = this.game.religion.faithRatio; + this.game.religion.faithRatio = 0; + this.game.religion.tcratioReserve = this.game.religion.tcratio; + this.game.religion.tcratio = 0; + this.game.religion.tclevel = this.game.religion.getTranscendenceLevel(); + + for (var i = 0; i < this.game.religion.transcendenceUpgrades.length; i++) + { + this.game.religion.transcendenceUpgrades[i].reserve += this.game.religion.transcendenceUpgrades[i].val; + this.game.religion.transcendenceUpgrades[i].val = 0; + this.game.religion.transcendenceUpgrades[i].on = 0; + } + } + + if (name == "disableMisc") + { + var bls = this.game.resPool.get("sorrow"); + bls.reserveValue = bls.value; + bls.value = 0; + + this.game.karmaZebrasReserve = this.game.karmaZebras; + this.game.karmaZebras = 0; + this.game.resPool.get("zebras").maxValue = 0; + this.game.resPool.get("zebras").reserveValue = this.game.resPool.get("zebras").value; + this.game.resPool.get("zebras").value = 0; + } + } + else + { + if (name == "disableMetaResources") + { + if (getCondition("disableMetaTechs").on) + { + for (var i = 0; i < this.game.prestige.perks.length; i++) + { + var perk = this.game.prestige.perks[i]; + + if (perk.defaultUnlocked) + { + perk.unlocked = false; + } + } + } + } + } + }, + + applyPending: function(){ + for (var i = 0; i < this.challenges.length; i++){ + var challenge = this.challenges[i]; + if (challenge.pending){ + challenge.pending = false; + challenge.on = 1; + this.handleChallengeToggle(challenge.name, true); + } + } + + for (var i = 0; i < this.conditions.length; i++){ + var condition = this.conditions[i]; + if (condition.pending){ + condition.pending = false; + condition.on = 1; + this.handleConditionToggle(condition.name, true); + } + } + }, getWeatherMod: function(season, res){ if (this.getChallenge("winterIsComing").on) @@ -460,11 +590,15 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui getName: function(model){ var meta = model.metadata; + name = meta.label if (meta.researched){ - return meta.label + "(" + meta.researched + ")"; - } else { - return meta.label; + name += "(" + meta.researched + ")"; } + if (meta.pending){ + name += " (" + $I("challendge.pending") + ")"; + } + + return name; }, updateVisible: function(model){ @@ -479,13 +613,22 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui }, handleTogglableOnOffClick: function(model) { + var on = model.metadata.on; + this.inherited(arguments); - - if (model.metadata.name == "atheism") + + if (!on && model.metadata.on) { - this.game.upgrade({buildings: ["temple"]}); + model.metadata.on = 0; + model.metadata.pending = !model.metadata.pending; } - } + + if (on && !model.metadata.on) + { + this.game.challenges.handleChallengeToggle(model.metadata.name, false); + } + } + }); dojo.declare("classes.ui.ConditionBtnController", com.nuclearunicorn.game.ui.BuildingBtnController, { @@ -502,6 +645,10 @@ dojo.declare("classes.ui.ConditionBtnController", com.nuclearunicorn.game.ui.Bui }, getName: function(model){ + if (model.metadata.pending){ + return model.metadata.label + " (" + $I("challendge.pending") + ")"; + } + return model.metadata.label; }, @@ -523,95 +670,15 @@ dojo.declare("classes.ui.ConditionBtnController", com.nuclearunicorn.game.ui.Bui if (!on && model.metadata.on) { - if (model.metadata.name == "disableMetaResources") - { - var metaRes = ["karma", "paragon", "burnedParagon", "apotheosis"] - for (var i = 0; i < metaRes.length; i++) - { - var res = this.game.resPool.get(metaRes[i]); - res.reserveValue = res.value; - res.value = 0; - } - - if (this.game.challenges.getCondition("disableMetaTechs").on) - { - for (var i = 0; i < this.game.prestige.perks.length; i++) - { - var perk = this.game.prestige.perks[i]; - - if (perk.defaultUnlocked) - { - perk.unlocked = true; - } - } - } - } - - if (model.metadata.name == "disableMetaTechs") - { - for (var i = 0; i < this.game.prestige.perks.length; i++) - { - var perk = this.game.prestige.perks[i]; - perk.reserve = perk.researched; - perk.unlocked = false; - perk.researched = false; - - if (this.game.challenges.getCondition("disableMetaResources").on && perk.defaultUnlocked) - { - perk.unlocked = true; - } - } - } - - if (model.metadata.name == "disableApo") - { - this.game.religion.faithRatioReserve = this.game.religion.faithRatio; - this.game.religion.faithRatio = 0; - this.game.religion.tcratioReserve = this.game.religion.tcratio; - this.game.religion.tcratio = 0; - this.game.religion.tclevel = this.game.religion.getTranscendenceLevel(); - - for (var i = 0; i < this.game.religion.transcendenceUpgrades.length; i++) - { - this.game.religion.transcendenceUpgrades[i].reserve += this.game.religion.transcendenceUpgrades[i].val; - this.game.religion.transcendenceUpgrades[i].val = 0; - this.game.religion.transcendenceUpgrades[i].on = 0; - } - } - - if (model.metadata.name == "disableMisc") - { - var bls = this.game.resPool.get("sorrow"); - bls.reserveValue = bls.value; - bls.value = 0; - - this.game.karmaZebrasReserve = this.game.karmaZebras; - this.game.karmaZebras = 0; - this.game.resPool.get("zebras").maxValue = 0; - this.game.resPool.get("zebras").reserveValue = this.game.resPool.get("zebras").value; - this.game.resPool.get("zebras").value = 0; - } + model.metadata.on = 0; + model.metadata.pending = !model.metadata.pending; } - + if (on && !model.metadata.on) { - if (model.metadata.name == "disableMetaResources") - { - if (this.game.challenges.getCondition("disableMetaTechs").on) - { - for (var i = 0; i < this.game.prestige.perks.length; i++) - { - var perk = this.game.prestige.perks[i]; - - if (perk.defaultUnlocked) - { - perk.unlocked = false; - } - } - } - } + this.game.challenges.handleConditionToggle(model.metadata.name, false); } - }, + } }); dojo.declare("classes.ui.ChallengePanel", com.nuclearunicorn.game.ui.Panel, { @@ -665,10 +732,39 @@ dojo.declare("classes.tab.ChallengesTab", com.nuclearunicorn.game.ui.tab, { this.conditionsPanel = new classes.ui.ConditionPanel($I("challendge.condition.panel.label"), this.game.challenges); this.conditionsPanel.game = this.game; this.conditionsPanel.render(container); + + var applyPendingBtn = new com.nuclearunicorn.game.ui.ButtonModern({ + name: $I("challendge.applyPending.label"), + description: $I("challendge.applyPending.desc"), + handler: dojo.hitch(this, function(){ + this.game.challenges.applyPending(); + }), + controller: new com.nuclearunicorn.game.ui.ButtonController(this.game, { + updateVisible: function (model) { + var visible = false; + for (var i = 0; i < this.game.challenges.challenges.length; i++){ + if (this.game.challenges.challenges[i].pending){ + visible = true + } + } + + for (var i = 0; i < this.game.challenges.conditions.length; i++){ + if (this.game.challenges.conditions[i].pending){ + visible = true; + } + } + + model.visible = visible; + } + }) + }, this.game); + applyPendingBtn.render(container); + this.applyPendingBtn = applyPendingBtn; }, update: function(){ this.challengesPanel.update(); this.conditionsPanel.update(); + this.applyPendingBtn.update(); } }); diff --git a/res/i18n/en.json b/res/i18n/en.json index 976366afd4..07e610dbe5 100644 --- a/res/i18n/en.json +++ b/res/i18n/en.json @@ -276,6 +276,9 @@ "challendge.condition.disableRewards.desc": "All Challenge Rewards effects will be disabled until this is re-enabled. Challenges still grant rewards. Increases challenge rewards.", "challendge.condition.disableMisc.label": "No Miscellaneous", "challendge.condition.disableMisc.desc": "BLS and Iron Will Zebras will be reset until this is re-enabled. Does NOT increase challenge rewards.", + "challendge.pending": "Pending", + "challendge.applyPending.label": "Apply Pending Changes", + "challendge.applyPending.desc": "Turn on Challenges/Conditions marked as Pending immediately", "space.centaurusSystemMission.desc": "Centaurus System is a warm faraway star system.", "space.centaurusSystemMission.label": "Centaurus System Mission", From 7221968e58df027065aa4e3c805c99dd627747ea Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 17 May 2019 22:04:33 -0400 Subject: [PATCH 22/58] Properly reset challenge state --- js/challenges.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/challenges.js b/js/challenges.js index aefc25a1bf..9cb50629d9 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -168,11 +168,19 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa for (var i = 0; i < this.challenges.length; i++){ var challenge = this.challenges[i]; challenge.on = 0; + challenge.researched = 0; + challenge.unlocked = (challenge.name == "ironWill" || challenge.name == "winterIsComing" || challenge.name == "anarchy") + challenge.pending = false; + challenge.rewardable = false; + challenge.rewarded = false; } for (var i = 0; i < this.conditions.length; i++){ var condition = this.conditions[i]; condition.on = 0; + condition.pending = false; + condition.rewardable = false; + condition.resets = 0; } }, From a91d4c912f3d6365e2cb8a7ff849b21ebd652b9b Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 17 May 2019 22:27:00 -0400 Subject: [PATCH 23/58] Make Iron Will stuff less confusing --- js/challenges.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/challenges.js b/js/challenges.js index 9cb50629d9..e3aa8882eb 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -208,6 +208,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa }, update: function(){ + this.getChallenge("ironWill").on = this.game.ironWill; // energy if (this.getChallenge("energy").unlocked == false) { if (this.game.resPool.energyProd != 0 || this.game.resPool.energyCons != 0) { @@ -611,6 +612,7 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui updateVisible: function(model){ model.visible = model.metadata.unlocked; + model.enabled = model.metadata.name != "ironWill"; // hack }, getPrices: function(model) { From 3066cb4c0622bf86c78bb5d5d7e99fde1b60dd19 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 17 May 2019 22:36:29 -0400 Subject: [PATCH 24/58] Description fixes --- js/challenges.js | 2 +- res/i18n/en.json | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js/challenges.js b/js/challenges.js index e3aa8882eb..4a6eb3e777 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -589,7 +589,7 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui getDescription: function(model) { if (this.game.bld.get("chronosphere").val > 0) { - var msgChronosphere = model.metadata.name == "ironWill" ? $I("challendge.btn.chronosphere.with.ironWill.desc"): $I("challendge.btn.chronosphere.desc"); + var msgChronosphere = model.metadata.name == "ironWill" ? $I("challendge.btn.chronosphere.with.ironWill.desc") : ""; } else { var msgChronosphere = ""; } diff --git a/res/i18n/en.json b/res/i18n/en.json index 07e610dbe5..e4283d2ad3 100644 --- a/res/i18n/en.json +++ b/res/i18n/en.json @@ -247,11 +247,10 @@ "challendge.atheism.desc": "Restart the game without faith bonus.

Goal: Reset with at least one cryochamber.", "challendge.atheism.effect.desc": "Increase your faith bonus limit by 100% per transcendence tier (equivalent to 20 Black Obelisks).", "challendge.atheism.label": "Atheism", - "challendge.btn.chronosphere.desc": " You won't gain reset bonus from chronospheres.", - "challendge.btn.chronosphere.with.ironWill.desc": " You won't gain reset bonus from chronospheres.
WARNING: the reset bonus from chronospheres will automatically disable IW.", + "challendge.btn.chronosphere.with.ironWill.desc": " WARNING: the reset bonus from chronospheres will automatically disable IW.", "challendge.btn.confirmation.dlg.text": "Are you sure you want to start this challenge by resetting the game ?", "challendge.btn.confirmation.dlg.title": "Challenge confirmation", - "challendge.btn.desc": "
Gain: {0}

Your game will be reset in order to enable this challenge. {1}", + "challendge.btn.desc": "
Gain: {0}

{1}", "challendge.btn.log.message.on.complete": "Congratulations! You complete the challenge {0}.", "challendge.energy.desc": "Restart the game with consumption of energy multiply by 2.

Goal: Unlock all energy production buildings and build at least one of them.", "challendge.energy.effect.desc": "Production bonuses cuts caused by negative energy are divided by 2.", From 3b4a18e5fd5a8697f9cbe357b5ed964b6bb9de82 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Thu, 23 May 2019 00:30:00 -0400 Subject: [PATCH 25/58] Clean up most egregious hack --- game.js | 31 +------------------------------ js/workshop.js | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/game.js b/game.js index e79de44f4b..19de1a64b3 100644 --- a/game.js +++ b/game.js @@ -1562,36 +1562,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.timeTab.visible = (this.science.get("calendar").researched || this.time.getVSU("usedCryochambers").val > 0); this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched || this.prestige.getPerk("adjustmentBureau").reserve; - //copied from workshop.js, very bad - //when that code gets moved somewhere better call it here - var scienceMaxBuilding = this.bld.getEffect("scienceMax"), - scienceMaxCompendiaCap = this.bld.getEffect("scienceMaxCompendia"), - compendiaScienceMax = Math.floor(this.resPool.get("compedium").value * 10); - - //iw compedia cap is set to 1000% instead of 100% - var iwScienceCapRatio = this.ironWill ? 10 : 1; - - var blackLibrary = this.religion.getTU("blackLibrary"); - if (this.prestige.getPerk("codexLeviathanianus").researched){ - var ttBoostRatio = ( - 0.05 * ( - 1 + - blackLibrary.val * ( - blackLibrary.effects["compendiaTTBoostRatio"] + - this.getEffect("blackLibraryBonus") ) - ) - ); - iwScienceCapRatio *= (1 + ttBoostRatio * this.religion.getTranscendenceLevel()); - } - - if (compendiaScienceMax > (scienceMaxBuilding * iwScienceCapRatio + scienceMaxCompendiaCap)){ - compendiaScienceMax = (scienceMaxBuilding * iwScienceCapRatio + scienceMaxCompendiaCap); - } - - this.workshop.effectsBase["scienceMax"] = compendiaScienceMax; - var cultureBonusRaw = Math.floor(this.resPool.get("manuscript").value); - this.workshop.effectsBase["cultureMax"] = this.getTriValue(cultureBonusRaw, 0.01); - this.workshop.effectsBase["oilMax"] = Math.floor(this.resPool.get("tanker").value * 500); + this.workshop.calculateMaxEffects(); this.updateCaches(); diff --git a/js/workshop.js b/js/workshop.js index a4825ec349..7aed4253db 100644 --- a/js/workshop.js +++ b/js/workshop.js @@ -2328,14 +2328,7 @@ dojo.declare("classes.managers.WorkshopManager", com.nuclearunicorn.core.TabMana this.game.village.sim.clearCraftJobs(); }, - update: function(){ - this.fastforward(1 / this.game.calendar.ticksPerDay); - }, - - fastforward: function(daysOffset) { - var times = daysOffset * this.game.calendar.ticksPerDay; - - //------------- this is a poor place for this kind of functionality ------------ + calculateMaxEffects: function(){ var scienceMaxBuilding = this.game.bld.getEffect("scienceMax"), scienceMaxCompendiaCap = this.game.bld.getEffect("scienceMaxCompendia"), compendiaScienceMax = Math.floor(this.game.resPool.get("compedium").value * 10); @@ -2365,6 +2358,17 @@ dojo.declare("classes.managers.WorkshopManager", com.nuclearunicorn.core.TabMana var cultureBonusRaw = Math.floor(this.game.resPool.get("manuscript").value); this.effectsBase["cultureMax"] = this.game.getTriValue(cultureBonusRaw, 0.01); this.effectsBase["oilMax"] = Math.floor(this.game.resPool.get("tanker").value * 500); + }, + + update: function(){ + this.fastforward(1 / this.game.calendar.ticksPerDay); + }, + + fastforward: function(daysOffset) { + var times = daysOffset * this.game.calendar.ticksPerDay; + + //------------- this is a poor place for this kind of functionality ------------ + this.calculateMaxEffects(); //sanity check if (this.game.village.getFreeEngineer() < 0){ From 28d91b972c0cbcf6b11a03f7f2ffcfaa5028a809 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 24 May 2019 01:29:02 -0400 Subject: [PATCH 26/58] Bunch of fixes --- game.js | 14 ++++++++++++-- js/challenges.js | 23 ++++++++++++++++++----- js/jsx/left.jsx.js | 2 +- js/resources.js | 7 +++++++ 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/game.js b/game.js index 19de1a64b3..c6d5d20ecf 100644 --- a/game.js +++ b/game.js @@ -3448,8 +3448,9 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var saveRatio = this.bld.get("chronosphere").val > 0 ? this.getEffect("resStasisRatio") : 0; // resStasisRatio excepted when challenge dojo.mixin(lsData.game, { - karmaKittens: karmaKittens, - karmaZebras: karmaZebras, + karmaKittens: (this.challenges.getCondition("disableMetaResources").on && this.challenges.getCondition("disableMetaResources").resets == 0) ? 0 : karmaKittens, + karmaZebras: (this.challenges.getCondition("disableMisc").on && this.challenges.getCondition("disableMisc").resets == 0) ? 0 : karmaZebras, + karmaZebrasReserve: (this.challenges.getCondition("disableMisc").on && this.challenges.getCondition("disableMisc").resets == 0) ? karmaZebras : 0, ironWill : saveRatio > 0 ? false : true, //chronospheres will disable IW deadKittens: 0, isCMBREnabled: false @@ -3499,6 +3500,9 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (res.maxValue || (this.challenges.getCondition("disableChrono").on && !res.persists)) { newRes.reserveValue = (this.challenges.getCondition("disableChrono").on ? res.reserveValue : 0) + value; } + else if ((res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") && this.challenges.getCondition("disableMetaResources").on && this.challenges.getCondition("disableMetaResources").resets == 0) { + newRes.reserveValue = this.resPool.get(res.name).reserveValue + value; + } else { newRes.value = value; } @@ -3506,6 +3510,12 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } } + if (this.challenges.getCondition("disableMetaResources").on && this.challenges.getCondition("disableMetaResources").resets == 0) { + var newRes = this.resPool.createResource("karma"); + newRes.reserveValue = this.getTriValue(Math.round(this.getTriValueOrigin(this.resPool.get("karma").reserveValue, 5)) + karmaKittens, 5); + newResources.push(newRes); + } + var newKittens= []; if (this.time.getVSU("cryochambers").on > 0) { var kittens = this.village.sim.kittens; diff --git a/js/challenges.js b/js/challenges.js index 4a6eb3e777..95248bc7fc 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -162,9 +162,13 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa }], game: null, + rewardable: false, rewarded: false, resetState: function(){ + this.rewardable = false; + this.rewarded = false; + for (var i = 0; i < this.challenges.length; i++){ var challenge = this.challenges[i]; challenge.on = 0; @@ -186,6 +190,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa save: function(saveData){ saveData.challenges = { + rewardable: this.rewardable, rewarded: this.rewarded, challenges: this.filterMetadata(this.challenges, ["name", "researched", "unlocked", "on", "pending", "rewardable", "rewarded"]), conditions: this.filterMetadata(this.conditions, ["name", "on", "pending", "rewardable", "resets"]) @@ -197,6 +202,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa return; } + this.rewardable = saveData.challenges.rewardable; this.rewarded = saveData.challenges.rewarded; this.loadMetadata(this.challenges, saveData.challenges.challenges); @@ -334,7 +340,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa } } - if (!this.rewarded) + if (this.rewardable && !this.rewarded) { apotheosis += 1; this.rewarded = true; @@ -449,11 +455,13 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa for (var i = 0; i < metaRes.length; i++) { var res = this.game.resPool.get(metaRes[i]); - res.reserveValue = res.value; + res.reserveValue += res.value; res.value = 0; } - if (getCondition("disableMetaTechs").on) + this.game.karmaKittens = 0; + + if (this.getCondition("disableMetaTechs").on) { for (var i = 0; i < this.game.prestige.perks.length; i++) { @@ -476,7 +484,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa perk.unlocked = false; perk.researched = false; - if (getCondition("disableMetaResources").on && perk.defaultUnlocked) + if (this.getCondition("disableMetaResources").on && perk.defaultUnlocked) { perk.unlocked = true; } @@ -516,7 +524,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa { if (name == "disableMetaResources") { - if (getCondition("disableMetaTechs").on) + if (this.getCondition("disableMetaTechs").on) { for (var i = 0; i < this.game.prestige.perks.length; i++) { @@ -623,6 +631,11 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui }, handleTogglableOnOffClick: function(model) { + if (model.metadata.name == "ironWill") + { + return; + } + var on = model.metadata.on; this.inherited(arguments); diff --git a/js/jsx/left.jsx.js b/js/jsx/left.jsx.js index 957471544e..91180aa380 100644 --- a/js/jsx/left.jsx.js +++ b/js/jsx/left.jsx.js @@ -111,7 +111,7 @@ WResourceRow = React.createClass({ if (game.challenges.getChallenge("winterIsComing").on) { - var modifier = (game.challenges.getChallengePenalty("winterIsComing"), (game.calendar.weather || "normal") + "Mod"); + var modifier = game.challenges.getChallengePenalty("winterIsComing", (game.calendar.weather || "normal") + "Mod"); } else { diff --git a/js/resources.js b/js/resources.js index bbcdf2ee33..6fe890a300 100644 --- a/js/resources.js +++ b/js/resources.js @@ -553,6 +553,12 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana { res.value += res.reserveValue; res.reserveValue = 0; + + if (res.name == "karma") + { + this.game.karmaKittens = Math.round(this.game.getTriValueOrigin(res.value, 5)); + res.value = this.game.getTriValue(this.game.karmaKittens, 5); + } } } else @@ -668,6 +674,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana } else if (res.value == 0 && res.unlocked == true) { if (res.name == "zebras" || res.name == "paragon" || + res.name == "apotheosis" || res.name == "elderBox"){ res.unlocked = false; } From 782051b35ab896ad82fed9b3961c4ecfeecc9704 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 24 May 2019 01:58:44 -0400 Subject: [PATCH 27/58] Reset ALL THE THINGS --- js/challenges.js | 7 +++++++ js/resources.js | 11 ++++++++++- res/i18n/en.json | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/js/challenges.js b/js/challenges.js index 95248bc7fc..be8b4dab09 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -518,6 +518,13 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa this.game.resPool.get("zebras").maxValue = 0; this.game.resPool.get("zebras").reserveValue = this.game.resPool.get("zebras").value; this.game.resPool.get("zebras").value = 0; + + var box = this.game.resPool.get("elderBox"); + box.reserveValue = box.value; + box.value = 0; + var paper = this.game.resPool.get("wrappingPaper"); + paper.reserveValue = paper.value; + paper.value = 0; } } else diff --git a/js/resources.js b/js/resources.js index 6fe890a300..e9d370a30b 100644 --- a/js/resources.js +++ b/js/resources.js @@ -561,6 +561,14 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana } } } + else if (res.name == "elderBox" || res.name == "wrappingPaper") + { + if ((this.game.loading || !this.game.challenges.getCondition("disableMisc").on) && res.reserveValue) + { + res.value += res.reserveValue; + res.reserveValue = 0; + } + } else { if ((this.game.loading || !this.game.challenges.getCondition("disableChrono").on) && res.reserveValue && (!res.maxValue || res.value < res.maxValue)) { @@ -675,7 +683,8 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana if (res.name == "zebras" || res.name == "paragon" || res.name == "apotheosis" || - res.name == "elderBox"){ + res.name == "elderBox" || + res.name == "wrappingPaper"){ res.unlocked = false; } } diff --git a/res/i18n/en.json b/res/i18n/en.json index e4283d2ad3..8d15ff60d6 100644 --- a/res/i18n/en.json +++ b/res/i18n/en.json @@ -274,7 +274,7 @@ "challendge.condition.disableRewards.label": "No Challenge Rewards", "challendge.condition.disableRewards.desc": "All Challenge Rewards effects will be disabled until this is re-enabled. Challenges still grant rewards. Increases challenge rewards.", "challendge.condition.disableMisc.label": "No Miscellaneous", - "challendge.condition.disableMisc.desc": "BLS and Iron Will Zebras will be reset until this is re-enabled. Does NOT increase challenge rewards.", + "challendge.condition.disableMisc.desc": "BLS, Iron Will Zebras, and Present Boxes/Wrapping Paper will be reset until this is re-enabled. Does NOT increase challenge rewards.", "challendge.pending": "Pending", "challendge.applyPending.label": "Apply Pending Changes", "challendge.applyPending.desc": "Turn on Challenges/Conditions marked as Pending immediately", From 00dc12abe36db0b13900a363f5e8437fdfe36b7f Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 2 Jun 2019 23:06:33 -0400 Subject: [PATCH 28/58] Apply cap when cap changes --- js/resources.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/resources.js b/js/resources.js index e9d370a30b..58a477e8d2 100644 --- a/js/resources.js +++ b/js/resources.js @@ -701,6 +701,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var resPerTick = game.getResourcePerTick(res.name, false); this.addResPerTick(res.name, resPerTick); + this.handleLimits(res); this.handleReserve(res); } From 158685262eff9f0df32efefd8f22e06fb416cd4d Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 2 Jun 2019 23:27:48 -0400 Subject: [PATCH 29/58] Minor bug fix --- game.js | 1 + js/challenges.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/game.js b/game.js index c6d5d20ecf..f18aca21ce 100644 --- a/game.js +++ b/game.js @@ -2049,6 +2049,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (save.challenges.currentChallenge) { this.challenges.getCondition("disableChrono").on = 1; this.challenges.getCondition("disableChrono").rewardable = true; + this.challenges.rewardable = true; } } diff --git a/js/challenges.js b/js/challenges.js index be8b4dab09..301f2aa49a 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -202,7 +202,8 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa return; } - this.rewardable = saveData.challenges.rewardable; + if (saveData.challenges.rewardable) + this.rewardable = saveData.challenges.rewardable; this.rewarded = saveData.challenges.rewarded; this.loadMetadata(this.challenges, saveData.challenges.challenges); From 2d9520058c38c36adafebc4eba3e401be8864f75 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 2 Jun 2019 23:34:21 -0400 Subject: [PATCH 30/58] Minor ui --- js/challenges.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/challenges.js b/js/challenges.js index 301f2aa49a..c746477c01 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -617,7 +617,7 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui var meta = model.metadata; name = meta.label if (meta.researched){ - name += "(" + meta.researched + ")"; + name += " (" + meta.researched + ")"; } if (meta.pending){ name += " (" + $I("challendge.pending") + ")"; From d174754d3ee41430fc9c3f142891750a92b3133e Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 15 Jun 2019 18:58:31 -0400 Subject: [PATCH 31/58] This fixes loads of issues on reset, but probably causes a bunch too and is a mess. Needs serious work --- game.js | 40 ++++++++++++++++++++++++++++------------ js/resources.js | 2 +- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/game.js b/game.js index 9c95e2ccd3..a0f16f3cd9 100644 --- a/game.js +++ b/game.js @@ -3432,6 +3432,14 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { }, _resetInternal: function(){ + var faithRatio = this.religion.faithRatio; + //pre-reset faith so people who forgot to do it properly would not be screwed + if (this.religion.getRU("apocripha").on){ + faithRatio += this.religion.getApocryphaResetBonus(1); + } + //------------------------------------------------------------------------------------------------------ + + var paragonBonus = this.challenges.getParagonBonus(); this.challenges.applyPending(); var kittens = this.resPool.get("kittens").value; @@ -3442,7 +3450,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var paragonPoints = 0; if (kittens > 70){ - paragonPoints = (kittens - 70) * (1 + this.challenges.getParagonBonus()); + paragonPoints = (kittens - 70) * (1 + paragonBonus); } var addRes = { @@ -3488,13 +3496,6 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { karmaZebras += bonusZebras; } - var faithRatio = this.religion.faithRatio; - //pre-reset faith so people who forgot to do it properly would not be screwed - if (this.religion.getRU("apocripha").on){ - faithRatio += this.religion.getApocryphaResetBonus(1); - } - //------------------------------------------------------------------------------------------------------ - // Trigger a save to make sure we're working with most recent data this.save(); @@ -3535,21 +3536,29 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { continue; //>: } var value = 0; + var reserveValue = 0; if (res.name == "timeCrystal"){ if (anachronomancy.researched){ value = res.value; } + else if (anachronomancy.reserve){ + reserveValue = res.reserveValue + (this.challenges.getCondition("disableChrono").on && this.challenges.getCondition("disableChrono").resets == 0) ? res.value : 0; + } } else if (res.persists){ value = res.value; + reserveValue = res.reserveValue; } else { if (!res.craftable || res.name == "wood"){ value = res.value * saveRatio; + reserveValue = (this.challenges.getCondition("disableChrono").on && this.challenges.getCondition("disableChrono").resets > 0) ? res.reserveValue : res.reserveValue * saveRatio; if (res.name == "void") { value = Math.floor(value); + reserveValue = Math.floor(reserveValue); } } else if (res.value > 0) { value = Math.sqrt(res.value) * saveRatio * 100; + reserveValue = (this.challenges.getCondition("disableChrono").on && this.challenges.getCondition("disableChrono").resets > 0) ? res.reserveValue : Math.sqrt(res.value + res.reserveValue) * saveRatio * 100 - value; } } @@ -3557,16 +3566,17 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { value += addRes[res.name]; } - if (value > 0){ + if (value > 0 || reserveValue > 0 || this.resPool.get(res.name).reserveValue > 0){ var newRes = this.resPool.createResource(res.name); if (res.maxValue || (this.challenges.getCondition("disableChrono").on && !res.persists)) { - newRes.reserveValue = (this.challenges.getCondition("disableChrono").on ? res.reserveValue : 0) + value; + newRes.reserveValue = value + reserveValue; } else if ((res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") && this.challenges.getCondition("disableMetaResources").on && this.challenges.getCondition("disableMetaResources").resets == 0) { newRes.reserveValue = this.resPool.get(res.name).reserveValue + value; } else { newRes.value = value; + newRes.reserveValue = reserveValue; } newResources.push(newRes); } @@ -3620,6 +3630,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (this.challenges.challenges[i].on && this.challenges.getCondition("disableChrono").on) { this.challenges.challenges[i].rewardable = true; } + + this.challenges.challenges[i].rewarded = false; } for (var i = 0; i < this.challenges.conditions.length; i++) { @@ -3639,6 +3651,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { cryptoPrice: this.calendar.cryptoPrice }, challenges: { + rewardable: this.challenges.getCondition("disableChrono").on ? true : false, + rewarded: false, challenges: this.challenges.challenges, conditions: this.challenges.conditions }, @@ -3649,11 +3663,13 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { perks: this.prestige.perks }, religion: { - faithRatio: faithRatio, + faithRatio: (this.challenges.getCondition("disableApo").on && this.challenges.getCondition("disableApo").resets == 1) ? 0 : faithRatio, tcratio: this.religion.tcratio, + faithRatioReserve: this.religion.faithRatioReserve, + tcratioReserve: this.religion.tcratioReserve, zu: [], ru: [], - tu: this.religion.filterMetadata(this.religion.transcendenceUpgrades, ["name", "val", "on", "unlocked"]) + tu: this.religion.filterMetadata(this.religion.transcendenceUpgrades, ["name", "val", "on", "unlocked", "reserve"]) }, science: { hideResearched: false, diff --git a/js/resources.js b/js/resources.js index 58a477e8d2..573322ff4f 100644 --- a/js/resources.js +++ b/js/resources.js @@ -539,7 +539,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana handleLimits: function(res) { if(res.maxValue && res.value > res.maxValue) { - if (this.game.migrating) { + if (this.game.migrating && res.name != "temporalFlux") { // Give the benefit of the doubt res.reserveValue = res.value - res.maxValue; } From bcd872448ffeaa7813243792e0299ed608f4299a Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Tue, 20 Aug 2019 00:34:21 -0400 Subject: [PATCH 32/58] Complete rewrite, code cleanup, improvements --- game.js | 324 ++++++++---------- js/buildings.js | 27 +- js/calendar.js | 57 ++-- js/challenges.js | 793 ++++++++++++++++++++++----------------------- js/jsx/left.jsx.js | 23 +- js/prestige.js | 27 +- js/religion.js | 33 +- js/resources.js | 141 +++----- js/science.js | 7 - js/space.js | 6 + js/time.js | 40 +-- js/toolbar.js | 9 +- js/ui.js | 4 +- js/village.js | 42 ++- res/i18n/en.json | 52 +-- 15 files changed, 727 insertions(+), 858 deletions(-) diff --git a/game.js b/game.js index 280786351a..a3c87ff2b1 100644 --- a/game.js +++ b/game.js @@ -36,6 +36,12 @@ dojo.declare("classes.game.Timer", null, { } }, + resetState: function(){ + for (var i=0; i < this.handlers.length; i++){ + this.handlers[i].phase = 0; + } + }, + scheduleEvent: function(handler){ this.scheduledHandlers.push(handler); }, @@ -1087,14 +1093,14 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { //on a side note, I hate those flags. Could we use gamePage.opts = []/{}; ? karmaKittens: 0, //counter for karmic reincarnation + karmaKittensReserve: 0, karmaZebras: 0, karmaZebrasReserve: 0, deadKittens: 0, ironWill: true, //true if player has no kittens or housing buildings saveVersion: 16, - loading: false, - migrating: false, + migrateResources: false, //FINALLY opts: null, @@ -1227,7 +1233,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.timeTab = new classes.tab.TimeTab({name:$I("tab.name.time"), id:"Time"}, this); this.timeTab.visible = false; this.addTab(this.timeTab); - + this.challengesTab = new classes.tab.ChallengesTab({name:$I("tab.name.challenges"), id:"Challenges"}, this); this.challengesTab.visible = false; this.addTab(this.challengesTab); @@ -1378,6 +1384,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.useWorkers = false; this.colorScheme = ""; this.karmaKittens = 0; + this.karmaKittensReserve = 0; this.karmaZebras = 0; this.karmaZebrasReserve = 0; this.ironWill = true; @@ -1407,6 +1414,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { forceLZ: false }; + this.timer.resetState(); this.resPool.resetState(); this.village.resetState(); this.calendar.resetState(); @@ -1439,7 +1447,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var saveData = { saveVersion: this.saveVersion, resources: this.resPool.filterMetadata( - this.resPool.resources, ["name", "value", "reserveValue", "unlocked", "isHidden"] + this.resPool.resources, ["name", "value", "reserve", "unlocked", "isHidden"] ) }; @@ -1459,6 +1467,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { useWorkers: this.useWorkers, colorScheme: this.colorScheme, karmaKittens: this.karmaKittens, + karmaKittensReserve: this.karmaKittensReserve, karmaZebras: this.karmaZebras, karmaZebrasReserve: this.karmaZebrasReserve, ironWill : this.ironWill, @@ -1556,9 +1565,6 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.updateOptionsUI(); return; } - - this.loading = true; - var success = true; try { @@ -1601,7 +1607,6 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { // Calculate effects (needs to be done after all managers are loaded) this.calculateAllEffects(); - this.updateCaches(); if (saveData && saveData.game){ var data = saveData.game; @@ -1611,6 +1616,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.colorScheme = data.colorScheme ? data.colorScheme : null; this.karmaKittens = (data.karmaKittens !== undefined) ? data.karmaKittens : 0; + this.karmaKittensReserve = (data.karmaKittensReserve !== undefined) ? data.karmaKittensReserve : 0; this.karmaZebras = (data.karmaZebras !== undefined) ? data.karmaZebras : 0; this.karmaZebrasReserve = (data.karmaZebrasReserve !== undefined) ? data.karmaZebrasReserve : 0; this.deadKittens = (data.deadKittens !== undefined) ? data.deadKittens : 0; @@ -1639,54 +1645,15 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.libraryTab.visible = (this.bld.get("library").on > 0); this.workshopTab.visible = (this.bld.get("workshop").on > 0); this.achievementTab.visible = (this.achievements.hasUnlocked()); - this.statsTab.visible = (this.karmaKittens > 0 || this.science.get("math").researched); + this.statsTab.visible = (this.karmaKittens > 0 || this.karmaKittensReserve > 0 || this.science.get("math").researched); this.diplomacyTab.visible = (this.diplomacy.hasUnlockedRaces()); this.religionTab.visible = (this.resPool.get("faith").value > 0 || this.challenges.getChallenge("atheism").on && this.bld.get("ziggurat").val > 0); this.spaceTab.visible = (this.science.get("rocketry").researched); this.timeTab.visible = (this.science.get("calendar").researched || this.time.getVSU("usedCryochambers").val > 0); - this.challengesTab.visible = this.prestige.getPerk("adjustmentBureau").researched || this.prestige.getPerk("adjustmentBureau").reserve; - - this.workshop.calculateMaxEffects(); - - this.updateCaches(); - - this.bld.get("pasture").action(this.bld.get("pasture"), this); - this.bld.get("oilWell").action(this.bld.get("oilWell"), this); - this.bld.get("reactor").action(this.bld.get("reactor"), this); - - this.resPool.energyProd = this.getEffect("energyProduction") * (1 + game.getEffect("energyProductionRatio")); - this.resPool.energyCons = this.getEffect("energyConsumption") * this.challenges.getChallengePenalty("energy") / this.challenges.getChallengeReward("energy"); - - - this.bld.get("observatory").action(this.bld.get("observatory"), this); - this.bld.get("amphitheatre").action(this.bld.get("amphitheatre"), this); - this.space.getBuilding("spaceBeacon").action(this.space.getBuilding("spaceBeacon"), this); - - this.updateCaches(); - - for (var i in this.resPool.resources) { - var res = this.resPool.resources[i]; - var maxValue = this.getEffect(res.name + "Max") || 0; - - maxValue = this.resPool.addResMaxRatios(res, maxValue); - - if (maxValue < 0 ){ - maxValue = 0; - } - - res.maxValue = maxValue; - } - - this.loading = false; - for (var i in this.resPool.resources) { - var res = this.resPool.resources[i]; - this.resPool.handleLimits(res); - } - this.migrating = false; + this.challengesTab.visible = (this.prestige.getPerk("adjustmentBureau").researched || this.prestige.getPerk("adjustmentBureau").reserve); - this.ui.load(); - this.render(); + this.ui.load(); return success; }, @@ -1831,6 +1798,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.load(); this.msg($I("save.import.msg")); + this.render(); + callback(); } catch (e) { console.log("Couldn't import the save of the game:"+e.stack); @@ -2125,27 +2094,26 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { save.saveVersion = 15; } - + if (save.saveVersion == 15) { if (save.challenges && save.challenges.challenges) { for (var i = 0; i < save.challenges.challenges.length; i++) { - if (save.challenges.challenges[i].name == save.challenges.currentChallenge) { - save.challenges.challenges[i].on = 1; - save.challenges.challenges[i].rewardable = true; + var challenge = save.challenges.challenges[i]; + if (challenge.name == save.challenges.currentChallenge) { + challenge.on = true; + challenge.rewardable = true; + + save.challenges.conditions = [{name: "disableChrono", on: true}]; + save.challenges.rewardable = true; } - - save.challenges.challenges[i].researched = save.challenges.challenges[i].researched ? 1 : 0; - } - - if (save.challenges.currentChallenge) { - this.challenges.getCondition("disableChrono").on = 1; - this.challenges.getCondition("disableChrono").rewardable = true; - this.challenges.rewardable = true; + + challenge.researched = challenge.researched ? 1 : 0; } } - + + this.migrateResources = true; + save.saveVersion = 16; - this.migrating = true; } return save; @@ -2237,19 +2205,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { perTick += perTickBaseSpace; // *SEASON MODIFIERS - if (!season){ - var season = this.calendar.getCurSeason(); - } - - var weatherMod = this.challenges.getWeatherMod(season, res); - - if (weatherMod < -0.95){ - weatherMod = -0.95; - } - - if (season.modifiers[res.name]){ - perTick *= weatherMod; - } + perTick *= this.calendar.getWeatherMod(res); // +VILLAGE JOB PRODUCTION var resMapProduction = this.village.getResProduction(); @@ -2321,7 +2277,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } // +*FAITH BONUS - perTick *= 1 + (this.religion.getProductionBonus() / 100 * (resName == "faith" ? this.challenges.getChallengeReward("atheism") : 1)); + perTick *= 1 + (this.religion.getProductionBonus() * (res.name == "faith" ? this.challenges.getChallengeReward("atheism") : 1) / 100); //+COSMIC RADIATION if (!this.opts.disableCMBR && res.name != "coal") { @@ -2426,20 +2382,10 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { stack.push(perTickBaseSpaceStack); // *SEASON MODIFIERS - if (!season){ - var season = this.calendar.getCurSeason(); - } - - var weatherMod = this.challenges.getWeatherMod(season, res); - - if (weatherMod < -0.95){ - weatherMod = -0.95; - } - stack.push({ name: $I("res.stack.weather"), type: "ratio", - value: weatherMod - 1 + value: this.calendar.getWeatherMod(res) - 1 }); // +VILLAGE JOB PRODUCTION @@ -2563,7 +2509,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { stack.push({ name: $I("res.stack.faith"), type: "ratio", - value: this.religion.getProductionBonus() / 100 + value: this.religion.getProductionBonus() * (res.name == "faith" ? this.challenges.getChallengeReward("atheism") : 1) / 100 }); if (!this.opts.disableCMBR && res.name != "coal") { @@ -2804,16 +2750,6 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { */ updateModel: function(){ - if (!this.challenges.getCondition("disableMisc").on) - { - this.karmaZebras += this.karmaZebrasReserve; - this.karmaZebrasReserve = 0; - this.resPool.get("zebras").maxValue = this.karmaZebras ? this.karmaZebras + 1 : 0; - this.resPool.get("zebras").value += this.resPool.get("zebras").reserveValue; - this.resPool.get("zebras").reserveValue = 0; - } - this.resPool.update(); - this.bld.update(); //business logic goes there @@ -2830,7 +2766,6 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.religion.update(); this.space.update(); this.challenges.update(); - this.prestige.update(); /*for (i in this.managers){ if (this.managers[i].update){ @@ -2838,14 +2773,16 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } }*/ + this.timer.update(); + + this.resPool.update(); + this.resPool.resConsHackForResTable(); //nah, kittens are not a resource anymore (?) var kittens = this.resPool.get("kittens"); kittens.value = this.village.getKittens(); //just a simple way to display them kittens.maxValue = this.village.maxKittens; - - this.timer.update(); }, huntAll: function(event){ @@ -3355,11 +3292,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (!confirmed) { return; } - if (game.challenges.getChallenge("atheism").on && game.time.getVSU("cryochambers").on > 0) { - if (game.ironWill){ - game.achievements.unlockHat("ivoryTowerHat"); - } - } + if (game.calendar.day < 0){ game.achievements.unlockHat("fezHat"); } @@ -3405,7 +3338,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { _getKarmaKittens: function(kittens){ var karmaKittens = 0; - if (this.challenges.getChallenge("anarchy").researched) { + if (this.challenges.getChallengeResearched("anarchy", true)) { kittens = kittens * 2; } @@ -3463,36 +3396,43 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { }, _resetInternal: function(){ - var faithRatio = this.religion.faithRatio; //pre-reset faith so people who forgot to do it properly would not be screwed if (this.religion.getRU("apocripha").on){ - faithRatio += this.religion.getApocryphaResetBonus(1); + this.religion.faithRatio += this.religion.getApocryphaResetBonus(1); } - //------------------------------------------------------------------------------------------------------ - var paragonBonus = this.challenges.getParagonBonus(); + for (var i = 0; i < this.challenges.conditions.length; i++) { + if (this.challenges.conditions[i].on && !this.challenges.conditions[i].rewardable && !this.challenges.conditions[i].name == "disableChrono") { + this.game.challenges.handleConditionToggle(this.challenges.conditions[i].name, false); + this.game.challenges.handleConditionToggle(this.challenges.conditions[i].name, true); + } + } this.challenges.applyPending(); var kittens = this.resPool.get("kittens").value; var karmaKittens = this.karmaKittens; + var karmaKittensReserve = this.karmaKittensReserve; if (kittens > 35){ - karmaKittens += this._getKarmaKittens(kittens); + if (this.challenges.getCondition("disableParagon").on && !this.challenges.getCondition("disableParagon").rewardable) { + karmaKittensReserve += this._getKarmaKittens(kittens); + } else { + karmaKittens += this._getKarmaKittens(kittens); + } } var paragonPoints = 0; + var paragonPointsReserve = 0; if (kittens > 70){ - paragonPoints = (kittens - 70) * (1 + paragonBonus); + paragonPoints = (kittens - 70) * (1 + this.prestige.getParagonBonus()); + paragonPointsReserve = (kittens - 70) * (1 + this.prestige.getParagonBonus(true)) - paragonPoints; } - var addRes = { - "paragon": paragonPoints - }; - var karmaZebras = parseInt(this.karmaZebras); //hack + var karmaZebrasReserve = parseInt(this.karmaZebrasReserve); //hack //that's all folks var addStats = { - "totalParagon": paragonPoints, + "totalParagon": paragonPoints + paragonPointsReserve, "totalResets": 1 }; @@ -3524,8 +3464,13 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { //-------------------------- very confusing and convoluted stuff related to karma zebras --------------- var bonusZebras = this._getBonusZebras(); if (this.resPool.get("zebras").value > 0 && this.ironWill){ - karmaZebras += bonusZebras; + if (this.challenges.getCondition("disableMisc").on && !this.challenges.getCondition("disableMisc").rewardable) { + karmaZebrasReserve += bonusZebras; + } else { + karmaZebras += bonusZebras; + } } + //------------------------------------------------------------------------------------------------------ // Trigger a save to make sure we're working with most recent data this.save(); @@ -3542,10 +3487,11 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var saveRatio = this.bld.get("chronosphere").val > 0 ? this.getEffect("resStasisRatio") : 0; // resStasisRatio excepted when challenge dojo.mixin(lsData.game, { - karmaKittens: (this.challenges.getCondition("disableMetaResources").on && this.challenges.getCondition("disableMetaResources").resets == 0) ? 0 : karmaKittens, - karmaZebras: (this.challenges.getCondition("disableMisc").on && this.challenges.getCondition("disableMisc").resets == 0) ? 0 : karmaZebras, - karmaZebrasReserve: (this.challenges.getCondition("disableMisc").on && this.challenges.getCondition("disableMisc").resets == 0) ? karmaZebras : 0, - ironWill : saveRatio > 0 ? false : true, //chronospheres will disable IW + karmaKittens: karmaKittens, + karmaKittensReserve: karmaKittensReserve, + karmaZebras: karmaZebras, + karmaZebrasReserve: karmaZebrasReserve, + ironWill : !this.challenges.getCondition("disableChrono") && saveRatio > 0 ? false : true, //chronospheres will disable IW deadKittens: 0, isCMBREnabled: false }); @@ -3559,6 +3505,8 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { var anachronomancy = this.prestige.getPerk("anachronomancy"); var fluxCondensator = this.workshop.get("fluxCondensator"); + var disableChrono = this.challenges.getCondition("disableChrono"); + var disableParagon = this.challenges.getCondition("disableParagon"); for (var i in this.resPool.resources){ var res = this.resPool.resources[i]; @@ -3567,59 +3515,68 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { continue; //>: } var value = 0; - var reserveValue = 0; + var reserve = 0; if (res.name == "timeCrystal"){ - if (anachronomancy.researched){ - value = res.value; - } - else if (anachronomancy.reserve){ - reserveValue = res.reserveValue + (this.challenges.getCondition("disableChrono").on && this.challenges.getCondition("disableChrono").resets == 0) ? res.value : 0; + if (anachronomancy.researched || anachronomancy.reserve){ + if (disableChrono.on) { + reserve = res.reserve + res.value; + } else { + value = res.value; + } } } else if (res.persists){ value = res.value; - reserveValue = res.reserveValue; + reserve = res.reserve; + + if (res.name == "paragon") { + reserve += paragonPointsReserve; + + if (disableParagon.on && !disableParagon.rewardable) { + reserve += paragonPoints; + } else { + value += paragonPoints; + } + } } else { if (!res.craftable || res.name == "wood"){ - value = res.value * saveRatio; - reserveValue = (this.challenges.getCondition("disableChrono").on && this.challenges.getCondition("disableChrono").resets > 0) ? res.reserveValue : res.reserveValue * saveRatio; + if (disableChrono.on) { + if (!disableChrono.rewardable) { + reserve = (res.value + res.reserve) * saveRatio; + } else { + reserve = res.reserve + res.value * saveRatio; + } + } else { + if (res.maxValue) { + reserve = (res.value + res.reserve) * saveRatio; + } else { + value = (res.value + res.reserve) * saveRatio; + } + } + if (res.name == "void") { value = Math.floor(value); - reserveValue = Math.floor(reserveValue); + reserve = Math.floor(reserve); } } else if (res.value > 0) { - value = Math.sqrt(res.value) * saveRatio * 100; - reserveValue = (this.challenges.getCondition("disableChrono").on && this.challenges.getCondition("disableChrono").resets > 0) ? res.reserveValue : Math.sqrt(res.value + res.reserveValue) * saveRatio * 100 - value; + if (disableChrono.on) { + reserve = res.reserve + Math.sqrt(res.value) * saveRatio * 100; + } else { + value = Math.sqrt(res.value) * saveRatio * 100; + } } } - if (addRes[res.name] > 0){ - value += addRes[res.name]; - } - - if (value > 0 || reserveValue > 0 || this.resPool.get(res.name).reserveValue > 0){ + if (value > 0 || reserve > 0){ var newRes = this.resPool.createResource(res.name); - if (res.maxValue || (this.challenges.getCondition("disableChrono").on && !res.persists)) { - newRes.reserveValue = value + reserveValue; - } - else if ((res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") && this.challenges.getCondition("disableMetaResources").on && this.challenges.getCondition("disableMetaResources").resets == 0) { - newRes.reserveValue = this.resPool.get(res.name).reserveValue + value; - } - else { - newRes.value = value; - newRes.reserveValue = reserveValue; - } + newRes.value = value; + newRes.reserve = reserve; newResources.push(newRes); } } - if (this.challenges.getCondition("disableMetaResources").on && this.challenges.getCondition("disableMetaResources").resets == 0) { - var newRes = this.resPool.createResource("karma"); - newRes.reserveValue = this.getTriValue(Math.round(this.getTriValueOrigin(this.resPool.get("karma").reserveValue, 5)) + karmaKittens, 5); - newResources.push(newRes); - } - var newKittens= []; + var reserveKittens= this.village.sim.reserve; if (this.time.getVSU("cryochambers").on > 0) { var kittens = this.village.sim.kittens; @@ -3637,41 +3594,40 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { } } - if (this.challenges.getCondition("disableChrono").on) - { - for (var i = 0; i < this.village.sim.reserveKittens.length; i++) - { - newKittens.push(this.village.sim.reserveKittens[i]); + if (disableChrono.on) { + for (var i = 0; i < newKittens.length; i++) { + reserveKittens.push(newKittens[i]); } + newKittens = []; } - if (!this.challenges.getCondition("disableChrono").on) { - var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on", "reserve"]); + if (newKittens.length > 0) { + var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on"]); usedCryochambers_reset[0]["val"] = newKittens.length; usedCryochambers_reset[0]["on"] = newKittens.length; - usedCryochambers_reset[0]["reserve"] = 0; } else { - var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on", "reserve"]); + var usedCryochambers_reset = this.time.filterMetadata([this.time.getVSU("usedCryochambers")], ["name", "val", "on"]); usedCryochambers_reset[0]["val"] = 0; usedCryochambers_reset[0]["on"] = 0; - usedCryochambers_reset[0]["reserve"] += newKittens.length; } - + for (var i = 0; i < this.challenges.challenges.length; i++) { - if (this.challenges.challenges[i].on && this.challenges.getCondition("disableChrono").on) { + if (this.challenges.challenges[i].on && disableChrono.on) { this.challenges.challenges[i].rewardable = true; } this.challenges.challenges[i].rewarded = false; } - + for (var i = 0; i < this.challenges.conditions.length; i++) { if (this.challenges.conditions[i].on) { - this.challenges.conditions[i].rewardable = true; - this.challenges.conditions[i].resets += 1; + if (!this.challenges.conditions[i].rewardable) { + this.challenges.conditions[i].rewardable = true; + } else { + this.challenges.conditions[i].resets++; + } } } - var saveData = { saveVersion: this.saveVersion, @@ -3682,10 +3638,10 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { cryptoPrice: this.calendar.cryptoPrice }, challenges: { - rewardable: this.challenges.getCondition("disableChrono").on ? true : false, - rewarded: false, challenges: this.challenges.challenges, - conditions: this.challenges.conditions + conditions: this.challenges.conditions, + rewardable: this.challenges.getCondition("disableChrono").on ? true : false, + rewarded: false }, diplomacy: { races: [] @@ -3694,13 +3650,13 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { perks: this.prestige.perks }, religion: { - faithRatio: (this.challenges.getCondition("disableApo").on && this.challenges.getCondition("disableApo").resets == 1) ? 0 : faithRatio, - tcratio: this.religion.tcratio, + faithRatio: this.religion.faithRatio, faithRatioReserve: this.religion.faithRatioReserve, + tcratio: this.religion.tcratio, tcratioReserve: this.religion.tcratioReserve, zu: [], ru: [], - tu: this.religion.filterMetadata(this.religion.transcendenceUpgrades, ["name", "val", "on", "unlocked", "reserve"]) + tu: this.religion.filterMetadata(this.religion.transcendenceUpgrades, ["name", "val", "on", "reserve", "unlocked"]) }, science: { hideResearched: false, @@ -3716,17 +3672,17 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { timestamp: Date.now() }, village :{ - kittens: this.challenges.getCondition("disableChrono").on ? [] : newKittens, - reserveKittens: this.challenges.getCondition("disableChrono").on ? newKittens : [], + kittens: newKittens, + reserve: reserveKittens, jobs: [], - traits: [] + traits: [], }, achievements: lsData.achievements, stats: stats, statsCurrent: statsCurrent }; - if (anachronomancy.researched && !this.challenges.getCondition("disableChrono").on){ + if (!disableChrono.on && anachronomancy.researched){ saveData.science.techs.push(this.science.get("chronophysics")); } LCstorage["com.nuclearunicorn.kittengame.savedata"] = JSON.stringify(saveData); diff --git a/js/buildings.js b/js/buildings.js index c077532c3d..9688375527 100644 --- a/js/buildings.js +++ b/js/buildings.js @@ -359,10 +359,15 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan "energyProduction": 2 }; effects["energyProduction"] *= 1 + game.getEffect("solarFarmRatio"); - if (game.calendar.season == 3) { - effects["energyProduction"] *= (1 - (0.25 / game.challenges.getChallengeReward("winterIsComing"))); - } else if (game.calendar.season == 1) { - effects["energyProduction"] /= (1 - (0.25 / game.challenges.getChallengeReward("winterIsComing"))); + if (game.challenges.getChallengeResearched("winterIsComing")) { + effects["energyProduction"] *= 2; + } + + if (game.calendar.getCurSeason().name == "winter") { + effects["energyProduction"] *= 0.75; + } else if (game.calendar.getCurSeason().name == "summer") { + effects["energyProduction"] /= 0.75; + effects["energyProduction"] *= this.game.challenges.getChallengeReward("winterIsComing"); } var seasonRatio = game.getEffect("solarFarmSeasonRatio"); @@ -551,9 +556,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan if (game.workshop.get("cryocomputing").researched){ effects["energyConsumption"] = 1; } - if (game.challenges.currentChallenge == "energy") { - effects["energyConsumption"] *= 2; - } + effects["energyConsumption"] *= game.challenges.getEnergyMod(); if (game.workshop.get("machineLearning").researched){ var dataCenterAIRatio = game.getEffect("dataCenterAIRatio"); @@ -650,6 +653,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan var energyCons = 0; if (game.workshop.get("biofuel").researched){ energyCons = 1; + energyCons *= game.challenges.getEnergyMod() self.togglable = true; } self.effects["energyConsumption"] = energyCons; @@ -964,6 +968,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }, calculateEffects: function(self, game) { self.effects["energyConsumption"] = 1; + self.effects["energyConsumption"] *= game.challenges.getEnergyMod(); }, lackResConvert: false, action: function(self, game){ @@ -1206,7 +1211,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan self.effects["oilPerTickBase"] = 0.02 * oilRatio; self.effects["energyConsumption"] = self.isAutomationEnabled - ? 1 + ? game.challenges.getEnergyMod() : 0; }, flavor: $I("buildings.oilWell.flavor") @@ -1254,6 +1259,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan } effects["energyConsumption"] = 2; + effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects = effects; } @@ -1325,6 +1331,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }, calculateEffects: function(self, game){ self.effects["energyConsumption"] = 2; + self.effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects["scienceMax"] = 0; if (game.workshop.get("lhc").researched){ @@ -1534,7 +1541,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan "cultureMax" : 0 }, calculateEffects: function(self, game) { - if (!game.challenges.getChallenge("atheism")) { + if (!game.challenges.getChallenge("atheism").on) { var effects = { "culturePerTickBase" : 0.05, "faithPerTickBase" : 0.005, @@ -1686,6 +1693,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan }, calculateEffects: function(self, game) { self.effects["energyConsumption"] = 20; + self.effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects["temporalFluxProduction"] = game.getEffect("temporalFluxProductionChronosphere"); } },{ @@ -1715,6 +1723,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan // Core #4: 6.5 ; Total: 17 ; Average: 4.25 = 17/4 = (3*4+5)/4 // etc. self.effects["energyConsumption"] = (3 * self.on + 5) / 4; + self.effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects["aiLevel"] = Math.round(Math.log(Math.max(game.resPool.get("gflops").value, 1))); }, diff --git a/js/calendar.js b/js/calendar.js index e201b0c665..e2221a80b2 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -779,32 +779,27 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { this.eventChance = 0; if (this.year > 3){ - if (this.game.challenges.getChallenge("winterIsComing").on) - { - var warmChance = this.game.challenges.getChallengePenalty("winterIsComing", "warmRate"); - var coldChance = this.game.challenges.getChallengePenalty("winterIsComing", "coldRate"); - } - else - { - var warmChance = 175; - var coldChance = 175; - if (this.season == 3 && this.game.challenges.getChallenge("winterIsComing").researched && !this.game.challenges.getCondition("disableRewards").on){ - coldChance = 0; + var coldChance = 175; + var warmChance = 175; + + if (this.game.challenges.getChallenge("winterIsComing").on) { + effect = this.game.challenges.getChallengeEffect("winterIsComing", "frequency"); + coldChance += effect; + warmChance -= effect; + if (warmChance < 0) { + warmChance = 0; } } + if (this.getCurSeason().name == "winter" && this.game.challenges.getChallengeResearched("winterIsComing")){ + coldChance = 0; + } var rand = this.game.rand(1000); - - if (rand < warmChance) - { + if (rand < warmChance){ this.weather = "warm" - } - else if (rand < warmChance + coldChance) - { + } else if (rand < warmChance + coldChance){ this.weather = "cold" - } - else - { + } else{ this.weather = null; } }else{ @@ -922,13 +917,27 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { } }, - getWeatherMod: function(){ - var mod = 0; + getWeatherMod: function(res){ + var mod = 1; + + if (this.getCurSeason().modifiers[res.name]){ + mod = this.getCurSeason().modifiers[res.name]; + } + if (this.weather == "warm"){ - mod = 0.15; + mod += 0.15; } else if (this.weather == "cold"){ - mod = -0.15; + mod -= 0.15; + } + + if (this.game.challenges.getChallenge("winterIsComing").on && this.weather == "cold") { + mod = ((mod + 1) * this.game.challenges.getChallengeEffect("winterIsComing", "modifier")) - 1; } + + if (this.getCurSeason().name == "spring"){ + mod *= this.game.challenges.getChallengeReward("winterIsComing"); + } + return mod; }, diff --git a/js/challenges.js b/js/challenges.js index 6190d83e50..f96270d2ff 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -12,173 +12,120 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa label: $I("challendge.ironWill.label"), description: $I("challendge.ironWill.desc"), effectDesc: $I("challendge.ironWill.effect.desc"), + difficulty: 100, researched: 0, - unlocked: true, - togglableOnOff: true, - val: 1 + unlocked: true },{ name: "winterIsComing", label: $I("challendge.winterIsComing.label"), description: $I("challendge.winterIsComing.desc"), effectDesc: $I("challendge.winterIsComing.effect.desc"), + repeatEffectDesc: $I("challendge.winterIsComing.repeatEffect.desc"), + res: "void", + resAmt: 1000, difficulty: 1, researched: 0, - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - rewarded: false + unlocked: true },{ name: "anarchy", label: $I("challendge.anarchy.label"), description: $I("challendge.anarchy.desc"), effectDesc: $I("challendge.anarchy.effect.desc"), + repeatEffectDesc: $I("challendge.anarchy.repeatEffect.desc"), + res: "relic", + resAmt: 10000, difficulty: 5, researched: 0, - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - rewarded: false + unlocked: true },{ name: "energy", label: $I("challendge.energy.label"), description: $I("challendge.energy.desc"), effectDesc: $I("challendge.energy.effect.desc"), + repeatEffectDesc: $I("challendge.energy.repeatEffect.desc"), + res: "antimatter", + resAmt: 5000, difficulty: 10, researched: 0, unlocked: false, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - rewarded: false + upgrades: { + buildings: ["library", "biolab", "calciner", "oilWell", "factory", "accelerator", "chronosphere", "aiCore"], + spaceBuilding: ["sattelite", "spaceStation", "moonOutpost", "moonBase", "orbitalArray", "containmentChamber"], + voidSpace: ["chronocontrol"] + } },{ name: "atheism", label: $I("challendge.atheism.label"), description: $I("challendge.atheism.desc"), effectDesc: $I("challendge.atheism.effect.desc"), + repeatEffectDesc: $I("challendge.atheism.repeatEffect.desc"), + res: "faith", + resAmt: 1000000, difficulty: 15, researched: 0, unlocked: false, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - rewarded: false + upgrades: { + buildings: ["chapel", "temple"] + } },{ name: "1000Years", label: $I("challendge.1000Years.label"), description: $I("challendge.1000Years.desc"), effectDesc: $I("challendge.1000Years.effect.desc"), + repeatEffectDesc: $I("challendge.1000Years.repeatEffect.desc"), + res: "timeCrystal", + resAmt: 20000, difficulty: 3, researched: 0, - unlocked: false, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - rewarded: false + unlocked: false }], - conditions:[ - { + conditions:[ + { name: "disableChrono", label: $I("challendge.condition.disableChrono.label"), description: $I("challendge.condition.disableChrono.desc"), - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - resets: 0 },{ - name: "disableMetaResources", - label: $I("challendge.condition.disableMetaResources.label"), - description: $I("challendge.condition.disableMetaResources.desc"), - bonus: 5, - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - resets: 0 + name: "disableParagon", + label: $I("challendge.condition.disableParagon.label"), + description: $I("challendge.condition.disableParagon.desc"), + bonus: 5 },{ - name: "disableMetaTechs", - label: $I("challendge.condition.disableMetaTechs.label"), - description: $I("challendge.condition.disableMetaTechs.desc"), - bonus: 10, - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - resets: 0 + name: "disableMetaphysics", + label: $I("challendge.condition.disableMetaphysics.label"), + description: $I("challendge.condition.disableMetaphysics.desc"), + bonus: 10 },{ name: "disableApo", label: $I("challendge.condition.disableApo.label"), description: $I("challendge.condition.disableApo.desc"), - bonus: 20, - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - resets: 0 + bonus: 20 },{ name: "disableRewards", label: $I("challendge.condition.disableRewards.label"), description: $I("challendge.condition.disableRewards.desc"), - bonus: 3, - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - resets: 0 + bonus: 3 },{ name: "disableMisc", label: $I("challendge.condition.disableMisc.label"), description: $I("challendge.condition.disableMisc.desc"), - unlocked: true, - togglableOnOff: true, - val: 1, - on: 0, - pending: false, - rewardable: false, - resets: 0 - }], + bonus: 1 + }], game: null, rewardable: false, rewarded: false, resetState: function(){ - this.rewardable = false; - this.rewarded = false; - for (var i = 0; i < this.challenges.length; i++){ var challenge = this.challenges[i]; - challenge.on = 0; - challenge.researched = 0; - challenge.unlocked = (challenge.name == "ironWill" || challenge.name == "winterIsComing" || challenge.name == "anarchy") + challenge.enabled = false; + challenge.on = false; challenge.pending = false; challenge.rewardable = false; challenge.rewarded = false; } - + for (var i = 0; i < this.conditions.length; i++){ var condition = this.conditions[i]; condition.on = 0; @@ -186,14 +133,17 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa condition.rewardable = false; condition.resets = 0; } + + this.rewardable = false; + this.rewarded = false; }, save: function(saveData){ saveData.challenges = { - rewardable: this.rewardable, - rewarded: this.rewarded, challenges: this.filterMetadata(this.challenges, ["name", "researched", "unlocked", "on", "pending", "rewardable", "rewarded"]), - conditions: this.filterMetadata(this.conditions, ["name", "on", "pending", "rewardable", "resets"]) + conditions: this.filterMetadata(this.conditions, ["name", "on", "pending", "rewardable", "resets"]), + rewardable: this.rewardable, + rewarded: this.rewarded }; }, @@ -202,20 +152,25 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa return; } - if (saveData.challenges.rewardable) - this.rewardable = saveData.challenges.rewardable; - this.rewarded = saveData.challenges.rewarded; - this.loadMetadata(this.challenges, saveData.challenges.challenges); - - if (saveData.challenges.conditions) - { + if (saveData.challenges.conditions){ this.loadMetadata(this.conditions, saveData.challenges.conditions); } + if (saveData.challenges.rewardable) { + this.rewardable = saveData.challenges.rewardable; + } + if (saveData.challenges.rewarded) { + this.rewarded = saveData.challenges.rewarded; + } }, update: function(){ - this.getChallenge("ironWill").on = this.game.ironWill; + if (this.game.ironWill && this.game.bld.get("library").on > 0) { + this.getChallenge("ironWill").on = true; + } else if (!this.game.ironWill) { + this.getChallenge("ironWill").on = false; + } + // energy if (this.getChallenge("energy").unlocked == false) { if (this.game.resPool.energyProd != 0 || this.game.resPool.energyCons != 0) { @@ -235,9 +190,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa ) { this.researchChallenge("energy"); } - } - - if (this.getChallenge("anarchy").on) { + } else if (this.getChallenge("anarchy").on) { if (this.game.bld.get("aiCore").val > 0){ this.researchChallenge("anarchy"); } @@ -249,45 +202,27 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa this.researchChallenge("winterIsComing"); } } - - if (this.getChallenge("atheism").on && this.game.time.getVSU("cryochambers").on > 0) { - this.researchChallenge("atheism"); - } - - if (game.challenges.getChallenge("1000Years").on && this.game.calendar.year >= 1000) { - game.challenges.researchChallenge("1000Years"); + + if (this.getChallenge("atheism").on) { + if (this.game.time.getVSU("cryochambers").on > 0){ + this.researchChallenge("atheism"); + + if (game.ironWill){ + game.achievements.unlockHat("ivoryTowerHat"); + } + } } - + var noChallenge = true; - for (var i = 0; i < this.challenges.length; i++) { if (this.challenges[i].on) { noChallenge = false; } } - - if (noChallenge && this.getCondition("disableChrono").on && this.game.space.getPlanet("moon").unlocked) - { + + if (noChallenge && this.game.space.getPlanet("moon").unlocked) { this.researchChallenge(); } - - for (var i = 0; i < this.challenges.length; i++) { - if (!this.challenges[i].on || !this.getCondition("disableChrono").on) { - this.challenges[i].rewardable = false; - } - } - - for (var i = 0; i < this.conditions.length; i++) { - if (!this.conditions[i].on) { - this.conditions[i].rewardable = false; - this.conditions[i].resets = 0; - - if (this.conditions[i].name == "disableMetaResources") - { - this.getCondition("disableMetaTechs").resets = 0; - } - } - } }, @@ -295,253 +230,322 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa getChallenge: function(name){ return this.getMeta(name, this.challenges); }, - + getCondition: function(name){ return this.getMeta(name, this.conditions); }, - researchChallenge: function(challenge) { + researchChallenge: function(name) { var apotheosis = 0; - if (challenge){ - if (this.getChallenge(challenge).rewardable && !this.getChallenge(challenge).rewarded){ - this.getChallenge(challenge).researched += 1; - this.getChallenge(challenge).rewarded = true; - this.game.msg($I("challendge.btn.log.message.on.complete", [this.getChallenge(challenge).label])); - - if (challenge == "winterIsComing"){ - this.game.resPool.get("void").reserveValue += 1000; - } - - if (challenge == "anarchy"){ - this.game.resPool.get("relic").reserveValue += 10000; - } - - if (challenge == "energy"){ - this.game.resPool.get("antimatter").reserveValue += 5000; - } - - if (challenge == "atheism"){ - this.game.religion.faithRatio += 1; - } - - if (challenge == "1000Years"){ - this.game.resPool.get("timeCrystal").reserveValue += 20000; - } - + var res; + var resAmt = 0; + var challenge; + if (name) { + var challenge = this.getChallenge(name); + if (challenge.rewardable && !challenge.rewarded) { + var res = this.game.resPool.get(challenge.res); + var resAmt = (challenge.resAmt * Math.pow(2, Math.sqrt(challenge.researched))); + var challengeTotal = 0; var challengeNumber = 0; for (var i = 0; i < this.challenges.length; i++) { if (this.challenges[i].rewardable) { - challengeNumber += 1; - challengeTotal += Math.pow(this.challenges[i].difficulty, 2) + challengeTotal += Math.pow(this.challenges[i].difficulty, 2); + challengeNumber++; } } - - apotheosis += Math.sqrt(challengeTotal) / challengeNumber; + + apotheosis += Math.floor(Math.sqrt(challengeTotal) / challengeNumber); } } - - if (this.rewardable && !this.rewarded) - { + if (this.rewardable && !this.rewarded) { apotheosis += 1; this.rewarded = true; } + + if (!apotheosis) { + return; + } + var conditionTotal = 1; for (var i = 0; i < this.conditions.length; i++) { if (this.conditions[i].on && this.conditions[i].bonus) { conditionTotal += Math.pow(this.conditions[i].bonus * (1 - this.game.getHyperbolicEffect(this.conditions[i].resets / 10, 1)), 2); } } - + + resAmt *= Math.sqrt(conditionTotal); apotheosis *= Math.sqrt(conditionTotal); - - if (apotheosis) - { - this.game.resPool.addRes(this.game.resPool.get("apotheosis"), Math.floor(apotheosis), true); - } - }, - - getChallengePenalty: function(name, type){ - var researched = this.getChallenge(name).researched; - var on = this.getChallenge(name).on; - - if (name == "winterIsComing") - { - if (type == "warmRate") - { - return Math.floor(175 - this.game.getHyperbolicEffect(researched * 10, 175)); - } - else if (type == "coldRate") - { - return Math.ceil(175 + this.game.getHyperbolicEffect(researched * 50, 825)); - } - else if (type == "warmMod") - { - return (1 - Math.ceil(60 + this.game.getHyperbolicEffect(researched, 40)) / 100); - } - else if (type == "normalMod") - { - return (1 - Math.ceil(75 + this.game.getHyperbolicEffect(researched, 25)) / 100); - } - else if (type == "coldMod") - { - return (1 - Math.ceil(90 + this.game.getHyperbolicEffect(researched, 10)) / 100); + + if (res) { + if (res.maxValue && res.value + resAmt > res.maxValue) { + res.reserve = res.value - res.maxValue; + res.value = res.maxValue; + } else { + res.value += resAmt; } } - else if (name == "anarchy") - { - return (Math.floor(50 + this.game.getHyperbolicEffect(researched * 5, 50)) / 100); - } - else if (!on) - { - return 1; - } - else if (name == "energy") - { - return (2 + researched * 0.1); - } - else if (name == "atheism") - { - return (1 + researched * 0.2); + + this.game.resPool.addRes(this.game.resPool.get("apotheosis"), apotheosis, true); + + if (challenge) { + challenge.researched++; + challenge.rewarded = true; + this.game.msg($I("challendge.btn.log.message.on.complete", [challenge.label, resAmt, res.title, apotheosis])); + } else { + this.game.msg($I("challendge.btn.log.message.on.complete.noChallenge", [apotheosis])); } - else if (name == "1000Years") - { - return (1 + researched * 0.5); + + this.game.calculateAllEffects(); + }, + + getChallengeResearched: function(name, alwaysUse) { + var challenge = this.getChallenge(name); + return (challenge.researched && ((!challenge.on && !this.getCondition("disableRewards").on) || alwaysUse)); + }, + + getChallengeEffect: function(name, type) { + var challenge = this.getChallenge(name) + + if (name == "winterIsComing") { + if (type == "frequency") { + return this.game.getHyperbolicEffect(challenge.researched * 50, 825); + } else { + return 1 - this.game.getHyperbolicEffect(researched * 0.1, 1); + } + } else if (name == "anarchy") { + return 0.5 - this.game.getHyperbolicEffect(researched * 0.05, 0.4); + } else if (name == "energy") { + return 2 + 0.1 * challenge.researched; + } else if (name == "atheism") { + return 1 - this.game.getHyperbolicEffect(challenge.researched * 0.1, 1); + } else if (name == "1000Years") { + return 1 + 0.5 * challenge.researched; } }, - - getChallengeReward: function(name, type){ - if (this.getChallenge(name).on || this.getCondition("disableRewards").on) - { + + getChallengeReward: function(name) { + var challenge = this.getChallenge(name); + + if (challenge.on || this.getCondition("disableRewards").on) { return 1; } - var researched = this.getChallenge(name).researched; - - if (name == "winterIsComing") - { - return 1 + this.game.getHyperbolicEffect(researched * 0.1, 1); - } - else if (name == "anarchy") - { - return 1 + this.game.getHyperbolicEffect(researched * 0.5, 4); - } - else if (name == "energy") - { - return 1 + this.game.getHyperbolicEffect(researched * 0.1, 1); - } - else if (name == "atheism") - { - return 1 + this.game.getHyperbolicEffect(researched * 0.25, 5); - } - else if (name == "1000Years") - { - return 1 - this.game.getHyperbolicEffect(researched * 0.1, 1); - } + if (name == "winterIsComing") { + var amt = 0.2; + var limit = 2; + } else if (name == "anarchy") { + var amt = 0.5; + var limit = 4; + } else if (name == "energy") { + var amt = -0.1; + var limit = 1; + } else if (name == "atheism") { + var amt = 0.25; + var limit = 4; + } else if (name == "1000Years") { + var amt = -0.1; + var limit = 1; + } + + return 1 + this.game.getHyperbolicEffect(challenge.researched * amt, limit); + }, + + getEnergyMod: function() { + return (game.challenges.getChallenge("energy").on ? this.getChallengeEffect("energy") : 1) * this.getChallengeReward("energy"); }, handleChallengeToggle: function(name, on) { - if (name == "atheism") - { - this.game.upgrade({buildings: ["temple"]}); + if (!on) { + this.getChallenge(name).rewardable = false; + } + + if (name == "anarchy") { + if (this.game.village.getFreeKittens() < 0 ){ + this.game.village.clearJobs(true); //sorry, just a stupid solution for this problem + } + this.game.villageTab.updateTab(); + } else if (name == "atheism") { + this.game.village.getJob("priest").unlocked = !on; + if (on) { + for (var i = 0; i < this.game.village.sim.kittens.length; i++) { + if (this.game.village.sim.kittens[i].job == "priest") { + this.game.village.unassignJob(this.game.village.sim.kittens[i]); + } + } + this.game.villageTab.updateTab(); + } } }, handleConditionToggle: function(name, on) { - if (on) - { - if (name == "disableMetaResources") - { - var metaRes = ["karma", "paragon", "burnedParagon", "apotheosis"] - for (var i = 0; i < metaRes.length; i++) - { + if (!on) { + this.getCondition(name).rewardable = false; + this.getCondition(name).resets = 0; + } + + if (name == "disableChrono" && !on) { + for (var i = 0; i < this.challenges.length; i++) { + this.challenges[i].rewardable = false; + } + + this.rewardable = false; + + if (this.game.prestige.getPerk("anachronomancy").researched) { + var chronophysics = this.game.science.get("chronophysics"); + chronophysics.researched = true; + this.game.unlock(chronophysics.unlocks); + + var timeCrystal = this.game.resPool.get("timeCrystal"); + timeCrystal.value += timeCrystal.reserve; + timeCrystal.reserve = 0; + } + + this.game.time.getVSU("usedCryochambers").val = this.game.village.sim.reserve.length; + this.game.time.getVSU("usedCryochambers").on = this.game.village.sim.reserve.length; + for (var i = 0; i < this.game.village.sim.reserve.length; i++) { + this.game.village.sim.kittens.push(this.game.village.sim.reserve[i]); + } + + this.game.village.sim.reserve = []; + } + + if (name == "disableParagon") { + if (on) { + var metaRes = ["karma", "paragon", "burnedParagon", "apotheosis"]; + for (var i = 0; i < metaRes.length; i++) { var res = this.game.resPool.get(metaRes[i]); - res.reserveValue += res.value; - res.value = 0; + + if (res.name == "karma") { + this.game.karmaKittensReserve = this.game.karmaKittens; + this.game.karmaKittens = 0; + res.value = 0; + } else { + res.reserve = res.value; + res.value = 0; + } } - this.game.karmaKittens = 0; - - if (this.getCondition("disableMetaTechs").on) - { - for (var i = 0; i < this.game.prestige.perks.length; i++) - { + if (this.getCondition("disableMetaphysics").on) { + for (var i = 0; i < this.game.prestige.perks.length; i++) { var perk = this.game.prestige.perks[i]; - - if (perk.defaultUnlocked) - { + + if (perk.defaultUnlocked) { perk.unlocked = true; } } } + } else { + var metaRes = ["karma", "paragon", "burnedParagon", "apotheosis"]; + for (var i = 0; i < metaRes.length; i++) { + var res = this.game.resPool.get(metaRes[i]); + + if (res.name == "karma") { + this.game.karmaKittens += this.game.karmaKittensReserve; + this.game.karmaKittensReserve = 0; + res.value = this.game.getTriValue(this.game.karmaKittens, 5); + } else { + res.value += res.reserve; + res.reserve = 0; + } + } + + if (this.getCondition("disableMetaphysics").on) { + for (var i = 0; i < this.game.prestige.perks.length; i++) { + var perk = this.game.prestige.perks[i]; + + if (!perk.researched) { + perk.unlocked = false; + } + } + } } - - if (name == "disableMetaTechs") - { - for (var i = 0; i < this.game.prestige.perks.length; i++) - { + } + + if (name == "disableMetaphysics") { + if (on) { + for (var i = 0; i < this.game.prestige.perks.length; i++) { var perk = this.game.prestige.perks[i]; perk.reserve = perk.researched; - perk.unlocked = false; perk.researched = false; - - if (this.getCondition("disableMetaResources").on && perk.defaultUnlocked) - { - perk.unlocked = true; + perk.unlocked = this.getCondition("disableParagon").on && perk.defaultUnlocked; + } + } else { + for (var i = 0; i < this.game.prestige.perks.length; i++) { + var perk = this.game.prestige.perks[i]; + + if (perk.reserve) { + if (perk.researched) { + for (var j = 0; j < perk.prices.length; j++) { + this.game.resPool.addResEvent(perk.prices[j].name, perk.prices[j].val); + } + } else { + perk.unlocked = true; + perk.researched = true; + this.game.unlock(perk.unlocks); + perk.reserve = false; + } } } } - - if (name == "disableApo") - { + } + + if (name == "disableApo") { + if (on) { this.game.religion.faithRatioReserve = this.game.religion.faithRatio; this.game.religion.faithRatio = 0; this.game.religion.tcratioReserve = this.game.religion.tcratio; this.game.religion.tcratio = 0; - this.game.religion.tclevel = this.game.religion.getTranscendenceLevel(); + this.game.religion.tclevel = 0; - for (var i = 0; i < this.game.religion.transcendenceUpgrades.length; i++) - { - this.game.religion.transcendenceUpgrades[i].reserve += this.game.religion.transcendenceUpgrades[i].val; + for (var i = 0; i < this.game.religion.transcendenceUpgrades.length; i++) { + this.game.religion.transcendenceUpgrades[i].reserve = this.game.religion.transcendenceUpgrades[i].val; this.game.religion.transcendenceUpgrades[i].val = 0; this.game.religion.transcendenceUpgrades[i].on = 0; } + } else { + this.game.religion.faithRatio += this.game.religion.faithRatioReserve; + this.game.religion.faithRatioReserve = 0; + this.game.religion.tcratio += this.game.religion.tcratioReserve; + this.game.religion.tcratioReserve = 0; + this.game.religion.tclevel = this.game.religion.getTranscendenceLevel(); + + for (var i = 0; i < this.game.religion.transcendenceUpgrades.length; i++) { + var tu = this.game.religion.transcendenceUpgrades[i]; + + var amt = Math.floor(Math.log(Math.pow(tu.priceRatio, tu.val) + Math.pow(tu.priceRatio, tu.reserve) - 1) / Math.log(tu.priceRatio)); + this.game.religion.transcendenceUpgrades[i].val = amt; + this.game.religion.transcendenceUpgrades[i].on = amt; + this.game.religion.transcendenceUpgrades[i].reserve = 0; + } } - - if (name == "disableMisc") - { - var bls = this.game.resPool.get("sorrow"); - bls.reserveValue = bls.value; - bls.value = 0; - + } + + if (name == "disableMisc") { + if (on) { this.game.karmaZebrasReserve = this.game.karmaZebras; this.game.karmaZebras = 0; this.game.resPool.get("zebras").maxValue = 0; - this.game.resPool.get("zebras").reserveValue = this.game.resPool.get("zebras").value; - this.game.resPool.get("zebras").value = 0; - - var box = this.game.resPool.get("elderBox"); - box.reserveValue = box.value; - box.value = 0; - var paper = this.game.resPool.get("wrappingPaper"); - paper.reserveValue = paper.value; - paper.value = 0; - } - } - else - { - if (name == "disableMetaResources") - { - if (this.getCondition("disableMetaTechs").on) - { - for (var i = 0; i < this.game.prestige.perks.length; i++) - { - var perk = this.game.prestige.perks[i]; - - if (perk.defaultUnlocked) - { - perk.unlocked = false; - } + + var miscRes = ["zebras", "sorrow", "elderBox", "wrappingPaper", "temporalFlux"]; + for (var i = 0; i < miscRes.length; i++) { + var res = this.game.resPool.get(miscRes[i]); + res.reserve = res.value; + res.value = 0; + } + } else { + this.karmaZebras += this.karmaZebrasReserve; + this.karmaZebrasReserve = 0; + this.game.resPool.get("zebras").maxValue = this.karmaZebras ? this.karmaZebras + 1 : 0; + + var miscRes = ["zebras", "sorrow", "elderBox", "wrappingPaper", "temporalFlux"]; + for (var i = 0; i < miscRes.length; i++) { + var res = this.game.resPool.get(miscRes[i]); + res.value += res.reserve; + res.reserve = 0; + + if (res.maxValue && res.value > res.maxValue) { + res.value = res.maxValue; } } } @@ -552,45 +556,21 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa for (var i = 0; i < this.challenges.length; i++){ var challenge = this.challenges[i]; if (challenge.pending){ + challenge.on = true; challenge.pending = false; - challenge.on = 1; + this.game.upgrade(challenge.upgrades); this.handleChallengeToggle(challenge.name, true); } - } + } for (var i = 0; i < this.conditions.length; i++){ var condition = this.conditions[i]; if (condition.pending){ + condition.on = true; condition.pending = false; - condition.on = 1; this.handleConditionToggle(condition.name, true); } - } - }, - - getWeatherMod: function(season, res){ - if (this.getChallenge("winterIsComing").on) - { - return this.getChallengePenalty("winterIsComing", (this.game.calendar.weather || "normal") + "Mod"); - } - else - { - var reward = 1; - if (this.game.calendar.weather == "warm") - { - reward = this.getChallengeReward("winterIsComing"); - } - if (this.game.calendar.weather == "cold") - { - reward = 1 / this.getChallengeReward("winterIsComing"); - } - var weatherMod = this.game.calendar.getWeatherMod(); - return Math.floor((((season.modifiers[res.name] - 1) * reward + 1) + weatherMod) * 100) / 100; - } - }, - - getParagonBonus: function(){ - return this.game.resPool.get("apotheosis").value / 100; + } } }); @@ -599,23 +579,28 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui getMetadata: function(model){ if (!model.metaCached){ model.metaCached = this.game.challenges.getChallenge(model.options.id); + model.metaCached.togglableOnOff = true; + model.metaCached.val = 1; //hack } return model.metaCached; }, getDescription: function(model) { - if (this.game.bld.get("chronosphere").val > 0) { - var msgChronosphere = model.metadata.name == "ironWill" ? $I("challendge.btn.chronosphere.with.ironWill.desc") : ""; + var challenge = model.metadata; + + if (challenge.name == "ironWill") { + var msg = $I("challendge.btn.ironWill.desc", [challenge.effectDesc, challenge.difficulty]); } else { - var msgChronosphere = ""; + var msg = $I("challendge.btn.desc", [challenge.effectDesc, challenge.repeatEffectDesc, this.game.resPool.get(challenge.res).title, challenge.resAmt, challenge.difficulty]); } - return this.inherited(arguments) + $I("challendge.btn.desc", [model.metadata.effectDesc, msgChronosphere]) ; + + return this.inherited(arguments) + msg; }, getName: function(model){ var meta = model.metadata; - name = meta.label + var name = meta.label; if (meta.researched){ name += " (" + meta.researched + ")"; } @@ -628,7 +613,6 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui updateVisible: function(model){ model.visible = model.metadata.unlocked; - model.enabled = model.metadata.name != "ironWill"; // hack }, getPrices: function(model) { @@ -636,30 +620,29 @@ dojo.declare("classes.ui.ChallengeBtnController", com.nuclearunicorn.game.ui.Bui }, buyItem: function(model, event, callback) { + this.handleTogglableOnOffClick(model); }, - - handleTogglableOnOffClick: function(model) { - if (model.metadata.name == "ironWill") - { - return; - } - - var on = model.metadata.on; + updateEnabled: function(model){ this.inherited(arguments); + if (model.metadata.name == "ironWill"){ + model.enabled = false; + } + }, - if (!on && model.metadata.on) - { - model.metadata.on = 0; - model.metadata.pending = !model.metadata.pending; + handleTogglableOnOffClick: function(model){ + if (model.metadata.name == "ironWill") { + return; } - if (on && !model.metadata.on) - { + if (model.metadata.on) { + model.metadata.on = false; + this.game.upgrade(model.metadata.upgrades); this.game.challenges.handleChallengeToggle(model.metadata.name, false); + } else { + model.metadata.pending = !model.metadata.pending; } - } - + } }); dojo.declare("classes.ui.ConditionBtnController", com.nuclearunicorn.game.ui.BuildingBtnController, { @@ -667,24 +650,35 @@ dojo.declare("classes.ui.ConditionBtnController", com.nuclearunicorn.game.ui.Bui getMetadata: function(model){ if (!model.metaCached){ model.metaCached = this.game.challenges.getCondition(model.options.id); + model.metaCached.togglableOnOff = true; + model.metaCached.val = 1; //hack } return model.metaCached; }, getDescription: function(model) { - return model.metadata.description; + var condition = model.metadata; + + if (condition.name == "disableChrono") { + return this.inherited(arguments); + } else { + return this.inherited(arguments) + $I("challendge.condition.btn.desc", [condition.bonus]); + } }, getName: function(model){ - if (model.metadata.pending){ - return model.metadata.label + " (" + $I("challendge.pending") + ")"; + + var meta = model.metadata; + var name = meta.label; + if (meta.pending){ + name += " (" + $I("challendge.pending") + ")"; } - return model.metadata.label; + return name; }, updateVisible: function(model){ - model.visible = model.metadata.unlocked; + model.visible = true; }, getPrices: function(model) { @@ -692,22 +686,15 @@ dojo.declare("classes.ui.ConditionBtnController", com.nuclearunicorn.game.ui.Bui }, buyItem: function(model, event, callback) { + this.handleTogglableOnOffClick(model); }, - - handleTogglableOnOffClick: function(model) { - var on = model.metadata.on; - - this.inherited(arguments); - - if (!on && model.metadata.on) - { - model.metadata.on = 0; - model.metadata.pending = !model.metadata.pending; - } - if (on && !model.metadata.on) - { + handleTogglableOnOffClick: function(model){ + if (model.metadata.on) { + model.metadata.on = false; this.game.challenges.handleConditionToggle(model.metadata.name, false); + } else { + model.metadata.pending = !model.metadata.pending; } } }); @@ -759,11 +746,15 @@ dojo.declare("classes.tab.ChallengesTab", com.nuclearunicorn.game.ui.tab, { this.challengesPanel = new classes.ui.ChallengePanel($I("challendge.panel.label"), this.game.challenges); this.challengesPanel.game = this.game; this.challengesPanel.render(container); - + this.conditionsPanel = new classes.ui.ConditionPanel($I("challendge.condition.panel.label"), this.game.challenges); this.conditionsPanel.game = this.game; this.conditionsPanel.render(container); + dojo.create("div", { style: { + marginBottom: "15px" + } }, container); + var applyPendingBtn = new com.nuclearunicorn.game.ui.ButtonModern({ name: $I("challendge.applyPending.label"), description: $I("challendge.applyPending.desc"), @@ -772,30 +763,28 @@ dojo.declare("classes.tab.ChallengesTab", com.nuclearunicorn.game.ui.tab, { }), controller: new com.nuclearunicorn.game.ui.ButtonController(this.game, { updateVisible: function (model) { - var visible = false; + model.visible = false; for (var i = 0; i < this.game.challenges.challenges.length; i++){ if (this.game.challenges.challenges[i].pending){ - visible = true + model.visible = true; } } - for (var i = 0; i < this.game.challenges.conditions.length; i++){ if (this.game.challenges.conditions[i].pending){ - visible = true; + model.visible = true; } } - - model.visible = visible; } }) }, this.game); applyPendingBtn.render(container); this.applyPendingBtn = applyPendingBtn; - }, - + }, + update: function(){ this.challengesPanel.update(); this.conditionsPanel.update(); this.applyPendingBtn.update(); + } }); diff --git a/js/jsx/left.jsx.js b/js/jsx/left.jsx.js index 91180aa380..000bdc0d91 100644 --- a/js/jsx/left.jsx.js +++ b/js/jsx/left.jsx.js @@ -15,9 +15,10 @@ WResourceRow = React.createClass({ var isEqual = oldRes.value == newRes.value && - oldRes.reserveValue == newRes.value && + oldRes.reserve == newRes.reserve && oldRes.maxValue == newRes.maxValue && oldRes.perTickCached == newRes.perTickCached && + oldRes.unlocked == newRes.unlocked && this.props.isEditMode == nextProp.isEditMode && this.props.isRequired == nextProp.isRequired && this.state.visible == nextState.visible; @@ -109,23 +110,7 @@ WResourceRow = React.createClass({ if (season.modifiers[res.name] && perTick !== 0 ){ - if (game.challenges.getChallenge("winterIsComing").on) - { - var modifier = game.challenges.getChallengePenalty("winterIsComing", (game.calendar.weather || "normal") + "Mod"); - } - else - { - var reward = 1; - if (game.calendar.weather == "warm") - { - reward = game.challenges.getChallengeReward("winterIsComing"); - } - if (game.calendar.weather == "cold") - { - reward = 1 / game.challenges.getChallengeReward("winterIsComing"); - } - var modifier = Math.floor(((season.modifiers[res.name] - 1) * reward + game.calendar.getWeatherMod())*100); - } + var modifier = Math.floor(game.calendar.getWeatherMod(res) - 1) * 100; weatherModValue = modifier ? "[" + (modifier > 0 ? "+" : "") + modifier.toFixed() + "%]" : ""; if (modifier > 0) { @@ -166,7 +151,7 @@ WResourceRow = React.createClass({ res.title || res.name ), $r("div", {className:"res-cell " + resAmtClassName + specialClass}, game.getDisplayValueExt(res.value)), - $r("div", {className:"res-cell " + resAmtClassName + specialClass + " reserve"}, !game.challenges.getCondition("disableChrono").on && !res.hideReserve && res.reserveValue ? "+" + game.getDisplayValueExt(res.reserveValue) : ""), + $r("div", {className:"res-cell " + resAmtClassName + specialClass + " reserve"}, !game.challenges.getCondition("disableChrono").on && res.maxValue && res.reserve ? "+" + game.getDisplayValueExt(res.reserve) : ""), $r("div", {className:"res-cell maxRes"}, res.maxValue ? "/" + game.getDisplayValueExt(res.maxValue) : "" ), diff --git a/js/prestige.js b/js/prestige.js index d08cd3ea26..e9c591c64d 100644 --- a/js/prestige.js +++ b/js/prestige.js @@ -433,6 +433,7 @@ dojo.declare("classes.managers.PrestigeManager", com.nuclearunicorn.core.TabMana var perk = this.perks[i]; perk.unlocked = perk.defaultUnlocked || false; perk.researched = false; + perk.reserve = false; } }, @@ -458,27 +459,7 @@ dojo.declare("classes.managers.PrestigeManager", com.nuclearunicorn.core.TabMana }, update: function(){ - if (!this.game.challenges.getCondition("disableMetaTechs").on) - { - for (var i = 0; i < this.perks.length; i++) - { - if (this.perks[i].reserve) - { - if (this.perks[i].researched) - { - for (var j = 0; j < this.perks[i].prices.length; j++) - { - this.game.resPool.addResEvent(this.perks[i].prices[j].name, this.perks[i].prices[j].val); - } - } - - this.perks[i].unlocked = true; - this.perks[i].researched = true; - this.game.unlock(this.perks[i].unlocks); - this.perks[i].reserve = false; - } - } - } + }, getPerk: function(name){ @@ -528,6 +509,10 @@ dojo.declare("classes.managers.PrestigeManager", com.nuclearunicorn.core.TabMana return storageRatio; }, + getParagonBonus: function(includeReserve){ + return (this.game.resPool.get("apotheosis").value + (includeReserve ? this.game.resPool.get("apotheosis").reserve : 0)) / 100; + }, + unlockAll: function(){ for (var i in this.perks){ this.perks[i].unlocked = true; diff --git a/js/religion.js b/js/religion.js index 105f1cb393..d2d904b534 100644 --- a/js/religion.js +++ b/js/religion.js @@ -7,10 +7,10 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana faith: 0, faithRatio : 0, - tcratio: 0, - corruption: 0, faithRatioReserve: 0, + tcratio: 0, tcratioReserve: 0, + corruption: 0, alicornCounter: 0, @@ -26,8 +26,8 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana this.faith = 0; this.corruption = 0; this.faithRatio = 0; - this.tcratio = 0; this.faithRatioReserve = 0; + this.tcratio = 0; this.tcratioReserve = 0; for (var i = 0; i < this.zigguratUpgrades.length; i++){ @@ -53,12 +53,12 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana faith: this.faith, corruption: this.corruption, faithRatio: this.faithRatio, - tcratio: this.tcratio, faithRatioReserve: this.faithRatioReserve, + tcratio: this.tcratio, tcratioReserve: this.tcratioReserve, zu: this.filterMetadata(this.zigguratUpgrades, ["name", "val", "on", "unlocked"]), ru: this.filterMetadata(this.religionUpgrades, ["name", "val", "on"]), - tu: this.filterMetadata(this.transcendenceUpgrades, ["name", "val", "on", "unlocked", "reserve"]), + tu: this.filterMetadata(this.transcendenceUpgrades, ["name", "val", "on", "reserve", "unlocked"]) }; }, @@ -70,8 +70,8 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana this.faith = saveData.religion.faith || 0; this.corruption = saveData.religion.corruption || 0; this.faithRatio = saveData.religion.faithRatio || 0; - this.tcratio = saveData.religion.tcratio || 0; this.faithRatioReserve = saveData.religion.faithRatioReserve || 0; + this.tcratio = saveData.religion.tcratio || 0; this.tcratioReserve = saveData.religion.tcratioReserve || 0; this.loadMetadata(this.zigguratUpgrades, saveData.religion.zu); this.loadMetadata(this.religionUpgrades, saveData.religion.ru); @@ -88,22 +88,6 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana }, update: function(){ - if (!this.game.challenges.getCondition("disableApo").on) - { - this.faithRatio += this.faithRatioReserve; - this.faithRatioReserve = 0; - this.tcratio += this.tcratioReserve; - this.tcratioReserve = 0; - this.tclevel = this.getTranscendenceLevel(); - - for (var i = 0; i < this.transcendenceUpgrades.length; i++) - { - this.transcendenceUpgrades[i].val += this.transcendenceUpgrades[i].reserve || 0; - this.transcendenceUpgrades[i].on += this.transcendenceUpgrades[i].reserve || 0; - this.transcendenceUpgrades[i].reserve = 0; - } - } - if (this.game.resPool.get("faith").value > 0 || this.game.challenges.getChallenge("atheism").on && this.game.bld.get("ziggurat").val > 0){ this.game.religionTab.visible = true; } @@ -754,7 +738,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana getProductionBonus: function(){ var rate = this.getRU("solarRevolution").on ? this.game.getTriValue(this.faith, 1000) : 0; //Solar Revolution capped to 1000% so it doesn't become game-breaking - var atheismBonus = (this.game.challenges.getChallenge("atheism").researched && !this.game.challenges.getCondition("disableRewards").on) ? this.getTranscendenceLevel() * 0.1 : 0; + var atheismBonus = this.game.challenges.getChallengeResearched("atheism") ? this.getTranscendenceLevel() * 0.1 : 0; var blackObeliskBonus = this.getTranscendenceLevel() * this.getTU("blackObelisk").val * 0.005; rate = this.game.getHyperbolicEffect(rate, 1000) * (1 + atheismBonus + blackObeliskBonus); return rate; @@ -1027,6 +1011,7 @@ dojo.declare("classes.ui.religion.SacrificeBtnController", com.nuclearunicorn.ga } var tearCount = this.game.bld.get("ziggurat").on * amt; + tearCount *= (this.game.challenges.getChallenge("atheism").on ? this.game.challenges.getChallengeEffect("atheism") : 1); this.game.resPool.addResEvent("unicorns", -unicornCount); this.game.resPool.addResEvent("tears", tearCount); @@ -1364,7 +1349,7 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.ReligionTab", com.nuclearunicorn.ga var sacrificeAlicornsBtn = classes.ui.religion.SacrificeBtn({ name: $I("religion.sacrificeAlicornsBtn.label"), description: $I("religion.sacrificeAlicornsBtn.desc"), - prices: [{ name: "alicorn", val: 25 * game.challenges.getChallengePenalty("atheism")}], + prices: [{ name: "alicorn", val: 25}], controller: new classes.ui.religion.SacrificeAlicornsBtnController(game) }, game); sacrificeAlicornsBtn.render(content); diff --git a/js/resources.js b/js/resources.js index 573322ff4f..707b934dbd 100644 --- a/js/resources.js +++ b/js/resources.js @@ -160,8 +160,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana title: $I("resources.zebras.title"), type : "common", transient: true, - visible: true, - hideReserve: true + visible: true },{ name : "starchart", title: $I("resources.starchart.title"), @@ -249,32 +248,28 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana name : "karma", title: $I("resources.karma.title"), type : "rare", - visible: true, - hideReserve: true + visible: true },{ name : "paragon", title: $I("resources.paragon.title"), type : "common", visible: true, color: "#6141CD", - persists: true, - hideReserve: true + persists: true },{ name : "burnedParagon", title : $I("resources.burnedParagon.title"), type : "common", visible: true, color: "#493099", - persists: true, - hideReserve: true + persists: true },{ name : "apotheosis", title : $I("resources.apotheosis.title"), type : "common", visible: true, color: "#7950FF", - persists: true, - hideReserve: true + persists: true },{ name : "timeCrystal", title: $I("resources.timeCrystal.title"), @@ -496,7 +491,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana for (var i = 0; i< this.resourceData.length; i++){ var res = dojo.clone(this.resourceData[i]); res.value = 0; - res.reserveValue = 0; + res.reserve = 0; res.unlocked = false; if (res.name == "oil" || res.name == "kerosene" || @@ -527,7 +522,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var res = { name: name, value: 0, - reserveValue: 0, + reserve: 0, //whether resource was marked by user as hidden or visible isHidden: false, @@ -537,64 +532,30 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana return res; }, - handleLimits: function(res) { - if(res.maxValue && res.value > res.maxValue) { - if (this.game.migrating && res.name != "temporalFlux") { - // Give the benefit of the doubt - res.reserveValue = res.value - res.maxValue; - } - res.value = res.maxValue; - } - }, - handleReserve: function(res) { - if (res.name == "karma" || res.name == "paragon" || res.name == "burnedParagon" || res.name == "apotheosis") - { - if ((this.game.loading || !this.game.challenges.getCondition("disableMetaResources").on) && res.reserveValue) - { - res.value += res.reserveValue; - res.reserveValue = 0; - - if (res.name == "karma") - { - this.game.karmaKittens = Math.round(this.game.getTriValueOrigin(res.value, 5)); - res.value = this.game.getTriValue(this.game.karmaKittens, 5); - } - } - } - else if (res.name == "elderBox" || res.name == "wrappingPaper") - { - if ((this.game.loading || !this.game.challenges.getCondition("disableMisc").on) && res.reserveValue) - { - res.value += res.reserveValue; - res.reserveValue = 0; - } - } - else - { - if ((this.game.loading || !this.game.challenges.getCondition("disableChrono").on) && res.reserveValue && (!res.maxValue || res.value < res.maxValue)) { - if (res.maxValue && res.value + res.reserveValue > res.maxValue) { - res.reserveValue -= (res.maxValue - res.value); - res.value = res.maxValue; - } - else { - res.value += res.reserveValue; - res.reserveValue = 0; - } - } - } - }, - - addRes: function(res, addedValue, event) { - if (this.game.calendar.day < 0 && !event || addedValue == 0) { + addRes: function(res, addedValue, event, preventLimitCheck) { + if (this.game.calendar.day < 0 && !event) { return 0; } var prevValue = res.value || 0; - res.value += addedValue; + res.value = res.value + addedValue; + if (res.maxValue && res.value > res.maxValue && !preventLimitCheck){ + if (this.game.migrateResources && res.name != "temporalFlux"){ + // Give the benefit of the doubt + res.reserve = res.value - res.maxValue; + } + res.value = res.maxValue; + } - if(!this.game.loading || res.name == "temporalFlux") { - this.handleLimits(res); + if (res.maxValue && res.value < res.maxValue && res.reserve && !this.game.challenges.getCondition("disableChrono").on){ + if (res.reserve > res.maxValue - res.value){ + res.reserve -= (res.maxValue - res.value); + res.value = res.maxValue; + } else { + res.value += res.reserve; + res.reserve = 0; + } } if (res.name == "void") { // Always an integer @@ -661,17 +622,12 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana * Iterates resources and updates their values with per tick increment */ update: function(){ + var game = this.game; for (var i in this.resources){ var res = this.resources[i]; if (res.name == "sorrow"){ - if (!this.game.challenges.getCondition("disableMisc").on) - { - res.value += res.reserveValue; - res.reserveValue = 0; - } - res.maxValue = 12 + (game.getEffect("blsLimit") || 0); res.value = res.value > res.maxValue ? res.maxValue : res.value; continue; @@ -682,9 +638,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana } else if (res.value == 0 && res.unlocked == true) { if (res.name == "zebras" || res.name == "paragon" || - res.name == "apotheosis" || - res.name == "elderBox" || - res.name == "wrappingPaper"){ + res.name == "elderBox"){ res.unlocked = false; } } @@ -701,15 +655,16 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var resPerTick = game.getResourcePerTick(res.name, false); this.addResPerTick(res.name, resPerTick); - this.handleLimits(res); - this.handleReserve(res); } + + this.game.migrateResources = false; + game.updateKarma(); //-------- this.energyProd = game.getEffect("energyProduction") * (1 + game.getEffect("energyProductionRatio")); - this.energyCons = game.getEffect("energyConsumption") * this.game.challenges.getChallengePenalty("energy") / this.game.challenges.getChallengeReward("energy"); + this.energyCons = game.getEffect("energyConsumption"); }, @@ -743,7 +698,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana } } } - }, + }, //Hack to reach the maxValue in resTable //AB: Questionable @@ -836,7 +791,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana for (var i = 0; i < this.resources.length; i++){ var res = this.resources[i]; res.value = 0; - res.reserveValue = 0; + res.reserve = 0; res.maxValue = 0; res.perTickCached = 0; res.unlocked = false; @@ -923,20 +878,24 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana }, getEnergyDelta: function(){ - if (this.energyProd == 0 && this.energyCons == 0){ - return 1; - } - var delta = this.energyProd / (this.energyCons ? this.energyCons : 1); - if (delta < 0.25){ - delta = 0.25; - } - if (delta > 4){ - delta = 4; - } - if ((this.game.challenges.getChallenge("energy").on || !this.game.challenges.getChallenge("energy").researched || this.game.challenges.getCondition("disableRewards").on) && delta > 1) { - delta = 1; - } + if (this.energyProd == 0 && this.energyCons == 0) { + return 1; + } else { + var delta = this.energyProd / (this.energyCons ? this.energyCons : 1); + if (delta < 0.25){ + delta = 0.25; + } + if (delta > 4){ + delta = 4; + } + if (this.game.challenges.getChallengeResearched("energy") && delta < 1) { + delta = 1 - (1 - delta) / 2; + } else if (delta > 1) { + delta = 1; + } + return delta; + } }, getVoidQuantity: function() { diff --git a/js/science.js b/js/science.js index 2730c1bd60..ba890c7fad 100644 --- a/js/science.js +++ b/js/science.js @@ -1028,13 +1028,6 @@ dojo.declare("com.nuclearunicorn.game.ui.tab.Library", com.nuclearunicorn.game.u update: function(){ this.inherited(arguments); - if (!this.game.science.get("chronophysics").researched && this.game.prestige.getPerk("anachronomancy").researched && !this.game.challenges.getCondition("disableChrono").on) - { - var chronophysics = this.game.science.get("chronophysics"); - chronophysics.researched = true; - this.game.unlock(chronophysics.unlocks); - } - if (this.metaphysicsPanel){ this.metaphysicsPanel.update(); } diff --git a/js/space.js b/js/space.js index 4b59aa0162..f0a68e13aa 100644 --- a/js/space.js +++ b/js/space.js @@ -264,6 +264,7 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager } else { self.effects["energyConsumption"] = 1; + self.effects["energyConsumption"] *= game.challenges.getEnergyMod(); } } },{ @@ -290,6 +291,7 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "scienceRatio": 0.5 }; effects["energyConsumption"] = 10; + effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects = effects; }, unlocks: { @@ -326,6 +328,7 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "unobtainiumPerTickSpace": 0.007 * (1+ game.getEffect("lunarOutpostRatio")) }; effects["energyConsumption"] = 5; + effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects = effects; }, lackResConvert: false, @@ -379,6 +382,7 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "energyConsumption" : 0 }; effects["energyConsumption"] = game.workshop.get("amBases").researched ? 5 : 10; + effects["energyConsumption"] *= game.challenges.getEnergyMod(); if (game.workshop.get("aiBases").researched){ for (var key in effects){ @@ -504,6 +508,7 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "spaceRatio": 0.02 }; effects["energyConsumption"] = 20; + effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects = effects; } }] @@ -552,6 +557,7 @@ dojo.declare("classes.managers.SpaceManager", com.nuclearunicorn.core.TabManager "energyConsumption" : 50 * (1+ game.space.getBuilding("heatsink").val * 0.01) }; + effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects = effects; } },{ diff --git a/js/time.js b/js/time.js index 3525cbcf7c..e71b4f9ce0 100644 --- a/js/time.js +++ b/js/time.js @@ -26,7 +26,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, flux: this.flux, heat: this.heat, cfu: this.filterMetadata(this.chronoforgeUpgrades, ["name", "val", "on", "heat", "isAutomationEnabled", "unlocked"]), - vsu: this.filterMetadata(this.voidspaceUpgrades, ["name", "val", "on", "reserve"]) + vsu: this.filterMetadata(this.voidspaceUpgrades, ["name", "val", "on"]) }; }, @@ -109,13 +109,6 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, }, update: function(){ - if (!this.game.challenges.getCondition("disableChrono").on && this.getVSU("usedCryochambers").reserve) - { - var cryochambers = this.getVSU("usedCryochambers"); - cryochambers.val += cryochambers.reserve; - cryochambers.reserve = 0; - } - if (this.isAccelerated && this.game.resPool.get("temporalFlux").value > 0){ this.game.resPool.addResEvent("temporalFlux", -1); } @@ -255,7 +248,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, amt = 5; //limit calculations needed per tick } self.heat -= 100 * amt; - game.time.shatter(amt); + game.time.shatter(amt * (this.game.challenges.getChallengeResearched("1000Years") ? self.on : 1)); } }, unlocked: true @@ -392,6 +385,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, "temporalParadoxDay": 1 + game.getEffect("temporalParadoxDayBonus") }; effects["energyConsumption"] = 15; + effects["energyConsumption"] *= game.challenges.getEnergyMod(); self.effects = effects; }, unlocks: { @@ -490,6 +484,9 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, this.flux += amt - 1 + remainingDaysInFirstYear / daysPerYear; game.challenges.getChallenge("1000Years").unlocked = true; + if (game.challenges.getChallenge("1000Years").on && cal.year >= 1000) { + game.challenges.researchChallenge("1000Years"); + } }, unlockAll: function(){ @@ -564,7 +561,7 @@ dojo.declare("classes.ui.TimeControlWgt", [mixin.IChildrenAware, mixin.IGameAwar } if (this.game.workshop.get("chronoforge").researched) { - var heatMax = this.game.getEffect("heatMax"); + var heatMax = this.game.getEffect("heatMax") * (this.game.challenges.getChallengeResearched("1000Years") ? 2 : 1); if(this.game.time.heat > heatMax){ this.timeSpan.innerHTML += "
Heat: " + this.game.getDisplayValueExt(this.game.time.heat) @@ -610,7 +607,7 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u getName: function(model) { var name = this.inherited(arguments); - if (this.game.time.heat > this.game.getEffect("heatMax")){ + if (this.game.time.heat > this.game.getEffect("heatMax") * (this.game.challenges.getChallengeResearched("1000Years") ? 2 : 1)){ name += " " + $I("time.overheat"); } return name; @@ -627,12 +624,12 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u if (darkYears > 0) { price["val"] = 1 + ((darkYears) / 1000) * 0.01; } - var heatMax = this.game.getEffect("heatMax"); + var heatMax = this.game.getEffect("heatMax") * (this.game.challenges.getChallengeResearched("1000Years") ? 2 : 1); if (this.game.time.heat > heatMax) { price["val"] *= (1 + (this.game.time.heat - heatMax) * 0.01); //1% per excessive heat unit } - - price["val"] *= this.game.challenges.getChallengePenalty("1000Years") * this.game.challenges.getChallengeReward("1000Years"); + + price["val"] *= (game.challenges.getChallenge("1000Years").on ? this.game.challenges.getChallengeEffect("1000Years") : 1) * this.game.challenges.getChallengeReward("1000Years"); } } @@ -644,9 +641,7 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u var prices_cloned = $.extend(true, [], model.options.prices); var impedance = this.game.getEffect("timeImpedance"); - var heatMax = this.game.getEffect("heatMax"); - - var heatFactor = (this.game.challenges.getChallenge("1000Years").researched && !this.game.challenges.getCondition("disableRewards").on) ? 5 : 10; + var heatMax = this.game.getEffect("heatMax") * (this.game.challenges.getChallengeResearched("1000Years") ? 2 : 1); for (var k = 0; k < amt; k++) { for (var i = 0; i < prices_cloned.length; i++) { @@ -657,11 +652,11 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u if (darkYears > 0) { priceLoop = 1 + ((darkYears) / 1000) * 0.01; } - if ((this.game.time.heat + k * heatFactor) > heatMax) { - priceLoop *= (1 + (this.game.time.heat + k * heatFactor - heatMax) * 0.01); //1% per excessive heat unit + if ((this.game.time.heat + k * 10) > heatMax) { + priceLoop *= (1 + (this.game.time.heat + k * 10 - heatMax) * 0.01); //1% per excessive heat unit } - - price["val"] *= this.game.challenges.getChallengePenalty("1000Years") * this.game.challenges.getChallengeReward("1000Years"); + + priceLoop *= (game.challenges.getChallenge("1000Years").on ? this.game.challenges.getChallengeEffect("1000Years") : 1) * this.game.challenges.getChallengeReward("1000Years"); pricesTotal += priceLoop; } } @@ -692,8 +687,7 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u }, doShatter: function(model, amt) { - var factor = (this.game.challenges.getChallenge("1000Years").researched && !this.game.challenges.getCondition("disableRewards").on) ? 5 : 10; - this.game.time.heat += amt*factor; + this.game.time.heat += amt*10; this.game.time.shatter(amt); }, diff --git a/js/toolbar.js b/js/toolbar.js index 84f99490fb..53ce370ad3 100644 --- a/js/toolbar.js +++ b/js/toolbar.js @@ -201,14 +201,13 @@ dojo.declare("classes.ui.toolbar.ToolbarEnergy", classes.ui.ToolbarIcon, { var energy = resPool.energyProd - resPool.energyCons; var delta = this.game.resPool.getEnergyDelta(); - var penalty = energy >= 0 ? "" :"

Production bonuses cuts: -" + Math.floor( (1-delta) * 100) + "%"; - if (!this.game.challenges.getChallenge("energy").on && this.game.challenges.getChallenge("energy").researched && !this.game.challenges.getCondition("disableRewards").on && energy > 0) - { - penalty = "

Production bonuses gains: +" + Math.floor( (delta-1) * 100) + "%"; + var mod = energy >= 0 ? "" :"

Production bonuses cuts: -" + Math.floor( (1-delta) * 100) + "%"; + if (this.game.challenges.getChallengeResearched("energy") && energy > 0) { + mod = "

Production bonuses gains: +" + Math.floor( (delta-1) * 100) + "%"; } return "Production: " + this.game.getDisplayValueExt(resPool.energyProd, true, false) + "Wt" + - "
Consumption: -" + this.game.getDisplayValueExt(resPool.energyCons) + "Wt" + penalty; + "
Consumption: -" + this.game.getDisplayValueExt(resPool.energyCons) + "Wt" + mod; } }); diff --git a/js/ui.js b/js/ui.js index cefd7c2387..7a5f0862e5 100644 --- a/js/ui.js +++ b/js/ui.js @@ -520,7 +520,7 @@ dojo.declare("classes.ui.DesktopUI", classes.ui.UISystem, { return; } - if (this.game.religion.faith > 0){ + if (this.game.religion.faith > 0 && !this.game.challenges.getChallenge("atheism").on){ if (this.fastPraiseContainer.style.visibility == "hidden"){ this.fastPraiseContainer.style.visibility = "visible"; } @@ -885,4 +885,4 @@ dojo.declare("classes.ui.DesktopUI", classes.ui.UISystem, { return this.keyStates.shiftKey; } -}); \ No newline at end of file +}); diff --git a/js/village.js b/js/village.js index ed6dabde5c..a144ab375f 100644 --- a/js/village.js +++ b/js/village.js @@ -158,7 +158,7 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag var leaderTrait = this.leader.trait.name; if (leaderTrait == trait) { var burnedParagonRatio = 1 + this.game.prestige.getBurnedParagonRatio(); - var reward = (this.game.challenges.getChallenge("anarchy").researched && !this.game.challenges.getCondition("disableRewards").on) ? Math.sqrt(this.leader.rank) : 1; + var reward = this.game.challenges.getChallengeResearched("anarchy") ? Math.sqrt(this.leader.rank) : 1; // Modify the defautlObject depends on trait switch (trait) { case "engineer": // Crafting bonus @@ -351,7 +351,7 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag } var diligentKittens = this.game.challenges.getChallenge("anarchy").on - ? Math.floor(this.getKittens() * this.game.challenges.getChallengePenalty("anarchy")) + ? Math.ceil(this.getKittens() * this.game.challenges.getChallengeEffect("anarchy")) : this.getKittens(); return diligentKittens - workingKittens; @@ -552,9 +552,15 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag kittens.push(_kitten); } + var reserve = []; + for (var i in this.sim.reserve){ + var _kitten = this.sim.reserve[i].save(); + reserve.push(_kitten); + } + saveData.village = { kittens : kittens, - reserveKittens: this.sim.reserveKittens, + reserve : reserve, maxKittens: this.maxKittens, jobs: this.filterMetadata(this.jobs, ["name", "unlocked", "value"]), map : this.map.villageData @@ -564,17 +570,17 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag load: function(saveData){ if (saveData.village){ var kittens = saveData.village.kittens; - var reserveKittens = saveData.village.reserveKittens; + var reserve = saveData.village.reserve; //quick legacy hack, remove in future if (!kittens.length) { kittens = []; } - if (!reserveKittens || !reserveKittens.length) { - reserveKittens = []; + if (!reserve) { + reserve = []; } this.sim.kittens = []; - this.sim.reserveKittens = []; + this.sim.reserve = []; this.game.village.traits = []; for (var i = kittens.length - 1; i >= 0; i--) { @@ -596,14 +602,14 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag this.sim.kittens.unshift(newKitten); } - - for (var i = reserveKittens.length - 1; i >= 0; i--) { - var reserveKitten = reserveKittens[i]; + + for (var i = reserve.length - 1; i >= 0; i--) { + var reserve = reserve[i]; var newKitten = new com.nuclearunicorn.game.village.Kitten(); - newKitten.load(reserveKitten); + newKitten.load(reserve); - this.sim.reserveKittens.unshift(newKitten); + this.sim.reserve.unshift(newKitten); } this.maxKittens = saveData.village.maxKittens; @@ -1202,7 +1208,7 @@ dojo.declare("classes.village.Map", null, { dojo.declare("classes.village.KittenSim", null, { kittens: null, - reserveKittens: null, + reserve: null, game: null, @@ -1223,16 +1229,6 @@ dojo.declare("classes.village.KittenSim", null, { if (!times) { times = 1; } - - if (!this.game.challenges.getCondition("disableChrono").on && this.reserveKittens) - { - for (var i = 0; i < this.reserveKittens.length; i++) - { - this.kittens.push(this.reserveKittens[i]); - } - - this.reserveKittens = []; - } if (this.kittens.length < this.maxKittens) { //Don't do maths if Maxed. this.nextKittenProgress += times * kittensPerTick; diff --git a/res/i18n/en.json b/res/i18n/en.json index 39ea4722e8..9453e8ca49 100644 --- a/res/i18n/en.json +++ b/res/i18n/en.json @@ -238,47 +238,51 @@ "stats.time.current": "Time Played", "stats.group.all": "All-Time Stats", "stats.group.current": "Current Game Stats", - "challendge.1000Years.desc": "Restart the game with a half-life time.

Goal: Reach year 1000.", - "challendge.1000Years.effect.desc": "Colder combustion of Time Crystal.", + "challendge.1000Years.desc": "Calendar Year doesn't advance normally after 500. Time crystal shatter price increases each time challenge is completed.
Goal: Reach year 1000.", + "challendge.1000Years.effect.desc": "Chrono Furnace shatters once each when heated and Heat limit is doubled.", + "challendge.1000Years.repeatEffect.desc": "Time crystal shatter price is reduced by 10% per completion.", "challendge.1000Years.label": "1000 years", - "challendge.anarchy.desc": "Restart the game with kittens acting their own way : kittens are lazy, always eat extra catnip and can't be assigned as leaders.

Goal: Construct AI Core", - "challendge.anarchy.effect.desc": "Kittens count double for karma", + "challendge.anarchy.desc": "Only half of kittens will work, they can't be made leaders or gain skills, and they always consume catnip. Proportion of kittens that will work decreases each time challenge is completed.
Goal: Construct AI Core.", + "challendge.anarchy.effect.desc": "Kittens count double for karma and leader trait effects scale with leader rank.", + "challendge.anarchy.repeatEffect.desc": "Master proficiency effect is increased by 50% per completion.", "challendge.anarchy.label": "Anarchy", - "challendge.atheism.desc": "Restart the game without faith bonus.

Goal: Reset with at least one cryochamber.", - "challendge.atheism.effect.desc": "Increase your faith bonus limit by 100% per transcendence tier (equivalent to 20 Black Obelisks).", + "challendge.atheism.desc": "Faith cannot be gained or used in any way. Sacrificing unicorns yields less tears each time challenge is completed.
Goal: Buy at least one cryochamber.", + "challendge.atheism.effect.desc": "Increases your faith bonus limit by 100% per transcendence tier (equivalent to 20 Black Obelisks).", + "challendge.atheism.repeatEffect.desc": "Faith bonus is increased by 25% on faith itself per completion.", "challendge.atheism.label": "Atheism", - "challendge.btn.chronosphere.with.ironWill.desc": " WARNING: the reset bonus from chronospheres will automatically disable IW.", - "challendge.btn.confirmation.dlg.text": "Are you sure you want to start this challenge by resetting the game ?", - "challendge.btn.confirmation.dlg.title": "Challenge confirmation", - "challendge.btn.desc": "
Gain: {0}

{1}", - "challendge.btn.log.message.on.complete": "Congratulations! You complete the challenge {0}.", - "challendge.energy.desc": "Restart the game with consumption of energy multiply by 2.

Goal: Unlock all energy production buildings and build at least one of them.", - "challendge.energy.effect.desc": "Production bonuses cuts caused by negative energy are divided by 2.", + "challendge.btn.ironWill.desc": "

{0}
Difficulty: {1}", + "challendge.btn.desc": "

Initial Reward: {0}
Repeat Reward: {1}
Resource Reward: {2}
Resource Reward Base Amount: {3}
Difficulty: {4}
Apotheosis is rewarded upon completion based on difficulty.", + "challendge.btn.log.message.on.complete": "Congratulations! You complete the challenge {0}.
You receive {1} {2} and {3} apotheosis.", + "challendge.btn.log.message.on.complete.noChallenge": "Congratulations! You've reached the moon.
You receive {0} apotheosis.", + "challendge.energy.desc": "Energy consumption is doubled. Energy consumption increases further each time challenge is completed.
Goal: Unlock all energy production buildings and build at least one of them.", + "challendge.energy.effect.desc": "Production bonuses cuts caused by negative energy are divided by 2 and production bonuses are increased by positive energy.", + "challendge.energy.repeatEffect.desc": "Energy consumption is reduced by 10% per completion.", "challendge.energy.label": "Energy", - "challendge.ironWill.desc": "Iron Will is a bit hidden challenge and you don't need to click here to enable it: reset the game and play without kittens.", - "challendge.ironWill.effect.desc": "Nothing", + "challendge.ironWill.desc": "Iron Will is a hidden challenge enabled by playing without kittens.", + "challendge.ironWill.effect.desc": "Resource and apotheosis rewards from other challenges are increased when also playing Iron Will.", "challendge.ironWill.label": "Iron Will", - "challendge.winterIsComing.desc": "Restart the game with only winter seasons. (Catnip will not benefit from paragon production bonus)

Goal: Get to Helios.", - "challendge.winterIsComing.effect.desc": "Warm seasons are more likely, and cold seasons are less likely.", + "challendge.winterIsComing.desc": "All seasons are winter and catnip will not benefit from paragon production bonus. Cold seasons are more common and decrease catnip yield by more each time challenge is completed
Goal: Get to Helios.", + "challendge.winterIsComing.effect.desc": "No more cold winters and Solar Farms are twice as effective year round.", + "challendge.winterIsComing.repeatEffect.desc": "Catnip Fields and Solar Farms have increased effectiveness in spring and summer, respectively, by 20% per completion.", "challendge.winterIsComing.label": "Winter Has Come", "challendge.panel.label": "Challenges", "challendge.condition.panel.label": "Conditions", "challendge.condition.disableChrono.label": "No Chronospheres", "challendge.condition.disableChrono.desc": "Benefits from Anachronomancy, Chronospheres, and Cryochambers will not be available on reset until this is re-enabled. Must be enabled to get challenge rewards.", - "challendge.condition.disableMetaResources.label": "No Metaphysics Resources", - "challendge.condition.disableMetaResources.desc": "Karma, Paragon, Burned Paragon, and Apotheosis will be reset until this is re-enabled. Increases challenge rewards.", - "challendge.condition.disableMetaTechs.label": "No Metaphysics Techs", - "challendge.condition.disableMetaTechs.desc": "Metaphysics Techs will be reset until this is re-enabled. Increases challenge rewards.", + "challendge.condition.disableParagon.label": "No Paragon", + "challendge.condition.disableParagon.desc": "Karma, Paragon, Burned Paragon, and Apotheosis will be reset until this is re-enabled. Increases challenge rewards.", + "challendge.condition.disableMetaphysics.label": "No Metaphysics", + "challendge.condition.disableMetaphysics.desc": "Metaphysics will be reset until this is re-enabled. Increases challenge rewards.", "challendge.condition.disableApo.label": "No Apocrypha", "challendge.condition.disableApo.desc": "Apocrypha, Transcendence Tiers, and Cryptotheology Upgrades will be reset until this is re-enabled. Increases challenge rewards.", "challendge.condition.disableRewards.label": "No Challenge Rewards", "challendge.condition.disableRewards.desc": "All Challenge Rewards effects will be disabled until this is re-enabled. Challenges still grant rewards. Increases challenge rewards.", "challendge.condition.disableMisc.label": "No Miscellaneous", - "challendge.condition.disableMisc.desc": "BLS, Iron Will Zebras, and Present Boxes/Wrapping Paper will be reset until this is re-enabled. Does NOT increase challenge rewards.", + "challendge.condition.disableMisc.desc": "BLS, Iron Will Zebras, Present Boxes/Wrapping Paper, and Temporal Flux will be reset until this is re-enabled. Increases challenge rewards.", + "challendge.condition.btn.desc": "

Bonus Multiplier: {0}", "challendge.pending": "Pending", "challendge.applyPending.label": "Apply Pending Changes", "challendge.applyPending.desc": "Turn on Challenges/Conditions marked as Pending immediately", - "space.centaurusSystemMission.desc": "Centaurus System is a warm faraway star system.", "space.centaurusSystemMission.label": "Centaurus System Mission", "space.duneMission.desc": "Dune is a large and lifeless planet covered by sand and volcanic rock.", @@ -1330,8 +1334,8 @@ "tab.name.religion": "Religion", "tab.name.space": "Space", "tab.name.time": "Time", - "tab.name.challenges": "Challenges", "tab.name.stats": "Stats", + "tab.name.challenges": "Challenges", "tab.name.achievements": "Achievements", "menu.save": "Save", "menu.import": "Import", From 51bd784436d2e2756a95f05911f2501166c110bd Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Tue, 20 Aug 2019 22:07:00 -0400 Subject: [PATCH 33/58] That's embarrassing --- js/jsx/left.jsx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jsx/left.jsx.js b/js/jsx/left.jsx.js index 000bdc0d91..31dc21162c 100644 --- a/js/jsx/left.jsx.js +++ b/js/jsx/left.jsx.js @@ -110,7 +110,7 @@ WResourceRow = React.createClass({ if (season.modifiers[res.name] && perTick !== 0 ){ - var modifier = Math.floor(game.calendar.getWeatherMod(res) - 1) * 100; + var modifier = Math.floor((game.calendar.getWeatherMod(res) - 1) * 100); weatherModValue = modifier ? "[" + (modifier > 0 ? "+" : "") + modifier.toFixed() + "%]" : ""; if (modifier > 0) { From 6db9b57295f4be8be959aa73417b3b870f528327 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 25 Aug 2019 11:16:08 -0400 Subject: [PATCH 34/58] That was close; make crafting behave sensibly with reserves --- js/jsx/left.jsx.js | 4 ++-- js/resources.js | 19 +++++++++++++++++-- js/workshop.js | 6 +++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/js/jsx/left.jsx.js b/js/jsx/left.jsx.js index 31dc21162c..459a1b3c96 100644 --- a/js/jsx/left.jsx.js +++ b/js/jsx/left.jsx.js @@ -227,7 +227,7 @@ WCraftShortcut = React.createClass({ $r("div", {className:"res-cell craft-link", onClick: this.doCraftAll}, $I("resources.craftTable.all")) : $r("div", {className:"res-cell craft-link"}); }else{ - elem = game.resPool.hasRes(craftPrices, craftRowAmt) ? + elem = game.resPool.hasRes(craftPrices, craftRowAmt, true) ? $r("div", {className:"res-cell craft-link", onClick: this.doCraft}, "+" + game.getDisplayValueExt(craftRowAmt * (1 + craftRatio), null, null, 0)) : $r("div", {className:"res-cell craft-link"}); @@ -285,7 +285,7 @@ WCraftShortcut = React.createClass({ hasMinAmt: function(recipe){ var minAmt = Number.MAX_VALUE; for (var j = 0; j < recipe.prices.length; j++){ - var totalRes = game.resPool.get(recipe.prices[j].name).value; + var totalRes = game.resPool.getTotal(recipe.prices[j].name); var allAmt = Math.floor(totalRes / recipe.prices[j].val); if (allAmt < minAmt){ minAmt = allAmt; diff --git a/js/resources.js b/js/resources.js index 707b934dbd..b532f62bfb 100644 --- a/js/resources.js +++ b/js/resources.js @@ -532,6 +532,15 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana return res; }, + getTotal: function(res) { + var res = this.get(res); + if (this.game.challenges.getCondition("disableChrono").on) { + return res.value; + } else { + return res.value + res.reserve; + } + }, + addRes: function(res, addedValue, event, preventLimitCheck) { if (this.game.calendar.day < 0 && !event) { return 0; @@ -816,7 +825,8 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana /** * Returns true if user has enough resources to construct AMT building with given price */ - hasRes: function(prices, amt){ + hasRes: function(prices, amt, includeReserve){ + includeReserve = includeReserve && !this.game.challenges.getCondition("disableChrono").on; if (!amt){ amt = 1; } @@ -827,7 +837,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var price = prices[i]; var res = this.get(price.name); - if (res.value < (price.val * amt)){ + if (res.value + (includeReserve ? res.reserve : 0) < (price.val * amt)){ hasRes = false; break; } @@ -863,6 +873,11 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana if (prices.length){ for( var i = 0; i < prices.length; i++){ var price = prices[i]; + var res = this.get(price.name); + if (!this.game.challenges.getCondition("disableChrono").on && price.val > res.value) { + res.reserve -= (price.val - res.value); + res.value = price.val; + } this.addResEvent(price.name, -price.val); } } diff --git a/js/workshop.js b/js/workshop.js index eefcb79e64..90c234abcc 100644 --- a/js/workshop.js +++ b/js/workshop.js @@ -2211,7 +2211,7 @@ dojo.declare("classes.managers.WorkshopManager", com.nuclearunicorn.core.TabMana var craftAmt = amt * (1 + craftRatio); //prevent undo giving free res - if (amt < 0 && this.game.resPool.get(res).value < Math.abs(craftAmt)) { + if (amt < 0 && this.game.resPool.getTotal(res) < Math.abs(craftAmt)) { return false; } @@ -2221,7 +2221,7 @@ dojo.declare("classes.managers.WorkshopManager", com.nuclearunicorn.core.TabMana prices[i].val *= amt; } - if (bypassResourceCheck || this.game.resPool.hasRes(prices)) { + if (bypassResourceCheck || this.game.resPool.hasRes(prices, 1, true)) { this.game.resPool.payPrices(prices); this.game.resPool.addResEvent(res,craftAmt); if (craft.upgrades){ @@ -2298,7 +2298,7 @@ dojo.declare("classes.managers.WorkshopManager", com.nuclearunicorn.core.TabMana var minAmt = Number.MAX_VALUE; for (var j = prices.length - 1; j >= 0; j--) { - var totalRes = this.game.resPool.get(prices[j].name).value; + var totalRes = this.game.resPool.getTotal(prices[j].name); var allAmt = totalRes / prices[j].val; // we need fraction here, do floor later if (allAmt < minAmt){ minAmt = allAmt; From 75f109c7a08e17bef3456a6fcfaffb8408fcc447 Mon Sep 17 00:00:00 2001 From: Wymrite Date: Sun, 5 Jan 2020 02:50:40 +0000 Subject: [PATCH 35/58] Incredibly Complex and Detailed Solar Panel Fix --- js/buildings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/buildings.js b/js/buildings.js index 7cdb999b9f..bb84df6adc 100644 --- a/js/buildings.js +++ b/js/buildings.js @@ -360,7 +360,7 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan effects["energyProduction"] *= 0.75; } else if (game.calendar.getCurSeason().name == "summer") { effects["energyProduction"] /= 0.75; - effects["energyProduction"] *= this.game.challenges.getChallengeReward("winterIsComing"); + effects["energyProduction"] *= game.challenges.getChallengeReward("winterIsComing"); } var seasonRatio = game.getEffect("solarFarmSeasonRatio"); From 968b37645d01e9aeef09e838169f0a1211319ac6 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 12 Jan 2020 18:04:29 -0500 Subject: [PATCH 36/58] Fix some bugs --- js/challenges.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/challenges.js b/js/challenges.js index f96270d2ff..7300c8d4b1 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -311,10 +311,10 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa if (type == "frequency") { return this.game.getHyperbolicEffect(challenge.researched * 50, 825); } else { - return 1 - this.game.getHyperbolicEffect(researched * 0.1, 1); + return 1 - this.game.getHyperbolicEffect(challenge.researched * 0.1, 1); } } else if (name == "anarchy") { - return 0.5 - this.game.getHyperbolicEffect(researched * 0.05, 0.4); + return 0.5 - this.game.getHyperbolicEffect(challenge.researched * 0.05, 0.4); } else if (name == "energy") { return 2 + 0.1 * challenge.researched; } else if (name == "atheism") { @@ -391,6 +391,16 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa this.rewardable = false; + var uncappedRes = ["starchart", "relic", "void", "blackcoin", "bloodstone"]; + for (var i = 0; i < this.game.resPool.resources.length; i++) { + var res = this.game.resPool.resources[i]; + + if (res.craftable || uncappedRes.indexOf(res.name) >= 0) { + res.value += res.reserve; + res.reserve = 0; + } + } + if (this.game.prestige.getPerk("anachronomancy").researched) { var chronophysics = this.game.science.get("chronophysics"); chronophysics.researched = true; From 9184b7c5871ff999e28734c7cc6354167adb054e Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Mon, 13 Jan 2020 18:45:17 -0500 Subject: [PATCH 37/58] Fix cryochamber bug --- js/village.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/village.js b/js/village.js index 9ed22804c8..a858b4b683 100644 --- a/js/village.js +++ b/js/village.js @@ -611,10 +611,10 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag } for (var i = reserve.length - 1; i >= 0; i--) { - var reserve = reserve[i]; + var reserveKitten = reserve[i]; var newKitten = new com.nuclearunicorn.game.village.Kitten(); - newKitten.load(reserve); + newKitten.load(reserveKitten); this.sim.reserve.unshift(newKitten); } From 27053e0cca47eb712e7ad32701a24410b61953cc Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Mon, 27 Jan 2020 22:29:08 -0500 Subject: [PATCH 38/58] More bug fixes --- js/buildings.js | 4 +++- js/challenges.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/buildings.js b/js/buildings.js index bb84df6adc..e5d5e49051 100644 --- a/js/buildings.js +++ b/js/buildings.js @@ -1430,7 +1430,9 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan self.effects["goldPerTickCon"] = -0.005; //~5 smelters var manpower = game.resPool.get("manpower"); - var mpratio = (manpower.maxValue * 0.007) / 100; + var manpowerMax = game.getEffect("manpowerMax") || 0; + manpowerMax = game.resPool.addResMaxRatios(manpower, manpowerMax); + var mpratio = (manpowerMax * 0.007) / 100; //hidden 1% boost to mints from village level mpratio *= (1 + game.village.map.villageLevel * 0.005); diff --git a/js/challenges.js b/js/challenges.js index 7300c8d4b1..ed13904625 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -190,7 +190,8 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa ) { this.researchChallenge("energy"); } - } else if (this.getChallenge("anarchy").on) { + } + if (this.getChallenge("anarchy").on) { if (this.game.bld.get("aiCore").val > 0){ this.researchChallenge("anarchy"); } From 5bffe26c3ef0fc64b3931075e9038ee23d98c66e Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Tue, 28 Jan 2020 21:55:41 -0500 Subject: [PATCH 39/58] Fix kitten starving to death on reset when using cryochambers without No Chronospheres --- js/village.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/village.js b/js/village.js index a858b4b683..7e8bd9273e 100644 --- a/js/village.js +++ b/js/village.js @@ -284,6 +284,10 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag var catnipPerTick = this.game.getResourcePerTick("catnip", true); var catnipVal = this.game.resPool.get("catnip").value; + // hack + // Starved kittens check should really happen after resPool.update() + if (!this.game.challenges.getCondition("disableChrono").on) + catnipVal += this.game.resPool.get("catnip").reserve; var resDiff = catnipVal + catnipPerTick; if (this.sim.getKittens() > 0){ From fb4265492871f1a5d82275fda46a37d6b06b9353 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 2 Feb 2020 17:15:43 -0500 Subject: [PATCH 40/58] Fix weather being applied to resources other than catnip --- js/calendar.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index e2221a80b2..27d3f4cc9b 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -922,20 +922,20 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { if (this.getCurSeason().modifiers[res.name]){ mod = this.getCurSeason().modifiers[res.name]; - } - if (this.weather == "warm"){ - mod += 0.15; - } else if (this.weather == "cold"){ - mod -= 0.15; - } + if (this.weather == "warm"){ + mod += 0.15; + } else if (this.weather == "cold"){ + mod -= 0.15; + } - if (this.game.challenges.getChallenge("winterIsComing").on && this.weather == "cold") { - mod = ((mod + 1) * this.game.challenges.getChallengeEffect("winterIsComing", "modifier")) - 1; - } + if (this.game.challenges.getChallenge("winterIsComing").on && this.weather == "cold") { + mod = ((mod + 1) * this.game.challenges.getChallengeEffect("winterIsComing", "modifier")) - 1; + } - if (this.getCurSeason().name == "spring"){ - mod *= this.game.challenges.getChallengeReward("winterIsComing"); + if (this.getCurSeason().name == "spring"){ + mod *= this.game.challenges.getChallengeReward("winterIsComing"); + } } return mod; From 18c5fddebd8c63828fc58f4ec06d6ee0b77ee259 Mon Sep 17 00:00:00 2001 From: Eric Barr Date: Wed, 22 Apr 2020 05:37:34 +0000 Subject: [PATCH 41/58] Fix to undefined error when enabling automation on Chrono Furnace. --- js/time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/time.js b/js/time.js index cd8fdd173d..92102ec94b 100644 --- a/js/time.js +++ b/js/time.js @@ -256,7 +256,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, amt = 5; //limit calculations needed per tick } self.heat -= 100 * amt; - game.time.shatter(amt * (this.game.challenges.getChallengeResearched("1000Years") ? self.on : 1)); + game.time.shatter(amt * (game.challenges.getChallengeResearched("1000Years") ? self.on : 1)); } }, unlocks: { From 27c1edf314a679e5571de0620b9beec9da113314 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 30 May 2020 08:42:32 -0400 Subject: [PATCH 42/58] Fix dumb mistakes --- js/calendar.js | 2 +- js/challenges.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index e4634d0803..d4a1810183 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -904,7 +904,7 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { } if (this.game.challenges.getChallenge("winterIsComing").on && this.weather == "cold") { - mod = ((mod + 1) * this.game.challenges.getChallengeEffect("winterIsComing", "modifier")) - 1; + mod = mod * this.game.challenges.getChallengeEffect("winterIsComing", "modifier"); } if (this.getCurSeason().name == "spring"){ diff --git a/js/challenges.js b/js/challenges.js index ed13904625..2fdc914c34 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -280,7 +280,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa if (res) { if (res.maxValue && res.value + resAmt > res.maxValue) { - res.reserve = res.value - res.maxValue; + res.reserve = res.value + resAmt - res.maxValue; res.value = res.maxValue; } else { res.value += resAmt; @@ -545,9 +545,9 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa res.value = 0; } } else { - this.karmaZebras += this.karmaZebrasReserve; - this.karmaZebrasReserve = 0; - this.game.resPool.get("zebras").maxValue = this.karmaZebras ? this.karmaZebras + 1 : 0; + this.game.karmaZebras += this.game.karmaZebrasReserve; + this.game.karmaZebrasReserve = 0; + this.game.resPool.get("zebras").maxValue = this.game.karmaZebras ? this.game.karmaZebras + 1 : 0; var miscRes = ["zebras", "sorrow", "elderBox", "wrappingPaper", "temporalFlux"]; for (var i = 0; i < miscRes.length; i++) { From 06e0ebef4fa1a923494ce7fa93f3a5a7a002121c Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sun, 31 May 2020 19:50:52 -0400 Subject: [PATCH 43/58] Fix rounding error --- js/jsx/left.jsx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jsx/left.jsx.js b/js/jsx/left.jsx.js index d31aa4a54c..ba96a52065 100644 --- a/js/jsx/left.jsx.js +++ b/js/jsx/left.jsx.js @@ -110,7 +110,7 @@ WResourceRow = React.createClass({ if (season.modifiers[res.name] && perTick !== 0 ){ - var modifier = Math.floor((game.calendar.getWeatherMod(res) - 1) * 100); + var modifier = Math.max(Math.round((game.calendar.getWeatherMod(res) - 1) * 100), -99); weatherModValue = modifier ? "[" + (modifier > 0 ? "+" : "") + modifier.toFixed() + "%]" : ""; if (modifier > 0) { From aa3a8dd73d41ae0b2b251c52d5416de5b184183d Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Thu, 4 Jun 2020 22:06:36 -0400 Subject: [PATCH 44/58] More fixes --- core.js | 4 ++++ game.js | 2 +- js/challenges.js | 39 ++++++++++++++++++++++++++------------- js/time.js | 6 +++--- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/core.js b/core.js index c943cc6db3..ff1604f195 100644 --- a/core.js +++ b/core.js @@ -2085,6 +2085,10 @@ dojo.declare("com.nuclearunicorn.game.ui.BuildingStackableBtnController", com.nu } if (meta.breakIronWill) { + // Research atheism before breaking iron will + // so bonus apotheosis is rewarded. + // Should find a better solution. + this.game.challenges.update(); this.game.ironWill = false; } diff --git a/game.js b/game.js index 08dfe8c35e..92e2be533c 100644 --- a/game.js +++ b/game.js @@ -3536,7 +3536,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { karmaKittensReserve: karmaKittensReserve, karmaZebras: karmaZebras, karmaZebrasReserve: karmaZebrasReserve, - ironWill : !this.challenges.getCondition("disableChrono") && saveRatio > 0 ? false : true, //chronospheres will disable IW + ironWill : !this.challenges.getCondition("disableChrono").on && saveRatio > 0 ? false : true, //chronospheres will disable IW deadKittens: 0, isCMBREnabled: false }); diff --git a/js/challenges.js b/js/challenges.js index 2fdc914c34..b0b8080a48 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -167,8 +167,10 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa update: function(){ if (this.game.ironWill && this.game.bld.get("library").on > 0) { this.getChallenge("ironWill").on = true; - } else if (!this.game.ironWill) { + this.getChallenge("ironWill").rewardable = true; + } else { this.getChallenge("ironWill").on = false; + this.getChallenge("ironWill").rewardable = false; } // energy @@ -208,15 +210,15 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa if (this.game.time.getVSU("cryochambers").on > 0){ this.researchChallenge("atheism"); - if (game.ironWill){ - game.achievements.unlockHat("ivoryTowerHat"); + if (this.game.ironWill){ + this.game.achievements.unlockHat("ivoryTowerHat"); } } } var noChallenge = true; for (var i = 0; i < this.challenges.length; i++) { - if (this.challenges[i].on) { + if (this.challenges[i].on && this.challenges[i].name != "ironWill") { noChallenge = false; } } @@ -252,15 +254,22 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa for (var i = 0; i < this.challenges.length; i++) { if (this.challenges[i].rewardable) { challengeTotal += Math.pow(this.challenges[i].difficulty, 2); - challengeNumber++; + if (this.challenges[i].name != "ironWill") + challengeNumber++; } } - apotheosis += Math.floor(Math.sqrt(challengeTotal) / challengeNumber); + apotheosis += Math.sqrt(challengeTotal) / challengeNumber; } } - if (this.rewardable && !this.rewarded) { - apotheosis += 1; + else if (this.rewardable && !this.rewarded) { + if (this.getChallenge("ironWill").rewardable && !this.getChallenge("ironWill").rewarded) { + apotheosis = 100; + this.getChallenge("ironWill").rewarded = true; + } + else { + apotheosis = 1; + } this.rewarded = true; } @@ -268,15 +277,17 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa return; } - var conditionTotal = 1; + var conditionTotal = 0; for (var i = 0; i < this.conditions.length; i++) { if (this.conditions[i].on && this.conditions[i].bonus) { conditionTotal += Math.pow(this.conditions[i].bonus * (1 - this.game.getHyperbolicEffect(this.conditions[i].resets / 10, 1)), 2); } } - resAmt *= Math.sqrt(conditionTotal); - apotheosis *= Math.sqrt(conditionTotal); + if (conditionTotal != 0) { + resAmt *= Math.sqrt(conditionTotal); + apotheosis *= Math.sqrt(conditionTotal); + } if (res) { if (res.maxValue && res.value + resAmt > res.maxValue) { @@ -287,12 +298,12 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa } } - this.game.resPool.addRes(this.game.resPool.get("apotheosis"), apotheosis, true); + this.game.resPool.addRes(this.game.resPool.get("apotheosis"), Math.floor(apotheosis), true); if (challenge) { challenge.researched++; challenge.rewarded = true; - this.game.msg($I("challendge.btn.log.message.on.complete", [challenge.label, resAmt, res.title, apotheosis])); + this.game.msg($I("challendge.btn.log.message.on.complete", [challenge.label, resAmt, res.title, Math.floor(apotheosis)])); } else { this.game.msg($I("challendge.btn.log.message.on.complete.noChallenge", [apotheosis])); } @@ -386,6 +397,8 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa } if (name == "disableChrono" && !on) { + this.game.ironWill = false; + for (var i = 0; i < this.challenges.length; i++) { this.challenges[i].rewardable = false; } diff --git a/js/time.js b/js/time.js index 61ccca8251..aad8053c72 100644 --- a/js/time.js +++ b/js/time.js @@ -685,7 +685,7 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u price["val"] *= (1 + (this.game.time.heat - heatMax) * 0.01); //1% per excessive heat unit } - price["val"] *= (game.challenges.getChallenge("1000Years").on ? this.game.challenges.getChallengeEffect("1000Years") : 1) * this.game.challenges.getChallengeReward("1000Years"); + price["val"] *= (this.game.challenges.getChallenge("1000Years").on ? this.game.challenges.getChallengeEffect("1000Years") : 1) * this.game.challenges.getChallengeReward("1000Years"); } } @@ -712,7 +712,7 @@ dojo.declare("classes.ui.time.ShatterTCBtnController", com.nuclearunicorn.game.u priceLoop *= (1 + (this.game.time.heat + k * 10 - heatMax) * 0.01); //1% per excessive heat unit } - priceLoop *= (game.challenges.getChallenge("1000Years").on ? this.game.challenges.getChallengeEffect("1000Years") : 1) * this.game.challenges.getChallengeReward("1000Years"); + priceLoop *= (this.game.challenges.getChallenge("1000Years").on ? this.game.challenges.getChallengeEffect("1000Years") : 1) * this.game.challenges.getChallengeReward("1000Years"); pricesTotal += priceLoop; } } @@ -968,7 +968,7 @@ dojo.declare("classes.ui.ResetWgt", [mixin.IChildrenAware, mixin.IGameAware], { var paragonPoints = 0; if (kittens > 70){ - paragonPoints = (kittens - 70); + paragonPoints = (kittens - 70) * (1 + this.game.prestige.getParagonBonus()); } msg += "
" + $I("time.reset.karma") + ": " + karmaPoints; From bcfc1fd81ebe8b3c06ccd1ae3ae34679e9ac760a Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 5 Jun 2020 10:31:47 -0400 Subject: [PATCH 45/58] Revert small change --- js/challenges.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/challenges.js b/js/challenges.js index b0b8080a48..2aadfa3a71 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -168,7 +168,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa if (this.game.ironWill && this.game.bld.get("library").on > 0) { this.getChallenge("ironWill").on = true; this.getChallenge("ironWill").rewardable = true; - } else { + } else if (!this.game.ironWill) { this.getChallenge("ironWill").on = false; this.getChallenge("ironWill").rewardable = false; } From 0137fa38f98d394870e1f46f7c56759d22ac25ed Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Fri, 5 Jun 2020 17:56:23 -0400 Subject: [PATCH 46/58] Take reserves into account for hunting and praising --- js/religion.js | 5 +++-- js/ui.js | 2 +- js/village.js | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/js/religion.js b/js/religion.js index 069823e461..5d31475372 100644 --- a/js/religion.js +++ b/js/religion.js @@ -752,9 +752,10 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana praise: function(){ var faith = this.game.resPool.get("faith"); - this.faith += faith.value * (1 + this.getApocryphaBonus()); //starting up from 100% ratio will work surprisingly bad - this.game.msg($I("religion.praise.msg", [this.game.getDisplayValueExt(faith.value, false, false, 0)]), "", "faith"); + this.faith += this.game.resPool.getTotal("faith") * (1 + this.getApocryphaBonus()); //starting up from 100% ratio will work surprisingly bad + this.game.msg($I("religion.praise.msg", [this.game.getDisplayValueExt(this.game.resPool.getTotal("faith"), false, false, 0)]), "", "faith"); faith.value = 0.0001; //have a nice autoclicking + faith.reserve = 0; }, diff --git a/js/ui.js b/js/ui.js index e267222634..f88a498b17 100644 --- a/js/ui.js +++ b/js/ui.js @@ -553,7 +553,7 @@ dojo.declare("classes.ui.DesktopUI", classes.ui.UISystem, { if (this.fastHuntContainer.style.visibility == "hidden"){ this.fastHuntContainer.style.visibility = "visible"; } - var huntCount = Math.floor(catpower.value / 100); + var huntCount = Math.floor(this.game.resPool.getTotal("manpower") / 100); $("#fastHuntContainerCount")[0].innerHTML = this.game.getDisplayValueExt(huntCount, false, false, 0) + (huntCount === 1 ? " time" : " times"); } else { diff --git a/js/village.js b/js/village.js index 6a536ae0f9..c05ce84141 100644 --- a/js/village.js +++ b/js/village.js @@ -707,14 +707,14 @@ dojo.declare("classes.managers.VillageManager", com.nuclearunicorn.core.TabManag }, huntAll: function() { - var mpower = this.game.resPool.get("manpower"); - var squads = Math.floor(mpower.value / 100); + var mpower = this.game.resPool.getTotal("manpower"); + var squads = Math.floor(mpower / 100); this.huntMultiple(squads); }, huntMultiple: function (squads){ - var mpower = this.game.resPool.get("manpower"); - squads = Math.min(squads, Math.floor(mpower.value / 100)); + var mpower = this.game.resPool.getTotal("manpower"); + squads = Math.min(squads, Math.floor(mpower / 100)); if (squads < 1){ return; From 0be5d6efc12b3423a19e3314449b4db996e59adc Mon Sep 17 00:00:00 2001 From: Ethaniel Kavelaars Date: Fri, 26 Jun 2020 23:12:00 +0200 Subject: [PATCH 47/58] Apply latest policy fixes from beta --- js/toolbar.js | 2 +- js/workshop.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/toolbar.js b/js/toolbar.js index 98a6409c12..f7bad95601 100644 --- a/js/toolbar.js +++ b/js/toolbar.js @@ -169,7 +169,7 @@ dojo.declare("classes.ui.toolbar.ToolbarHappiness", classes.ui.ToolbarIcon, { tooltip += $I("village.happiness.festival") + ": +30%
"; } - var unhappiness = this.game.village.getUnhappiness(), + var unhappiness = this.game.village.getUnhappiness() / (1 + this.game.getEffect("unhappinessRatio")), unhappinessReduction = unhappiness * this.game.getEffect("unhappinessRatio", true); tooltip += $I("village.happiness.penalty") + ": -" + this.game.getDisplayValueExt(unhappiness+unhappinessReduction, false, false, 0) + "%
"; diff --git a/js/workshop.js b/js/workshop.js index 1346e99b22..f67fa5fdd7 100644 --- a/js/workshop.js +++ b/js/workshop.js @@ -2188,7 +2188,7 @@ dojo.declare("classes.managers.WorkshopManager", com.nuclearunicorn.core.TabMana }, getCraftPrice: function(craft) { - if (craft.name != "ship") { + if (craft.name != "ship" && craft.name != "manuscript") { return craft.prices; } From c4e04ddefdf7b7d0f8742747807be37c13823e9f Mon Sep 17 00:00:00 2001 From: Eric Barr Date: Wed, 1 Jul 2020 22:49:56 +0000 Subject: [PATCH 48/58] Re-enable the 1000year reward of heat shattering once per Chronoforge --- js/time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/time.js b/js/time.js index 1d1e3a87d2..91317aff51 100644 --- a/js/time.js +++ b/js/time.js @@ -263,7 +263,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, amt = 5; //limit calculations needed per tick } self.heat -= 100 * amt; - game.time.shatter(amt * (game.challenges.getChallengeResearched("1000Years") ? self.on : 1)); + game.time.shatter(amt * (game.challenges.getChallengeResearched("1000Years", true) ? self.on : 1)); } }, unlocks: { From d339f777b86de02ea438a9a7885ee1701f03244e Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Wed, 1 Jul 2020 23:03:22 -0400 Subject: [PATCH 49/58] Fix time crystals not returning from reserve when Anachronomancy is reserved --- js/challenges.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/challenges.js b/js/challenges.js index 542f0083c9..b046be5096 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -437,7 +437,7 @@ dojo.declare("classes.managers.ChallengesManager", com.nuclearunicorn.core.TabMa } } - if (this.game.prestige.getPerk("anachronomancy").researched) { + if (this.game.prestige.getPerk("anachronomancy").researched || this.game.prestige.getPerk("anachronomancy").reserve) { var chronophysics = this.game.science.get("chronophysics"); chronophysics.researched = true; this.game.unlock(chronophysics.unlocks); From 6c505da260d69faf93786e5d94be40ea31e4aef4 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 4 Jul 2020 08:22:03 -0400 Subject: [PATCH 50/58] Revert incorrect change --- js/time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/time.js b/js/time.js index 91317aff51..1d1e3a87d2 100644 --- a/js/time.js +++ b/js/time.js @@ -263,7 +263,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, amt = 5; //limit calculations needed per tick } self.heat -= 100 * amt; - game.time.shatter(amt * (game.challenges.getChallengeResearched("1000Years", true) ? self.on : 1)); + game.time.shatter(amt * (game.challenges.getChallengeResearched("1000Years") ? self.on : 1)); } }, unlocks: { From b177521539c997241f7e6408464c016e95bb3777 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Tue, 14 Jul 2020 13:04:00 -0400 Subject: [PATCH 51/58] Fix broken Solar Revolution --- js/religion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/religion.js b/js/religion.js index ae8cab0ba7..12c6b56e0a 100644 --- a/js/religion.js +++ b/js/religion.js @@ -768,7 +768,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana getSolarRevolutionRatio: function() { var uncappedBonus = this.getRU("solarRevolution").on ? this.game.getUnlimitedDR(this.faith, 1000) / 100 : 0; - return this.game.getLimitedDR(uncappedBonus, 10 + this.game.getEffect("solarRevolutionLimit") + this.game.challenges.getChallengeResearched("atheism") ? this.transcendenceTier : 0); + return this.game.getLimitedDR(uncappedBonus, 10 + this.game.getEffect("solarRevolutionLimit") + (this.game.challenges.getChallengeResearched("atheism") ? this.transcendenceTier : 0)); }, getApocryphaBonus: function(){ From d3f53767c9b258be748631f0d865bc2caab75080 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 15 Aug 2020 00:31:12 -0400 Subject: [PATCH 52/58] Fix weather being applied to resources other than catnip (again) --- js/calendar.js | 8 ++++---- js/jsx/left.jsx.js | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index f35bf18f88..0d37a8739b 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -912,13 +912,13 @@ dojo.declare("com.nuclearunicorn.game.Calendar", null, { }, getWeatherMod: function(res){ - if (this.game.science.getPolicy("communism").researched && this.getCurSeason().name == "winter" && this.weather == "cold"){ - return 0; - } - var mod = 1; if (this.getCurSeason().modifiers[res.name]){ + if (this.game.science.getPolicy("communism").researched && this.getCurSeason().name == "winter" && this.weather == "cold"){ + return 0; + } + mod = this.getCurSeason().modifiers[res.name]; if (this.weather == "warm"){ diff --git a/js/jsx/left.jsx.js b/js/jsx/left.jsx.js index a6e06c558b..b03bce519f 100644 --- a/js/jsx/left.jsx.js +++ b/js/jsx/left.jsx.js @@ -159,7 +159,12 @@ WResourceRow = React.createClass({ if (season.modifiers[res.name] && perTick !== 0 ){ - var modifier = Math.max(Math.round((game.calendar.getWeatherMod(res) - 1) * 100), -99); + var modifier = game.calendar.getWeatherMod(res); + if (modifier == 0) { + modifier = -100; + } else { + modifier = Math.max(Math.round((modifier - 1) * 100), -99); + } weatherModValue = modifier ? "[" + (modifier > 0 ? "+" : "") + modifier.toFixed() + "%]" : ""; if (modifier > 0) { From d6536789f1bba6bd43eb878cf9b9cb2245453bf6 Mon Sep 17 00:00:00 2001 From: Chris142857 Date: Sat, 15 Aug 2020 12:37:11 -0400 Subject: [PATCH 53/58] Added option to re-enable old overcapping behavior --- game.js | 33 ++++++++++++++++++++++++++++++++- index.html | 3 +++ js/resources.js | 6 +++++- js/ui.js | 1 + 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/game.js b/game.js index 15799c3bf3..f6208d9cc8 100644 --- a/game.js +++ b/game.js @@ -1312,6 +1312,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { tooltipsInRightColumn: false, noConfirm: false, IWSmelter: true, + disableHardCaps: false, disableCMBR: false, disableTelemetry: false, enableRedshift: false, @@ -1426,6 +1427,35 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { this.effectsMgr = new com.nuclearunicorn.game.EffectsManager(this); }, + getHardCapsEnforced: function() { + // Modify this and setHardCapsEnabled to manage hard caps behavior + // Uncomment to enforce hard caps (current default alpha behavior) + // return true; + // Uncomment to not enforce hard caps (original behavior) + // return false; + return !this.opts.disableHardCaps; + }, + + setHardCapsEnforced: function(on) { + // Handles turning hard caps on and off + for (var i = 0; i < this.resPool.resources.length; i++) { + var res = this.resPool.resources[i]; + if (on) { + if (res.maxValue && res.value > res.maxValue) { + res.reserve += res.value - res.maxValue; + res.value = res.maxValue; + } + } else { + if (!this.challenges.getCondition("disableChrono").on) { + res.value += res.reserve; + res.reserve = 0; + } + } + } + + this.opts.disableHardCaps = !on; + }, + setDropboxClient: function(dropBoxClient) { this.dropBoxClient = dropBoxClient; }, @@ -1577,6 +1607,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { tooltipsInRightColumn: false, noConfirm: false, IWSmelter: true, + disableHardCaps: false, disableCMBR: false, disableTelemetry: false, enableRedshift: false, @@ -3765,7 +3796,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { reserve = res.reserve + res.value * saveRatio; } } else { - if (res.maxValue) { + if (res.maxValue && this.getHardCapsEnforced()) { reserve = (res.value + res.reserve) * saveRatio; } else { value = (res.value + res.reserve) * saveRatio; diff --git a/index.html b/index.html index b5d6250860..e30fd31571 100644 --- a/index.html +++ b/index.html @@ -565,6 +565,9 @@
+
+ +
diff --git a/js/resources.js b/js/resources.js index 2b782161a5..549cce31ff 100644 --- a/js/resources.js +++ b/js/resources.js @@ -607,7 +607,11 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana // Give the benefit of the doubt res.reserve = res.value - res.maxValue; } - res.value = res.maxValue; + if (this.game.getHardCapsEnforced()) { + res.value = res.maxValue; + } else { + res.value = Math.min(res.value, Math.max(prevValue, res.maxValue)); + } } if (res.maxValue && res.value < res.maxValue && res.reserve && !this.game.challenges.getCondition("disableChrono").on){ diff --git a/js/ui.js b/js/ui.js index d1d385fadb..4b132c242b 100644 --- a/js/ui.js +++ b/js/ui.js @@ -706,6 +706,7 @@ dojo.declare("classes.ui.DesktopUI", classes.ui.UISystem, { $("#disableTelemetry")[0].checked = game.opts.disableTelemetry; $("#noConfirm")[0].checked = game.opts.noConfirm; $("#IWSmelter")[0].checked = game.opts.IWSmelter; + $("#disableHardCaps")[0].checked = game.opts.disableHardCaps; var selectedLang = i18nLang.getLanguage(); var locales = i18nLang.getAvailableLocales(); From 19669931822f0d35dc23c20b2a5586f067e03410 Mon Sep 17 00:00:00 2001 From: Jonathan Beverley Date: Fri, 23 Sep 2022 18:43:04 -0400 Subject: [PATCH 54/58] this is the math-only subset of TAME_INFINITY. Designed to easier to review. --- game.js | 15 +++++++++++---- js/challenges.js | 4 ++-- js/diplomacy.js | 7 +++---- js/religion.js | 16 +++++++++++++--- js/resources.js | 19 ++++++++----------- js/time.js | 2 +- 6 files changed, 38 insertions(+), 25 deletions(-) diff --git a/game.js b/game.js index 4dc3d5d408..b941fc4097 100644 --- a/game.js +++ b/game.js @@ -2028,7 +2028,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { }, - // Unlimited Diminishing Return + // Limited Diminishing Return //getHyperbolicEffect getLimitedDR: function(effect, limit) { var absEffect = Math.abs(effect); @@ -3995,6 +3995,10 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { }, toDisplaySeconds : function (secondsRaw) { + if (secondsRaw == Infinity) { + return "∞"; + } + var sec_num = parseInt(secondsRaw, 10); // don't forget the second param var year_secs = 86400 * 365; @@ -4621,7 +4625,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { if (value > 0) { var newRes = this.resPool.createResource(res.name); - newRes.value = value; + newRes.value = Math.min(value, Number.MAX_VALUE); newResources.push(newRes); } } @@ -4782,11 +4786,14 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { // Unlimited Diminishing Return //getTriValue getUnlimitedDR: function(value, stripe) { - return (Math.sqrt(1 + 8 * value / stripe) - 1) / 2; + var result = (Math.sqrt(1 + (value / stripe) * 8) - 1) / 2; + return result == Infinity + ? Math.sqrt(value) / Math.sqrt(stripe) * Math.SQRT2 + : result; }, getInverseUnlimitedDR: function(value, stripe) { - return value * (value + 1) * stripe / 2; + return stripe / 2 * value * (value + 1); }, getTab: function(name) { diff --git a/js/challenges.js b/js/challenges.js index 5c7493b8b7..03c77bb44d 100644 --- a/js/challenges.js +++ b/js/challenges.js @@ -518,7 +518,7 @@ dojo.declare("classes.reserveMan", null,{ } if (value > 0) { - reserveResources[res.name] = Math.max(reserveResources[res.name] || 0, value); + reserveResources[res.name] = Math.max(reserveResources[res.name] || 0, Math.min(value, Number.MAX_VALUE)); } } this.game.challenges.reserves.reserveResources = reserveResources; @@ -558,7 +558,7 @@ dojo.declare("classes.reserveMan", null,{ } var resCap = this.game.resPool.get(i).maxValue; if(!resCap){ - this.game.resPool.get(i).value += this.reserveResources[i]; + this.game.resPool.get(i).value = Math.min(this.game.resPool.get(i).value + this.reserveResources[i], Number.MAX_VALUE); }else{ this.game.resPool.get(i).value = Math.max(this.game.resPool.get(i).value, this.reserveResources[i]); } diff --git a/js/diplomacy.js b/js/diplomacy.js index c18c649a07..2aba809611 100644 --- a/js/diplomacy.js +++ b/js/diplomacy.js @@ -538,7 +538,7 @@ dojo.declare("classes.managers.DiplomacyManager", null, { } //Update Trade Stats - this.game.stats.getStat("totalTrades").val += successfullTradeAmount; + this.game.stats.getStat("totalTrades").val = Math.min(this.game.stats.getStat("totalTrades").val + successfullTradeAmount, Number.MAX_VALUE); this.game.stats.getStatCurrent("totalTrades").val += successfullTradeAmount; return boughtResources; @@ -683,7 +683,7 @@ dojo.declare("classes.managers.DiplomacyManager", null, { buyBcoin: function(){ var amt = this.game.resPool.get("relic").value / this.game.calendar.cryptoPrice; - this.game.resPool.get("blackcoin").value += amt; + amt = this.game.resPool.addResEvent("blackcoin", amt); this.game.resPool.get("relic").value = 0; this.game.msg($I("trade.bcoin.buy.msg", [this.game.getDisplayValueExt(amt)])); @@ -691,9 +691,8 @@ dojo.declare("classes.managers.DiplomacyManager", null, { sellBcoin: function(){ var amt = this.game.resPool.get("blackcoin").value * this.game.calendar.cryptoPrice; - this.game.resPool.get("relic").value += amt; + var amt = this.game.resPool.addResEvent("relic", amt); this.game.resPool.get("blackcoin").value = 0; - this.game.msg($I("trade.bcoin.sell.msg", [this.game.getDisplayValueExt(amt)])); }, diff --git a/js/religion.js b/js/religion.js index 2968c02929..978ac84366 100644 --- a/js/religion.js +++ b/js/religion.js @@ -1032,6 +1032,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana praise: function(){ var faith = this.game.resPool.get("faith"); this.faith += faith.value * (1 + this.getApocryphaBonus()); //starting up from 100% ratio will work surprisingly bad + this.faith = Math.min(this.faith, Number.MAX_VALUE); this.game.msg($I("religion.praise.msg", [this.game.getDisplayValueExt(faith.value, false, false, 0)]), "", "faith"); faith.value = 0.0001; //have a nice autoclicking @@ -1060,6 +1061,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana _resetFaithInternal: function(bonusRatio) { var ttPlus1 = (this.game.religion.getRU("transcendence").on ? this.game.religion.transcendenceTier : 0) + 1; this.faithRatio += this.faith / 1000000 * ttPlus1 * ttPlus1 * bonusRatio; + this.faithRatio = Math.min(this.faithRatio, Number.MAX_VALUE); this.faith = 0.01; }, @@ -1072,9 +1074,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana var game = this.game; game.ui.confirm($I("religion.transcend.confirmation.title"), $I("religion.transcend.confirmation.msg"), function() { //Transcend one Level at a time - var needNextLevel = - religion._getTranscendTotalPrice(religion.transcendenceTier + 1) - - religion._getTranscendTotalPrice(religion.transcendenceTier); + var needNextLevel = _getTranscendNextPrice(); if (religion.faithRatio > needNextLevel) { religion.faithRatio -= needNextLevel; @@ -1103,6 +1103,10 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana return this.game.getInverseUnlimitedDR(Math.exp(tier) / 10, 0.1); }, + _getTranscendNextPrice: function() { + return this._getTranscendTotalPrice(this.transcendenceTier + 1) - this._getTranscendTotalPrice(this.transcendenceTier); + }, + unlockAll: function(){ for (var i in this.religionUpgrades){ this.religionUpgrades[i].unlocked = true; @@ -1254,6 +1258,12 @@ dojo.declare("com.nuclearunicorn.game.ui.TranscendBtnController", com.nuclearuni return model.options.name + (this.game.religion.transcendenceTier > 0 ? " [" + this.game.religion.transcendenceTier + "]" : ""); }, + updateEnabled: function(model) { + model.enabled = this.game.religion._getTranscendNextPrice() < Infinity; + model.highlightUnavailable = this.game.opts.highlightUnavailable; + model.resourceIsLimited = model.highlightUnavailable && !model.enabled; + }, + updateVisible: function (model) { model.visible = this.game.religion.getRU("transcendence").on; } diff --git a/js/resources.js b/js/resources.js index e7b41410d8..0dea33a09c 100644 --- a/js/resources.js +++ b/js/resources.js @@ -608,11 +608,10 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana } var prevValue = res.value || 0; - - //if already overcap, allow to remain that way unless removing resources. - var limit = Math.max(res.value, res.maxValue || Number.POSITIVE_INFINITY); - res.value += addedValue; + res.value = Math.min(prevValue + addedValue, Number.MAX_VALUE); if (!preventLimitCheck) { + //if already overcap, allow to remain that way unless removing resources. + var limit = Math.max(prevValue, res.maxValue || Number.MAX_VALUE); res.value = Math.min(res.value, limit); } @@ -687,7 +686,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var res = this.resources[i]; if (res.name == "sorrow"){ res.maxValue = 16 + (game.getEffect("blsLimit") || 0); - res.value = res.value > res.maxValue ? res.maxValue : res.value; + res.value = Math.min(res.value, res.maxValue); continue; } @@ -703,18 +702,16 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var maxValue = game.getEffect(res.name + "Max") || 0; - maxValue = this.addResMaxRatios(res, maxValue); + maxValue = Math.min(this.addResMaxRatios(res, maxValue), Number.MAX_VALUE); var challengeEffect = this.game.getEffect(res.name + "MaxChallenge"); if(challengeEffect){ + // Negative effect, no need to cap again to Number.MAX_VALUE challengeEffect = this.game.getLimitedDR(this.addResMaxRatios(res, challengeEffect), maxValue - 1 - game.bld.effectsBase[res.name +'Max']||0); maxValue += challengeEffect; } - if (maxValue < 0 ){ - maxValue = 0; - } - res.maxValue = maxValue; + res.maxValue = Math.max(maxValue, 0); if(game.loadingSave){ //hack to stop production before game.calculateAllEffects after manual import continue; } @@ -931,7 +928,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana var price = prices[i]; var res = this.get(price.name); - if (res.maxValue > 0 && price.val > res.maxValue && price.val > res.value){ + if (price.val == Infinity || res.maxValue > 0 && price.val > res.maxValue && price.val > res.value){ return true; } if (res.craftable && price.val > res.value){ //account for chronosphere resets etc diff --git a/js/time.js b/js/time.js index 114ddefa15..b2b2433de8 100644 --- a/js/time.js +++ b/js/time.js @@ -534,7 +534,7 @@ dojo.declare("classes.managers.TimeManager", com.nuclearunicorn.core.TabManager, var limits = {}; for (var j = 0; j < game.resPool.resources.length; j++) { var res = game.resPool.resources[j]; - limits[res.name] = Math.max(res.value, res.maxValue || Number.POSITIVE_INFINITY); + limits[res.name] = Math.max(res.value, res.maxValue || Number.MAX_VALUE); game.resPool.addRes(res, game.getResourcePerTick(res.name, true) * remainingTicksInCurrentYear * shatterTCGain, false, true); } if (this.game.workshop.get("chronoEngineers").researched) { From 6fea6305ba27966c140a2f2f59fd88ec9c0ccf57 Mon Sep 17 00:00:00 2001 From: Jonathan Beverley Date: Sat, 24 Sep 2022 18:39:47 -0400 Subject: [PATCH 55/58] fix husky error --- js/religion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/religion.js b/js/religion.js index 978ac84366..170bfc8313 100644 --- a/js/religion.js +++ b/js/religion.js @@ -1074,7 +1074,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana var game = this.game; game.ui.confirm($I("religion.transcend.confirmation.title"), $I("religion.transcend.confirmation.msg"), function() { //Transcend one Level at a time - var needNextLevel = _getTranscendNextPrice(); + var needNextLevel = this._getTranscendNextPrice(); if (religion.faithRatio > needNextLevel) { religion.faithRatio -= needNextLevel; From f49f8855807b1f3e173a82f1a7a08007e1c947ea Mon Sep 17 00:00:00 2001 From: Jonathan Beverley Date: Sat, 24 Sep 2022 18:39:55 -0400 Subject: [PATCH 56/58] add tests for fix_infinity --- test/game.test.js | 168 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 163 insertions(+), 5 deletions(-) diff --git a/test/game.test.js b/test/game.test.js index 9484f5103b..17ddcbe1b8 100644 --- a/test/game.test.js +++ b/test/game.test.js @@ -1,4 +1,4 @@ -/* global +/* global test, expect, @@ -30,6 +30,7 @@ test("basic sanity check, game must load hoglasave without crashing", () => { var loadResult = game.load(); expect(loadResult).toBe(true); + game.resetState(); // drop state to avoid messing up future tests }); // HELPER FUNCTIONS TO REDUCE BOILERPLATE @@ -62,7 +63,7 @@ test("Pollution values must be sane", () => { var bld = game.bld; var POL_LBASE = bld.getPollutionLevelBase(); - + expect(POL_LBASE).toBeGreaterThanOrEqual(100000); @@ -180,7 +181,7 @@ test("Reset should assign a correct ammount of paragon and preserve certain upgr expect(saveData.resources.length).toBe(1); expect(saveData.resources[0].name).toBe("paragon"); expect(saveData.resources[0].value).toBe(30); - + game.load(); expect(game.resPool.get("paragon").value).toBe(30); //TBD: please add more reset test cases there @@ -198,7 +199,7 @@ test("Reset should assign a correct ammount of paragon and preserve certain upgr game.load(); game.globalEffectsCached = {}; - + _build("hut", 100); for (var i = 0; i < 100; i++){ game.village.sim.addKitten(); @@ -238,6 +239,163 @@ test("Reset should assign a correct ammount of paragon and preserve certain upgr //TODO: test on all ranges of HG, including 0, 10, 100, 1K and 4K, use helper function to set up HG vals }); +//-------------------------------- +// Reset test +//-------------------------------- +test("Safe infinity tests", () => { + // -------- toDisplaySeconds --------- + const tdsVector = [ + [55, "55$unit.s$ "], + [100000, "1$unit.d$ 3$unit.h$ 46$unit.m$ 40$unit.s$ "], + [-5, "-1$unit.y$ 364$unit.d$ "], // we don't judge, we just want it to terminate + [1e20, "3.17T$unit.y$ 167$unit.d$ "], + [1e308, "1$unit.s$ "], // it's getting hard not to judge + [2e308, "∞"] + ] + for (const [seconds,display] of tdsVector) { + expect(game.toDisplaySeconds(seconds)).toBe(display); + } + + // we'd like a test of _resetInternal here + // it should do a reset with some chronospheres and + // somehow manage to test that resources work out??? + // maybe we can just do the reserves step? + + // -------- (Inverse) Unlimited Diminishing Returns -------- + oldUDR = function(value, stripe) { + return (Math.sqrt(1 + 8 * value / stripe) - 1) / 2; + }; + oldIUDR = function(value, stripe) { + return value * (value + 1) * stripe / 2; + }; + + const udrVector = [0, 10, 100, 1e9, 1e100, 1e307, Infinity]; + const stripe = 75; + for (const tv of udrVector) { + expect(game.getUnlimitedDR(tv,stripe)).toBe(oldUDR(tv,stripe)); + expect(game.getInverseUnlimitedDR(tv,stripe)).toBe(oldIUDR(tv,stripe)); + } + const nearlyInfinity = [5e307, 1e308, 1.7e308]; + for (const tv of nearlyInfinity) { + expect(game.getUnlimitedDR(tv,stripe)).toBeLessThan(Math.sqrt(Number.MAX_VALUE)); + expect(game.getUnlimitedDR(tv,stripe)).toBeGreaterThan(Math.sqrt(1e150)); + } + const halfInfinity = [1e150, 5e151, 7e152, 2e153]; + for (const tv of halfInfinity) { + expect(game.getInverseUnlimitedDR(tv,stripe)).toBeLessThan(Number.MAX_VALUE); + expect(game.getInverseUnlimitedDR(tv,stripe)).toBeGreaterThan(1e300); + } + + // -------- buyBcoin / sellBcoin -------- + let reserves = new classes.reserveMan(game); + const price = game.calendar.cryptoPrice; + const chronoVector = [ + [2e6/price, 2e6, 2e6*price], + [4e12/price, 4e12, 4e12*price], + [7e153/price, 7e153, 7e153*price], + [1e308/price, 1e308, Number.MAX_VALUE], + ]; + game.workshop.unlock("fluxCondensator"); + for (const [low,tv,high] of chronoVector) { + game.resPool.get("relic").value = tv; + game.resPool.get("blackcoin").value = 0; + game.diplomacy.buyBcoin(); + expect(game.resPool.get("blackcoin").value).toBe(low); + game.diplomacy.sellBcoin(); + expect(game.resPool.get("relic").value).toBe(low*price); + + game.resPool.get("relic").value = 0; + game.resPool.get("blackcoin").value = tv; + game.diplomacy.sellBcoin(); + expect(game.resPool.get("relic").value).toBe(high); + game.diplomacy.buyBcoin(); + expect(game.resPool.get("blackcoin").value).toBe(high/price); + } + + // -------- faith, worship, and epiphany -------- + const faithVector = [ + [777, 777*2], + [1e21, 1e21*2], + [1e300, 1e300*2], + [1e308, Number.MAX_VALUE], + ]; + expect(game.religion.getApocryphaBonus()).toBe(0); // sanity checking + for (const [f,w] of faithVector) { + game.resPool.get("faith").value = f; + game.religion.praise(); + game.resPool.get("faith").value = f; + game.religion.praise(); + expect(game.religion.faith).toBe(w); // game.religion.faith is "worship" + } + const epiphanyVector = [ + [777, 1e9, 777 * 1e3], + [1e21, 1e12, 1e21 * 1e6], + [1e200, 1e100, 1e200 * 1e94], + [1e300, 1e15, Number.MAX_VALUE], + [1e306, 1e9, Number.MAX_VALUE], + ]; + expect(game.religion.faithRatio).toBe(0); // epiphany, sanity checking + expect(game.religion.transcendenceTier).toBe(0); // sanity checking + for (const [w,bonus,e] of epiphanyVector) { + game.religion.faith = w; + game.religion.resetFaith(bonus, false); + expect(game.religion.faithRatio).toBe(e); // game.religion.faithRatio is "epiphany" + game.religion.faithRatio = 0; // clean up for next loop + } + + // -------- basic resources code -------- + const resourceVector = [ + ["catnip", 1000, 2000, false, 3000], + ["catnip", 2000, 4000, false, 5000], // initial cap + ["catnip", 1e308, 4000, false, 1e308], + ["catnip", 2000, 1e308, false, 5000], + ["catnip", 1e308, 1e308, false, 1e308], + ["catnip", Infinity, 4000, false, Number.MAX_VALUE], + ["catnip", 2000, Infinity, false, 5000], + ["catnip", 2000, Infinity, true, Number.MAX_VALUE], + ["catnip", 1e308, 1e308, true, Number.MAX_VALUE], + + ["beam", 1000, 2000, false, 3000], + ["beam", 2000, 4000, false, 6000], + ["beam", 1e308, 4000, false, 1e308], // rounding + ["beam", 2000, 1e308, false, 1e308], + ["beam", 1e308, 1e308, false, Number.MAX_VALUE], + ["beam", Infinity, 4000, false, Number.MAX_VALUE], + ["beam", 2000, Infinity, false, Number.MAX_VALUE], + ["beam", 2000, Infinity, true, Number.MAX_VALUE], + ["beam", 1e308, 1e308, true, Number.MAX_VALUE], + ]; + game.updateCaches(); // update resource limits: effectBase -> catnipMax + expect(game.getEffect("catnipMax")).toBe(5000); + game.resPool.update(); // update resource limits: catnipMax -> catnip.maxValue + expect(game.resPool.get("catnip").maxValue).toBe(5000); + for (const [resName,before,add,noLimit,after] of resourceVector) { + const res = game.resPool.get(resName); + res.value = before + expect(res.value).toBe(before); + game.resPool.addRes(res, add, true, noLimit); + expect(res.value).toBe(after); + res.value = 0; // clear for future + } + + // -------- storage limits -------- + const priceVector = [ + [[{name:"catnip", val:4000}], false], + [[{name:"catnip", val:6000}], true], + [[{name:"catnip", val:Infinity}], true], + [[{name:"beam", val:6000}], false], + [[{name:"beam", val:1e308}], false], + [[{name:"beam", val:Number.MAX_VALUE}], false], + [[{name:"beam", val:Infinity}], true], + ] + for (const [price,limited] of priceVector) { + expect(game.resPool.isStorageLimited(price)).toBe(limited); + } + + // We perhaps should test the changes to game.resPool.update(), but that + // code shouldn't actually do anything, because it's not possible to get + // resource limits up past P, even with endgame tech. +}); test("Test NR calls", () => { game.heartbeat(); @@ -248,5 +406,5 @@ test("Test NR calls", () => { game.opts.disableTelemetry = true; game.heartbeat(); expect(newrelic.addPageAction).toHaveBeenCalledTimes(0); +}); -}); \ No newline at end of file From ec7e5fa092397a3343b152d81e069a3f6da5c8ea Mon Sep 17 00:00:00 2001 From: Jonathan Beverley Date: Fri, 17 Feb 2023 12:21:18 -0500 Subject: [PATCH 57/58] fix scoping issue that is preventing transcend --- js/religion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/religion.js b/js/religion.js index b0ab5b396f..51666605ea 100644 --- a/js/religion.js +++ b/js/religion.js @@ -1141,7 +1141,7 @@ dojo.declare("classes.managers.ReligionManager", com.nuclearunicorn.core.TabMana var game = this.game; game.ui.confirm($I("religion.transcend.confirmation.title"), $I("religion.transcend.confirmation.msg"), function() { //Transcend one Level at a time - var needNextLevel = this._getTranscendNextPrice(); + var needNextLevel = religion._getTranscendNextPrice(); if (religion.faithRatio > needNextLevel) { religion.faithRatio -= needNextLevel; From 50315c71991f5792255fafc1f80d4b9208c7ff80 Mon Sep 17 00:00:00 2001 From: Ziggurat Date: Sat, 28 Oct 2023 00:56:20 +0000 Subject: [PATCH 58/58] Merged in dev/alpha (pull request #1239) Dev/beta -> Dev/alpha with a merge conflict fix * fix unit test * reducing spaceport effect even further * Merged in spaceportBalancing (pull request #1233) Increased Spaceport effect, decreased power consumption * Increased Spaceport effect, decreased power consumption Approved-by: Arima B. * fix siphoning not using necrocornsNaiveFastForward fix bug where corruption is multiplied by days and divided by ticks per day for comparison of necrocorn per day values in necrocornFastForward * Merged in master (pull request #1234) Redshift pacts logic bugfixes * fix siphoning not using necrocornsNaiveFastForward fix bug where corruption is multiplied by days and divided by ticks per day for comparison of necrocorn per day values in necrocornFastForward * Merged in Ziggurat/set-queue_redshift-flag-to-true-on-main-1698452752943 (pull request #1237) set QUEUE_REDSHIFT flag to true on main * Merged bloodrizer/kitten-game:master into AZiggurat/kitten-game-ziggurats-fork:master * Merged bloodrizer/kitten-game:dev/beta into AZiggurat/kitten-game-ziggurats-fork:dev/beta * Merge branch 'master' into dev/beta # Conflicts: # game.js * Merge branch 'dev/beta' into dev/alpha # Conflicts: # test/game.test.js --- changelog.txt | 4 + core.js | 120 ++++++++++----- game.js | 53 +++++-- index.html | 11 +- js/buildings.js | 192 +++++++++++++++++------ js/jsx/left.jsx.js | 33 +++- js/jsx/map.jsx.js | 297 ------------------------------------ js/religion.js | 20 +-- js/science.js | 3 +- js/space.js | 38 ++--- js/time.js | 16 +- kg-workspace.code-workspace | 18 ++- res/default.css | 6 +- res/i18n/en.json | 20 ++- test/game.test.js | 39 +++++ test/setup.js | 1 - 16 files changed, 426 insertions(+), 445 deletions(-) delete mode 100644 js/jsx/map.jsx.js diff --git a/changelog.txt b/changelog.txt index 7083dc4bd3..841a3536f2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +v 1.4.9.3 +Major: +* Spaceport + v 1.4.9.2 Major: * Queue diff --git a/core.js b/core.js index 117d666720..90adaa0750 100644 --- a/core.js +++ b/core.js @@ -851,7 +851,8 @@ dojo.declare("com.nuclearunicorn.game.ui.Button", com.nuclearunicorn.core.Contro style: { position: "relative", display: this.model.visible ? "block" : "none" - } + }, + tabIndex: 0 }, btnContainer); if (this.model.twoRow) { @@ -879,6 +880,7 @@ dojo.declare("com.nuclearunicorn.game.ui.Button", com.nuclearunicorn.core.Contro this.updateVisible(); dojo.connect(this.domNode, "onclick", this, "onClick"); + dojo.connect(this.domNode, "onkeypress", this, "onKeyPress"); this.afterRender(); }, @@ -906,6 +908,12 @@ dojo.declare("com.nuclearunicorn.game.ui.Button", com.nuclearunicorn.core.Contro }, + onKeyPress: function(event){ + if (event.key == "Enter"){ + this.onClick(event); + } + }, + afterRender: function(){ var prices = this.model.prices; @@ -1275,12 +1283,12 @@ ButtonModernHelper = { // description var descDiv = dojo.create("div", { - innerHTML: model.description, + innerHTML: controller.getDescription(model), className: "desc" }, tooltip); - if (model.metadata && model.metadata.isAutomationEnabled !== undefined){ //TODO: use proper metadata flag + if (model.metadata && typeof(model.metadata.isAutomationEnabled) == "boolean"){ //undefined or null don't count here dojo.create("div", { innerHTML: model.metadata.isAutomationEnabled ? $I("btn.aon.tooltip") : $I("btn.aoff.tooltip"), className: "desc small" + (model.metadata.isAutomationEnabled ? " auto-on" : " auto-off") @@ -1461,6 +1469,10 @@ dojo.declare("com.nuclearunicorn.game.ui.ButtonModern", com.nuclearunicorn.game. updateLink: function(buttonLink, modelLink) { if (buttonLink) { + if (!modelLink) { //This only ever happens if I mess around with console commands + dojo.destroy(buttonLink.link); + return; + } buttonLink.link.textContent = modelLink.title; if (modelLink.cssClass) {buttonLink.link.className = modelLink.cssClass;} if (modelLink.tooltip) {buttonLink.link.title = modelLink.tooltip;} @@ -1499,7 +1511,7 @@ dojo.declare("com.nuclearunicorn.game.ui.BuildingBtnController", com.nuclearunic } }; } - if (typeof(model.metadata.isAutomationEnabled) != "undefined" && model.metadata.isAutomationEnabled !== null) { + if (typeof(model.metadata.isAutomationEnabled) == "boolean") { model.toggleAutomationLink = { title: model.metadata.isAutomationEnabled ? "A" : "*", tooltip: model.metadata.isAutomationEnabled ? $I("btn.aon.tooltip") : $I("btn.aoff.tooltip"), @@ -1566,8 +1578,14 @@ dojo.declare("com.nuclearunicorn.game.ui.BuildingBtnController", com.nuclearunic return false; }, + //Called whenever we turn the building on or off. + //The function was previously empty, so I repurposed it for possible non-proportional calculations. metadataHasChanged: function(model) { - // do nothing + var meta = model.metadata; + if (meta.calculateEffects){ + meta.calculateEffects(meta, this.game); + this.game.calendar.cycleEffectsBasics(meta.effects, meta.name); //(Only relevant for space buildings) + } }, off: function(model, amt) { @@ -1978,6 +1996,12 @@ dojo.declare("com.nuclearunicorn.game.ui.BuildingStackableBtnController", com.nu } }, + /** + * Ultimate entry point to building construction + * @param {*} model + * @param {*} maxBld + * + */ build: function(model, maxBld){ var meta = model.metadata; var counter = 0; @@ -1985,48 +2009,55 @@ dojo.declare("com.nuclearunicorn.game.ui.BuildingStackableBtnController", com.nu maxBld = meta.limitBuild - meta.val; } - if (model.enabled && this.hasResources(model) || this.game.devMode ){ - while (this.hasResources(model) && maxBld > 0){ - this.incrementValue(model); - this.payPrice(model); + + if (!model.enabled && !this.game.devMode){ + return 0; + } + + while ((this.game.devMode || this.hasResources(model)) && maxBld > 0){ + this.incrementValue(model); + this.payPrice(model); - counter++; - maxBld--; - } + counter++; + maxBld--; + } + + if (!counter){ + return 0; + } - if (counter > 1) { - this.game.msg($I("construct.all.msg", [meta.label, counter]), "notice"); - } + if (counter > 1) { + this.game.msg($I("construct.all.msg", [meta.label, counter]), "notice"); + } - if (meta.breakIronWill) { - this.game.ironWill = false; - var liberty = this.game.science.getPolicy("liberty"); - liberty.calculateEffects(liberty, this.game); - var zebraOutpostMeta = this.game.bld.getBuildingExt("zebraOutpost").meta; - zebraOutpostMeta.calculateEffects(zebraOutpostMeta, this.game); - zebraOutpostMeta.jammed = false; - this.game.diplomacy.onLeavingIW(); - } + if (meta.breakIronWill) { + this.game.ironWill = false; + var liberty = this.game.science.getPolicy("liberty"); + liberty.calculateEffects(liberty, this.game); + var zebraOutpostMeta = this.game.bld.getBuildingExt("zebraOutpost").meta; + zebraOutpostMeta.calculateEffects(zebraOutpostMeta, this.game); + zebraOutpostMeta.jammed = false; + this.game.diplomacy.onLeavingIW(); + } - if (meta.unlocks) { - this.game.unlock(meta.unlocks); - } + if (meta.unlocks) { + this.game.unlock(meta.unlocks); + } - if (meta.calculateEffects){ - meta.calculateEffects(meta, this.game); - this.game.calendar.cycleEffectsBasics(meta.effects, meta.name); //(Only relevant for space buildings) - } - if (meta.unlockScheme && meta.val >= meta.unlockScheme.threshold) { - this.game.ui.unlockScheme(meta.unlockScheme.name); - } + if (meta.calculateEffects){ + meta.calculateEffects(meta, this.game); + this.game.calendar.cycleEffectsBasics(meta.effects, meta.name); //(Only relevant for space buildings) + } + if (meta.unlockScheme && meta.val >= meta.unlockScheme.threshold) { + this.game.ui.unlockScheme(meta.unlockScheme.name); + } - if (meta.upgrades) { - if (meta.updateEffects) { - meta.updateEffects(meta, this.game); - } - this.game.upgrade(meta.upgrades); + if (meta.upgrades) { + if (meta.updateEffects) { + meta.updateEffects(meta, this.game); } - } + this.game.upgrade(meta.upgrades); + } return counter; }, @@ -2243,6 +2274,7 @@ dojo.declare("com.nuclearunicorn.game.ui.Panel", [com.nuclearunicorn.game.ui.Con this.toggle = dojo.create("div", { innerHTML: this.collapsed ? "+" : "-", + tabIndex: 0, className: "toggle" + (this.collapsed ? " collapsed" : ""), style: { float: "right" @@ -2264,6 +2296,7 @@ dojo.declare("com.nuclearunicorn.game.ui.Panel", [com.nuclearunicorn.game.ui.Con dojo.connect(this.toggle, "onclick", this, function(){ this.collapse(!this.collapsed); }); + dojo.connect(this.toggle, "onkeypress", this, "onKeyPress"); this.panelDiv = panel; @@ -2275,6 +2308,13 @@ dojo.declare("com.nuclearunicorn.game.ui.Panel", [com.nuclearunicorn.game.ui.Con return this.contentDiv; }, + + onKeyPress: function(event){ + if (event.key == "Enter"){ + this.collapse(!this.collapsed); + } + }, + collapse: function(isCollapsed){ this.collapsed = isCollapsed; diff --git a/game.js b/game.js index b3167a3fb0..f84b9498d2 100644 --- a/game.js +++ b/game.js @@ -1062,6 +1062,19 @@ dojo.declare("com.nuclearunicorn.game.EffectsManager", null, { title: $I("effectsMgr.statics.queueCap"), type: "fixed" }, + //Spaceports + "moonBaseStorageBonus": { + title: $I( "effectsMgr.statics.moonBaseStorageBonus.title" ), + type: "ratio" + }, + "planetCrackerStorageBonus": { + title: $I( "effectsMgr.statics.planetCrackerStorageBonus.title" ), + type: "ratio" + }, + "cryostationStorageBonus": { + title: $I( "effectsMgr.statics.cryostationStorageBonus.title" ), + type: "ratio" + }, // cycleEffects "spaceElevator-prodTransferBonus": { title: $I("effectsMgr.statics.spaceElevator-prodTransferBonus.title"), @@ -1795,23 +1808,28 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { featureFlags: { VILLAGE_MAP: { beta: true, - main: false + main: false, + mobile: false }, SPACE_EXPL: { beta: true, - main: false + main: false, + mobile: false }, MAUSOLEUM_PACTS:{ beta: true, - main: true + main: true, + mobile: true }, QUEUE:{ beta: true, - main: true + main: true, + mobile: true }, QUEUE_REDSHIFT: { beta: true, - main: false + main: true, + mobile: true } }, @@ -3573,11 +3591,19 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { //console.error("Unable to fetch resource stack for resName '" + resName + "'"); return; } - stack.push({ - name: $I("res.stack.buildings"), - type: "perDay", - value: this.getEffect(res.name + "PerDay") - }); + if (resName == "necrocorn"){ + stack.push({ + name: $I("res.stack.buildings"), + type: "perDay", + value: this.getEffect("necrocornPerDay") + this.religion.pactsManager.getSiphonedCorruption(1) + }); + }else{ + stack.push({ + name: $I("res.stack.buildings"), + type: "perDay", + value: this.getEffect(res.name + "PerDay") + }); + } if(resName == "necrocorn"){ var corruptionStack = []; corruptionStack.push({ @@ -3963,9 +3989,13 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { resStringDay = this.processResourcePerTickStack(resStackDay, res, 0), //processResourcePerTickStack can work with perDay stack resPerDay = this.getResourcePerDay(res.name); if (this.opts.usePercentageResourceValues){ + resStringDay = "
" + resStringDay; resStringDay += "
" + $I("res.netGain") + ": " + this.getDisplayValueExt(resPerDay, true, true); } - return resString + resStringDay; + var totalPerDayDelta = "
" + $I("res.netGainPerDay") + ": " + + this.getDisplayValueExt(resPerTick * this.calendar.ticksPerDay + this.getEffect("alicornPerDay")) + ; + return resString + resStringDay + totalPerDayDelta; } return resString; }, @@ -4961,6 +4991,7 @@ dojo.declare("com.nuclearunicorn.game.ui.GamePage", null, { pacts: this.religion.pactsManager.pacts.map(getName), challenges: this.challenges.challenges.map(getName) }; + this.upgrade({ buildings: ["warehouse"]}); this.upgrade(metaKeys); this.upgrade({policies: ["authocracy"]}); }, diff --git a/index.html b/index.html index e325c976a3..a0e91830d8 100644 --- a/index.html +++ b/index.html @@ -65,7 +65,7 @@