From 661e8fd7b44ef727cf25bec00753fdace6d0fb9f Mon Sep 17 00:00:00 2001 From: Khafra Date: Sun, 31 Mar 2024 23:56:07 -0400 Subject: [PATCH] add bribe code (#587) --- src/Hepteracts.ts | 18 +++++++++--------- src/ImportExport.ts | 17 +++++++++++++++++ src/Synergism.ts | 2 +- translations/en.json | 7 ++++++- translations/source.json | 7 ++++++- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/Hepteracts.ts b/src/Hepteracts.ts index 7df2bc128..01a3cbcfd 100644 --- a/src/Hepteracts.ts +++ b/src/Hepteracts.ts @@ -223,17 +223,17 @@ export class HepteractCraft { player.wowAbyssals = 0 } - for (const item in this.OTHER_CONVERSIONS) { - if (typeof player[item as keyof Player] === 'number') { - ;(player[item as keyof Player] as number) -= amountToCraft * craftCostMulti - * this.OTHER_CONVERSIONS[item as keyof Player]! + for (const item of (Object.keys(this.OTHER_CONVERSIONS) as (keyof Player)[])) { + if (typeof player[item] === 'number') { + ;(player[item] as number) -= amountToCraft * craftCostMulti + * this.OTHER_CONVERSIONS[item]! } - if ((player[item as keyof Player] as number) < 0) { - ;(player[item as keyof Player] as number) = 0 - } else if (player[item as keyof Player] instanceof Cube) { - ;(player[item as keyof Player] as Cube).sub( - amountToCraft * craftCostMulti * this.OTHER_CONVERSIONS[item as keyof Player]! + if ((player[item] as number) < 0) { + ;(player[item] as number) = 0 + } else if (player[item] instanceof Cube) { + ;(player[item] as Cube).sub( + amountToCraft * craftCostMulti * this.OTHER_CONVERSIONS[item]! ) } else if (item === 'worlds') { player.worlds.sub(amountToCraft * this.OTHER_CONVERSIONS[item]!) diff --git a/src/ImportExport.ts b/src/ImportExport.ts index b54b60841..ae886dd42 100644 --- a/src/ImportExport.ts +++ b/src/ImportExport.ts @@ -505,6 +505,23 @@ export const promocodes = async (input: string | null, amount?: number) => { el.textContent = i18next.t('importexport.promocodes.khafra', { x: player.worlds.applyBonus(quarks) }) + } else if (input === 'alonso bribe' && !player.codes.get(47)) { + const craft = player.hepteractCrafts.quark + + if (!craft.UNLOCKED) { + return Alert(i18next.t('importexport.promocodes.bribe.notUnlocked')) + } + + const cap = craft.computeActualCap() + + if (cap <= craft.BAL + 1) { + return Alert(i18next.t('importexport.promocodes.bribe.overCapacity')) + } + + player.codes.set(47, true) + craft.BAL++ + + return Alert(i18next.t('importexport.promocodes.bribe.thanks')) } else if (input.toLowerCase() === 'daily' && !player.dailyCodeUsed) { player.dailyCodeUsed = true let rewardMessage = i18next.t('importexport.promocodes.daily.message') diff --git a/src/Synergism.ts b/src/Synergism.ts index 899b97bc7..5ac87b07c 100644 --- a/src/Synergism.ts +++ b/src/Synergism.ts @@ -534,7 +534,7 @@ export const player: Player = { subtabNumber: 0, // create a Map with keys defaulting to false - codes: new Map(Array.from({ length: 46 }, (_, i) => [i + 1, false])), + codes: new Map(Array.from({ length: 47 }, (_, i) => [i + 1, false])), loaded1009: true, loaded1009hotfix1: true, diff --git a/translations/en.json b/translations/en.json index a9147c270..a5986a834 100644 --- a/translations/en.json +++ b/translations/en.json @@ -3413,7 +3413,12 @@ "moreThan1": "You will gain {{x}} Octeracts (when they come out) every second, assuming you have them unlocked!", "one": "You will gain an Octeract (when they come out) every {{x}} seconds, assuming you have them unlocked!" }, - "invalid": "Your code is either invalid or already used. Try again!" + "invalid": "Your code is either invalid or already used. Try again!", + "bribe": { + "notUnlocked": "Hmmm... you aren't ready yet.", + "overCapacity": "You can't hold more!", + "thanks": "Thank Alonso (in Discord) for the bribe." + } } }, "toggles": { diff --git a/translations/source.json b/translations/source.json index e3e65f49b..3cb2e5afb 100644 --- a/translations/source.json +++ b/translations/source.json @@ -3385,7 +3385,12 @@ "moreThan1": "You will gain {{x}} Octeracts (when they come out) every second, assuming you have them unlocked!", "one": "You will gain an Octeract (when they come out) every {{x}} seconds, assuming you have them unlocked!" }, - "invalid": "Your code is either invalid or already used. Try again!" + "invalid": "Your code is either invalid or already used. Try again!", + "bribe": { + "notUnlocked": "Hmmm... you aren't ready yet.", + "overCapacity": "You can't hold more!", + "thanks": "Thank Alonso (in Discord) for the bribe." + } } }, "toggles": {