From 524cd99eda42156b3133a1198c454af7a1ad3f44 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 20 Dec 2023 17:22:50 -0500 Subject: [PATCH] Rebalanace vouchers and add golden voucher --- src/system/game-data.ts | 13 +++++++++- src/system/voucher.ts | 27 ++++++++++++++------- src/ui/egg-gacha-ui-handler.ts | 44 +++++++++++++++++++++++----------- 3 files changed, 60 insertions(+), 24 deletions(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index d9ab91b48..66c811be7 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -126,7 +126,8 @@ export class GameData { this.voucherCounts = { [VoucherType.REGULAR]: 0, [VoucherType.PLUS]: 0, - [VoucherType.PREMIUM]: 0 + [VoucherType.PREMIUM]: 0, + [VoucherType.GOLDEN]: 0 }; this.eggs = []; this.initDexData(); @@ -206,6 +207,16 @@ export class GameData { } if (data.voucherCounts) { + // TODO: Remove + if (data.voucherUnlocks && !data.voucherCounts.hasOwnProperty(VoucherType.GOLDEN)) { + data.voucherCounts[VoucherType.GOLDEN] = 0; + for (let v of Object.keys(data.voucherUnlocks)) { + const voucherType = vouchers[v].voucherType; + if (voucherType > VoucherType.REGULAR) + data.voucherCounts[VoucherType.REGULAR] += voucherType === VoucherType.GOLDEN ? 15 : voucherType === VoucherType.PREMIUM ? 5 : 4; + } + } + Utils.getEnumKeys(VoucherType).forEach(key => { const index = VoucherType[key]; this.voucherCounts[index] = data.voucherCounts[index] || 0; diff --git a/src/system/voucher.ts b/src/system/voucher.ts index 5df9f84cf..d6e900203 100644 --- a/src/system/voucher.ts +++ b/src/system/voucher.ts @@ -6,7 +6,8 @@ import { Achv, achvs } from "./achv"; export enum VoucherType { REGULAR, PLUS, - PREMIUM + PREMIUM, + GOLDEN } export class Voucher { @@ -37,10 +38,12 @@ export class Voucher { getTier(): ModifierTier { switch (this.voucherType) { case VoucherType.REGULAR: - return ModifierTier.GREAT; + return ModifierTier.COMMON; case VoucherType.PLUS: - return ModifierTier.ULTRA; + return ModifierTier.GREAT; case VoucherType.PREMIUM: + return ModifierTier.ULTRA; + case VoucherType.GOLDEN: return ModifierTier.MASTER; } } @@ -54,6 +57,8 @@ export function getVoucherTypeName(voucherType: VoucherType): string { return 'Egg Voucher Plus'; case VoucherType.PREMIUM: return 'Egg Voucher Premium'; + case VoucherType.GOLDEN: + return 'Egg Voucher Gold'; } } @@ -65,6 +70,8 @@ export function getVoucherTypeIcon(voucherType: VoucherType): string { return 'pair_of_tickets'; case VoucherType.PREMIUM: return 'mystic_ticket'; + case VoucherType.GOLDEN: + return 'golden_mystic_ticket'; } } @@ -81,10 +88,12 @@ const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ]; (function() { for (let achv of voucherAchvs) { const voucherType = achv.score >= 150 - ? VoucherType.PREMIUM - : achv.score >= 75 - ? VoucherType.PLUS - : VoucherType.REGULAR; + ? VoucherType.GOLDEN + : achv.score >= 100 + ? VoucherType.PREMIUM + : achv.score >= 75 + ? VoucherType.PLUS + : VoucherType.REGULAR; vouchers[achv.id] = new Voucher(voucherType, achv.description); } @@ -93,8 +102,8 @@ const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ]; for (let trainerType of bossTrainerTypes) { const voucherType = trainerConfigs[trainerType].moneyMultiplier < 10 - ? VoucherType.REGULAR - : VoucherType.PLUS; + ? VoucherType.PLUS + : VoucherType.PREMIUM; const key = TrainerType[trainerType]; vouchers[key] = new Voucher(voucherType, `Defeat ${trainerConfigs[trainerType].name}`); } diff --git a/src/ui/egg-gacha-ui-handler.ts b/src/ui/egg-gacha-ui-handler.ts index 7b17317b1..dcdebe51d 100644 --- a/src/ui/egg-gacha-ui-handler.ts +++ b/src/ui/egg-gacha-ui-handler.ts @@ -5,7 +5,7 @@ import MessageUiHandler from "./message-ui-handler"; import * as Utils from "../utils"; import { ModifierTier } from "../modifier/modifier-type"; import { EGG_SEED, Egg, GachaType, getEggTierDefaultHatchWaves, getEggDescriptor, getLegendaryGachaSpeciesForTimestamp, getTypeGachaTypeForTimestamp } from "../data/egg"; -import { VoucherType, getVoucherTypeIcon } from "../system/voucher"; +import { Voucher, VoucherType, getVoucherTypeIcon } from "../system/voucher"; import { getPokemonSpecies } from "../data/pokemon-species"; import { Type } from "../data/type"; @@ -144,18 +144,18 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.eggGachaOptionsContainer = this.scene.add.container((this.scene.game.canvas.width / 6), 148); this.eggGachaContainer.add(this.eggGachaOptionsContainer); - this.eggGachaOptionSelectBg = this.scene.add.nineslice(0, 0, 'window', null, 96, 96, 6, 6, 6, 6); + this.eggGachaOptionSelectBg = this.scene.add.nineslice(0, 0, 'window', null, 96, 112, 6, 6, 6, 6); this.eggGachaOptionSelectBg.setOrigin(1, 1); this.eggGachaOptionsContainer.add(this.eggGachaOptionSelectBg); - const optionText = addTextObject(this.scene, 0, 0, ' x1 1 Pull\n x10 10 Pulls\n x1 5 Pulls\n x1 10 Pulls\nCancel', TextStyle.WINDOW, { maxLines: 5 }); + const optionText = addTextObject(this.scene, 0, 0, ' x1 1 Pull\n x10 10 Pulls\n x1 5 Pulls\n x1 10 Pulls\n x1 25 Pulls\nCancel', TextStyle.WINDOW); optionText.setLineSpacing(12); this.eggGachaOptionsContainer.add(optionText); optionText.setPositionRelative(this.eggGachaOptionSelectBg, 16, 9); - new Array(4).fill(null).map((_, i) => { - const voucherType = i < 2 ? VoucherType.REGULAR : i === 2 ? VoucherType.PLUS : VoucherType.PREMIUM; + new Array(5).fill(null).map((_, i) => { + const voucherType = i < 2 ? VoucherType.REGULAR : i === 2 ? VoucherType.PLUS : i === 3 ? VoucherType.PREMIUM : VoucherType.GOLDEN; const icon = this.scene.add.sprite(0, 0, 'items', getVoucherTypeIcon(voucherType)); icon.setScale(0.5); icon.setPositionRelative(this.eggGachaOptionSelectBg, 20, 17 + i * 16); @@ -253,9 +253,9 @@ export default class EggGachaUiHandler extends MessageUiHandler { const tierValue = Utils.randInt(256); return tierValue >= 52 ? ModifierTier.COMMON : tierValue >= 8 ? ModifierTier.GREAT : tierValue >= 1 ? ModifierTier.ULTRA : ModifierTier.MASTER; }); - /*if (pullCount >= 100 && !tiers.filter(t => t >= ModifierTier.ULTRA).length) - tiers[Utils.randInt(tiers.length)] = ModifierTier.ULTRA;*/ - if (pullCount >= 10 && !tiers.filter(t => t >= ModifierTier.GREAT).length) + if (pullCount >= 25 && !tiers.filter(t => t >= ModifierTier.ULTRA).length) + tiers[Utils.randInt(tiers.length)] = ModifierTier.ULTRA; + else if (pullCount >= 10 && !tiers.filter(t => t >= ModifierTier.GREAT).length) tiers[Utils.randInt(tiers.length)] = ModifierTier.GREAT; const timestamp = new Date().getTime(); @@ -355,18 +355,21 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.transitioning = false; this.eggGachaSummaryContainer.setVisible(true); + const eggScale = eggs.length < 20 ? 1 : 0.5; + this.scene.tweens.add({ targets: this.eggGachaOverlay, alpha: 0.5, ease: 'Sine.easeOut', duration: 750, onComplete: () => { - const rows = Math.ceil(eggs.length / 5); - const cols = Math.min(eggs.length, 5); + const rowItems = 5; + const rows = Math.ceil(eggs.length / rowItems); + const cols = Math.min(eggs.length, rowItems); const height = this.eggGachaOverlay.displayHeight - this.eggGachaMessageBox.displayHeight; const eggContainers = eggs.map((egg, t) => { - const col = t % 5; - const row = Math.floor(t / 5); + const col = t % rowItems; + const row = Math.floor(t / rowItems); const sliceWidth = this.eggGachaOverlay.displayWidth / (cols + 2); const sliceHeight = height / (rows + 2); const yOffset = (sliceHeight / 2 * (row / Math.max(rows - 1, 1))) + sliceHeight / 4; @@ -381,7 +384,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { eggText.setTint(getModifierTierTextTint(!egg.isManaphyEgg() ? egg.tier : ModifierTier.ULTRA)); ret.add(eggText); - this.eggGachaSummaryContainer.add(ret); + this.eggGachaSummaryContainer.addAt(ret, 0); return ret; }); @@ -390,7 +393,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { targets: eggContainer, delay: this.getDelayValue(e * 100), duration: this.getDelayValue(350), - scale: 1, + scale: eggScale, ease: 'Sine.easeOut' }); }); @@ -520,6 +523,19 @@ export default class EggGachaUiHandler extends MessageUiHandler { } break; case 4: + if (!this.scene.gameData.voucherCounts[VoucherType.GOLDEN]) { + error = true; + this.showError('You don\'t have enough vouchers!'); + } else if (this.scene.gameData.eggs.length < 75) { + this.consumeVouchers(VoucherType.GOLDEN, 1); + this.pull(25); + success = true; + } else { + error = true; + this.showError('You have too many eggs!'); + } + break; + case 5: ui.revertMode(); success = true; break;