diff --git a/README.md b/README.md index bcca64fb7..0cc9c752c 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ - Battle info - Owned icon - Status effect indicator - - Gender icon - Evolution - Evolution screen - Background (ripped video?) - Particles - Modifiers - PP Up + - Ether/elixir - Type enhancers - Evolution items - Various mainline game items for various enhancements diff --git a/public/images/ui/boolean0.png b/public/images/ui/boolean0.png deleted file mode 100644 index d3d368697..000000000 Binary files a/public/images/ui/boolean0.png and /dev/null differ diff --git a/public/images/ui/pbinfo_gender_f.png b/public/images/ui/pbinfo_gender_f.png deleted file mode 100644 index 8ec68a3e7..000000000 Binary files a/public/images/ui/pbinfo_gender_f.png and /dev/null differ diff --git a/public/images/ui/pbinfo_gender_m.png b/public/images/ui/pbinfo_gender_m.png deleted file mode 100644 index ae34b03fe..000000000 Binary files a/public/images/ui/pbinfo_gender_m.png and /dev/null differ diff --git a/src/battle-info.ts b/src/battle-info.ts index 9f56bde11..3014092e8 100644 --- a/src/battle-info.ts +++ b/src/battle-info.ts @@ -1,6 +1,8 @@ import { default as Pokemon } from './pokemon'; import { getLevelTotalExp, getLevelRelExp } from './exp'; import * as Utils from './utils'; +import { addTextObject, TextStyle } from './text'; +import { getGenderSymbol, getGenderColor } from './gender'; export default class BattleInfo extends Phaser.GameObjects.Container { private player: boolean; @@ -13,6 +15,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { private lastName: string; private nameText: Phaser.GameObjects.Text; + private genderText: Phaser.GameObjects.Text; private levelContainer: Phaser.GameObjects.Container; private hpBar: Phaser.GameObjects.Image; private levelNumbersContainer: Phaser.GameObjects.Container; @@ -37,41 +40,31 @@ export default class BattleInfo extends Phaser.GameObjects.Container { box.setOrigin(1, 0.5); this.add(box); - const nameText = this.scene.add.text(player ? -115 : -124, player ? -15.2 : -11.2, '', { - color: '#404040', - font: '72px emerald' - }); - nameText.setShadow(4, 4, '#ded6b5'); - nameText.setOrigin(0, 0); - nameText.setScale(0.1666666667); - this.add(nameText); + this.nameText = addTextObject(this.scene, player ? -115 : -124, player ? -15.2 : -11.2, '', TextStyle.BATTLE_INFO); + this.nameText.setOrigin(0, 0); + this.add(this.nameText); - this.nameText = nameText; + this.genderText = addTextObject(this.scene, 0, 0, '', TextStyle.BATTLE_INFO); + this.genderText.setOrigin(0, 0); + this.genderText.setPositionRelative(this.nameText, 0, 2); + this.add(this.genderText); - const levelContainer = this.scene.add.container(player ? -41 : -50, player ? -10 : -5); - this.add(levelContainer); - - this.levelContainer = levelContainer; + this.levelContainer = this.scene.add.container(player ? -41 : -50, player ? -10 : -5); + this.add(this.levelContainer); const levelOverlay = this.scene.add.image(0, 0, 'overlay_lv'); - levelContainer.add(levelOverlay); + this.levelContainer.add(levelOverlay); - const hpBar = this.scene.add.image(player ? -61 : -71, player ? -1 : 4.5, 'overlay_hp'); - hpBar.setOrigin(0); - this.add(hpBar); + this.hpBar = this.scene.add.image(player ? -61 : -71, player ? -1 : 4.5, 'overlay_hp'); + this.hpBar.setOrigin(0); + this.add(this.hpBar); - this.hpBar = hpBar; - - const levelNumbersContainer = this.scene.add.container(9.5, 0); - levelContainer.add(levelNumbersContainer); - - this.levelNumbersContainer = levelNumbersContainer; + this.levelNumbersContainer = this.scene.add.container(9.5, 0); + this.levelContainer.add(this.levelNumbersContainer); if (this.player) { - const hpNumbersContainer = this.scene.add.container(-15, 10); - this.add(hpNumbersContainer); - - this.hpNumbersContainer = hpNumbersContainer; + this.hpNumbersContainer = this.scene.add.container(-15, 10); + this.add(this.hpNumbersContainer); const expBar = this.scene.add.image(-98, 18, 'overlay_exp'); expBar.setOrigin(0); @@ -84,7 +77,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container { initInfo(pokemon: Pokemon) { this.nameText.setText(pokemon.name); - this.lastName = pokemon.species.name; + + const nameSizeTest = addTextObject(this.scene, 0, 0, pokemon.name, TextStyle.BATTLE_INFO); + const nameTextWidth = nameSizeTest.displayWidth; + nameSizeTest.destroy(); + + this.genderText.setText(getGenderSymbol(pokemon.gender)); + this.genderText.setColor(getGenderColor(pokemon.gender)); + this.genderText.setPositionRelative(this.nameText, nameTextWidth, 0); this.hpBar.setScale(pokemon.getHpRatio(), 1); if (this.player) @@ -107,11 +107,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (!this.scene) return; - if (this.lastName !== pokemon.species.name) { - this.nameText.setText(pokemon.name); - this.lastName = pokemon.species.name; - } - const updatePokemonHp = () => { const duration = Utils.clampInt(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000); this.scene.tweens.add({ diff --git a/src/battle-phase.ts b/src/battle-phase.ts index 31670d409..1a5154609 100644 --- a/src/battle-phase.ts +++ b/src/battle-phase.ts @@ -247,10 +247,7 @@ export class SummonPhase extends BattlePhase { onComplete: () => { playerPokemon.cry(); playerPokemon.getSprite().clearTint(); - this.scene.time.delayedCall(1000, () => { - this.scene.currentBattle.addParticipant(playerPokemon); - this.end(); - }); + this.scene.time.delayedCall(1000, () => this.end()); } }); } @@ -326,13 +323,7 @@ export class CheckSwitchPhase extends BattlePhase { super.start(); this.scene.ui.showText('Will you switch\nPOKéMON?', null, () => { - this.scene.ui.setMode(Mode.SWITCH_CHECK, () => { - console.log('handler', this.scene.ui.getHandler()); - console.log(this.scene.ui.getHandler().getCursor()) - if (this.scene.ui.getHandler().getCursor()) - this.scene.currentBattle.addParticipant(this.scene.getPlayerPokemon()); - this.end(); - }); + this.scene.ui.setMode(Mode.SWITCH_CHECK, () => this.end()); }); } } @@ -348,6 +339,8 @@ export class CommandPhase extends BattlePhase { //interp(this.scene); this.scene.ui.setMode(Mode.COMMAND); + console.log('add participant', this.scene.getPlayerPokemon().name) + this.scene.currentBattle.addParticipant(this.scene.getPlayerPokemon()); } handleCommand(command: Command, cursor: integer): boolean{ diff --git a/src/battle-scene.ts b/src/battle-scene.ts index f0efa7566..b23de5767 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -103,6 +103,7 @@ export default class BattleScene extends Phaser.Scene { this.loadImage('pbinfo_enemy', 'ui'); this.loadImage('overlay_lv', 'ui'); this.loadAtlas('numbers', 'ui'); + this.loadAtlas('gender', 'ui'); this.loadAtlas('overlay_hp', 'ui'); this.loadImage('overlay_exp', 'ui'); this.loadImage('level_up_stats', 'ui'); diff --git a/src/gender.ts b/src/gender.ts new file mode 100644 index 000000000..4d5ba00a9 --- /dev/null +++ b/src/gender.ts @@ -0,0 +1,25 @@ +export enum Gender { + GENDERLESS = -1, + FEMALE, + MALE +} + +export function getGenderSymbol(gender: Gender) { + switch (gender) { + case Gender.MALE: + return '♂'; + case Gender.FEMALE: + return '♀'; + } + return ''; +} + +export function getGenderColor(gender: Gender) { + switch (gender) { + case Gender.MALE: + return '#40c8f8'; + case Gender.FEMALE: + return '#f89890'; + } + return '#ffffff'; +} \ No newline at end of file diff --git a/src/pokemon-species.ts b/src/pokemon-species.ts index 141d059f1..35f62b9d2 100644 --- a/src/pokemon-species.ts +++ b/src/pokemon-species.ts @@ -18,8 +18,8 @@ export default class PokemonSpecies { public legendary: boolean; public mythical: boolean; public species: string; - public type1: integer; - public type2: integer; + public type1: Type; + public type2: Type; public height: number; public weight: number; public ability1: string; diff --git a/src/pokemon-stat.ts b/src/pokemon-stat.ts index c0023b91d..8f74fb444 100644 --- a/src/pokemon-stat.ts +++ b/src/pokemon-stat.ts @@ -10,7 +10,7 @@ export enum Stat { }; export function getStatName(stat: Stat) { - let ret; + let ret: string; switch (stat) { case Stat.HP: ret = 'Max. HP'; diff --git a/src/pokemon.ts b/src/pokemon.ts index 84735f822..f949a1cc8 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -9,8 +9,9 @@ import * as Utils from './utils'; import { getTypeDamageMultiplier } from './type'; import { getLevelTotalExp } from './exp'; import { Stat } from './pokemon-stat'; -import { ExpShareModifier, PokemonBaseStatModifier as PokemonBaseStatBoosterModifier, ShinyRateBoosterModifier } from './modifier'; +import { PokemonBaseStatModifier as PokemonBaseStatBoosterModifier, ShinyRateBoosterModifier } from './modifier'; import { PokeballType } from './pokeball'; +import { Gender } from './gender'; export default abstract class Pokemon extends Phaser.GameObjects.Container { public id: integer; @@ -22,7 +23,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public level: integer; public exp: integer; public levelExp: integer; - public gender: integer; + public gender: Gender; public hp: integer; public stats: integer[]; public ivs: integer[]; @@ -67,13 +68,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { //this.id = parseInt(Utils.decToBin(this.ivs[Stat.HP]) + Utils.decToBin(this.ivs[Stat.ATK]) + Utils.decToBin(this.ivs[Stat.DEF]) + Utils.decToBin(this.ivs[Stat.SPATK]) + Utils.decToBin(this.ivs[Stat.SPDEF]) + Utils.decToBin(this.ivs[Stat.SPD]) + this.id.toString(2).slice(30)); if (this.species.malePercent === null) - this.gender = -1; + this.gender = Gender.GENDERLESS; else { - const genderChance = (this.id % 256) / 32; + const genderChance = (this.id % 256) * 0.390625; if (genderChance < this.species.malePercent) - this.gender = 0; + this.gender = Gender.MALE; else - this.gender = 1; + this.gender = Gender.FEMALE; } const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16)); diff --git a/src/text.ts b/src/text.ts index 2d8620c5b..b6f422f5d 100644 --- a/src/text.ts +++ b/src/text.ts @@ -1,12 +1,14 @@ export enum TextStyle { MESSAGE, WINDOW, + BATTLE_INFO, PARTY }; export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) { let styleOptions; let shadowColor; + let shadowSize = 6; switch (style) { case TextStyle.WINDOW: @@ -31,6 +33,15 @@ export function addTextObject(scene: Phaser.Scene, x: number, y: number, content }; shadowColor = '#6b5a73'; break; + case TextStyle.BATTLE_INFO: + styleOptions = { + fontFamily: 'emerald', + fontSize: '72px', + color: '#404040' + }; + shadowColor = '#ded6b5'; + shadowSize = 4; + break; case TextStyle.PARTY: styleOptions = { fontFamily: 'pkmnems', @@ -49,7 +60,7 @@ export function addTextObject(scene: Phaser.Scene, x: number, y: number, content const ret = scene.add.text(x, y, content, styleOptions); ret.setScale(0.1666666667); - ret.setShadow(6, 6, shadowColor); + ret.setShadow(shadowSize, shadowSize, shadowColor); ret.setLineSpacing(5); return ret; diff --git a/src/ui/switch-check-ui-handler.ts b/src/ui/switch-check-ui-handler.ts index 7bee69728..335fb23a5 100644 --- a/src/ui/switch-check-ui-handler.ts +++ b/src/ui/switch-check-ui-handler.ts @@ -61,7 +61,7 @@ export default class SwitchCheckUiHandler extends AwaitableUiHandler { if (keyCode === keyCodes.Z || keyCode === keyCodes.X) { success = true; if (keyCode === keyCodes.X) - this.cursor = 1; + this.setCursor(1); if (this.onActionInput) { if (!this.cursor) this.scene.unshiftPhase(new SwitchPhase(this.scene, false, true)); @@ -88,7 +88,6 @@ export default class SwitchCheckUiHandler extends AwaitableUiHandler { } setCursor(cursor: integer): boolean { - const ui = this.getUi(); const ret = super.setCursor(cursor); if (!this.cursorObj) {