Add WiP move attributes system
This commit is contained in:
parent
1cf81869d0
commit
c9c4e82f7f
|
@ -1338,9 +1338,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/i18next": {
|
||||
"version": "22.4.13",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.13.tgz",
|
||||
"integrity": "sha512-GX7flMHRRqQA0I1yGLmaZ4Hwt1JfLqagk8QPDPZsqekbKtXsuIngSVWM/s3SLgNkrEXjA+0sMGNuOEkkmyqmWg==",
|
||||
"version": "22.4.14",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.14.tgz",
|
||||
"integrity": "sha512-VtLPtbdwGn0+DAeE00YkiKKXadkwg+rBUV+0v8v0ikEjwdiJ0gmYChVE4GIa9HXymY6wKapkL93vGT7xpq6aTw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
|
|
|
@ -342,7 +342,7 @@ export function loadMoveAnimAssets(scene: BattleScene, moveIds: Moves[], startLo
|
|||
scene.loadImage(bg, 'battle_anims');
|
||||
for (let s of sounds)
|
||||
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())
|
||||
scene.load.start();
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import PartyUiHandler from "./ui/party-ui-handler";
|
|||
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor as getPokeballTintColor, PokeballType } from "./pokeball";
|
||||
import { pokemonLevelMoves } from "./pokemon-level-moves";
|
||||
import { MoveAnim, loadMoveAnimAssets } from "./battle-anims";
|
||||
import { StatusEffect } from "./status-effect";
|
||||
|
||||
export class BattlePhase {
|
||||
protected scene: BattleScene;
|
||||
|
@ -246,6 +247,7 @@ export class SummonPhase extends BattlePhase {
|
|||
onComplete: () => {
|
||||
playerPokemon.cry();
|
||||
playerPokemon.getSprite().clearTint();
|
||||
playerPokemon.resetSummonData();
|
||||
this.scene.time.delayedCall(1000, () => this.end());
|
||||
}
|
||||
});
|
||||
|
@ -337,6 +339,9 @@ export class CommandPhase extends BattlePhase {
|
|||
|
||||
this.scene.ui.setMode(Mode.COMMAND);
|
||||
this.scene.currentBattle.addParticipant(this.scene.getPlayerPokemon());
|
||||
|
||||
this.scene.getPlayerPokemon().resetTurnData();
|
||||
this.scene.getEnemyPokemon().resetTurnData();
|
||||
}
|
||||
|
||||
handleCommand(command: Command, cursor: integer): boolean{
|
||||
|
@ -441,6 +446,7 @@ abstract class MovePhase extends BattlePhase {
|
|||
console.log(this.pokemon.moveset);
|
||||
this.scene.ui.showText(`${this.pokemon.name} used\n${this.move.getName()}!`, null, () => {
|
||||
this.move.ppUsed++;
|
||||
|
||||
if (this.move.getMove().category !== MoveCategory.STATUS) {
|
||||
if (this.hitCheck())
|
||||
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, () =>{
|
||||
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.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 {
|
||||
private text: string;
|
||||
private prompt: boolean;
|
||||
|
|
1224
src/move.ts
1224
src/move.ts
File diff suppressed because it is too large
Load Diff
|
@ -13,6 +13,7 @@ import { PokemonBaseStatModifier as PokemonBaseStatBoosterModifier, ShinyRateBoo
|
|||
import { PokeballType } from './pokeball';
|
||||
import { Gender } from './gender';
|
||||
import { Anim, initAnim, loadMoveAnimAssets, moveAnims } from './battle-anims';
|
||||
import { StatusEffect } from './status-effect';
|
||||
|
||||
export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
public id: integer;
|
||||
|
@ -29,8 +30,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
public stats: integer[];
|
||||
public ivs: integer[];
|
||||
public moveset: PokemonMove[];
|
||||
public status: StatusEffect;
|
||||
public winCount: integer;
|
||||
|
||||
public summonData: PokemonSummonData;
|
||||
public battleSummonData: PokemonBattleSummonData;
|
||||
public turnData: PokemonTurnData;
|
||||
|
||||
private shinySparkle: Phaser.GameObjects.Sprite;
|
||||
|
||||
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.ivs = dataSource.ivs;
|
||||
this.moveset = dataSource.moveset;
|
||||
this.status = dataSource.status;
|
||||
this.winCount = dataSource.winCount;
|
||||
} else {
|
||||
this.generateAndPopulateMoveset();
|
||||
|
@ -96,6 +103,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
/*else
|
||||
this.shiny = Utils.randInt(16) === 0;*/
|
||||
|
||||
this.status = StatusEffect.NONE;
|
||||
|
||||
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 {
|
||||
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 {
|
||||
RANDOM,
|
||||
SMART_RANDOM,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -92,13 +92,22 @@ export default class FightUiHandler extends UiHandler {
|
|||
ui.add(this.cursorObj);
|
||||
}
|
||||
|
||||
const pokemonMove = (this.scene as BattleScene).getPlayerPokemon().moveset[cursor];
|
||||
this.typeIcon.setTexture('types', Type[pokemonMove.getMove().type].toLowerCase());
|
||||
const moveset = (this.scene as BattleScene).getPlayerPokemon().moveset;
|
||||
|
||||
const maxPP = pokemonMove.getMove().pp + pokemonMove.ppUp;
|
||||
const pp = maxPP - pokemonMove.ppUsed;
|
||||
const hasMove = cursor < moveset.length;
|
||||
|
||||
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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue