Compare commits

...

3 Commits

Author SHA1 Message Date
Greenlamp2
622885767d
Enforce Consistent Spacing with ESLint's space-before-blocks and keyword-spacing Rules (#1308)
* added rule no-trailing-spaces

* added rule space-before-block

* added rule keyword spacing
2024-05-23 19:19:20 -05:00
Greenlamp2
e2be6ba002
added rule no-trailing-spaces (#1307) 2024-05-23 18:45:04 -05:00
Franck TROUILLEZ
68e94845ab
Add BattleInfo to TargetSelectUiHandler to move when target selected (#1255)
This change allows to move the box containing the battle info of the ennemy pokemons during double battle when the user has to choose a target. In addition to the pokemon opacity constantly changing, the battle info will also move up and down to indicate which Pokemon is targeted.

It exposes the BattleInfo object from the Pokemon object through an accessor method.
2024-05-23 18:28:53 -04:00
117 changed files with 891 additions and 840 deletions

View File

@ -22,7 +22,13 @@
"@typescript-eslint/no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax
"brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors
"curly": ["error", "all"], // Enforces the use of curly braces for all control statements
"@typescript-eslint/brace-style": ["error", "1tbs"]
"@typescript-eslint/brace-style": ["error", "1tbs"],
"no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines
"skipBlankLines": false, // Enforces the rule even on blank lines
"ignoreComments": false // Enforces the rule on lines containing comments
}],
"space-before-blocks": ["error", "always"], // Enforces a space before blocks
"keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords
}
}
]

View File

