Merge 1aa1f653dc into 7061bb0d70
commit
3076ae2044
|
|
@ -54,6 +54,18 @@ export abstract class ArenaTag {
|
||||||
? allMoves[this.sourceMove].name
|
? allMoves[this.sourceMove].name
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When given an arena tag or json representing one, load the data for it.
|
||||||
|
* This is meant to be inherited from by any arena tag with custom attributes
|
||||||
|
* @param {ArenaTag | any} source An arena tag, or json representing one
|
||||||
|
*/
|
||||||
|
loadTag(source: ArenaTag | any): void {
|
||||||
|
this.turnCount = source.turnCount;
|
||||||
|
this.sourceMove = source.sourceMove;
|
||||||
|
this.sourceId = source.sourceId;
|
||||||
|
this.side = source.side;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MistTag extends ArenaTag {
|
export class MistTag extends ArenaTag {
|
||||||
|
|
@ -169,6 +181,17 @@ class WishTag extends ArenaTag {
|
||||||
arena.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), this.healHp, null, true, false));
|
arena.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), this.healHp, null, true, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a WishTag or json representing one, load the data for it.
|
||||||
|
* @param {WishTag | any} source A WishTag
|
||||||
|
*/
|
||||||
|
loadTag(source: WishTag | any): void {
|
||||||
|
super.loadTag(source);
|
||||||
|
this.battlerIndex = source.battlerIndex as BattlerIndex;
|
||||||
|
this.triggerMessage = source.triggerMessage;
|
||||||
|
this.healHp = source.healHp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WeakenMoveTypeTag extends ArenaTag {
|
export class WeakenMoveTypeTag extends ArenaTag {
|
||||||
|
|
@ -188,6 +211,15 @@ export class WeakenMoveTypeTag extends ArenaTag {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a WeakenMoveTypeTag or json representing one, load the data for it.
|
||||||
|
* @param {WeakenMoveTypeTag | any} source A WeakenMoveTypeTag
|
||||||
|
*/
|
||||||
|
loadTag(source: WeakenMoveTypeTag | any): void {
|
||||||
|
super.loadTag(source);
|
||||||
|
this.weakenedType = source.weakenedType as Type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MudSportTag extends WeakenMoveTypeTag {
|
class MudSportTag extends WeakenMoveTypeTag {
|
||||||
|
|
@ -252,6 +284,16 @@ export class ArenaTrapTag extends ArenaTag {
|
||||||
getMatchupScoreMultiplier(pokemon: Pokemon): number {
|
getMatchupScoreMultiplier(pokemon: Pokemon): number {
|
||||||
return pokemon.isGrounded() ? 1 : Phaser.Math.Linear(0, 1 / Math.pow(2, this.layers), Math.min(pokemon.getHpRatio(), 0.5) * 2);
|
return pokemon.isGrounded() ? 1 : Phaser.Math.Linear(0, 1 / Math.pow(2, this.layers), Math.min(pokemon.getHpRatio(), 0.5) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an ArenaTrapTag or json representing one, load the data for it.
|
||||||
|
* @param {ArenaTrapTag | any} source An ArenaTrapTag
|
||||||
|
*/
|
||||||
|
loadTag(source: ArenaTrapTag | any): void {
|
||||||
|
super.loadTag(source);
|
||||||
|
this.layers = source.layers;
|
||||||
|
this.maxLayers = source.maxLayers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpikesTag extends ArenaTrapTag {
|
class SpikesTag extends ArenaTrapTag {
|
||||||
|
|
@ -331,6 +373,15 @@ class ToxicSpikesTag extends ArenaTrapTag {
|
||||||
return 1.25;
|
return 1.25;
|
||||||
return super.getMatchupScoreMultiplier(pokemon);
|
return super.getMatchupScoreMultiplier(pokemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a ToxicSpikesTag or json representing one, load the data for it.
|
||||||
|
* @param {ToxicSpikesTag | any} source A ToxicSpikesTag
|
||||||
|
*/
|
||||||
|
loadTag(source: ToxicSpikesTag | any): void {
|
||||||
|
super.loadTag(source);
|
||||||
|
this.neutralized = source.neutralized;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DelayedAttackTag extends ArenaTag {
|
class DelayedAttackTag extends ArenaTag {
|
||||||
|
|
@ -352,6 +403,15 @@ class DelayedAttackTag extends ArenaTag {
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(arena: Arena): void { }
|
onRemove(arena: Arena): void { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a DelayedAttackTag or json representing one, load the data for it.
|
||||||
|
* @param {DelayedAttackTag | any} source A DelayedAttackTag
|
||||||
|
*/
|
||||||
|
loadTag(source: DelayedAttackTag | any): void {
|
||||||
|
super.loadTag(source);
|
||||||
|
this.targetIndex = source.targetIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StealthRockTag extends ArenaTrapTag {
|
class StealthRockTag extends ArenaTrapTag {
|
||||||
|
|
@ -496,7 +556,7 @@ class TailwindTag extends ArenaTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMove: Moves, sourceId: integer, targetIndex?: BattlerIndex, side: ArenaTagSide = ArenaTagSide.BOTH): ArenaTag {
|
export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMove: Moves, sourceId: integer, side: ArenaTagSide = ArenaTagSide.BOTH, targetIndex?: BattlerIndex): ArenaTag {
|
||||||
switch (tagType) {
|
switch (tagType) {
|
||||||
case ArenaTagType.MIST:
|
case ArenaTagType.MIST:
|
||||||
return new MistTag(turnCount, sourceId, side);
|
return new MistTag(turnCount, sourceId, side);
|
||||||
|
|
@ -531,3 +591,14 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMov
|
||||||
return new TailwindTag(turnCount, sourceId, side);
|
return new TailwindTag(turnCount, sourceId, side);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When given an arena tag or json representing one, creates the actual ArenaTag object with the same data loaded.
|
||||||
|
* @param {ArenaTag | any} source An arena tag, or json representing one.
|
||||||
|
* @return {ArenaTag} The valid arena tag with correct data loaded.
|
||||||
|
*/
|
||||||
|
export function loadArenaTag(source: ArenaTag | any): ArenaTag {
|
||||||
|
const tag = getArenaTag(source.tagType, source.turnCount, source.sourceMove, source.sourceId, source.side, source?.targetIndex);
|
||||||
|
tag.loadTag(source);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
@ -497,7 +497,7 @@ export class Arena {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newTag = getArenaTag(tagType, turnCount || 0, sourceMove, sourceId, targetIndex, side);
|
const newTag = getArenaTag(tagType, turnCount || 0, sourceMove, sourceId, side, targetIndex);
|
||||||
this.tags.push(newTag);
|
this.tags.push(newTag);
|
||||||
newTag.onAdd(this);
|
newTag.onAdd(this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Arena } from "../field/arena";
|
import { Arena } from "../field/arena";
|
||||||
import { ArenaTag } from "../data/arena-tag";
|
import { ArenaTag, loadArenaTag } from "../data/arena-tag";
|
||||||
import { Biome } from "../data/enums/biome";
|
import { Biome } from "../data/enums/biome";
|
||||||
import { Weather } from "../data/weather";
|
import { Weather } from "../data/weather";
|
||||||
|
|
||||||
|
|
@ -12,6 +12,10 @@ export default class ArenaData {
|
||||||
const sourceArena = source instanceof Arena ? source as Arena : null;
|
const sourceArena = source instanceof Arena ? source as Arena : null;
|
||||||
this.biome = sourceArena ? sourceArena.biomeType : source.biome;
|
this.biome = sourceArena ? sourceArena.biomeType : source.biome;
|
||||||
this.weather = sourceArena ? sourceArena.weather : source.weather ? new Weather(source.weather.weatherType, source.weather.turnsLeft) : undefined;
|
this.weather = sourceArena ? sourceArena.weather : source.weather ? new Weather(source.weather.weatherType, source.weather.turnsLeft) : undefined;
|
||||||
this.tags = sourceArena ? sourceArena.tags : [];
|
const arenaTags: ArenaTag[] = sourceArena ? sourceArena.tags : source.tags;
|
||||||
|
this.tags = [];
|
||||||
|
for (let tag of arenaTags) {
|
||||||
|
this.tags.push(loadArenaTag(tag))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -688,8 +688,7 @@ export class GameData {
|
||||||
});
|
});
|
||||||
|
|
||||||
scene.arena.weather = sessionData.arena.weather;
|
scene.arena.weather = sessionData.arena.weather;
|
||||||
// TODO
|
scene.arena.tags = sessionData.arena.tags;
|
||||||
//scene.arena.tags = sessionData.arena.tags;
|
|
||||||
|
|
||||||
const modifiersModule = await import('../modifier/modifier');
|
const modifiersModule = await import('../modifier/modifier');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue