Skip to content
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
63 changes: 62 additions & 1 deletion src/resets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { global, save, seededRandom, webWorker, clearSavedMessages, clearStates } from './vars.js';
import { tagEvent, calcPrestige, updateResetStats } from './functions.js';
import { tagEvent, calcPrestige, updateResetStats, messageQueue } from './functions.js';
import { loc } from './locale.js';
import { races, planetTraits } from './races.js';
import { unlockAchieve, unlockFeat, checkAchievements, universeAffix, alevel } from './achieve.js';

Expand All @@ -23,6 +24,7 @@ export function warhead(){
let geo = global.city.geology;

let gains = calcPrestige('mad');
logPrestigeGains(gains);

global.stats.mad++;
updateResetStats();
Expand Down Expand Up @@ -102,6 +104,7 @@ export function bioseed(){
let atmo = global.city.ptrait;

let gains = calcPrestige('bioseed');
logPrestigeGains(gains);

global.stats.bioseed++;
updateResetStats();
Expand Down Expand Up @@ -240,6 +243,7 @@ export function cataclysm_end(){
clearSavedMessages();

let gains = calcPrestige('cataclysm');
logPrestigeGains(gains);

global.stats.cataclysm++;
updateResetStats();
Expand Down Expand Up @@ -375,6 +379,7 @@ export function big_bang(){
let atmo = global.city.ptrait;

let gains = calcPrestige('bigbang');
logPrestigeGains(gains);

checkAchievements();

Expand Down Expand Up @@ -473,6 +478,7 @@ export function vacuumCollapse(){
let atmo = global.city.ptrait;

let gains = calcPrestige('vacuum');
logPrestigeGains(gains);

checkAchievements();

Expand Down Expand Up @@ -544,6 +550,7 @@ export function ascend(){
let geo = global.city.geology;

let gains = calcPrestige('ascend');
logPrestigeGains(gains);

global.stats.ascend++;
updateResetStats();
Expand Down Expand Up @@ -682,6 +689,7 @@ export function descension(){
grandDeathTour('di');

let gains = calcPrestige('descend');
logPrestigeGains(gains);
global.prestige.Artifact.count += gains.artifact;
global.stats.artifact += gains.artifact;

Expand Down Expand Up @@ -760,6 +768,7 @@ export function apotheosis(){
let geo = global.city.geology;

let gains = calcPrestige('apotheosis');
logPrestigeGains(gains);

global.stats.apotheosis++;
updateResetStats();
Expand Down Expand Up @@ -856,6 +865,7 @@ export function terraform(planet){
let geo = planet.geology;

let gains = calcPrestige('terraform');
logPrestigeGains(gains);

global.stats.terraform++;
updateResetStats();
Expand Down Expand Up @@ -959,6 +969,7 @@ export function aiApocalypse(){
let geo = global.city.geology;

let gains = calcPrestige('ai');
logPrestigeGains(gains);
checkAchievements();

global.stats.aiappoc++;
Expand Down Expand Up @@ -1029,6 +1040,7 @@ export function matrix(){
let geo = global.city.geology;

let gains = calcPrestige('matrix');
logPrestigeGains(gains);

unlockAchieve(`biome_${biome}`);
atmo.forEach(function(a){
Expand Down Expand Up @@ -1114,6 +1126,7 @@ export function retirement(){
let geo = global.city.geology;

let gains = calcPrestige('retired');
logPrestigeGains(gains);

unlockAchieve(`biome_${biome}`);
atmo.forEach(function(a){
Expand Down Expand Up @@ -1199,6 +1212,7 @@ export function gardenOfEden(){
let geo = global.city.geology;

let gains = calcPrestige('eden');
logPrestigeGains(gains);

unlockAchieve(`biome_${biome}`);
atmo.forEach(function(a){
Expand Down Expand Up @@ -1261,6 +1275,53 @@ export function gardenOfEden(){
window.location.reload();
}

function formatPrestigeGain(value){
let amount = Number(value);
if (!isFinite(amount)){
return value.toString();
}
if (Math.floor(amount) === amount){
return amount.toString();
}
return (+amount.toFixed(3)).toString();
}

function prestigeGainList(items){
if (items.length <= 1){
return items[0] || '';
}
if (items.length === 2){
return loc('reset_prestige_gained_pair',[items[0],items[1]]);
}
return loc('reset_prestige_gained_pair',[
items.slice(0,-1).join(', '),
items[items.length - 1]
]);
}

function logPrestigeGains(gains){
let prestigeResources = [
['plasmid', global.race.universe === 'antimatter' ? loc('resource_AntiPlasmid_name') : loc('resource_Plasmid_name')],
['phage', loc('resource_Phage_name')],
['dark', loc('resource_Dark_name')],
['harmony', loc('resource_Harmony_name')],
['artifact', loc('resource_Artifact_name')],
['supercoiled', loc('resource_Supercoiled_name')],
['cores', loc('resource_AICore_name')]
];

let earned = [];
prestigeResources.forEach(function(resource){
let key = resource[0];
if (gains.hasOwnProperty(key) && gains[key] > 0){
earned.push(`${formatPrestigeGain(gains[key])} ${resource[1]}`);
}
});

if (earned.length > 0){
messageQueue(loc('reset_prestige_gained',[prestigeGainList(earned)]),'success',false,['major_events']);
}
}
function resetCommon(args){
global.city = {
calendar: {
Expand Down
2 changes: 2 additions & 0 deletions strings/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
"settings17": "Always power on new structures, even when remaining electricity or support is insufficient.",
"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_prestige_gained": "Prestige gained: %0",
"reset_prestige_gained_pair": "%0 and %1",
"reset_soft": "Soft Reset Game",
"reset_hard": "Hard Reset Game",
"pause": "Pause Game",
Expand Down