@ -254,7 +254,7 @@ export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (pokemon.hp === pokemon.getMaxHp() &&
pokemon.getMaxHp() > 1 && //Checks if pokemon has wonder_guard (which forces 1hp)
(args[0] as Utils.NumberHolder).value >= pokemon.hp){ //Damage >= hp
(args[0] as Utils.NumberHolder).value >= pokemon.hp) { //Damage >= hp
return pokemon.addTag(BattlerTagType.STURDY, 1);
}
@ -499,11 +499,11 @@ export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr {
applyMoveAttrs(IncrementMovePriorityAttr,attacker,null,move.getMove(),attackPriority);
applyAbAttrs(IncrementMovePriorityAbAttr, attacker, null, move.getMove(), attackPriority);
if(move.getMove().moveTarget===MoveTarget.USER) {
if (move.getMove().moveTarget===MoveTarget.USER) {
return false;
}
if(attackPriority.value > 0 && !move.getMove().isMultiTarget()) {
if (attackPriority.value > 0 && !move.getMove().isMultiTarget()) {
cancelled.value = true;
return true;
}
@ -955,7 +955,7 @@ export class MoveTypeChangePowerMultiplierAbAttr extends VariableMoveTypeAbAttr
private newType: Type;
private powerMultiplier: number;
constructor(matchType: Type, newType: Type, powerMultiplier: number){
constructor(matchType: Type, newType: Type, powerMultiplier: number) {
super(true);
this.matchType = matchType;
this.newType = newType;
@ -986,7 +986,7 @@ export class MoveTypeChangeAttr extends PreAttackAbAttr {
private powerMultiplier: number;
private condition: PokemonAttackCondition;
constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition){
constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition) {
super(true);
this.newType = newType;
this.powerMultiplier = powerMultiplier;
@ -1015,7 +1015,7 @@ export class DamageBoostAbAttr extends PreAttackAbAttr {
private damageMultiplier: number;
private condition: PokemonAttackCondition;
constructor(damageMultiplier: number, condition: PokemonAttackCondition){
constructor(damageMultiplier: number, condition: PokemonAttackCondition) {
super(true);
this.damageMultiplier = damageMultiplier;
this.condition = condition;
@ -1860,7 +1860,7 @@ export class MultCritAbAttr extends AbAttr {
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const critMult = args[0] as Utils.NumberHolder;
if (critMult.value > 1){
if (critMult.value > 1) {
critMult.value *= this.multAmount;
return true;
}
@ -1892,7 +1892,7 @@ export class ConditionalCritAbAttr extends AbAttr {
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const target = (args[1] as Pokemon);
const move = (args[2] as Move);
if(!this.condition(pokemon,target,move)) {
if (!this.condition(pokemon,target,move)) {
return false;
}
@ -2410,8 +2410,8 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr {
*/
applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
let hadEffect: boolean = false;
for(const opp of pokemon.getOpponents()) {
if(opp.status !== undefined && opp.status.effect === StatusEffect.SLEEP) {
for (const opp of pokemon.getOpponents()) {
if (opp.status !== undefined && opp.status.effect === StatusEffect.SLEEP) {
opp.damageAndUpdate(Math.floor(Math.max(1, opp.getMaxHp() / 8)), HitResult.OTHER);
pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: `${getPokemonPrefix(opp)}${opp.name}`}));
hadEffect = true;
@ -2440,7 +2440,7 @@ export class FetchBallAbAttr extends PostTurnAbAttr {
*/
applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
const lastUsed = pokemon.scene.currentBattle.lastUsedPokeball;
if(lastUsed !== null && pokemon.isPlayer) {
if (lastUsed !== null && pokemon.isPlayer) {
pokemon.scene.pokeballCounts[lastUsed]++;
pokemon.scene.currentBattle.lastUsedPokeball = null;
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` found a\n${getPokeballName(lastUsed)}!`));
@ -2575,7 +2575,7 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr {
* @returns if enemy Pokemon is trapped or not
*/
applyCheckTrapped(pokemon: Pokemon, passive: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean {
if (otherPokemon.getTypes().includes(Type.GHOST)){
if (otherPokemon.getTypes().includes(Type.GHOST)) {
trapped.value = false;
return false;
}

View File

@ -236,7 +236,7 @@ export async function printPokemon() {
let generationIndex = 0;
if (!region) {
while (++generationIndex < 9 && dexId > generationDexNumbers[generationIndex]){}
while (++generationIndex < 9 && dexId > generationDexNumbers[generationIndex]) {}
} else {
generationIndex = regionalForms.indexOf(region.toLowerCase()) + 6;
}

View File

@ -178,7 +178,7 @@ export class FlinchedTag extends BattlerTag {
}
export class InterruptedTag extends BattlerTag {
constructor(sourceMove: Moves){
constructor(sourceMove: Moves) {
super(BattlerTagType.INTERRUPTED, BattlerTagLapseType.PRE_MOVE, 0, sourceMove);
}
@ -585,7 +585,7 @@ export class MinimizeTag extends BattlerTag {
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
//If a pokemon dynamaxes they lose minimized status
if(pokemon.isMax()){
if (pokemon.isMax()) {
return false;
}
return lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType);

View File

@ -137,7 +137,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
pokemon.battleData.berriesEaten.push(berryType);
}
const ppRestoreMove = pokemon.getMoveset().find(m => !m.getPpRatio()) ? pokemon.getMoveset().find(m => !m.getPpRatio()) : pokemon.getMoveset().find(m => m.getPpRatio() < 1);
if(ppRestoreMove !== undefined){
if (ppRestoreMove !== undefined) {
ppRestoreMove.ppUsed = Math.max(ppRestoreMove.ppUsed - 10, 0);
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` restored PP to its move ${ppRestoreMove.getName()}\nusing its ${getBerryName(berryType)}!`));
}

View File

@ -923,7 +923,7 @@ export class HalfSacrificialAttr extends MoveEffectAttr {
const cancelled = new Utils.BooleanHolder(false);
// Check to see if the Pokemon has an ability that blocks non-direct damage
applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled);
if (!cancelled.value){
if (!cancelled.value) {
user.damageAndUpdate(Math.ceil(user.getMaxHp()/2), HitResult.OTHER, false, true, true);
user.scene.queueMessage(getPokemonMessage(user, " cut its own HP to power up its move!")); // Queue recoil message
}
@ -1054,7 +1054,7 @@ export class IgnoreWeatherTypeDebuffAttr extends MoveAttr {
/** The {@linkcode WeatherType} this move ignores */
public weather: WeatherType;
constructor(weather: WeatherType){
constructor(weather: WeatherType) {
super();
this.weather = weather;
}
@ -1542,9 +1542,9 @@ export class EatBerryAttr extends MoveEffectAttr {
return false;
}
if(this.chosenBerry === undefined) { // if no berry has been provided, pick a random berry from their inventory
if (this.chosenBerry === undefined) { // if no berry has been provided, pick a random berry from their inventory
const heldBerries = this.getTargetHeldBerries(target);
if(heldBerries.length <= 0) {
if (heldBerries.length <= 0) {
return false;
}
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
@ -1555,7 +1555,7 @@ export class EatBerryAttr extends MoveEffectAttr {
const preserve = new Utils.BooleanHolder(false);
target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve);
if (!preserve.value){ // remove the eaten berry if not preserved
if (!preserve.value) { // remove the eaten berry if not preserved
if (!--this.chosenBerry.stackCount) {
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
}
@ -1592,7 +1592,7 @@ export class StealEatBerryAttr extends EatBerryAttr {
const cancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // check for abilities that block item theft
if(cancelled.value === true) {
if (cancelled.value === true) {
return false;
}
@ -2012,7 +2012,7 @@ export class PostVictoryStatChangeAttr extends MoveAttr {
this.showMessage = showMessage;
}
applyPostVictory(user: Pokemon, target: Pokemon, move: Move): void {
if(this.condition && !this.condition(user, target, move)) {
if (this.condition && !this.condition(user, target, move)) {
return false;
}
const statChangeAttr = new StatChangeAttr(this.stats, this.levels, this.showMessage);
@ -2257,7 +2257,7 @@ export class LessPPMorePowerAttr extends VariablePowerAttr {
let ppRemains = ppMax - ppUsed;
/** Reduce to 0 to avoid negative numbers if user has 1PP before attack and target has Ability.PRESSURE */
if(ppRemains < 0) {
if (ppRemains < 0) {
ppRemains = 0;
}
@ -2713,7 +2713,7 @@ export class PresentPowerAttr extends VariablePowerAttr {
export class KnockOffPowerAttr extends VariablePowerAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if(target.getHeldItems().length > 0){
if (target.getHeldItems().length > 0) {
(args[0] as Utils.NumberHolder).value *= 1.5;
return true;
}
@ -2744,7 +2744,7 @@ export class VariableAtkAttr extends MoveAttr {
}
export class TargetAtkUserAtkAttr extends VariableAtkAttr {
constructor(){
constructor() {
super();
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
@ -2831,7 +2831,7 @@ export class MinimizeAccuracyAttr extends VariableAccuracyAttr {
* @returns true if the function succeeds
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (target.getTag(BattlerTagType.MINIMIZED)){
if (target.getTag(BattlerTagType.MINIMIZED)) {
const accuracy = args[0] as Utils.NumberHolder;
accuracy.value = -1;
@ -3086,7 +3086,7 @@ export class TerrainPulseTypeAttr extends VariableMoveTypeAttr {
* @returns true if the function succeeds
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if(!user.isGrounded) {
if (!user.isGrounded) {
return false;
}
@ -3140,7 +3140,7 @@ export class MatchUserTypeAttr extends VariableMoveTypeAttr {
const userTypes = user.getTypes(true);
if(userTypes.includes(Type.STELLAR)) { // will not change to stellar type
if (userTypes.includes(Type.STELLAR)) { // will not change to stellar type
const nonTeraTypes = user.getTypes();
type.value = nonTeraTypes[0];
return true;
@ -3594,7 +3594,7 @@ export class ProtectAttr extends AddBattlerTagAttr {
while (moveHistory.length) {
turnMove = moveHistory.shift();
if(!allMoves[turnMove.move].getAttrs(ProtectAttr).length || turnMove.result !== MoveResult.SUCCESS) {
if (!allMoves[turnMove.move].getAttrs(ProtectAttr).length || turnMove.result !== MoveResult.SUCCESS) {
break;
}
timesUsed++;
@ -3746,7 +3746,7 @@ export class RemoveArenaTrapAttr extends MoveEffectAttr {
return false;
}
if(this.targetBothSides){
if (this.targetBothSides) {
user.scene.arena.removeTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER);
@ -3782,7 +3782,7 @@ export class RemoveScreensAttr extends MoveEffectAttr {
return false;
}
if(this.targetBothSides){
if (this.targetBothSides) {
user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, ArenaTagSide.PLAYER);
@ -3790,7 +3790,7 @@ export class RemoveScreensAttr extends MoveEffectAttr {
user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.ENEMY);
user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.ENEMY);
user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, ArenaTagSide.ENEMY);
} else{
} else {
user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
@ -3821,13 +3821,13 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise(resolve => {
// If user is player, checks if the user has fainted pokemon
if(user instanceof PlayerPokemon
if (user instanceof PlayerPokemon
&& user.scene.getParty().findIndex(p => p.isFainted())>-1) {
(user as PlayerPokemon).revivalBlessing().then(() => {
resolve(true);
});
// If user is enemy, checks that it is a trainer, and it has fainted non-boss pokemon in party
} else if(user instanceof EnemyPokemon
} else if (user instanceof EnemyPokemon
&& user.hasTrainer()
&& user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) {
// Selects a random fainted pokemon
@ -3838,11 +3838,11 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
pokemon.heal(Math.min(Math.max(Math.ceil(Math.floor(0.5 * pokemon.getMaxHp())), 1), pokemon.getMaxHp()));
user.scene.queueMessage(`${pokemon.name} was revived!`,0,true);
if(user.scene.currentBattle.double && user.scene.getEnemyParty().length > 1) {
if (user.scene.currentBattle.double && user.scene.getEnemyParty().length > 1) {
const allyPokemon = user.getAlly();
if(slotIndex<=1) {
if (slotIndex<=1) {
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, pokemon.getFieldIndex(), slotIndex, false, false, false));
} else if(allyPokemon.isFainted()){
} else if (allyPokemon.isFainted()) {
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, allyPokemon.getFieldIndex(), slotIndex, false, false,false));
}
}
@ -3855,7 +3855,7 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
}
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
if(user.hasTrainer() && user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) {
if (user.hasTrainer() && user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) {
return 20;
}
@ -3994,7 +3994,7 @@ export class RemoveTypeAttr extends MoveEffectAttr {
return false;
}
if(user.isTerastallized && user.getTeraType() === this.removedType) { // active tera types cannot be removed
if (user.isTerastallized && user.getTeraType() === this.removedType) { // active tera types cannot be removed
return false;
}
@ -4804,7 +4804,7 @@ export class FirstMoveCondition extends MoveCondition {
export class hitsSameTypeAttr extends VariableMoveTypeMultiplierAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder;
if (!user.getTypes().some(type => target.getTypes().includes(type))){
if (!user.getTypes().some(type => target.getTypes().includes(type))) {
multiplier.value = 0;
return true;
}

View File

@ -35,7 +35,7 @@ export enum Nature {
export function getNatureName(nature: Nature, includeStatEffects: boolean = false, forStarterSelect: boolean = false, ignoreBBCode: boolean = false, uiTheme: UiTheme = UiTheme.DEFAULT): string {
let ret = Utils.toReadableString(Nature[nature]);
//Translating nature
if(i18next.exists("nature:" + ret)){
if (i18next.exists("nature:" + ret)) {
ret = i18next.t("nature:" + ret as any);
}
if (includeStatEffects) {

View File

@ -549,7 +549,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
try {
sprite.play(key);
tintSprite.play(key);
} catch(error: unknown) {
} catch (error: unknown) {
console.error(`Couldn't play animation for '${key}'!\nIs the image for this Pokemon missing?\n`, error);
return false;
@ -1330,10 +1330,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
break;
}
let weight = levelMove[0];
if (weight === 0){ // Evo Moves
if (weight === 0) { // Evo Moves
weight = 50;
}
if (weight === 1 && allMoves[levelMove[1]].power >= 80){ // Assume level 1 moves with 80+ BP are "move reminder" moves and bump their weight
if (weight === 1 && allMoves[levelMove[1]].power >= 80) { // Assume level 1 moves with 80+ BP are "move reminder" moves and bump their weight
weight = 40;
}
if (allMoves[levelMove[1]].name.endsWith(" (N)")) {
@ -1379,7 +1379,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
}
const moveId = speciesEggMoves[this.species.getRootSpeciesId()][3];
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()){ // No rare egg moves before e4
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) { // No rare egg moves before e4
movePool.push([moveId, 30]);
}
if (this.fusionSpecies) {
@ -1390,14 +1390,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
}
const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][3];
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()){// No rare egg moves before e4
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) {// No rare egg moves before e4
movePool.push([moveId, 30]);
}
}
}
}
if (this.isBoss()){ // Bosses never get self ko moves
if (this.isBoss()) { // Bosses never get self ko moves
movePool = movePool.filter(m => !allMoves[m[0]].getAttrs(SacrificialAttr).length);
}
movePool = movePool.filter(m => !allMoves[m[0]].getAttrs(SacrificialAttrOnHit).length);
@ -1717,7 +1717,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (!isTypeImmune) {
damage.value = Math.ceil(((((2 * source.level / 5 + 2) * power.value * sourceAtk.value / targetDef.value) / 50) + 2) * stabMultiplier.value * typeMultiplier.value * arenaAttackTypeMultiplier.value * screenMultiplier.value * ((this.scene.randBattleSeedInt(15) + 85) / 100) * criticalMultiplier.value);
if (isPhysical && source.status && source.status.effect === StatusEffect.BURN) {
if(!move.getAttrs(BypassBurnDamageReductionAttr).length) {
if (!move.getAttrs(BypassBurnDamageReductionAttr).length) {
const burnDamageReductionCancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled);
if (!burnDamageReductionCancelled.value) {
@ -1878,7 +1878,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const surviveDamage = new Utils.BooleanHolder(false);
if (!preventEndure && this.hp - damage <= 0) {
if(this.hp >= 1 && this.getTag(BattlerTagType.ENDURING)) {
if (this.hp >= 1 && this.getTag(BattlerTagType.ENDURING)) {
surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING);
} else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) {
surviveDamage.value = this.lapseTag(BattlerTagType.STURDY);
@ -2072,7 +2072,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0);
this.generateName();
const abilityCount = this.getSpeciesForm().getAbilityCount();
if (this.abilityIndex >= abilityCount){// Shouldn't happen
if (this.abilityIndex >= abilityCount) {// Shouldn't happen
this.abilityIndex = abilityCount - 1;
}
this.scene.gameData.setPokemonSeen(this, false);
@ -2765,6 +2765,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.battleInfo?.destroy();
super.destroy();
}
getBattleInfo(): BattleInfo {
return this.battleInfo;
}
}
export default interface Pokemon {
@ -2916,9 +2920,9 @@ export class PlayerPokemon extends Pokemon {
revivalBlessing(): Promise<void> {
return new Promise(resolve => {
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => {
if(slotIndex >= 0 && slotIndex<6) {
if (slotIndex >= 0 && slotIndex<6) {
const pokemon = this.scene.getParty()[slotIndex];
if(!pokemon || !pokemon.isFainted()) {
if (!pokemon || !pokemon.isFainted()) {
resolve();
}
@ -2927,13 +2931,13 @@ export class PlayerPokemon extends Pokemon {
pokemon.heal(Math.min(Math.max(Math.ceil(Math.floor(0.5 * pokemon.getMaxHp())), 1), pokemon.getMaxHp()));
this.scene.queueMessage(`${pokemon.name} was revived!`,0,true);
if(this.scene.currentBattle.double && this.scene.getParty().length > 1) {
if (this.scene.currentBattle.double && this.scene.getParty().length > 1) {
const allyPokemon = this.getAlly();
if(slotIndex<=1) {
if (slotIndex<=1) {
// Revived ally pokemon
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), slotIndex, false, false, true));
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true));
} else if(allyPokemon.isFainted()) {
} else if (allyPokemon.isFainted()) {
// Revived party pokemon, and ally pokemon is fainted
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, allyPokemon.getFieldIndex(), slotIndex, false, false, true));
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true));
@ -2988,12 +2992,12 @@ export class PlayerPokemon extends Pokemon {
this.generateName();
if (!isFusion) {
const abilityCount = this.getSpeciesForm().getAbilityCount();
if (this.abilityIndex >= abilityCount){ // Shouldn't happen
if (this.abilityIndex >= abilityCount) { // Shouldn't happen
this.abilityIndex = abilityCount - 1;
}
} else {
const abilityCount = this.getFusionSpeciesForm().getAbilityCount();
if (this.fusionAbilityIndex >= abilityCount){// Shouldn't happen
if (this.fusionAbilityIndex >= abilityCount) {// Shouldn't happen
this.fusionAbilityIndex = abilityCount - 1;
}
}

View File

@ -1802,7 +1802,7 @@ export class CommandPhase extends FieldPhase {
console.log(moveTargets, playerPokemon.name);
if (moveTargets.targets.length <= 1 || moveTargets.multiple) {
turnCommand.move.targets = moveTargets.targets;
} else if(playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1) {
} else if (playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1) {
turnCommand.move.targets = playerPokemon.getMoveQueue()[0].targets;
} else {
this.scene.unshiftPhase(new SelectTargetPhase(this.scene, this.fieldIndex));
@ -1902,7 +1902,7 @@ export class CommandPhase extends FieldPhase {
this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true;
}
} else if (trapTag) {
if(trapTag.sourceMove === Moves.INGRAIN && this.scene.getPokemonById(trapTag.sourceId).isOfType(Type.GHOST)) {
if (trapTag.sourceMove === Moves.INGRAIN && this.scene.getPokemonById(trapTag.sourceId).isOfType(Type.GHOST)) {
success = true;
this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch
? { command: Command.POKEMON, cursor: cursor, args: args }
@ -2578,7 +2578,7 @@ export class MovePhase extends BattlePhase {
showMoveText(): void {
if (this.move.getMove().getAttrs(ChargeAttr).length) {
const lastMove = this.pokemon.getLastXMoves() as TurnMove[];
if (!lastMove.length || lastMove[0].move !== this.move.getMove().id || lastMove[0].result !== MoveResult.OTHER){
if (!lastMove.length || lastMove[0].move !== this.move.getMove().id || lastMove[0].result !== MoveResult.OTHER) {
this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500);
return;
}

View File

@ -908,7 +908,7 @@ export class GameData {
v = [];
}
for (const md of v) {
if(md?.className === "ExpBalanceModifier") { // Temporarily limit EXP Balance until it gets reworked
if (md?.className === "ExpBalanceModifier") { // Temporarily limit EXP Balance until it gets reworked
md.stackCount = Math.min(md.stackCount, 4);
}
ret.push(new PersistentModifierData(md, player));

View File

@ -79,7 +79,7 @@ describe("check if every variant's sprite are correctly set", () => {
}
} else if (!mlist.hasOwnProperty(name)) {
errors.push(`named - missing key ${name} in masterlist for ${trimmedFilePath}`);
}else {
} else {
const raw = fs.readFileSync(filePath, {encoding: "utf8", flag: "r"});
const data = JSON.parse(raw);
for (const key of Object.keys(data)) {

View File

@ -3,7 +3,7 @@ const path = require("path");
export function getAppRootDir () {
let currentDir = __dirname;
while(!fs.existsSync(path.join(currentDir, "package.json"))) {
while (!fs.existsSync(path.join(currentDir, "package.json"))) {
currentDir = path.join(currentDir, "..");
}
return currentDir;

View File

@ -12,6 +12,8 @@ import { BattleStat } from "#app/data/battle-stat";
const battleStatOrder = [ BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.ACC, BattleStat.EVA, BattleStat.SPD ];
export default class BattleInfo extends Phaser.GameObjects.Container {
private baseY: number;
private player: boolean;
private mini: boolean;
private boss: boolean;
@ -57,6 +59,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
constructor(scene: Phaser.Scene, x: number, y: number, player: boolean) {
super(scene, x, y);
this.baseY = y;
this.player = player;
this.mini = !player;
this.boss = false;
@ -417,6 +420,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.x += 10 * (offset === this.player ? 1 : -1);
this.y += 27 * (offset ? 1 : -1);
this.baseY = this.y;
}
updateInfo(pokemon: Pokemon, instant?: boolean): Promise<void> {
@ -655,6 +659,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.statNumbers[i].setFrame(battleStats[s].toString());
});
}
getBaseY(): number {
return this.baseY;
}
resetY(): void {
this.y = this.baseY;
}
}
export class PlayerBattleInfo extends BattleInfo {

View File

@ -107,7 +107,7 @@ export default class PartyUiHandler extends MessageUiHandler {
};
public static FilterFainted = (pokemon: PlayerPokemon) => {
if(!pokemon.isFainted()) {
if (!pokemon.isFainted()) {
return `${pokemon.name} still has energy\nto battle!`;
}
return null;
@ -423,13 +423,13 @@ export default class PartyUiHandler extends MessageUiHandler {
}
break;
case Button.RIGHT:
if (slotCount === battlerCount){
if (slotCount === battlerCount) {
success = this.setCursor(6);
break;
} else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1){
} else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1) {
success = this.setCursor(2);
break;
} else if (slotCount > battlerCount && this.cursor < battlerCount){
} else if (slotCount > battlerCount && this.cursor < battlerCount) {
success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount);
break;
}
@ -717,7 +717,7 @@ export default class PartyUiHandler extends MessageUiHandler {
case PartyOption.MOVE_3:
case PartyOption.MOVE_4:
const move = pokemon.moveset[option - PartyOption.MOVE_1];
if(this.showMovePp) {
if (this.showMovePp) {
const maxPP = move.getMovePp();
const currPP = maxPP - move.ppUsed;
optionName = `${move.getName()} ${currPP}/${maxPP}`;

View File

@ -1392,7 +1392,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
//Growth translate
let growthReadable = Utils.toReadableString(GrowthRate[species.growthRate]);
const growthAux = growthReadable.replace(" ", "_");
if(i18next.exists("growth:" + growthAux)){
if (i18next.exists("growth:" + growthAux)) {
growthReadable = i18next.t("growth:"+ growthAux as any);
}
this.pokemonGrowthRateText.setText(growthReadable);

View File

@ -310,7 +310,7 @@ export default class SummaryUiHandler extends UiHandler {
this.splicedIcon.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip());
}
if(this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) {
if (this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) {
this.championRibbon.setVisible(true);
} else {
this.championRibbon.setVisible(false);
@ -450,7 +450,7 @@ export default class SummaryUiHandler extends UiHandler {
case Button.LEFT:
this.moveSelect = false;
this.setCursor(Page.STATS);
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE){
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
this.hideMoveEffect();
this.destroyBlinkCursor();
success = true;
@ -623,7 +623,7 @@ export default class SummaryUiHandler extends UiHandler {
x: forward ? "-=214" : "+=214",
duration: 250,
onComplete: () => {
if (forward){
if (forward) {
this.populatePageContainer(this.summaryPageContainer);
if (this.cursor===Page.MOVES) {
this.moveCursorObj = null;
@ -1022,7 +1022,7 @@ export default class SummaryUiHandler extends UiHandler {
this.hideMoveEffect();
}
destroyBlinkCursor(){
destroyBlinkCursor() {
if (this.moveCursorBlinkTimer) {
this.moveCursorBlinkTimer.destroy();
this.moveCursorBlinkTimer = null;

View File

@ -16,6 +16,7 @@ export default class TargetSelectUiHandler extends UiHandler {
private targets: BattlerIndex[];
private targetFlashTween: Phaser.Tweens.Tween;
private targetBattleInfoMoveTween: Phaser.Tweens.Tween;
constructor(scene: BattleScene) {
super(scene, Mode.TARGET_SELECT);
@ -116,6 +117,25 @@ export default class TargetSelectUiHandler extends UiHandler {
}
});
if (this.targetBattleInfoMoveTween) {
this.targetBattleInfoMoveTween.stop();
const lastTarget = this.scene.getField()[lastCursor];
if (lastTarget) {
lastTarget.getBattleInfo().resetY();
}
}
const targetBattleInfo = target.getBattleInfo();
this.targetBattleInfoMoveTween = this.scene.tweens.add({
targets: [ targetBattleInfo ],
y: { start: targetBattleInfo.getBaseY(), to: targetBattleInfo.getBaseY() + 1 },
loop: -1,
duration: Utils.fixedInt(250),
ease: "Linear",
yoyo: true
});
return ret;
}
@ -128,6 +148,15 @@ export default class TargetSelectUiHandler extends UiHandler {
if (target) {
target.setAlpha(1);
}
const targetBattleInfo = target.getBattleInfo();
if (this.targetBattleInfoMoveTween) {
this.targetBattleInfoMoveTween.stop();
this.targetBattleInfoMoveTween = null;
}
if (targetBattleInfo) {
targetBattleInfo.resetY();
}
}
clear() {