Skip to content

Commit

Permalink
Merge branch 'dev/alpha' into dev/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent-Call authored Nov 18, 2023
2 parents 796bda2 + 50315c7 commit 9e206e8
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 34 deletions.
2 changes: 1 addition & 1 deletion core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ ButtonModernHelper = {

// description
var descDiv = dojo.create("div", {
innerHTML: model.description,
innerHTML: controller.getDescription(model),
className: "desc"
}, tooltip);

Expand Down
15 changes: 11 additions & 4 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,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);
Expand Down Expand Up @@ -4074,6 +4074,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;
Expand Down Expand Up @@ -4777,7 +4781,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);
}
}
Expand Down Expand Up @@ -4941,11 +4945,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) {
Expand Down
1 change: 1 addition & 0 deletions js/buildings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,7 @@ dojo.declare("classes.ui.btn.StagingBldBtnController", classes.ui.btn.BuildingBt
metadataRaw.calculateEffects(metadataRaw, this.game);
}
this.game.time.queue.onDeltagrade(model.options.building);

this.game.upgrade(metadataRaw.upgrades);
this.game.render();
},
Expand Down
4 changes: 2 additions & 2 deletions js/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,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;
Expand Down Expand Up @@ -625,7 +625,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]);
}
Expand Down
7 changes: 3 additions & 4 deletions js/diplomacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,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;
Expand Down Expand Up @@ -697,17 +697,16 @@ 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)]), "", "blackcoin");

},

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)])), "", "blackcoin";
},

Expand Down
16 changes: 13 additions & 3 deletions js/religion.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,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

Expand Down Expand Up @@ -1138,6 +1139,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;
},

Expand All @@ -1150,9 +1152,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 = religion._getTranscendNextPrice();

if (religion.faithRatio > needNextLevel) {
religion.faithRatio -= needNextLevel;
Expand Down Expand Up @@ -1181,6 +1181,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;
Expand Down Expand Up @@ -1332,6 +1336,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;
}
Expand Down
19 changes: 8 additions & 11 deletions js/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,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);
}

Expand Down Expand Up @@ -688,7 +687,7 @@ dojo.declare("classes.managers.ResourceManager", com.nuclearunicorn.core.TabMana
var res = this.resources[i];
if (res.name == "sorrow"){
res.maxValue = 17 + (game.getEffect("blsLimit") || 0);
res.value = res.value > res.maxValue ? res.maxValue : res.value;
res.value = Math.min(res.value, res.maxValue);
continue;
}

Expand All @@ -704,18 +703,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;
}
Expand Down Expand Up @@ -946,7 +943,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
Expand Down
2 changes: 1 addition & 1 deletion js/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,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) {
Expand Down
Loading

0 comments on commit 9e206e8

Please sign in to comment.