From fdc1bc5b61d43dc511343d30a0ee8116ccb41b0d Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 7 Nov 2023 18:43:48 -0500 Subject: [PATCH] Fix issues with item transfer and add scrolling --- public/images/ui/party_options_bottom.png | Bin 198 -> 0 bytes public/images/ui/party_options_center.png | Bin 148 -> 0 bytes public/images/ui/party_options_top.png | Bin 200 -> 0 bytes .../images/ui/party_options_wide_bottom.png | Bin 204 -> 0 bytes .../images/ui/party_options_wide_center.png | Bin 154 -> 0 bytes public/images/ui/party_options_wide_top.png | Bin 208 -> 0 bytes src/battle-scene.ts | 6 -- src/modifier/modifier-type.ts | 6 +- src/ui/party-ui-handler.ts | 101 ++++++++++++++---- 9 files changed, 84 insertions(+), 29 deletions(-) delete mode 100644 public/images/ui/party_options_bottom.png delete mode 100644 public/images/ui/party_options_center.png delete mode 100644 public/images/ui/party_options_top.png delete mode 100644 public/images/ui/party_options_wide_bottom.png delete mode 100644 public/images/ui/party_options_wide_center.png delete mode 100644 public/images/ui/party_options_wide_top.png diff --git a/public/images/ui/party_options_bottom.png b/public/images/ui/party_options_bottom.png deleted file mode 100644 index d30c62ab07f4654dc7c2e123a057956dc22cc77a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^aX`$*!3HF~_%*)(sa{VP#}JR>Z!akd9aa!VP-o8@K?^PS6)s8>PfR_rBVfNW`To1ba{Z*ul}ut$h8t!SU1|q9jKR~@&t;ucLK6Vel}y_J diff --git a/public/images/ui/party_options_center.png b/public/images/ui/party_options_center.png deleted file mode 100644 index b177e64d2e789c642a32433e6a5374dd8184923a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^aX>7Z!al|H5&-HUKHnB zBqS**X(`mX=8Vv;9=(O96F5(t@=8(JWF!>n&boY=OWTS{v%vCwj31Pwqqa_y=>54c zzTNtoRjB30DfevR`5Ah|Z&vNR7#lWq<%M4_XFT@U9G?_8F>CexwYTpi%iAQmPUR8_ zPMOztIIs9cB8OI(#&cN%*$=b-_wV}h>8a2DcmAogZ{8cHp4(5-4?SU=G5tVMyg{12 zt&n9XLssytv~|B1Uw2gcmC-qKVTR<>pJrTF!X5K!r)UK0nij8E&!oXH{d~ZY{o=>w zOm{!>ziz>@N}el5M$1L6T3J12aO#=On*1-+yU^c0)o{boH?KhMX7F_Nb6Mw<&;$TG CS5fHz diff --git a/public/images/ui/party_options_wide_center.png b/public/images/ui/party_options_wide_center.png deleted file mode 100644 index ef75c43fa275ee018e283faedf6a7dab80208e4b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^6M$HNgAGXj{PryYNF{o@IEG~0dwWSyw84Ra^&r3I z1a*I05AWEP)GZ`EhcY53_!PtsQCP-%Ol^cwebLn3?x=>ZPlXy0000< KMNUMnLSTZZt5SCW diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 343e69067..e3ce16b3a 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -216,12 +216,6 @@ export default class BattleScene extends Phaser.Scene { this.loadImage('party_message_large', 'ui'); this.loadImage('party_message_options', 'ui'); this.loadImage('party_message_options_wide', 'ui'); - this.loadImage('party_options_top', 'ui'); - this.loadImage('party_options_center', 'ui'); - this.loadImage('party_options_bottom', 'ui'); - this.loadImage('party_options_wide_top', 'ui'); - this.loadImage('party_options_wide_center', 'ui'); - this.loadImage('party_options_wide_bottom', 'ui'); this.loadAtlas('party_cancel', 'ui'); this.loadImage('summary_bg', 'ui'); diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 7b8d6a7cf..a4136ed2a 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -703,7 +703,7 @@ export const modifierTypes = { ENEMY_DAMAGE_BOOSTER: () => new ModifierType('Damage Token', 'Increases damage by 20%', (type, _args) => new Modifiers.EnemyDamageBoosterModifier(type, 20), 'wl_item_drop'), ENEMY_DAMAGE_REDUCTION: () => new ModifierType('Protection Token', 'Reduces incoming damage by 10%', (type, _args) => new Modifiers.EnemyDamageReducerModifier(type, 10), 'wl_guard_spec'), - //ENEMY_SUPER_EFFECT_BOOSTER: () => new ModifierType('Type Advantage Token', 'Increases damage of super effective attacks by 30%', (type, _args) => new Modifiers.EnemySuperEffectiveDamageBoosterModifier(type, 30), 'wl_super_potion'), + //ENEMY_SUPER_EFFECT_BOOSTER: () => new ModifierType('Type Advantage Token', 'Increases damage of super effective attacks by 30%', (type, _args) => new Modifiers.EnemySuperEffectiveDamageBoosterModifier(type, 30), 'wl_custom_super_effective'), ENEMY_HEAL: () => new ModifierType('Recovery Token', 'Heals 5% of max HP every turn', (type, _args) => new Modifiers.EnemyTurnHealModifier(type, 10), 'wl_potion'), ENEMY_ATTACK_POISON_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType('Poison Token', 10, StatusEffect.POISON, 'wl_antidote'), ENEMY_ATTACK_PARALYZE_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType('Paralyze Token', 10, StatusEffect.PARALYSIS, 'wl_paralyze_heal'), @@ -964,7 +964,7 @@ export function getPlayerModifierTypeOptionsForWave(waveIndex: integer, count: i export function getEnemyBuffModifierForWave(tier: ModifierTier, enemyModifiers: Modifiers.PersistentModifier[]): Modifiers.EnemyPersistentModifier { const tierStackCount = tier === ModifierTier.ULTRA ? 10 : tier === ModifierTier.GREAT ? 5 : 1; - const retryCount = 35; + const retryCount = 50; let candidate = getNewModifierTypeOption(null, ModifierPoolType.ENEMY_BUFF, tier); let r = 0; let matchingModifier: Modifiers.PersistentModifier; @@ -990,7 +990,7 @@ function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, if (tier === undefined) { const tierValue = Utils.randSeedInt(256); if (player && tierValue) { - const partyShinyCount = party.filter(p => p.shiny).length; + const partyShinyCount = party.filter(p => p.isShiny()).length; const upgradeOdds = Math.floor(32 / Math.max((partyShinyCount * 2), 1)); upgrade = !Utils.randSeedInt(upgradeOdds); } else diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 5a0747ac4..d4af49cb0 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -35,7 +35,9 @@ export enum PartyOption { SPLICE, SUMMARY, RELEASE, - MOVE_1, + SCROLL_UP = 1000, + SCROLL_DOWN = 1001, + MOVE_1 = 2000, MOVE_2, MOVE_3, MOVE_4 @@ -60,7 +62,10 @@ export default class PartyUiHandler extends MessageUiHandler { private partyMessageBox: Phaser.GameObjects.Image; private optionsMode: boolean; - private optionsCursor: integer; + private optionsScroll: boolean; + private optionsCursor: integer = 0; + private optionsScrollCursor: integer = 0; + private optionsScrollTotal: integer = 0; private optionsContainer: Phaser.GameObjects.Container; private optionsCursorObj: Phaser.GameObjects.Image; private options: integer[]; @@ -208,8 +213,9 @@ export default class PartyUiHandler extends MessageUiHandler { if (option === PartyOption.TRANSFER && filterResult === null && this.partyUiMode === PartyUiMode.MOVE_MODIFIER) filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]); } else { + const transferPokemon = this.scene.getParty()[this.transferCursor]; const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier - && (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[]; + && (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === transferPokemon.id) as PokemonHeldItemModifier[]; filterResult = (this.selectFilter as PokemonModifierTransferSelectFilter)(pokemon, itemModifiers[this.transferOptionCursor]); } if (filterResult === null) { @@ -353,7 +359,32 @@ export default class PartyUiHandler extends MessageUiHandler { if (this.optionsMode) { changed = this.optionsCursor !== cursor; - this.optionsCursor = cursor; + let isScroll = false; + if (changed && this.optionsScroll) { + if (Math.abs(cursor - this.optionsCursor) === this.options.length - 1) { + this.optionsScrollCursor = cursor ? this.optionsScrollTotal - 8 : 0; + this.updateOptions(); + } else { + const isDown = cursor && cursor > this.optionsCursor; + if (isDown) { + if (this.options[cursor] === PartyOption.SCROLL_DOWN) { + isScroll = true; + this.optionsScrollCursor++; + } + } else { + if (!cursor && this.optionsScrollCursor) { + isScroll = true; + this.optionsScrollCursor--; + } + } + if (isScroll && this.optionsScrollCursor === 1) + this.optionsScrollCursor += isDown ? 1 : -1; + } + } + if (isScroll) { + this.updateOptions(); + } else + this.optionsCursor = cursor; if (!this.optionsCursorObj) { this.optionsCursorObj = this.scene.add.image(0, 0, 'cursor'); this.optionsCursorObj.setOrigin(0, 0); @@ -423,9 +454,13 @@ export default class PartyUiHandler extends MessageUiHandler { this.showText(optionsMessage, 0); - const optionsBottom = this.scene.add.image(0, 0, `party_options${wideOptions ? '_wide' : ''}_bottom`); - optionsBottom.setOrigin(1, 1); - this.optionsContainer.add(optionsBottom); + this.updateOptions(); + + this.setCursor(0); + } + + updateOptions(): void { + const wideOptions = this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER; const pokemon = this.scene.getParty()[this.cursor]; @@ -434,6 +469,12 @@ export default class PartyUiHandler extends MessageUiHandler { && (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[] : null; + if (this.options.length) { + this.options.splice(0, this.options.length); + this.optionsContainer.removeAll(true); + this.eraseOptionsCursor(); + } + if (this.partyUiMode !== PartyUiMode.MOVE_MODIFIER && (this.transferMode || this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER)) { switch (this.partyUiMode) { case PartyUiMode.SWITCH: @@ -480,9 +521,32 @@ export default class PartyUiHandler extends MessageUiHandler { this.options.push(im); } + this.optionsScrollTotal = this.options.length; + let optionStartIndex = this.optionsScrollCursor; + let optionEndIndex = Math.min(this.optionsScrollTotal, optionStartIndex + (!optionStartIndex || this.optionsScrollCursor + 8 >= this.optionsScrollTotal ? 8 : 7)); + + this.optionsScroll = this.optionsScrollTotal > 9; + + if (this.optionsScroll) { + this.options.splice(optionEndIndex, this.optionsScrollTotal); + this.options.splice(0, optionStartIndex); + if (optionStartIndex) + this.options.unshift(PartyOption.SCROLL_UP); + if (optionEndIndex < this.optionsScrollTotal) + this.options.push(PartyOption.SCROLL_DOWN); + } + this.options.push(PartyOption.CANCEL); - for (let o = 0; o < this.options.length; o++) { + const optionBg = this.scene.add.nineslice(0, 0, 'window', null, wideOptions ? 144 : 94, 16 * this.options.length + 13, 6, 6, 6, 6); + optionBg.setOrigin(1, 1); + + this.optionsContainer.add(optionBg); + + optionStartIndex = 0; + optionEndIndex = this.options.length; + + for (let o = optionStartIndex; o < optionEndIndex; o++) { const option = this.options[this.options.length - (o + 1)]; let optionName: string; if (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode || option === PartyOption.CANCEL) { @@ -497,7 +561,11 @@ export default class PartyUiHandler extends MessageUiHandler { optionName = Utils.toReadableString(PartyOption[option]); break; } - } else { + } else if (option === PartyOption.SCROLL_UP) + optionName = '↑'; + else if (option === PartyOption.SCROLL_DOWN) + optionName = '↓'; + else { const itemModifier = itemModifiers[option]; optionName = itemModifier.type.name; if (itemModifier.stackCount > 1) @@ -505,27 +573,17 @@ export default class PartyUiHandler extends MessageUiHandler { } const yCoord = -6 - 16 * o; - const optionBg = this.scene.add.image(0, yCoord, `party_options${wideOptions ? '_wide' : ''}_center`); const optionText = addTextObject(this.scene, -79 - (wideOptions ? 50 : 0), yCoord - 16, optionName, TextStyle.WINDOW); - - optionBg.setOrigin(1, 1); optionText.setOrigin(0, 0); - this.optionsContainer.add(optionBg); this.optionsContainer.add(optionText); } - - const optionsTop = this.scene.add.image(0, -6 - 16 * this.options.length, `party_options${wideOptions ? '_wide' : ''}_top`); - optionsTop.setOrigin(1, 1); - this.optionsContainer.add(optionsTop); - - this.setCursor(0); } startTransfer(): void { this.transferMode = true; this.transferCursor = this.cursor; - this.transferOptionCursor = this.optionsCursor; + this.transferOptionCursor = this.optionsCursor + this.optionsScrollCursor + (this.options[0] === PartyOption.SCROLL_UP ? -1 : 0); this.partySlots[this.transferCursor].setTransfer(true); } @@ -579,6 +637,9 @@ export default class PartyUiHandler extends MessageUiHandler { clearOptions() { this.optionsMode = false; + this.optionsScroll = false; + this.optionsScrollCursor = 0; + this.optionsScrollTotal = 0; this.options.splice(0, this.options.length); this.optionsContainer.removeAll(true); this.eraseOptionsCursor();