Refactor source files and add berries

This commit is contained in:
Flashfyre committed 2023-04-20 15:46:05 -04:00
1 parent 6135243641
commit 3546f3b5a7
103 files changed
+2598 -1171

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-1
View File
@@ -1,5 +1,4 @@
{
"id": 1001,
"graphic": "",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2008,
"graphic": "PRAS- Status",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2017,
"graphic": "PRAS- Bide",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2009,
"graphic": "PRAS- Wrapping",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2006,
"graphic": "PRAS- Status",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2023,
"graphic": "PRAS- Shell Smash",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2007,
"graphic": "PRAS- Status",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2015,
"graphic": "PRAS- Covet",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2011,
"graphic": "PRAS- CURSE2",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2021,
"graphic": "PRAS- Curse",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2111,
"graphic": "PRAS- Electric",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2013,
"graphic": "PRAS- Fire Spin",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2005,
"graphic": "PRAS- Status",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2112,
"graphic": "PRAS- Grass",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2103,
"graphic": "PRAS- Weather",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2106,
"graphic": "weather",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2000,
"graphic": "PRAS- Recovery",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2105,
"graphic": "PRAS- Weather",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2012,
"graphic": "PRAS- Absorption2",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2022,
"graphic": "PRAS- Magma Storm",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2110,
"graphic": "PRAS- Orbs",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2003,
"graphic": "PRAS- Status",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2001,
"graphic": "PRAS- Status",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2014,
"graphic": "PRAS- Protect",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2113,
"graphic": "PRAS- Mirror Coat",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2019,
"graphic": "PRAS- Lucky Chant",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2101,
"graphic": "PRAS- Weather",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2018,
"graphic": "PRAS- Sand Tomb",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2102,
"graphic": "weather",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2004,
"graphic": "PRAS- Status",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2107,
"graphic": "PRAS- Gust",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2100,
"graphic": "weather",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2002,
"graphic": "PRAS- Poison",
"frames": [
[
File diff suppressed because it is too large. Load diff
@@ -1,5 +1,4 @@
{
"id": 2016,
"graphic": "PRAS- Whirlpool",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 2020,
"graphic": "PRAS- Lucky Chant",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2104,
"graphic": "weather",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 2010,
"graphic": "PRAS- Wrapping",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 1002,
"graphic": "PRAS- Dig",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 1003,
"graphic": "PRAS- Dive",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1011,
"graphic": "PRAS- Wish",
"frames": [
[
-1
View File
@@ -1,5 +1,4 @@
{
"id": 1000,
"graphic": "PRAS- Fly",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1007,
"graphic": "PRAS- Freeze Shock",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1010,
"graphic": "PRAS- Ice Burn",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1012,
"graphic": "PRAS- Gust",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1005,
"graphic": "",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1006,
"graphic": "",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1009,
"graphic": "",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1008,
"graphic": "",
"frames": [
[
@@ -1,5 +1,4 @@
{
"id": 1004,
"graphic": "PRAS- Orbs",
"frames": [
[
+935 -872
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

+7 -7
View File
@@ -1,14 +1,14 @@
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import BattleScene from "./battle-scene";
import { Biome, BiomePoolTier, BiomeTierPools, biomePools } from "./biome";
import { Biome, BiomePoolTier, BiomeTierPools, biomePools } from "./data/biome";
import * as Utils from "./utils";
import PokemonSpecies, { getPokemonSpecies } from "./pokemon-species";
import { Species } from "./species";
import { Weather, WeatherType, getWeatherClearMessage, getWeatherStartMessage } from "./weather";
import PokemonSpecies, { getPokemonSpecies } from "./data/pokemon-species";
import { Species } from "./data/species";
import { Weather, WeatherType, getWeatherClearMessage, getWeatherStartMessage } from "./data/weather";
import { CommonAnimPhase, MessagePhase } from "./battle-phases";
import { CommonAnim } from "./battle-anims";
import { Type } from "./type";
import Move from "./move";
import { CommonAnim } from "./data/battle-anims";
import { Type } from "./data/type";
import Move from "./data/move";
export class Arena {
private scene: BattleScene;
+49 -15
View File
@@ -1,28 +1,29 @@
import BattleScene, { startingLevel, startingWave } from "./battle-scene";
import { default as Pokemon, PlayerPokemon, EnemyPokemon, PokemonMove, MoveResult, DamageResult } from "./pokemon";
import * as Utils from './utils';
import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, ConditionalMoveAttr, HitsTagAttr, MissEffectAttr, MoveCategory, MoveEffectAttr, MoveFlags, MoveHitEffectAttr, Moves, MultiHitAttr, OverrideMoveEffectAttr, VariableAccuracyAttr } from "./move";
import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, ConditionalMoveAttr, HitsTagAttr, MissEffectAttr, MoveCategory, MoveEffectAttr, MoveFlags, MoveHitEffectAttr, Moves, MultiHitAttr, OverrideMoveEffectAttr, VariableAccuracyAttr } from "./data/move";
import { Mode } from './ui/ui';
import { Command } from "./ui/command-ui-handler";
import { Stat } from "./pokemon-stat";
import { ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HitHealModifier, PokemonExpBoosterModifier, TempBattleStatBoosterModifier } from "./modifier";
import { Stat } from "./data/pokemon-stat";
import { BerryModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HealingBoosterModifier, HitHealModifier, PokemonExpBoosterModifier, TempBattleStatBoosterModifier } from "./modifier/modifier";
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./pokeball";
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims";
import { StatusEffect, getStatusEffectActivationText, getStatusEffectCatchRateMultiplier, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "./status-effect";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./data/pokeball";
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims";
import { StatusEffect, getStatusEffectActivationText, getStatusEffectCatchRateMultiplier, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "./data/status-effect";
import { SummaryUiMode } from "./ui/summary-ui-handler";
import EvolutionSceneHandler from "./ui/evolution-scene-handler";
import { EvolutionPhase } from "./evolution-phase";
import { BattlePhase } from "./battle-phase";
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "./battle-stat";
import { Biome, biomeLinks } from "./biome";
import { ModifierTypeOption, PokemonModifierType, PokemonMoveModifierType, TempBattleStat, getModifierTypeOptionsForWave, regenerateModifierPoolThresholds } from "./modifier-type";
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "./data/battle-stat";
import { Biome, biomeLinks } from "./data/biome";
import { ModifierTypeOption, PokemonModifierType, PokemonMoveModifierType, getModifierTypeOptionsForWave, regenerateModifierPoolThresholds } from "./modifier/modifier-type";
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { BattleTagLapseType, BattleTagType, HideSpriteTag as HiddenTag } from "./battle-tag";
import { BattleTagLapseType, BattleTagType, HideSpriteTag as HiddenTag } from "./data/battle-tag";
import { getPokemonMessage } from "./messages";
import { Starter } from "./ui/starter-select-ui-handler";
import { Gender } from "./gender";
import { Weather, WeatherType, getRandomWeatherType, getWeatherDamageMessage, getWeatherLapseMessage } from "./weather";
import { Gender } from "./data/gender";
import { Weather, WeatherType, getRandomWeatherType, getWeatherDamageMessage, getWeatherLapseMessage } from "./data/weather";
import { TempBattleStat } from "./data/temp-battle-stat";
export class SelectStarterPhase extends BattlePhase {
constructor(scene: BattleScene) {
@@ -593,6 +594,10 @@ export class TurnEndPhase extends BattlePhase {
this.scene.pushPhase(new MessagePhase(this.scene, `${dm.getName()} is disabled\nno more!`));
}
const hasUsableBerry = pokemon.isPlayer() && !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ pokemon ]));
if (hasUsableBerry)
this.scene.pushPhase(new BerryPhase(this.scene, pokemon.isPlayer()));
pokemon.battleSummonData.turnCount++;
};
@@ -670,7 +675,7 @@ export class CommonAnimPhase extends PokemonPhase {
}
start() {
new CommonBattleAnim(this.anim, this.getPokemon()).play(this.scene, () => {
new CommonBattleAnim(this.anim, this.getPokemon(), this.getPokemon().isPlayer() ? this.scene.getEnemyPokemon() : this.scene.getPlayerPokemon()).play(this.scene, () => {
this.end();
});
}
@@ -775,7 +780,7 @@ export abstract class MovePhase extends BattlePhase {
this.scene.unshiftPhase(new MessagePhase(this.scene,
getPokemonMessage(this.pokemon, getStatusEffectHealText(this.pokemon.status.effect))));
this.pokemon.resetStatus();
this.pokemon.updateInfo(true);
this.pokemon.updateInfo();
}
doMove();
}
@@ -1536,6 +1541,32 @@ export class LearnMovePhase extends PartyMemberPokemonPhase {
}
}
export class BerryPhase extends CommonAnimPhase {
constructor(scene: BattleScene, player: boolean) {
super(scene, player, CommonAnim.USE_ITEM);
}
start() {
let berryModifier: BerryModifier;
if (this.player) {
if ((berryModifier = this.scene.applyModifier(BerryModifier, this.getPokemon()) as BerryModifier)) {
if (berryModifier.consumed) {
if (!--berryModifier.stackCount)
this.scene.removeModifier(berryModifier);
else
berryModifier.consumed = false;
this.scene.updateModifiers();
}
super.start();
return;
}
}
this.end();
}
}
export class PokemonHealPhase extends CommonAnimPhase {
private hpHealed: integer;
private message: string;
@@ -1564,7 +1595,10 @@ export class PokemonHealPhase extends CommonAnimPhase {
const fullHp = pokemon.getHpRatio() >= 1;
if (!fullHp) {
pokemon.hp = Math.min(pokemon.hp + this.hpHealed, pokemon.getMaxHp());
const hpRestoreMultiplier = new Utils.IntegerHolder(1);
if (this.player)
this.scene.applyModifiers(HealingBoosterModifier, hpRestoreMultiplier);
pokemon.hp = Math.min(pokemon.hp + this.hpHealed * hpRestoreMultiplier.value, pokemon.getMaxHp());
pokemon.updateInfo().then(() => super.end());
} else if (this.showFullHpMessage)
this.message = getPokemonMessage(pokemon, `'s\nHP is full!`);
+31 -16
View File
@@ -1,24 +1,24 @@
import Phaser from 'phaser';
import { Biome } from './biome';
import { Biome } from './data/biome';
import UI from './ui/ui';
import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, SelectStarterPhase, MessagePhase } from './battle-phases';
import { PlayerPokemon, EnemyPokemon } from './pokemon';
import PokemonSpecies, { allSpecies, getPokemonSpecies } from './pokemon-species';
import PokemonSpecies, { allSpecies, getPokemonSpecies } from './data/pokemon-species';
import * as Utils from './utils';
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PartyShareModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ConsumablePokemonMoveModifier, ModifierPredicate } from './modifier';
import { PokeballType } from './pokeball';
import { Species } from './species';
import { initAutoPlay } from './auto-play';
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PartyShareModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ConsumablePokemonMoveModifier, ModifierPredicate } from './modifier/modifier';
import { PokeballType } from './data/pokeball';
import { Species } from './data/species';
import { initAutoPlay } from './system/auto-play';
import { Battle } from './battle';
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from './battle-anims';
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from './data/battle-anims';
import { BattlePhase } from './battle-phase';
import { initGameSpeed } from './game-speed';
import { initGameSpeed } from './system/game-speed';
import { Arena } from './arena';
import { GameData } from './game-data';
import { GameData } from './system/game-data';
import StarterSelectUiHandler from './ui/starter-select-ui-handler';
import { TextStyle, addTextObject } from './text';
import { Moves } from './move';
import { getDefaultModifierTypeForTier } from './modifier-type';
import { TextStyle, addTextObject } from './ui/text';
import { Moves } from './data/move';
import { getDefaultModifierTypeForTier } from './modifier/modifier-type';
const enableAuto = true;
export const startingLevel = 5;
@@ -598,7 +598,7 @@ export default class BattleScene extends Phaser.Scene {
if ((modifier as PersistentModifier).add(this.modifiers, !!virtual)) {
if (!virtual && !this.sound.get(soundName))
this.sound.play(soundName);
} if (!virtual) {
} else if (!virtual) {
const defaultModifierType = getDefaultModifierTypeForTier(modifier.type.tier);
this.addModifier(defaultModifierType.newModifier()).then(() => resolve());
this.unshiftPhase(new MessagePhase(this, `The stack for this item is full.\n You will receive ${defaultModifierType.name} instead.`, null, true));
@@ -617,9 +617,12 @@ export default class BattleScene extends Phaser.Scene {
const args: any[] = [ pokemon ];
if (modifier instanceof PokemonHpRestoreModifier) {
const hpRestoreMultiplier = new Utils.IntegerHolder(1);
this.applyModifiers(HealingBoosterModifier, hpRestoreMultiplier);
args.push(hpRestoreMultiplier.value);
if (!(modifier as PokemonHpRestoreModifier).fainted) {
const hpRestoreMultiplier = new Utils.IntegerHolder(1);
this.applyModifiers(HealingBoosterModifier, hpRestoreMultiplier);
args.push(hpRestoreMultiplier.value);
} else
args.push(1);
}
if (modifier.shouldApply(args))
@@ -704,4 +707,16 @@ export default class BattleScene extends Phaser.Scene {
console.log('Applied', modifier.type.name);
}
}
applyModifier(modifierType: { new(...args: any[]): Modifier }, ...args: any[]): PersistentModifier {
const modifiers = this.modifiers.filter(m => m instanceof modifierType && m.shouldApply(args));
for (let modifier of modifiers) {
if (modifier.apply(args)) {
console.log('Applied', modifier.type.name);
return modifier;
}
}
return null;
}
}
File renamed without changes.
@@ -1,8 +1,8 @@
//import { battleAnimRawData } from "./battle-anim-raw-data";
import BattleScene from "./battle-scene";
import BattleScene from "../battle-scene";
import { ChargeAttr, Moves, allMoves } from "./move";
import Pokemon from "./pokemon";
import * as Utils from "./utils";
import Pokemon from "../pokemon";
import * as Utils from "../utils";
//import fs from 'vite-plugin-fs/browser';
export enum AnimFrameTarget {
@@ -41,8 +41,9 @@ export enum ChargeAnim {
}
export enum CommonAnim {
HEALTH_UP = 2000,
POISON,
USE_ITEM = 2000,
HEALTH_UP,
POISON = 2010,
TOXIC,
PARALYSIS,
SLEEP,
@@ -79,7 +80,7 @@ export enum CommonAnim {
PSYCHIC_TERRAIN
}
export class Anim {
export class AnimConfig {
public id: integer;
public graphic: string;
public frames: AnimFrame[][];
@@ -226,7 +227,7 @@ class AnimTimedSoundEvent extends AnimTimedEvent {
public pitch: number;
constructor(frameIndex: integer, resourceName: string, source?: any) {
super(frameIndex, resourceName + (resourceName && resourceName.indexOf('.') === -1 ? '.ogg' : ''));
super(frameIndex, resourceName + (resourceName && resourceName.indexOf('.') === -1 ? resourceName.startsWith('PRSFX-') ? '.wav' : '.ogg' : ''));
if (source) {
this.volume = source.volume;
@@ -349,9 +350,9 @@ class AnimTimedAddBgEvent extends AnimTimedBgEvent {
}
}
export const moveAnims = new Map<Moves, Anim | [Anim, Anim]>();
export const chargeAnims = new Map<ChargeAnim, Anim | [Anim, Anim]>();
export const commonAnims = new Map<CommonAnim, Anim>();
export const moveAnims = new Map<Moves, AnimConfig | [AnimConfig, AnimConfig]>();
export const chargeAnims = new Map<ChargeAnim, AnimConfig | [AnimConfig, AnimConfig]>();
export const commonAnims = new Map<CommonAnim, AnimConfig>();
export function initCommonAnims(): Promise<void> {
return new Promise(resolve => {
@@ -362,7 +363,7 @@ export function initCommonAnims(): Promise<void> {
const commonAnimId = commonAnimIds[ca];
commonAnimFetches.push(fetch(`./battle-anims/common-${commonAnimNames[ca].toLowerCase().replace(/\_/g, '-')}.json`)
.then(response => response.json())
.then(cas => commonAnims.set(commonAnimId, new Anim(cas))));
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))));
}
Promise.allSettled(commonAnimFetches).then(() => resolve());
});
@@ -430,22 +431,22 @@ export function initMoveChargeAnim(chargeAnim: ChargeAnim): Promise<void> {
});
}
function populateMoveAnim(move: Moves, animSource: any) {
const moveAnim = new Anim(animSource);
function populateMoveAnim(move: Moves, animSource: any): void {
const moveAnim = new AnimConfig(animSource);
if (moveAnims.get(move) === null) {
moveAnims.set(move, moveAnim);
return;
}
moveAnims.set(move, [ moveAnims.get(move) as Anim, moveAnim ]);
moveAnims.set(move, [ moveAnims.get(move) as AnimConfig, moveAnim ]);
}
function populateMoveChargeAnim(chargeAnim: ChargeAnim, animSource: any) {
const moveChargeAnim = new Anim(animSource);
const moveChargeAnim = new AnimConfig(animSource);
if (chargeAnims.get(chargeAnim) === null) {
chargeAnims.set(chargeAnim, moveChargeAnim);
return;
}
chargeAnims.set(chargeAnim, [ chargeAnims.get(chargeAnim) as Anim, moveChargeAnim ]);
chargeAnims.set(chargeAnim, [ chargeAnims.get(chargeAnim) as AnimConfig, moveChargeAnim ]);
}
export function loadCommonAnimAssets(scene: BattleScene, startLoad?: boolean): Promise<void> {
@@ -456,12 +457,12 @@ export function loadCommonAnimAssets(scene: BattleScene, startLoad?: boolean): P
export function loadMoveAnimAssets(scene: BattleScene, moveIds: Moves[], startLoad?: boolean): Promise<void> {
return new Promise(resolve => {
const moveAnimations = moveIds.map(m => moveAnims.get(m)).flat();
const moveAnimations = moveIds.map(m => moveAnims.get(m) as AnimConfig).flat();
for (let moveId of moveIds) {
const chargeAttr = allMoves[moveId - 1].getAttrs(ChargeAttr) as ChargeAttr[];
if (chargeAttr.length) {
const moveChargeAnims = chargeAnims.get(chargeAttr[0].chargeAnim);
moveAnimations.push(moveChargeAnims instanceof Anim ? moveChargeAnims : moveChargeAnims[0]);
moveAnimations.push(moveChargeAnims instanceof AnimConfig ? moveChargeAnims : moveChargeAnims[0]);
if (Array.isArray(moveChargeAnims))
moveAnimations.push(moveChargeAnims[1]);
}
@@ -470,7 +471,7 @@ export function loadMoveAnimAssets(scene: BattleScene, moveIds: Moves[], startLo
});
}
function loadAnimAssets(scene: BattleScene, anims: Anim[], startLoad?: boolean): Promise<void> {
function loadAnimAssets(scene: BattleScene, anims: AnimConfig[], startLoad?: boolean): Promise<void> {
return new Promise(resolve => {
const backgrounds = new Set<string>();
const sounds = new Set<string>();
@@ -515,7 +516,7 @@ export abstract class BattleAnim {
this.sprites = [];
}
abstract getAnim(): Anim;
abstract getAnim(): AnimConfig;
abstract isOppAnim(): boolean;
@@ -738,7 +739,7 @@ export class CommonBattleAnim extends BattleAnim {
this.commonAnim = commonAnim;
}
getAnim(): Anim {
getAnim(): AnimConfig {
return commonAnims.get(this.commonAnim);
}
@@ -760,10 +761,10 @@ export class MoveAnim extends BattleAnim {
this.move = move;
}
getAnim(): Anim {
return moveAnims.get(this.move) instanceof Anim
? moveAnims.get(this.move) as Anim
: moveAnims.get(this.move)[this.user.isPlayer() ? 0 : 1] as Anim;
getAnim(): AnimConfig {
return moveAnims.get(this.move) instanceof AnimConfig
? moveAnims.get(this.move) as AnimConfig
: moveAnims.get(this.move)[this.user.isPlayer() ? 0 : 1] as AnimConfig;
}
isOppAnim(): boolean {
@@ -800,10 +801,10 @@ export class MoveChargeAnim extends MoveAnim {
this.chargeAnim = chargeAnim;
}
getAnim(): Anim {
return chargeAnims.get(this.chargeAnim) instanceof Anim
? chargeAnims.get(this.chargeAnim) as Anim
: chargeAnims.get(this.chargeAnim)[this.user.isPlayer() ? 0 : 1] as Anim;
getAnim(): AnimConfig {
return chargeAnims.get(this.chargeAnim) instanceof AnimConfig
? chargeAnims.get(this.chargeAnim) as AnimConfig
: chargeAnims.get(this.chargeAnim)[this.user.isPlayer() ? 0 : 1] as AnimConfig;
}
}
@@ -840,14 +841,15 @@ export function populateAnims() {
const animName = fields[1].slice(nameIndex, fields[1].indexOf('\n', nameIndex));
if (!moveNameToId.hasOwnProperty(animName) && !commonAnimId && !chargeAnimId)
continue;
let anim = new Anim();
anim.id = commonAnimId || chargeAnimId || moveNameToId[animName];
let anim = commonAnimId || chargeAnimId ? new AnimConfig() : new AnimConfig();
if (anim instanceof AnimConfig)
(anim as AnimConfig).id = moveNameToId[animName];
if (commonAnimId)
commonAnims.set(commonAnimId, anim);
else if (chargeAnimId)
chargeAnims.set(chargeAnimId, !isOppMove ? anim : [ chargeAnims.get(chargeAnimId) as Anim, anim ]);
chargeAnims.set(chargeAnimId, !isOppMove ? anim : [ chargeAnims.get(chargeAnimId) as AnimConfig, anim ]);
else
moveAnims.set(moveNameToId[animName], !isOppMove ? anim : [ moveAnims.get(moveNameToId[animName]) as Anim, anim ]);
moveAnims.set(moveNameToId[animName], !isOppMove ? anim as AnimConfig : [ moveAnims.get(moveNameToId[animName]) as AnimConfig, anim as AnimConfig ]);
for (let f = 0; f < fields.length; f++) {
const field = fields[f];
const fieldName = field.slice(0, field.indexOf(':'));
@@ -940,6 +942,8 @@ export function populateAnims() {
}
const animReplacer = (k, v) => {
if (k === 'id' && !v)
return undefined;
if (v instanceof Map)
return Object.fromEntries(v);
if (v instanceof AnimTimedEvent)
@@ -950,21 +954,21 @@ export function populateAnims() {
/*for (let ma of moveAnims.keys()) {
const data = moveAnims.get(ma);
(async () => {
await fs.writeFile(`./public/battle-anims/${Moves[ma].toLowerCase().replace(/\_/g, '-')}.json`, JSON.stringify(data, animReplacer, ' '));
await fs.writeFile(`../public/battle-anims/${Moves[ma].toLowerCase().replace(/\_/g, '-')}.json`, JSON.stringify(data, animReplacer, ' '));
})();
}
for (let ca of chargeAnims.keys()) {
const data = chargeAnims.get(ca);
(async () => {
await fs.writeFile(`./public/battle-anims/${chargeAnimNames[chargeAnimIds.indexOf(ca)].replace(/\_/g, '-')}.json`, JSON.stringify(data, animReplacer, ' '));
await fs.writeFile(`../public/battle-anims/${chargeAnimNames[chargeAnimIds.indexOf(ca)].replace(/\_/g, '-')}.json`, JSON.stringify(data, animReplacer, ' '));
})();
}
for (let cma of commonAnims.keys()) {
const data = commonAnims.get(cma);
(async () => {
await fs.writeFile(`./public/battle-anims/common-${commonAnimNames[commonAnimIds.indexOf(cma)].replace(/\_/g, '-')}.json`, JSON.stringify(data, animReplacer, ' '));
await fs.writeFile(`../public/battle-anims/common-${commonAnimNames[commonAnimIds.indexOf(cma)].replace(/\_/g, '-')}.json`, JSON.stringify(data, animReplacer, ' '));
})();
}*/
}
File renamed without changes.
+5 -5
View File
@@ -1,10 +1,10 @@
import { CommonAnim, CommonBattleAnim } from "./battle-anims";
import { CommonAnimPhase, DamagePhase, MessagePhase, MovePhase, ObtainStatusEffectPhase, PokemonHealPhase } from "./battle-phases";
import { getPokemonMessage } from "./messages";
import Pokemon from "./pokemon";
import { CommonAnimPhase, DamagePhase, MessagePhase, MovePhase, ObtainStatusEffectPhase, PokemonHealPhase } from "../battle-phases";
import { getPokemonMessage } from "../messages";
import Pokemon from "../pokemon";
import { Stat } from "./pokemon-stat";
import { StatusEffect } from "./status-effect";
import * as Utils from "./utils";
import * as Utils from "../utils";
export enum BattleTagType {
NONE,
@@ -101,7 +101,7 @@ export class ConfusedTag extends PseudoStatusTag {
}
lapse(pokemon: Pokemon, lapseType: BattleTagLapseType): boolean {
const ret = super.lapse(pokemon, lapseType);
const ret = lapseType !== BattleTagLapseType.CUSTOM && super.lapse(pokemon, lapseType);
if (ret) {
pokemon.scene.unshiftPhase(new MessagePhase(pokemon.scene, getPokemonMessage(pokemon, ' is\nconfused!')));
+60
View File
@@ -0,0 +1,60 @@
import { MessagePhase, PokemonHealPhase } from "../battle-phases";
import { getPokemonMessage } from "../messages";
import Pokemon from "../pokemon";
import { BattleTagType } from "./battle-tag";
import { getStatusEffectHealText } from "./status-effect";
export enum BerryType {
SITRUS,
LUM
}
export function getBerryName(berryType: BerryType) {
switch (berryType) {
case BerryType.SITRUS:
return 'SITRUS BERRY';
case BerryType.LUM:
return 'LUM BERRY';
}
}
export function getBerryEffectDescription(berryType: BerryType) {
switch (berryType) {
case BerryType.SITRUS:
return 'Restores 25% HP if HP is below 50%';
case BerryType.LUM:
return 'Cures any non-volatile status condition and confusion';
}
}
export type BerryPredicate = (pokemon: Pokemon) => boolean;
export function getBerryPredicate(berryType: BerryType): BerryPredicate {
switch (berryType) {
case BerryType.SITRUS:
return (pokemon: Pokemon) => pokemon.getHpRatio() < 0.5;
case BerryType.LUM:
return (pokemon: Pokemon) => !!pokemon.status || !!pokemon.getTag(BattleTagType.CONFUSED);
}
}
export type BerryEffectFunc = (pokemon: Pokemon) => void;
export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
switch (berryType) {
case BerryType.SITRUS:
return (pokemon: Pokemon) => {
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, true, Math.floor(pokemon.getMaxHp() / 4), getPokemonMessage(pokemon, `'s ${getBerryName(berryType)}\nrestored its HP!`), true));
};
case BerryType.LUM:
return (pokemon: Pokemon) => {
if (pokemon.status) {
pokemon.scene.unshiftPhase(new MessagePhase(pokemon.scene,
getPokemonMessage(pokemon, getStatusEffectHealText(pokemon.status.effect))));
pokemon.resetStatus();
pokemon.updateInfo();
} else if (pokemon.getTag(BattleTagType.CONFUSED))
pokemon.lapseTag(BattleTagType.CONFUSED);
};
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
import { pokemonEvolutions, SpeciesEvolution } from "./pokemon-evolutions";
import { Species } from "./species";
import { Type } from './type';
import * as Utils from './utils';
import * as Utils from '../utils';
import beautify from 'json-beautify';
View File
File renamed without changes.
File renamed without changes.
+4 -4
View File
@@ -1,12 +1,12 @@
import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims";
import { DamagePhase, EnemyMovePhase, MessagePhase, ObtainStatusEffectPhase, PlayerMovePhase, PokemonHealPhase, StatChangePhase } from "./battle-phases";
import { DamagePhase, EnemyMovePhase, MessagePhase, ObtainStatusEffectPhase, PlayerMovePhase, PokemonHealPhase, StatChangePhase } from "../battle-phases";
import { BattleStat } from "./battle-stat";
import { BattleTagType } from "./battle-tag";
import { getPokemonMessage } from "./messages";
import Pokemon, { EnemyPokemon, MoveResult, PlayerPokemon, PokemonMove, TurnMove } from "./pokemon";
import { getPokemonMessage } from "../messages";
import Pokemon, { EnemyPokemon, MoveResult, PlayerPokemon, PokemonMove, TurnMove } from "../pokemon";
import { StatusEffect, getStatusEffectDescriptor } from "./status-effect";
import { Type } from "./type";
import * as Utils from "./utils";
import * as Utils from "../utils";
import { WeatherType } from "./weather";
export enum MoveCategory {
+2 -2
View File
@@ -1,5 +1,5 @@
import BattleScene from "./battle-scene";
import { toPokemonUpperCase } from "./utils";
import BattleScene from "../battle-scene";
import { toPokemonUpperCase } from "../utils";
export enum PokeballType {
POKEBALL,
@@ -1,13 +1,13 @@
import { Gender } from "./gender";
import { AttackTypeBoosterModifier } from "./modifier";
import { AttackTypeBoosterModifierType } from "./modifier-type";
import { AttackTypeBoosterModifier } from "../modifier/modifier";
import { AttackTypeBoosterModifierType } from "../modifier/modifier-type";
import { Moves } from "./move";
import { PokeballType } from "./pokeball";
import Pokemon from "./pokemon";
import Pokemon from "../pokemon";
import { Stat } from "./pokemon-stat";
import { Species } from "./species";
import { Type } from "./type";
import * as Utils from "./utils";
import * as Utils from "../utils";
export enum SpeciesWildEvolutionDelay {
NONE,
File renamed without changes.
@@ -1,11 +1,10 @@
import { Abilities } from './abilities';
import BattleScene from './battle-scene';
import { Abilities } from './ability';
import BattleScene from '../battle-scene';
import { GrowthRate } from './exp';
import { EnemyPokemon } from './pokemon';
import { pokemonEvolutions } from './pokemon-evolutions';
import { Species } from './species';
import { Type } from './type';
import * as Utils from './utils';
import * as Utils from '../utils';
export function getPokemonSpecies(species: Species): PokemonSpecies {
if (species >= Species.XERNEAS)
@@ -1,4 +1,4 @@
import { toPokemonUpperCase } from "./utils";
import { toPokemonUpperCase } from "../utils";
export enum Stat {
HP = 0,
File renamed without changes.
@@ -1,4 +1,4 @@
import * as Utils from "./utils";
import * as Utils from "../utils";
export enum StatusEffect {
NONE,
+36
View File
@@ -0,0 +1,36 @@
import { BattleStat, getBattleStatName } from "./battle-stat";
export enum TempBattleStat {
ATK,
DEF,
SPATK,
SPDEF,
SPD,
ACC,
CRIT
}
export function getTempBattleStatName(tempBattleStat: TempBattleStat) {
if (tempBattleStat === TempBattleStat.CRIT)
return 'critical-hit ratio';
return getBattleStatName(tempBattleStat as integer as BattleStat);
}
export function getTempBattleStatBoosterItemName(tempBattleStat: TempBattleStat) {
switch (tempBattleStat) {
case TempBattleStat.ATK:
return 'X Attack';
case TempBattleStat.DEF:
return 'X Defense';
case TempBattleStat.SPATK:
return 'X Sp. Atk';
case TempBattleStat.SPDEF:
return 'X Sp. Def';
case TempBattleStat.SPD:
return 'X Speed';
case TempBattleStat.ACC:
return 'X Accuracy';
case TempBattleStat.CRIT:
return 'Dire Hit';
}
}
View File
File renamed without changes.
View File
File renamed without changes.
+3 -3
View File
@@ -1,9 +1,9 @@
import { Biome } from "./biome";
import { getPokemonMessage } from "./messages";
import Pokemon from "./pokemon";
import { getPokemonMessage } from "../messages";
import Pokemon from "../pokemon";
import { Type } from "./type";
import Move, { AttackMove } from "./move";
import * as Utils from "./utils";
import * as Utils from "../utils";
export enum WeatherType {
NONE,
+1 -1
View File
@@ -1,7 +1,7 @@
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { BattlePhase } from "./battle-phase";
import BattleScene from "./battle-scene";
import { SpeciesEvolution } from "./pokemon-evolutions";
import { SpeciesEvolution } from "./data/pokemon-evolutions";
import EvolutionSceneHandler from "./ui/evolution-scene-handler";
import * as Utils from "./utils";
import { Mode } from "./ui/ui";
@@ -1,14 +1,16 @@
import { BattleStat, getBattleStatName } from './battle-stat';
import { BattleStat, getBattleStatName } from '../data/battle-stat';
import * as Modifiers from './modifier';
import { AttackMove, Moves, allMoves } from './move';
import { PokeballType, getPokeballName } from './pokeball';
import { PlayerPokemon, PokemonMove } from './pokemon';
import { EvolutionItem, pokemonEvolutions } from './pokemon-evolutions';
import { Stat, getStatName } from './pokemon-stat';
import { tmSpecies } from './tms';
import { Type } from './type';
import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from './ui/party-ui-handler';
import * as Utils from './utils';
import { AttackMove, Moves, allMoves } from '../data/move';
import { PokeballType, getPokeballName } from '../data/pokeball';
import { PlayerPokemon, PokemonMove } from '../pokemon';
import { EvolutionItem, pokemonEvolutions } from '../data/pokemon-evolutions';
import { Stat, getStatName } from '../data/pokemon-stat';
import { tmSpecies } from '../data/tms';
import { Type } from '../data/type';
import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from '../ui/party-ui-handler';
import * as Utils from '../utils';
import { TempBattleStat, getTempBattleStatBoosterItemName, getTempBattleStatName } from '../data/temp-battle-stat';
import { BerryType, getBerryEffectDescription, getBerryName } from '../data/berry';
type Modifier = Modifiers.Modifier;
@@ -59,13 +61,19 @@ class AddPokeballModifierType extends ModifierType {
export class PokemonModifierType extends ModifierType {
public selectFilter: PokemonSelectFilter;
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, iconImage?: string, group?: string) {
super(name, description, newModifierFunc, iconImage, group);
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, iconImage?: string, group?: string, soundName?: string) {
super(name, description, newModifierFunc, iconImage, group, soundName);
this.selectFilter = selectFilter;
}
}
export class PokemonHeldItemModifierType extends PokemonModifierType {
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, iconImage?: string, group?: string, soundName?: string) {
super(name, description, newModifierFunc, selectFilter, iconImage, group, soundName);
}
}
export class PokemonHpRestoreModifierType extends PokemonModifierType {
protected restorePoints: integer;
protected percent: boolean;
@@ -157,41 +165,6 @@ export class PokemonAllMovePpRestoreModifierType extends PokemonModifierType {
}
}
export enum TempBattleStat {
ATK,
DEF,
SPATK,
SPDEF,
SPD,
ACC,
CRIT
}
function getTempBattleStatName(tempBattleStat: TempBattleStat) {
if (tempBattleStat === TempBattleStat.CRIT)
return 'critical-hit ratio';
return getBattleStatName(tempBattleStat as integer as BattleStat);
}
function getTempBattleStatBoosterItemName(tempBattleStat: TempBattleStat) {
switch (tempBattleStat) {
case TempBattleStat.ATK:
return 'X Attack';
case TempBattleStat.DEF:
return 'X Defense';
case TempBattleStat.SPATK:
return 'X Sp. Atk';
case TempBattleStat.SPDEF:
return 'X Sp. Def';
case TempBattleStat.SPD:
return 'X Speed';
case TempBattleStat.ACC:
return 'X Accuracy';
case TempBattleStat.CRIT:
return 'Dire Hit';
}
}
export class TempBattleStatBoosterModifierType extends ModifierType {
public tempBattleStat: TempBattleStat;
@@ -246,7 +219,7 @@ function getAttackTypeBoosterItemName(type: Type) {
}
}
export class AttackTypeBoosterModifierType extends PokemonModifierType {
export class AttackTypeBoosterModifierType extends PokemonHeldItemModifierType {
public moveType: Type;
public boostPercent: integer;
@@ -284,7 +257,7 @@ function getBaseStatBoosterItemName(stat: Stat) {
}
}
export class PokemonBaseStatBoosterModifierType extends PokemonModifierType {
export class PokemonBaseStatBoosterModifierType extends PokemonHeldItemModifierType {
private stat: Stat;
constructor(name: string, stat: Stat, _iconImage?: string) {
@@ -312,7 +285,7 @@ export class ExpBoosterModifierType extends ModifierType {
}
}
export class PokemonExpBoosterModifierType extends PokemonModifierType {
export class PokemonExpBoosterModifierType extends PokemonHeldItemModifierType {
constructor(name: string, boostPercent: integer, iconImage?: string) {
super(name, `Increases the holder's gain of EXP. Points by ${boostPercent}%`, (_type, args) => new Modifiers.PokemonExpBoosterModifier(this, (args[0] as PlayerPokemon).id, boostPercent),
(_pokemon: PlayerPokemon) => null, iconImage);
@@ -486,7 +459,14 @@ const modifierPool = {
new WeightedModifierType(new ModifierTypeGenerator((party: PlayerPokemon[]) => {
const randTempBattleStat = Utils.randInt(7) as TempBattleStat;
return new TempBattleStatBoosterModifierType(randTempBattleStat);
}), 4)
}), 4),
new WeightedModifierType(new ModifierTypeGenerator((party: PlayerPokemon[]) => {
const berryTypes = Utils.getEnumValues(BerryType);
const randBerryType = berryTypes[Utils.randInt(berryTypes.length)];
return new PokemonHeldItemModifierType(getBerryName(randBerryType), getBerryEffectDescription(randBerryType),
(type, args) => new Modifiers.BerryModifier(type, (args[0] as PlayerPokemon).id, randBerryType),
() => null, null, 'berry');
}), 2)
].map(m => { m.setTier(ModifierTier.COMMON); return m; }),
[ModifierTier.GREAT]: [
new WeightedModifierType(new AddPokeballModifierType(PokeballType.GREAT_BALL, 5, 'gb'), 12),
@@ -524,6 +504,8 @@ const modifierPool = {
new WeightedModifierType(new ModifierTypeGenerator((party: PlayerPokemon[]) => {
const partyMemberCompatibleTms = party.map(p => p.compatibleTms);
const uniqueCompatibleTms = partyMemberCompatibleTms.flat().filter((tm, i, array) => array.indexOf(tm) === i);
if (!uniqueCompatibleTms.length)
return null;
const randTmIndex = Utils.randInt(uniqueCompatibleTms.length);
return new TmModifierType(uniqueCompatibleTms[randTmIndex]);
}), 4),
@@ -535,14 +517,16 @@ const modifierPool = {
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
[ModifierTier.ULTRA]: [
new WeightedModifierType(new AddPokeballModifierType(PokeballType.ULTRA_BALL, 5, 'ub'), 8),
new WeightedModifierType(new EvolutionItemModifierTypeGenerator(), 5),
new WeightedModifierType(new AttackTypeBoosterModifierTypeGenerator(), 3),
new WeightedModifierType(new EvolutionItemModifierTypeGenerator(), 12),
new WeightedModifierType(new AttackTypeBoosterModifierTypeGenerator(), 5),
new ModifierType('OVAL CHARM', 'For every X (no. of party members) items in a POKéMON\'s held item stack, give one to each other party member',
(type, _args) => new Modifiers.PartyShareModifier(type), 'oval_charm'),
new ModifierType('HEALING CHARM', 'Doubles the effectiveness of HP restoring moves and items (excludes revives)', (type, _args) => new Modifiers.HealingBoosterModifier(type, 2), 'healing_charm'),
new WeightedModifierType(new PokemonModifierType('SHELL BELL', 'Heals 1/8 of a POKéMON\'s dealt damage', (type, args) => new Modifiers.HitHealModifier(type, (args[0] as PlayerPokemon).id)), 2),
new WeightedModifierType(new PokemonHeldItemModifierType('SHELL BELL', 'Heals 1/8 of a POKéMON\'s dealt damage', (type, args) => new Modifiers.HitHealModifier(type, (args[0] as PlayerPokemon).id)), 2),
new WeightedModifierType(new ExpBoosterModifierType('EXP CHARM', 25), 4),
new WeightedModifierType(new PokemonExpBoosterModifierType('LUCKY EGG', 50), 3),
new WeightedModifierType(new ModifierType('BERRY POUCH', 'Adds a 25% chance that a used berry will not be consumed',
(type, _args) => new Modifiers.PreserveBerryModifier(type)), 3),
new WeightedModifierType(new ModifierType('EXP. BALANCE', 'All EXP. Points received from battles is split among the lower leveled party members', (type, _args) => new Modifiers.ExpBalanceModifier(type), 'exp_balance'), 1)
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
[ModifierTier.MASTER]: [
+86 -19
View File
@@ -1,16 +1,19 @@
import * as ModifierTypes from './modifier-type';
import { LearnMovePhase, LevelUpPhase, PokemonHealPhase } from "./battle-phases";
import BattleScene from "./battle-scene";
import { getLevelTotalExp } from "./exp";
import { PokeballType } from "./pokeball";
import Pokemon, { PlayerPokemon } from "./pokemon";
import { Stat } from "./pokemon-stat";
import { addTextObject, TextStyle } from "./text";
import { Type } from './type';
import { EvolutionPhase } from './evolution-phase';
import { pokemonEvolutions } from './pokemon-evolutions';
import { getPokemonMessage } from './messages';
import * as Utils from "./utils";
import { CommonAnimPhase, LearnMovePhase, LevelUpPhase, PokemonHealPhase } from "../battle-phases";
import BattleScene from "../battle-scene";
import { getLevelTotalExp } from "../data/exp";
import { PokeballType } from "../data/pokeball";
import Pokemon, { PlayerPokemon } from "../pokemon";
import { Stat } from "../data/pokemon-stat";
import { addTextObject, TextStyle } from "../ui/text";
import { Type } from '../data/type';
import { EvolutionPhase } from '../evolution-phase';
import { pokemonEvolutions } from '../data/pokemon-evolutions';
import { getPokemonMessage } from '../messages';
import * as Utils from "../utils";
import { TempBattleStat } from '../data/temp-battle-stat';
import { BerryType, getBerryEffectFunc, getBerryPredicate } from '../data/berry';
import { CommonAnim } from '../data/battle-anims';
type ModifierType = ModifierTypes.ModifierType;
export type ModifierPredicate = (modifier: Modifier) => boolean;
@@ -185,10 +188,10 @@ export class AddPokeballModifier extends ConsumableModifier {
}
export class TempBattleStatBoosterModifier extends PersistentModifier {
private tempBattleStat: ModifierTypes.TempBattleStat;
private tempBattleStat: TempBattleStat;
private battlesLeft: integer;
constructor(type: ModifierTypes.TempBattleStatBoosterModifierType, tempBattleStat: ModifierTypes.TempBattleStat) {
constructor(type: ModifierTypes.TempBattleStatBoosterModifierType, tempBattleStat: TempBattleStat) {
super(type);
this.tempBattleStat = tempBattleStat;
@@ -200,7 +203,7 @@ export class TempBattleStatBoosterModifier extends PersistentModifier {
}
apply(args: any[]): boolean {
const tempBattleStat = args[0] as ModifierTypes.TempBattleStat;
const tempBattleStat = args[0] as TempBattleStat;
if (tempBattleStat === this.tempBattleStat) {
const statLevel = args[1] as Utils.IntegerHolder;
@@ -353,15 +356,79 @@ export class HitHealModifier extends PokemonHeldItemModifier {
if (pokemon.turnData.damageDealt && pokemon.getHpRatio() < 1) {
const scene = pokemon.scene;
const hpRestoreMultiplier = new Utils.IntegerHolder(1);
scene.applyModifiers(HealingBoosterModifier, hpRestoreMultiplier);
scene.unshiftPhase(new PokemonHealPhase(scene, true, Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount * hpRestoreMultiplier.value, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
scene.unshiftPhase(new PokemonHealPhase(scene, true, Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
}
return true;
}
}
export class BerryModifier extends PokemonHeldItemModifier {
public berryType: BerryType;
public consumed: boolean;
constructor(type: ModifierType, pokemonId: integer, berryType: BerryType) {
super(type, pokemonId);
this.berryType = berryType;
this.consumed = false;
}
match(modifier: Modifier) {
return modifier instanceof BerryModifier && (modifier as BerryModifier).berryType === this.berryType;
}
clone() {
return new BerryModifier(this.type, this.pokemonId, this.berryType);
}
shouldApply(args: any[]): boolean {
return !this.consumed && super.shouldApply(args) && getBerryPredicate(this.berryType)(args[0] as Pokemon);
}
apply(args: any[]): boolean {
const pokemon = args[0] as Pokemon;
const preserve = new Utils.BooleanHolder(false);
pokemon.scene.applyModifiers(PreserveBerryModifier, preserve);
getBerryEffectFunc(this.berryType)(pokemon);
if (!preserve.value)
this.consumed = true;
return true;
}
}
export class PreserveBerryModifier extends PersistentModifier {
constructor(type: ModifierType) {
super(type);
}
match(modifier: Modifier) {
return modifier instanceof PreserveBerryModifier;
}
clone() {
return new PreserveBerryModifier(this.type);
}
shouldApply(args: any[]): boolean {
return super.shouldApply(args) && args[0] instanceof Utils.BooleanHolder;
}
apply(args: any[]): boolean {
if (!(args[0] as Utils.BooleanHolder).value)
(args[0] as Utils.BooleanHolder).value = this.getStackCount() === this.getMaxStackCount() || Utils.randInt(this.getMaxStackCount()) < this.getStackCount();
return true;
}
getMaxStackCount(): number {
return 4;
}
}
export abstract class ConsumablePokemonModifier extends ConsumableModifier {
public pokemonId: integer;
@@ -383,7 +450,7 @@ export abstract class ConsumablePokemonModifier extends ConsumableModifier {
export class PokemonHpRestoreModifier extends ConsumablePokemonModifier {
private restorePoints: integer;
private percent: boolean;
private fainted: boolean;
public fainted: boolean;
constructor(type: ModifierType, pokemonId: integer, restorePoints: integer, percent: boolean, fainted?: boolean) {
super(type, pokemonId);
+20 -20
View File
@@ -1,26 +1,26 @@
import Phaser from 'phaser';
import BattleScene from './battle-scene';
import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from './battle-info';
import Move, { StatChangeAttr, HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariablePowerAttr, Moves, allMoves, MoveCategory } from "./move";
import { pokemonLevelMoves } from './pokemon-level-moves';
import { default as PokemonSpecies, PokemonSpeciesForm, getPokemonSpecies } from './pokemon-species';
import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from './ui/battle-info';
import Move, { StatChangeAttr, HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariablePowerAttr, Moves, allMoves, MoveCategory } from "./data/move";
import { pokemonLevelMoves } from './data/pokemon-level-moves';
import { default as PokemonSpecies, PokemonSpeciesForm, getPokemonSpecies } from './data/pokemon-species';
import * as Utils from './utils';
import { Type, getTypeDamageMultiplier } from './type';
import { getLevelTotalExp } from './exp';
import { Stat } from './pokemon-stat';
import { AttackTypeBoosterModifier, PokemonBaseStatModifier as PokemonBaseStatBoosterModifier, ShinyRateBoosterModifier, TempBattleStatBoosterModifier } from './modifier';
import { PokeballType } from './pokeball';
import { Gender } from './gender';
import { initMoveAnim, loadMoveAnimAssets } from './battle-anims';
import { Status, StatusEffect } from './status-effect';
import { tmSpecies } from './tms';
import { pokemonEvolutions, pokemonPrevolutions, SpeciesEvolution, SpeciesEvolutionCondition } from './pokemon-evolutions';
import { Type, getTypeDamageMultiplier } from './data/type';
import { getLevelTotalExp } from './data/exp';
import { Stat } from './data/pokemon-stat';
import { AttackTypeBoosterModifier, PokemonBaseStatModifier, ShinyRateBoosterModifier, TempBattleStatBoosterModifier } from './modifier/modifier';
import { PokeballType } from './data/pokeball';
import { Gender } from './data/gender';
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 { BattleStat } from './battle-stat';
import { BattleTag, BattleTagLapseType, BattleTagType, getBattleTag } from './battle-tag';
import { Species } from './species';
import { WeatherType } from './weather';
import { TempBattleStat } from './modifier-type';
import { BattleStat } from './data/battle-stat';
import { BattleTag, BattleTagLapseType, BattleTagType, getBattleTag } from './data/battle-tag';
import { Species } from './data/species';
import { WeatherType } from './data/weather';
import { TempBattleStat } from './data/temp-battle-stat';
export default abstract class Pokemon extends Phaser.GameObjects.Container {
public id: integer;
@@ -280,7 +280,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (!this.stats)
this.stats = [ 0, 0, 0, 0, 0, 0 ];
const baseStats = this.getSpeciesForm().baseStats.slice(0);
this.scene.applyModifiers(PokemonBaseStatBoosterModifier, this, baseStats);
this.scene.applyModifiers(PokemonBaseStatModifier, this, baseStats);
const stats = Utils.getEnumValues(Stat);
for (let s of stats) {
const isHp = s === Stat.HP;
+14 -14
View File
@@ -1,17 +1,17 @@
import { SelectModifierPhase } from "./battle-phases";
import BattleScene, { Button } from "./battle-scene";
import { ModifierTier, ModifierType, ModifierTypeOption, PokemonBaseStatBoosterModifierType, PokemonHpRestoreModifierType, PokemonReviveModifierType } from "./modifier-type";
import Pokemon, { AiType, EnemyPokemon, PlayerPokemon, PokemonMove } from "./pokemon";
import { Species } from "./species";
import { getTypeDamageMultiplier } from "./type";
import BattleMessageUiHandler from "./ui/battle-message-ui-handler";
import CommandUiHandler from "./ui/command-ui-handler";
import FightUiHandler from "./ui/fight-ui-handler";
import MessageUiHandler from "./ui/message-ui-handler";
import ModifierSelectUiHandler from "./ui/modifier-select-ui-handler";
import PartyUiHandler, { PartyUiMode } from "./ui/party-ui-handler";
import ConfirmUiHandler from "./ui/confirm-ui-handler";
import { Mode } from "./ui/ui";
import { SelectModifierPhase } from "../battle-phases";
import BattleScene, { Button } from "../battle-scene";
import { ModifierTier, ModifierType, ModifierTypeOption, PokemonBaseStatBoosterModifierType, PokemonHpRestoreModifierType, PokemonReviveModifierType } from "../modifier/modifier-type";
import Pokemon, { AiType, EnemyPokemon, PlayerPokemon, PokemonMove } from "../pokemon";
import { Species } from "../data/species";
import { getTypeDamageMultiplier } from "../data/type";
import BattleMessageUiHandler from "../ui/battle-message-ui-handler";
import CommandUiHandler from "../ui/command-ui-handler";
import FightUiHandler from "../ui/fight-ui-handler";
import MessageUiHandler from "../ui/message-ui-handler";
import ModifierSelectUiHandler from "../ui/modifier-select-ui-handler";
import PartyUiHandler, { PartyUiMode } from "../ui/party-ui-handler";
import ConfirmUiHandler from "../ui/confirm-ui-handler";
import { Mode } from "../ui/ui";
export function initAutoPlay() {
const thisArg = this as BattleScene;
+7 -7
View File
@@ -1,10 +1,10 @@
import BattleScene from "./battle-scene";
import { Gender } from "./gender";
import Pokemon from "./pokemon";
import { pokemonPrevolutions } from "./pokemon-evolutions";
import PokemonSpecies, { allSpecies } from "./pokemon-species";
import { Species } from "./species";
import * as Utils from "./utils";
import BattleScene from "../battle-scene";
import { Gender } from "../data/gender";
import Pokemon from "../pokemon";
import { pokemonPrevolutions } from "../data/pokemon-evolutions";
import PokemonSpecies, { allSpecies } from "../data/pokemon-species";
import { Species } from "../data/species";
import * as Utils from "../utils";
interface SaveData {
trainerId: integer;
@@ -1,5 +1,5 @@
import BattleScene from "./battle-scene";
import * as Utils from "./utils";
import BattleScene from "../battle-scene";
import * as Utils from "../utils";
export function initGameSpeed() {
const thisArg = this as BattleScene;
+2 -2
View File
@@ -1,7 +1,7 @@
import { CommandPhase } from "../battle-phases";
import BattleScene, { Button } from "../battle-scene";
import { getPokeballName, PokeballType } from "../pokeball";
import { addTextObject, TextStyle } from "../text";
import { getPokeballName, PokeballType } from "../data/pokeball";
import { addTextObject, TextStyle } from "./text";
import { Command } from "./command-ui-handler";
import { Mode } from "./ui";
import UiHandler from "./uiHandler";
+6 -6
View File
@@ -1,10 +1,10 @@
import { default as Pokemon } from './pokemon';
import { getLevelTotalExp, getLevelRelExp } from './exp';
import * as Utils from './utils';
import { default as Pokemon } from '../pokemon';
import { getLevelTotalExp, getLevelRelExp } from '../data/exp';
import * as Utils from '../utils';
import { addTextObject, TextStyle } from './text';
import { getGenderSymbol, getGenderColor } from './gender';
import { StatusEffect } from './status-effect';
import BattleScene from './battle-scene';
import { getGenderSymbol, getGenderColor } from '../data/gender';
import { StatusEffect } from '../data/status-effect';
import BattleScene from '../battle-scene';
export default class BattleInfo extends Phaser.GameObjects.Container {
private player: boolean;
+2 -2
View File
@@ -1,9 +1,9 @@
import BattleScene, { Button } from "../battle-scene";
import { addTextObject, TextStyle } from "../text";
import { addTextObject, TextStyle } from "./text";
import UI, { Mode } from "./ui";
import * as Utils from "../utils";
import MessageUiHandler from "./message-ui-handler";
import { getStatName, Stat } from "../pokemon-stat";
import { getStatName, Stat } from "../data/pokemon-stat";
export default class BattleMessageUiHandler extends MessageUiHandler {
private levelUpStatsContainer: Phaser.GameObjects.Container;
+2 -2
View File
@@ -1,6 +1,6 @@
import BattleScene, { Button } from "../battle-scene";
import { Biome, biomeLinks, getBiomeName } from "../biome";
import { addTextObject, TextStyle } from "../text";
import { Biome, biomeLinks, getBiomeName } from "../data/biome";
import { addTextObject, TextStyle } from "./text";
import { Mode } from "./ui";
import UiHandler from "./uiHandler";
+1 -1
View File
@@ -1,6 +1,6 @@
import { CommandPhase } from "../battle-phases";
import BattleScene, { Button } from "../battle-scene";
import { addTextObject, TextStyle } from "../text";
import { addTextObject, TextStyle } from "./text";
import { toPokemonUpperCase } from "../utils";
import { PartyUiMode } from "./party-ui-handler";
import UI, { Mode } from "./ui";
+1 -1
View File
@@ -1,5 +1,5 @@
import BattleScene, { Button } from "../battle-scene";
import { addTextObject, TextStyle } from "../text";
import { addTextObject, TextStyle } from "./text";
import { Mode } from "./ui";
import UiHandler from "./uiHandler";
+2 -2
View File
@@ -1,6 +1,6 @@
import BattleScene, { Button } from "../battle-scene";
import { addTextObject, TextStyle } from "../text";
import { Type } from "../type";
import { addTextObject, TextStyle } from "./text";
import { Type } from "../data/type";
import { Command } from "./command-ui-handler";
import { Mode } from "./ui";
import UiHandler from "./uiHandler";
-3
View File
@@ -1,3 +0,0 @@
import BattleScene from "../battle-scene";
import { Modifier } from "../modifier";
+3 -3
View File
@@ -1,7 +1,7 @@
import BattleScene, { Button } from "../battle-scene";
import { ModifierTier, ModifierType, ModifierTypeOption } from "../modifier-type";
import { getPokeballAtlasKey, PokeballType } from "../pokeball";
import { addTextObject, TextStyle } from "../text";
import { ModifierTier, ModifierType, ModifierTypeOption } from "../modifier/modifier-type";
import { getPokeballAtlasKey, PokeballType } from "../data/pokeball";
import { addTextObject, TextStyle } from "./text";
import AwaitableUiHandler from "./awaitable-ui-handler";
import { Mode } from "./ui";
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandPhase, SummonMissingPhase } from "../battle-phases";
import BattleScene, { Button } from "../battle-scene";
import { PlayerPokemon, PokemonMove } from "../pokemon";
import { addTextObject, TextStyle } from "../text";
import { addTextObject, TextStyle } from "./text";
import { Command } from "./command-ui-handler";
import MessageUiHandler from "./message-ui-handler";
import { Mode } from "./ui";
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff. Show more