Add WiP move attributes system

pull/1/head
Flashfyre 2023-04-03 23:38:31 -04:00
parent 1cf81869d0
commit c9c4e82f7f
7 changed files with 760 additions and 576 deletions

6
package-lock.json generated
View File

@ -1338,9 +1338,9 @@
} }
}, },
"node_modules/i18next": { "node_modules/i18next": {
"version": "22.4.13", "version": "22.4.14",
"resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.13.tgz", "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.14.tgz",
"integrity": "sha512-GX7flMHRRqQA0I1yGLmaZ4Hwt1JfLqagk8QPDPZsqekbKtXsuIngSVWM/s3SLgNkrEXjA+0sMGNuOEkkmyqmWg==", "integrity": "sha512-VtLPtbdwGn0+DAeE00YkiKKXadkwg+rBUV+0v8v0ikEjwdiJ0gmYChVE4GIa9HXymY6wKapkL93vGT7xpq6aTw==",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",

View File

@ -342,7 +342,7 @@ export function loadMoveAnimAssets(scene: BattleScene, moveIds: Moves[], startLo
scene.loadImage(bg, 'battle_anims'); scene.loadImage(bg, 'battle_anims');
for (let s of sounds) for (let s of sounds)
scene.loadSe(s, 'battle_anims', s); scene.loadSe(s, 'battle_anims', s);
this.scene.load.once(Phaser.Loader.Events.COMPLETE, () => resolve()); scene.load.once(Phaser.Loader.Events.COMPLETE, () => resolve());
if (startLoad && !scene.load.isLoading()) if (startLoad && !scene.load.isLoading())
scene.load.start(); scene.load.start();
}); });

View File

