Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resource buffer to building costs to keep resources for upkeep costs #938

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion evolve/main.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { global, save, seededRandom, webWorker, keyMultiplier, keyMap, srSpeak, sizeApproximation, p_on, support_on, gal_on, quantum_level, tmp_vars, setupStats } from './vars.js';
import { global, save, seededRandom, webWorker, keyMultiplier, keyMap, srSpeak, sizeApproximation, breakdown, p_on, support_on, gal_on, quantum_level, tmp_vars, setupStats } from './vars.js';
import { loc } from './locale.js';
import { timeCheck, timeFormat, vBind, popover, clearPopper, flib, tagEvent, clearElement, costMultiplier, darkEffect, genCivName, powerModifier, powerCostMod, calcPrestige, adjustCosts, modRes, messageQueue, buildQueue, format_emblem, shrineBonusActive, calc_mastery, calcPillar, calcGenomeScore, getShrineBonus, eventActive, easterEgg, getHalloween, trickOrTreat, deepClone, hoovedRename } from './functions.js';
import { unlockAchieve, challengeIcon, alevel, universeAffix } from './achieve.js';
Expand Down Expand Up @@ -6690,9 +6690,14 @@ export function checkCosts(costs){
if (testCost === 0){
return;
}
if(global.settings.keepResourceBuffer){
for (let consumer in breakdown.p.consume[res]){
testCost += Math.max(0, -(breakdown.p.consume[res][consumer]))
}
}
let f_res = res === 'Species' ? global.race.species : res;
let fail_max = global.resource[f_res].max >= 0 && testCost > global.resource[f_res].max ? true : false;
if (testCost > Number(global.resource[f_res].amount) + global.resource[f_res].diff || fail_max){
if (testCost > Number(global.resource[f_res].amount) || fail_max){
test = false;
return;
}
Expand Down
7 changes: 6 additions & 1 deletion src/arpa.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { global, keyMultiplier, sizeApproximation, srSpeak } from './vars.js';
import { global, keyMultiplier, breakdown, sizeApproximation, srSpeak } from './vars.js';
import { clearElement, popover, clearPopper, flib, fibonacci, eventActive, timeFormat, vBind, messageQueue, adjustCosts, calcQueueMax, calcRQueueMax, buildQueue, calcPrestige, calc_mastery, darkEffect, easterEgg, getTraitDesc, removeFromQueue, arpaTimeCheck, deepClone } from './functions.js';
import { actions, updateQueueNames, drawTech, drawCity, addAction, removeAction, wardenLabel, checkCosts } from './actions.js';
import { races, traits, cleanAddTrait, cleanRemoveTrait, traitSkin, fathomCheck } from './races.js';
Expand Down Expand Up @@ -1595,6 +1595,11 @@ function checkArpaCosts(costs){
var test = true;
Object.keys(costs).forEach(function (res){
var testCost = Number(costs[res]()) / 100;
if(global.settings.keepResourceBuffer){
for (let consumer in breakdown.p.consume[res]){
testCost += Math.max(0, -(breakdown.p.consume[res][consumer]))
}
}
if (testCost > Number(global['resource'][res].amount)) {
test = false;
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export function mainVue(){
}
});

['1','3','4','5','6','7','8','9','10','11','12','13','14','15','16'].forEach(function(k){
['1','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17'].forEach(function(k){
popover(`settings${k}`, function(){
return loc(`settings${k}`);
},
Expand Down Expand Up @@ -1303,6 +1303,7 @@ export function index(){
<b-switch class="setting" v-model="s.qKey"><span class="settings6" aria-label="${loc('settings6')}">{{ 'q_key' | label }}</span></b-switch>
<b-switch class="setting" v-model="s.qAny"><span class="settings7" aria-label="${loc('settings7')}">{{ 'q_any' | label }}</span></b-switch>
<b-switch class="setting" v-model="s.qAny_res"><span class="settings14" aria-label="${loc('settings14')}">{{ 'q_any_res' | label }}</span></b-switch>
<b-switch class="setting" v-model="s.keepResourceBuffer"><span class="settings17" aria-label="${loc('settings17')}">{{ 'keep_resource_buffer' | label }}</span></b-switch>
<b-switch class="setting" v-model="s.sPackOn" @input="stringPackOn"><span class="settings13" aria-label="${loc('settings13')}">{{ 's_pack_on' | label }}</span></b-switch>
<b-switch class="setting" v-model="s.expose"><span class="settings8" aria-label="${loc('settings8')}">{{ 'expose' | label }}</span></b-switch>
<b-switch class="setting" v-model="s.tabLoad" @input="toggleTabLoad"><span class="settings11" aria-label="${loc('settings11')}">{{ 'tabLoad' | label }}</span></b-switch>
Expand Down
8 changes: 7 additions & 1 deletion src/vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export var global = {
export var tmp_vars = {};
export var breakdown = {
c: {},
p: {}
p: {
consume: {}
}
};
export var power_generated = {};
export var p_on = {};
Expand Down Expand Up @@ -1791,6 +1793,10 @@ if (global.city['foundry'] && !global.city.foundry['Quantium']){
global.city.foundry['Quantium'] = 0;
}

if (!global.settings['keepResourceBuffer']){
global.settings['keepResourceBuffer'] = false;
}

if (!global.settings['arpa']){
global.settings['arpa'] = {
arpaTabs: 0,
Expand Down
2 changes: 2 additions & 0 deletions strings/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
"settings14": "Do not enforce research queue order",
"settings15": "How the Building Queue manages merging similar items in the queue. It can merge similar items if they're nearby each other in the queue, regardless of where they are in the queue, or never merge them at all.",
"settings16": "Enable Experimental Touch Device enhancements",
"settings17": "Only allow building structures when enough resources to pay fuel/crafting/trade costs will be left over.",
"keep_resource_buffer": "Keep Resource Buffer",
"enable_reset": "Enable Reset Buttons",
"reset_warn": "Warning: This completely resets all your progress and cannot be undone. This is NOT a prestige mechanic; you are wiping out your game data. Keep this button disabled.",
"reset_soft": "Soft Reset Game",
Expand Down
2 changes: 1 addition & 1 deletion wiki/wiki.js

Large diffs are not rendered by default.