From e72ede26d896ce9825412650ca7421ac9ca48b70 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 12 Feb 2024 16:38:46 -0500 Subject: [PATCH] Implement catch count based starter value decreases --- public/images/ui/starter_select_bg.png | Bin 1423 -> 1424 bytes src/system/game-data.ts | 34 ++++++++++++ src/ui/starter-select-ui-handler.ts | 74 +++++++++++++++++++------ src/ui/summary-ui-handler.ts | 4 +- 4 files changed, 94 insertions(+), 18 deletions(-) diff --git a/public/images/ui/starter_select_bg.png b/public/images/ui/starter_select_bg.png index 870354f1f1c4521acc64ac9ce2878cea0f0deb05..04a85b59d9ac6f0b2af50fa2b4291afe5846b0a2 100644 GIT binary patch delta 1136 zcmeC@p1?gpr9Rx##WAGf*4w)ai*9E~v|T(um%-W5(HV#jI~{g%j&IUeG}vHJurM)k z!GZ+|5BPb{20b{k`{c6AcULZr-*jFvSIk8!vhK6SU9-(+|NT>ySh~&o;ybyte0lxV zTCcOOZhf1>^PI81O8z|0{U5gL$~SM{_;c4S*GN4!+d8lFA0OAh{CBthbfH|q%HKb1 zYQAnNNp)NH^3u*fef74kvAK(8$Zwi+`eB62Wji;Q6kGlsM{55ZT`IADyT04i*XuP) zCHF^_&HpF2EVOoc_4jj2XM8YNH$8A_sQ&!jzPTp9^?p}6$bbL1{P6b3n(nt{(qHqw zzC7NO{N>u}(){`L8)ICK{M%mt`1*ISDt-CV{q_Il&iFrG zuGk$}WBoslktz7==|{Kow$Bf{U$(pSYQt-pef53v2hQ@$caMDVtnK|~_h?oQpSyS8 zA6s{C?K%11|Ktj`9{&DO@Vc^oL2&;r2J^rgLBX#ZdnyBWJ26|y&B}OovbCXJr+?S+ zPk-D}BED`kshg1eV@lk+FSmEI8GQMmx%bR7Jw^??qwLsloBu~myMP)E0=SDmpav83 z%zqSIv*1UJss2 zrY`>fR@~SERKw2rC_6M%*Y!MNKHC1Md9|F~)#--cYA!a~9KL=g_{zP8NRwjwvpkzb z=bI}OtlhVRW%4T)naMINJd^oYRO%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a?t}lLq9a7C|68A&@w10_I^% GX2m}RcV0XI diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 8b42ae48f..ce84da5c0 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -857,6 +857,40 @@ export class GameData { return ret; } + getSpeciesStarterValue(speciesId: Species): number { + const baseValue = speciesStarters[speciesId]; + let value = baseValue; + const caughtHatchedCount = this.dexData[speciesId].caughtCount + this.dexData[speciesId].hatchedCount; + + const decrementValue = (value: number) => { + if (value > 1) + value--; + else + value /= 2; + return value; + } + + let thresholdA: integer; + let thresholdB: integer; + + if (baseValue >= 8) + [ thresholdA, thresholdB ] = [ 3, 10 ]; + else if (baseValue >= 6) + [ thresholdA, thresholdB ] = [ 5, 20 ]; + else if (baseValue >= 4) + [ thresholdA, thresholdB ] = [ 10, 30 ]; + else + [ thresholdA, thresholdB ] = [ 25, 100 ]; + + if (caughtHatchedCount >= thresholdA) { + value = decrementValue(value); + if (caughtHatchedCount >= thresholdB) + value = decrementValue(value); + } + + return value; + } + getFormIndex(attr: bigint): integer { if (!attr || attr < DexAttr.DEFAULT_FORM) return 0; diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 0d8a61352..d3d6c6af1 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -1,5 +1,5 @@ import BattleScene, { Button } from "../battle-scene"; -import PokemonSpecies, { SpeciesFormKey, allSpecies, getPokemonSpecies, speciesStarters as speciesStarterValues } from "../data/pokemon-species"; +import PokemonSpecies, { allSpecies, getPokemonSpecies, speciesStarters } from "../data/pokemon-species"; import { Species } from "../data/enums/species"; import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text"; import { Mode } from "./ui"; @@ -42,6 +42,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private pokemonAbilityText: Phaser.GameObjects.Text; private pokemonNatureLabelText: Phaser.GameObjects.Text; private pokemonNatureText: BBCodeText; + private pokemonCaughtCountLabelText: Phaser.GameObjects.Text; + private pokemonCaughtCountText: Phaser.GameObjects.Text; private genOptionsText: Phaser.GameObjects.Text; private instructionsText: Phaser.GameObjects.Text; private starterSelectMessageBoxContainer: Phaser.GameObjects.Container; @@ -114,7 +116,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler.setup(this.scene); - this.pokemonNumberText = addTextObject(this.scene, 17, 1, '000', TextStyle.SUMMARY); + this.pokemonNumberText = addTextObject(this.scene, 17, 1, '0000', TextStyle.SUMMARY); this.pokemonNumberText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonNumberText); @@ -135,24 +137,33 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonGenderText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonGenderText); - this.pokemonAbilityLabelText = addTextObject(this.scene, 6, 126, 'Ability:', TextStyle.SUMMARY, { fontSize: '64px' }); + this.pokemonAbilityLabelText = addTextObject(this.scene, 6, 126, 'Ability:', TextStyle.SUMMARY, { fontSize: '56px' }); this.pokemonAbilityLabelText.setOrigin(0, 0); this.pokemonAbilityLabelText.setVisible(false); this.starterSelectContainer.add(this.pokemonAbilityLabelText); - this.pokemonAbilityText = addTextObject(this.scene, 34, 126, '', TextStyle.SUMMARY, { fontSize: '64px' }); + this.pokemonAbilityText = addTextObject(this.scene, 30, 126, '', TextStyle.SUMMARY, { fontSize: '56px' }); this.pokemonAbilityText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonAbilityText); - this.pokemonNatureLabelText = addTextObject(this.scene, 6, 135, 'Nature:', TextStyle.SUMMARY, { fontSize: '64px' }); + this.pokemonNatureLabelText = addTextObject(this.scene, 6, 135, 'Nature:', TextStyle.SUMMARY, { fontSize: '56px' }); this.pokemonNatureLabelText.setOrigin(0, 0); this.pokemonNatureLabelText.setVisible(false); this.starterSelectContainer.add(this.pokemonNatureLabelText); - this.pokemonNatureText = addBBCodeTextObject(this.scene, 34, 135, '', TextStyle.SUMMARY, { fontSize: '64px' }); + this.pokemonNatureText = addBBCodeTextObject(this.scene, 30, 135, '', TextStyle.SUMMARY, { fontSize: '56px' }); this.pokemonNatureText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonNatureText); + this.pokemonCaughtCountLabelText = addTextObject(this.scene, 6, 144, 'Caught/Hatched:', TextStyle.SUMMARY, { fontSize: '56px' }); + this.pokemonCaughtCountLabelText.setOrigin(0, 0); + this.pokemonCaughtCountLabelText.setVisible(false); + this.starterSelectContainer.add(this.pokemonCaughtCountLabelText); + + this.pokemonCaughtCountText = addTextObject(this.scene, 58, 144, '0/0 (0)', TextStyle.SUMMARY, { fontSize: '56px' }); + this.pokemonCaughtCountText.setOrigin(0, 0); + this.starterSelectContainer.add(this.pokemonCaughtCountText); + this.genOptionsText = addTextObject(this.scene, 124, 7, '', TextStyle.WINDOW, { fontSize: 72, lineSpacing: 39, align: 'center' }); this.genOptionsText.setShadowOffset(4.5, 4.5); this.genOptionsText.setOrigin(0.5, 0); @@ -217,7 +228,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.genSpecies.push([]); for (let species of allSpecies) { - if (!speciesStarterValues.hasOwnProperty(species.speciesId) || species.generation !== g + 1 || !species.isObtainable()) + if (!speciesStarters.hasOwnProperty(species.speciesId) || species.generation !== g + 1 || !species.isObtainable()) continue; starterSpecies.push(species.speciesId); this.speciesLoaded.set(species.speciesId, false); @@ -272,7 +283,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`); this.starterSelectContainer.add(this.pokemonSprite); - this.instructionsText = addTextObject(this.scene, 4, 148, '', TextStyle.PARTY, { fontSize: '42px' }); + this.instructionsText = addTextObject(this.scene, 4, 156, '', TextStyle.PARTY, { fontSize: '42px' }); this.starterSelectContainer.add(this.instructionsText); this.starterSelectMessageBoxContainer = this.scene.add.container(0, this.scene.game.canvas.height / 6); @@ -434,7 +445,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } } const species = this.genSpecies[this.getGenCursorWithScroll()][this.cursor]; - if (!isDupe && this.tryUpdateValue(speciesStarterValues[species.speciesId])) { + if (!isDupe && this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId))) { const cursorObj = this.starterCursorObjs[this.starterCursors.length]; cursorObj.setVisible(true); cursorObj.setPosition(this.cursorObj.x, this.cursorObj.y); @@ -636,10 +647,33 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const genLimit = this.genSpecies[genCursorWithScroll].length; for (let s = 0; s < 81; s++) { - const slotVisible = s < genLimit && !!(this.scene.gameData.dexData[this.genSpecies[genCursorWithScroll][s].speciesId].caughtAttr); - this.starterValueLabels[s].setText(slotVisible ? speciesStarterValues[this.genSpecies[genCursorWithScroll][s].speciesId] : 0); + const speciesId = s < genLimit ? this.genSpecies[genCursorWithScroll][s].speciesId : 0 as Species; + const slotVisible = speciesId && !!(this.scene.gameData.dexData[speciesId].caughtAttr); + if (slotVisible) { + const baseStarterValue = speciesStarters[speciesId]; + const starterValue = slotVisible ? this.scene.gameData.getSpeciesStarterValue(speciesId) : 0; + let valueStr = starterValue.toString(); + if (valueStr.startsWith('0.')) + valueStr = valueStr.slice(1); + this.starterValueLabels[s].setText(valueStr); + let textStyle: TextStyle; + switch (baseStarterValue - starterValue) { + case 0: + textStyle = TextStyle.WINDOW; + break; + case 1: + case 0.5: + textStyle = TextStyle.SUMMARY_BLUE; + break; + default: + textStyle = TextStyle.SUMMARY_GOLD; + break; + } + this.starterValueLabels[s].setColor(getTextColor(textStyle)); + this.starterValueLabels[s].setShadowColor(getTextColor(textStyle, true)); + } this.starterValueLabels[s].setVisible(slotVisible); - this.shinyIcons[s].setVisible(slotVisible && !!(this.scene.gameData.dexData[this.genSpecies[genCursorWithScroll][s].speciesId].caughtAttr & DexAttr.SHINY)); + this.shinyIcons[s].setVisible(slotVisible && !!(this.scene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY)); } } else { changed = super.setCursor(cursor); @@ -716,7 +750,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.lastSpecies = species; if (species && this.speciesStarterDexEntry?.caughtAttr) { - this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 3)); + this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4)); this.pokemonNameText.setText(species.name); this.pokemonGrowthRateText.setText(Utils.toReadableString(GrowthRate[species.growthRate])); this.pokemonGrowthRateText.setColor(getGrowthRateColor(species.growthRate)); @@ -724,6 +758,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonGrowthRateLabelText.setVisible(true); this.pokemonAbilityLabelText.setVisible(true); this.pokemonNatureLabelText.setVisible(true); + this.pokemonCaughtCountLabelText.setVisible(true); + this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry.caughtCount}/${this.speciesStarterDexEntry.hatchedCount} (${this.speciesStarterDexEntry.caughtCount + this.speciesStarterDexEntry.hatchedCount})`); + this.pokemonCaughtCountText.setVisible(true); this.iconAnimHandler.addOrUpdate(this.starterSelectGenIconContainers[species.generation - 1].getAt(this.genSpecies[species.generation - 1].indexOf(species)) as Phaser.GameObjects.Sprite, PokemonIconAnimMode.PASSIVE); let starterIndex = -1; @@ -748,12 +785,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, defaultNature); } } else { - this.pokemonNumberText.setText(Utils.padInt(0, 3)); + this.pokemonNumberText.setText(Utils.padInt(0, 4)); this.pokemonNameText.setText(species ? '???' : ''); this.pokemonGrowthRateText.setText(''); this.pokemonGrowthRateLabelText.setVisible(false); this.pokemonAbilityLabelText.setVisible(false); this.pokemonNatureLabelText.setVisible(false); + this.pokemonCaughtCountLabelText.setVisible(false); + this.pokemonCaughtCountText.setVisible(false); this.setSpeciesDetails(species, false, 0, false, 0, 0); } @@ -879,10 +918,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } tryUpdateValue(add?: integer): boolean { - const value = this.starterGens.reduce((total: integer, gen: integer, i: integer) => total += speciesStarterValues[this.genSpecies[gen][this.starterCursors[i]].speciesId], 0); + const value = this.starterGens.reduce((total: integer, gen: integer, i: integer) => total += this.scene.gameData.getSpeciesStarterValue(this.genSpecies[gen][this.starterCursors[i]].speciesId), 0); const newValue = value + (add || 0); const overLimit = newValue > 10; - this.valueLimitLabel.setText(`${newValue}/10`); + let newValueStr = newValue.toString(); + if (newValueStr.startsWith('0.')) + newValueStr = newValueStr.slice(1); + this.valueLimitLabel.setText(`${newValueStr}/10`); this.valueLimitLabel.setColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK)); this.valueLimitLabel.setShadowColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK, true)); if (overLimit) { diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 58f4e243a..1ed34dbb5 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -94,7 +94,7 @@ export default class SummaryUiHandler extends UiHandler { this.shinyOverlay.setOrigin(0, 1); this.summaryContainer.add(this.shinyOverlay); - this.numberText = addTextObject(this.scene, 17, -149, '000', TextStyle.SUMMARY); + this.numberText = addTextObject(this.scene, 17, -149, '0000', TextStyle.SUMMARY); this.numberText.setOrigin(0, 1); this.summaryContainer.add(this.numberText); @@ -196,7 +196,7 @@ export default class SummaryUiHandler extends UiHandler { this.shinyOverlay.setVisible(this.pokemon.isShiny()); - this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 3)); + this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 4)); this.numberText.setColor(getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD)); this.numberText.setShadowColor(getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true));