@ -10,6 +10,7 @@ import PartyUiHandler from "./ui/party-ui-handler";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor as getPokeballTintColor, PokeballType } from "./pokeball"; import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor as getPokeballTintColor, PokeballType } from "./pokeball";
import { pokemonLevelMoves } from "./pokemon-level-moves"; import { pokemonLevelMoves } from "./pokemon-level-moves";
import { MoveAnim, loadMoveAnimAssets } from "./battle-anims"; import { MoveAnim, loadMoveAnimAssets } from "./battle-anims";
import { StatusEffect } from "./status-effect";
export class BattlePhase { export class BattlePhase {
protected scene: BattleScene; protected scene: BattleScene;
@ -246,6 +247,7 @@ export class SummonPhase extends BattlePhase {
onComplete: () => { onComplete: () => {
playerPokemon.cry(); playerPokemon.cry();
playerPokemon.getSprite().clearTint(); playerPokemon.getSprite().clearTint();
playerPokemon.resetSummonData();
this.scene.time.delayedCall(1000, () => this.end()); this.scene.time.delayedCall(1000, () => this.end());
} }
}); });
@ -337,6 +339,9 @@ export class CommandPhase extends BattlePhase {
this.scene.ui.setMode(Mode.COMMAND); this.scene.ui.setMode(Mode.COMMAND);
this.scene.currentBattle.addParticipant(this.scene.getPlayerPokemon()); this.scene.currentBattle.addParticipant(this.scene.getPlayerPokemon());
this.scene.getPlayerPokemon().resetTurnData();
this.scene.getEnemyPokemon().resetTurnData();
} }
handleCommand(command: Command, cursor: integer): boolean{ handleCommand(command: Command, cursor: integer): boolean{
@ -441,6 +446,7 @@ abstract class MovePhase extends BattlePhase {
console.log(this.pokemon.moveset); console.log(this.pokemon.moveset);
this.scene.ui.showText(`${this.pokemon.name} used\n${this.move.getName()}!`, null, () => { this.scene.ui.showText(`${this.pokemon.name} used\n${this.move.getName()}!`, null, () => {
this.move.ppUsed++; this.move.ppUsed++;
if (this.move.getMove().category !== MoveCategory.STATUS) { if (this.move.getMove().category !== MoveCategory.STATUS) {
if (this.hitCheck()) if (this.hitCheck())
this.scene.unshiftPhase(this.getEffectPhase()); this.scene.unshiftPhase(this.getEffectPhase());
@ -507,8 +513,14 @@ abstract class MoveEffectPhase extends PokemonPhase {
new MoveAnim(this.move.getMove().id as Moves, user, target).play(this.scene, () =>{ new MoveAnim(this.move.getMove().id as Moves, user, target).play(this.scene, () =>{
this.getTargetPokemon().apply(this.getUserPokemon(), this.move, () => this.end()); this.getTargetPokemon().apply(this.getUserPokemon(), this.move, () => this.end());
if (this.getTargetPokemon().hp <= 0) if (this.getUserPokemon().hp <= 0) {
this.scene.pushPhase(new FaintPhase(this.scene, this.player));
this.getTargetPokemon().resetBattleSummonData();
}
if (this.getTargetPokemon().hp <= 0) {
this.scene.pushPhase(new FaintPhase(this.scene, !this.player)); this.scene.pushPhase(new FaintPhase(this.scene, !this.player));
this.getUserPokemon().resetBattleSummonData();
}
}); });
} }
@ -549,6 +561,24 @@ export class EnemyMoveEffectPhase extends MoveEffectPhase {
} }
} }
export class ObtainStatusEffectPhase extends PokemonPhase {
private statusEffect: StatusEffect;
constructor(scene: BattleScene, player: boolean, statusEffect: StatusEffect) {
super(scene, player);
}
start() {
const pokemon = this.getPokemon();
if (pokemon.status === StatusEffect.NONE) {
pokemon.status = this.statusEffect;
// Show message and animation
this.end();
} else
this.end();
}
}
export class MessagePhase extends BattlePhase { export class MessagePhase extends BattlePhase {
private text: string; private text: string;
private prompt: boolean; private prompt: boolean;

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ import { PokemonBaseStatModifier as PokemonBaseStatBoosterModifier, ShinyRateBoo
import { PokeballType } from './pokeball'; import { PokeballType } from './pokeball';
import { Gender } from './gender'; import { Gender } from './gender';
import { Anim, initAnim, loadMoveAnimAssets, moveAnims } from './battle-anims'; import { Anim, initAnim, loadMoveAnimAssets, moveAnims } from './battle-anims';
import { StatusEffect } from './status-effect';
export default abstract class Pokemon extends Phaser.GameObjects.Container { export default abstract class Pokemon extends Phaser.GameObjects.Container {
public id: integer; public id: integer;
@ -29,8 +30,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
public stats: integer[]; public stats: integer[];
public ivs: integer[]; public ivs: integer[];
public moveset: PokemonMove[]; public moveset: PokemonMove[];
public status: StatusEffect;
public winCount: integer; public winCount: integer;
public summonData: PokemonSummonData;
public battleSummonData: PokemonBattleSummonData;
public turnData: PokemonTurnData;
private shinySparkle: Phaser.GameObjects.Sprite; private shinySparkle: Phaser.GameObjects.Sprite;
constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, dataSource?: Pokemon) { constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, dataSource?: Pokemon) {
@ -52,6 +58,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.stats = dataSource.stats; this.stats = dataSource.stats;
this.ivs = dataSource.ivs; this.ivs = dataSource.ivs;
this.moveset = dataSource.moveset; this.moveset = dataSource.moveset;
this.status = dataSource.status;
this.winCount = dataSource.winCount; this.winCount = dataSource.winCount;
} else { } else {
this.generateAndPopulateMoveset(); this.generateAndPopulateMoveset();
@ -96,6 +103,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
/*else /*else
this.shiny = Utils.randInt(16) === 0;*/ this.shiny = Utils.randInt(16) === 0;*/
this.status = StatusEffect.NONE;
this.winCount = 0; this.winCount = 0;
} }
@ -476,6 +485,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}); });
} }
resetSummonData() {
this.summonData = new PokemonSummonData();
this.resetBattleSummonData();
}
resetBattleSummonData() {
this.battleSummonData = new PokemonBattleSummonData();
}
resetTurnData() {
this.turnData = new PokemonTurnData();
}
getExpValue(victor: Pokemon): integer { getExpValue(victor: Pokemon): integer {
return ((this.species.baseExp * this.level) / 5) * ((Math.round(Math.sqrt(2 * this.level + 10)) * Math.pow(2 * this.level + 10, 2)) / (Math.round(Math.sqrt(this.level + victor.level + 10)) * Math.pow(this.level + victor.level + 10, 2))) + 1; return ((this.species.baseExp * this.level) / 5) * ((Math.round(Math.sqrt(2 * this.level + 10)) * Math.pow(2 * this.level + 10, 2)) / (Math.round(Math.sqrt(this.level + victor.level + 10)) * Math.pow(this.level + victor.level + 10, 2))) + 1;
} }
@ -639,6 +661,19 @@ export class EnemyPokemon extends Pokemon {
} }
} }
export class PokemonSummonData {
public confusionTurns: integer;
}
export class PokemonBattleSummonData {
public infatuated: boolean;
}
export class PokemonTurnData {
public flinched: boolean;
public hitsLeft: integer;
}
export enum AiType { export enum AiType {
RANDOM, RANDOM,
SMART_RANDOM, SMART_RANDOM,

18
src/status-effect.ts Normal file
View File

@ -0,0 +1,18 @@
export enum StatusEffect {
NONE,
POISON,
TOXIC,
PARALYSIS,
SLEEP,
FREEZE,
BURN
}
export class Status {
public statusType: StatusEffect;
public turnCount: integer;
constructor(statusType: StatusEffect) {
this.statusType = statusType;
}
}

View File

@ -92,13 +92,22 @@ export default class FightUiHandler extends UiHandler {
ui.add(this.cursorObj); ui.add(this.cursorObj);
} }
const pokemonMove = (this.scene as BattleScene).getPlayerPokemon().moveset[cursor]; const moveset = (this.scene as BattleScene).getPlayerPokemon().moveset;
this.typeIcon.setTexture('types', Type[pokemonMove.getMove().type].toLowerCase());
const maxPP = pokemonMove.getMove().pp + pokemonMove.ppUp; const hasMove = cursor < moveset.length;
const pp = maxPP - pokemonMove.ppUsed;
this.ppText.setText(`${Utils.padInt(pp, 2, ' ')}/${Utils.padInt(maxPP, 2, ' ')}`); if (hasMove) {
const pokemonMove = moveset[cursor];
this.typeIcon.setTexture('types', Type[pokemonMove.getMove().type].toLowerCase());
const maxPP = pokemonMove.getMove().pp + pokemonMove.ppUp;
const pp = maxPP - pokemonMove.ppUsed;
this.ppText.setText(`${Utils.padInt(pp, 2, ' ')}/${Utils.padInt(maxPP, 2, ' ')}`);
}
this.typeIcon.setVisible(hasMove);
this.ppText.setVisible(hasMove);
this.cursorObj.setPosition(13 + (cursor % 2 === 1 ? 100 : 0), -31 + (cursor >= 2 ? 15 : 0)); this.cursorObj.setPosition(13 + (cursor % 2 === 1 ? 100 : 0), -31 + (cursor >= 2 ? 15 : 0));