From db5db6127259e8a72de2fdf822fa117137299bce Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sun, 23 Apr 2023 16:36:03 -0400 Subject: [PATCH] Add stats screen to summary --- public/images/ui/summary_stats.png | Bin 0 -> 1545 bytes .../images/ui/summary_stats_overlay_exp.png | Bin 0 -> 89 bytes src/battle-scene.ts | 2 + src/pokemon.ts | 2 +- src/ui/summary-ui-handler.ts | 81 ++++++++++++++++-- 5 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 public/images/ui/summary_stats.png create mode 100644 public/images/ui/summary_stats_overlay_exp.png diff --git a/public/images/ui/summary_stats.png b/public/images/ui/summary_stats.png new file mode 100644 index 0000000000000000000000000000000000000000..e744f84be8f0da06f0028e5f964de56940e4f772 GIT binary patch literal 1545 zcmbW1dpOg39LJ|xn6RU8Y>`_WED9MF-H35W$}P<8k=$>QGTS(%5_X10AyP|^v$4rE zcTL9OF^6g{Lq7@SZqDR3JIiw}|D3=2;3wCKlhxSY-J%Z2nYm{McG-q zh+nSw6ie+E-?yuE(?KBcA1Le7mlB8OMh+DW*@M!?^3WSQe z?pbRRiFTjF)hr5yr&Z;j17)?RDGf}S6}IG(X!0h~NktjjA!bDlGA-)qBUn>SeZRyg zfh?Rlpw*(xgd$r*Z53@Q;%5qYY$TiD#mmmsp;uwz1;P*o1IP5%WjCIn`Ki^US}Jm) z8m&E%K-+u=)TqoD^gTl`AmhVALHkfSU9ei-G88zkqPz(5S8U|G+3mc8D|U+R09NmiGdVITaYH*thCrrP@T zGQ`cHdR<{*IF{N}eH>}!_>n!(G$@z&Bu9D4l~4@Bg?cCHC3c5PZbsbs(C`9BQ1q<) zg6SER;0#3QK<1aB6Q5;1c4BIYNAEq8PLefmeeOaZx!PRx*ovJ_5#5EfkgqgPrc+L; zl0qz{0ORLKN^y$iu04QcJxCpar-4{IPI-X*C2oPYSxRP`p-SSql#Dt8bPEhs5;uHf zal|) zvj-bGqxIu&Uc*hbHU45UMBTE>F6~GjUZ1R4vc*Mu*BdzokWszN$_2Vt`v-@`30>z4 zx$ew8ulW~m-EWi?SO<>7-5EXn_w5P8LrqwWqHF(Z5*xg^OtT8k=1U4+A?~ra2Qt!IdiqV0Vvp zs}Z)6N_y6}9{56WYNbr*^&XEL-}*8PksCeV=*!u-PQYE)w+C*8`MhaZVcn$o-x0_v-l13E`VF|&Z_^cty(aSN2Y`$}HwfB#>BH^R zsK|mViGgwZ10KB*2i&La_GsUonD@dt`uluaC}vIi(mqtJDk6Tg7rSw}aw?)j*CB_A zteCC|!yG?_r@=H78)F#lPz7{vNg3}YhD=|A!7CBP@$9p9er%YZUZUX}FA-vKE-zKE zS4lAbBH`x{m;Fwu(G6hMbbd-5fjX^g>;X%qMWT1tocDOA1rM;0K2iFQAC4I@nQe4; z37KDXZU8sg!`#KtLRP+1vMZo5E4nvebt_3xQ)`7I?JlZFYs`y@KP?M z@&~1^lK}f*?6#4W?>7>yJ9obf$>K9awa4)WtWd^VDFgGkOKNy5XDZVm%TCoDJ{VQT z&+1wQatnQ&FQVDOSn;p8J(X%=3*IpyX|w?-M9roy==pHuL`8>W$X$cI5yBW$CzqtE ztLJ0RVuiRKPA0ggxLzQm5L1N|#s_|a*K96zZjfm{veg|-J!{Swgdo5%Pk~JCOwWvy zkrKTs=t-L<_hzHZ;<@`a6u^S3gYXWb|72wCBTuQo;_9M1xo)0K0neL(AHz%woJJ4+ zes1<~p|Z`qSMwHh{XD>gngsf<9zf)p-;nrs2LKkVa;LpJR_oYb5pr{kR3tH})b3~*$HI$OJP2juWL%EZRQ#*n?9{pZ1^u1cT`gQu&X%Q~loCIBcn6>k6l literal 0 HcmV?d00001 diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 8f69dba607b..1e5cfeccb67 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -176,6 +176,8 @@ export default class BattleScene extends Phaser.Scene { this.loadImage('summary_bg', 'ui'); this.loadImage('summary_overlay_shiny', 'ui'); this.loadImage('summary_profile', 'ui'); + this.loadImage('summary_stats', 'ui'); + this.loadImage('summary_stats_overlay_exp', 'ui'); this.loadImage('summary_moves', 'ui'); this.loadImage('summary_moves_effect', 'ui'); this.loadImage('summary_moves_overlay_row', 'ui'); diff --git a/src/pokemon.ts b/src/pokemon.ts index c2566ee0f89..90d6b48202b 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -15,7 +15,7 @@ import { initMoveAnim, loadMoveAnimAssets } from './data/battle-anims'; import { Status, StatusEffect } from './data/status-effect'; import { tmSpecies } from './data/tms'; import { pokemonEvolutions, pokemonPrevolutions, SpeciesEvolution, SpeciesEvolutionCondition } from './data/pokemon-evolutions'; -import { DamagePhase, FaintPhase, MessagePhase } from './battle-phases'; +import { DamagePhase, FaintPhase } from './battle-phases'; import { BattleStat } from './data/battle-stat'; import { BattlerTag, BattlerTagLapseType, BattlerTagType, getBattlerTag } from './data/battler-tag'; import { Species } from './data/species'; diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 30df0407b81..f8b9c98a0e6 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -8,9 +8,13 @@ import { TextStyle, addTextObject } from "./text"; import Move, { MoveCategory } from "../data/move"; import { getPokeballAtlasKey } from "../data/pokeball"; import { getGenderColor, getGenderSymbol } from "../data/gender"; +import { getLevelTotalExp } from "../data/exp"; +import { BlendModes } from "phaser"; +import { Stat, getStatName } from "../data/pokemon-stat"; enum Page { PROFILE, + STATS, MOVES } @@ -385,14 +389,75 @@ export default class SummaryUiHandler extends UiHandler { page = this.cursor; if (pageContainer.getAll().length > 1) { - if (this.movesContainer) - this.movesContainer.removeAll(true); + pageContainer.each((o: Phaser.GameObjects.GameObject) => { + if (o instanceof Phaser.GameObjects.Container) + o.removeAll(true); + }); pageContainer.removeBetween(1, undefined, true); } const pageBg = (pageContainer.getAt(0) as Phaser.GameObjects.Sprite); pageBg.setTexture(this.getPageKey(page)); switch (page) { + case Page.STATS: + const statsContainer = this.scene.add.container(0, -pageBg.height); + pageContainer.add(statsContainer); + + const stats = Utils.getEnumValues(Stat) as Stat[]; + + stats.forEach((stat, s) => { + const statName = stat !== Stat.HP + ? getStatName(stat) + : 'HP'; + const rowIndex = s % 3; + const colIndex = Math.floor(s / 3); + + const statLabel = addTextObject(this.scene, 27 + 115 * colIndex, 56 + 16 * rowIndex, statName, TextStyle.SUMMARY); + statLabel.setOrigin(0.5, 0); + statsContainer.add(statLabel); + + const statValueText = stat !== Stat.HP + ? this.pokemon.stats[s].toString() + : `${this.pokemon.hp}/${this.pokemon.getMaxHp()}`; + + const statValue = addTextObject(this.scene, 120 + 88 * colIndex, 56 + 16 * rowIndex, statValueText, TextStyle.WINDOW); + statValue.setOrigin(1, 0); + statsContainer.add(statValue); + }); + + const totalLvExp = getLevelTotalExp(this.pokemon.level, this.pokemon.species.growthRate); + const expRatio = this.pokemon.level < 100 ? this.pokemon.levelExp / totalLvExp : 0; + + const expLabel = addTextObject(this.scene, 6, 112, 'EXP. POINTS', TextStyle.SUMMARY); + expLabel.setOrigin(0, 0); + statsContainer.add(expLabel); + + const nextLvExpLabel = addTextObject(this.scene, 6, 128, 'NEXT LV.', TextStyle.SUMMARY); + nextLvExpLabel.setOrigin(0, 0); + statsContainer.add(nextLvExpLabel); + + const expText = addTextObject(this.scene, 208, 112, this.pokemon.exp.toString(), TextStyle.WINDOW); + expText.setOrigin(1, 0); + statsContainer.add(expText); + + const nextLvExpText = addTextObject(this.scene, 208, 128, (totalLvExp - this.pokemon.levelExp).toString(), TextStyle.WINDOW); + nextLvExpText.setOrigin(1, 0); + statsContainer.add(nextLvExpText); + + const expOverlay = this.scene.add.image(140, 145, 'summary_stats_overlay_exp'); + expOverlay.setOrigin(0, 0); + statsContainer.add(expOverlay); + + const expMaskRect = this.scene.make.graphics({}); + expMaskRect.setScale(6); + expMaskRect.fillStyle(0xFFFFFF); + expMaskRect.beginPath(); + expMaskRect.fillRect(140 + pageContainer.x, 145 + pageContainer.y + 21, Math.floor(expRatio * 64), 3); + + const expMask = expMaskRect.createGeometryMask(); + + expOverlay.setMask(expMask); + break; case Page.MOVES: this.movesContainer = this.scene.add.container(5, -pageBg.height + 26); pageContainer.add(this.movesContainer); @@ -462,13 +527,13 @@ export default class SummaryUiHandler extends UiHandler { this.moveDescriptionText = addTextObject(this.scene, 2, 84, '', TextStyle.WINDOW, { wordWrap: { width: 1212 } }); this.movesContainer.add(this.moveDescriptionText); - const maskRect = this.scene.make.graphics({}); - maskRect.setScale(6); - maskRect.fillStyle(0xFFFFFF); - maskRect.beginPath(); - maskRect.fillRect(112, 130, 202, 46); + const moveDescriptionTextMaskRect = this.scene.make.graphics({}); + moveDescriptionTextMaskRect.setScale(6); + moveDescriptionTextMaskRect.fillStyle(0xFFFFFF); + moveDescriptionTextMaskRect.beginPath(); + moveDescriptionTextMaskRect.fillRect(112, 130, 202, 46); - const moveDescriptionTextMask = maskRect.createGeometryMask(); + const moveDescriptionTextMask = moveDescriptionTextMaskRect.createGeometryMask(); this.moveDescriptionText.setMask(moveDescriptionTextMask); break;