mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
[Refactor] Clean up some TODO
s from the strict-null
refactor (#4267)
This commit is contained in:
parent
e9ee2c1179
commit
8a8adad7fe
@ -123,6 +123,7 @@ export class Ability implements Localizable {
|
|||||||
type AbAttrApplyFunc<TAttr extends AbAttr> = (attr: TAttr, passive: boolean) => boolean | Promise<boolean>;
|
type AbAttrApplyFunc<TAttr extends AbAttr> = (attr: TAttr, passive: boolean) => boolean | Promise<boolean>;
|
||||||
type AbAttrCondition = (pokemon: Pokemon) => boolean;
|
type AbAttrCondition = (pokemon: Pokemon) => boolean;
|
||||||
|
|
||||||
|
// TODO: Can this be improved?
|
||||||
type PokemonAttackCondition = (user: Pokemon | null, target: Pokemon | null, move: Move) => boolean;
|
type PokemonAttackCondition = (user: Pokemon | null, target: Pokemon | null, move: Move) => boolean;
|
||||||
type PokemonDefendCondition = (target: Pokemon, user: Pokemon, move: Move) => boolean;
|
type PokemonDefendCondition = (target: Pokemon, user: Pokemon, move: Move) => boolean;
|
||||||
type PokemonStatStageChangeCondition = (target: Pokemon, statsChanged: BattleStat[], stages: number) => boolean;
|
type PokemonStatStageChangeCondition = (target: Pokemon, statsChanged: BattleStat[], stages: number) => boolean;
|
||||||
@ -2432,7 +2433,7 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
|
|||||||
pokemon.setStatStage(s, target.getStatStage(s));
|
pokemon.setStatStage(s, target.getStatStage(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
pokemon.summonData.moveset = target.getMoveset().map(m => new PokemonMove(m!.moveId, m!.ppUsed, m!.ppUp)); // TODO: are those bangs correct?
|
pokemon.summonData.moveset = target.getMoveset().map(m => new PokemonMove(m?.moveId ?? Moves.NONE, m?.ppUsed, m?.ppUp));
|
||||||
pokemon.summonData.types = target.getTypes();
|
pokemon.summonData.types = target.getTypes();
|
||||||
|
|
||||||
|
|
||||||
@ -3152,12 +3153,12 @@ export class ForewarnAbAttr extends PostSummonAbAttr {
|
|||||||
} else if (move?.getMove().power === -1) {
|
} else if (move?.getMove().power === -1) {
|
||||||
movePower = 80;
|
movePower = 80;
|
||||||
} else {
|
} else {
|
||||||
movePower = move!.getMove().power; // TODO: is this bang correct?
|
movePower = move?.getMove().power ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movePower > maxPowerSeen) {
|
if (movePower > maxPowerSeen) {
|
||||||
maxPowerSeen = movePower;
|
maxPowerSeen = movePower;
|
||||||
maxMove = move!.getName(); // TODO: is this bang correct?
|
maxMove = move?.getName() ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5175,8 +5176,7 @@ export function initAbilities() {
|
|||||||
.attr(IgnoreOpponentStatStagesAbAttr)
|
.attr(IgnoreOpponentStatStagesAbAttr)
|
||||||
.ignorable(),
|
.ignorable(),
|
||||||
new Ability(Abilities.TINTED_LENS, 4)
|
new Ability(Abilities.TINTED_LENS, 4)
|
||||||
//@ts-ignore
|
.attr(DamageBoostAbAttr, 2, (user, target, move) => (target?.getMoveEffectiveness(user!, move) ?? 1) <= 0.5),
|
||||||
.attr(DamageBoostAbAttr, 2, (user, target, move) => target?.getMoveEffectiveness(user, move) <= 0.5), // TODO: fix TS issues
|
|
||||||
new Ability(Abilities.FILTER, 4)
|
new Ability(Abilities.FILTER, 4)
|
||||||
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getMoveEffectiveness(user, move) >= 2, 0.75)
|
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getMoveEffectiveness(user, move) >= 2, 0.75)
|
||||||
.ignorable(),
|
.ignorable(),
|
||||||
@ -5294,8 +5294,9 @@ export function initAbilities() {
|
|||||||
.attr(WonderSkinAbAttr)
|
.attr(WonderSkinAbAttr)
|
||||||
.ignorable(),
|
.ignorable(),
|
||||||
new Ability(Abilities.ANALYTIC, 5)
|
new Ability(Abilities.ANALYTIC, 5)
|
||||||
//@ts-ignore
|
.attr(MovePowerBoostAbAttr, (user, target, move) =>
|
||||||
.attr(MovePowerBoostAbAttr, (user, target, move) => !!target?.getLastXMoves(1).find(m => m.turn === target?.scene.currentBattle.turn) || user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command !== Command.FIGHT, 1.3), // TODO fix TS issues
|
!!target?.getLastXMoves(1).find(m => m.turn === target?.scene.currentBattle.turn)
|
||||||
|
|| user?.scene.currentBattle.turnCommands[target?.getBattlerIndex() ?? BattlerIndex.ATTACKER]?.command !== Command.FIGHT, 1.3),
|
||||||
new Ability(Abilities.ILLUSION, 5)
|
new Ability(Abilities.ILLUSION, 5)
|
||||||
.attr(UncopiableAbilityAbAttr)
|
.attr(UncopiableAbilityAbAttr)
|
||||||
.attr(UnswappableAbilityAbAttr)
|
.attr(UnswappableAbilityAbAttr)
|
||||||
@ -5460,8 +5461,7 @@ export function initAbilities() {
|
|||||||
.bypassFaint()
|
.bypassFaint()
|
||||||
.partial(),
|
.partial(),
|
||||||
new Ability(Abilities.STAKEOUT, 7)
|
new Ability(Abilities.STAKEOUT, 7)
|
||||||
//@ts-ignore
|
.attr(MovePowerBoostAbAttr, (user, target, move) => user?.scene.currentBattle.turnCommands[target?.getBattlerIndex() ?? BattlerIndex.ATTACKER]?.command === Command.POKEMON, 2),
|
||||||
.attr(MovePowerBoostAbAttr, (user, target, move) => user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command === Command.POKEMON, 2), // TODO: fix TS issues
|
|
||||||
new Ability(Abilities.WATER_BUBBLE, 7)
|
new Ability(Abilities.WATER_BUBBLE, 7)
|
||||||
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
|
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
|
||||||
.attr(MoveTypePowerBoostAbAttr, Type.WATER, 2)
|
.attr(MoveTypePowerBoostAbAttr, Type.WATER, 2)
|
||||||
@ -5599,8 +5599,7 @@ export function initAbilities() {
|
|||||||
new Ability(Abilities.PRISM_ARMOR, 7)
|
new Ability(Abilities.PRISM_ARMOR, 7)
|
||||||
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getMoveEffectiveness(user, move) >= 2, 0.75),
|
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getMoveEffectiveness(user, move) >= 2, 0.75),
|
||||||
new Ability(Abilities.NEUROFORCE, 7)
|
new Ability(Abilities.NEUROFORCE, 7)
|
||||||
//@ts-ignore
|
.attr(MovePowerBoostAbAttr, (user, target, move) => (target?.getMoveEffectiveness(user!, move) ?? 1) >= 2, 1.25),
|
||||||
.attr(MovePowerBoostAbAttr, (user, target, move) => target?.getMoveEffectiveness(user, move) >= 2, 1.25), // TODO: fix TS issues
|
|
||||||
new Ability(Abilities.INTREPID_SWORD, 8)
|
new Ability(Abilities.INTREPID_SWORD, 8)
|
||||||
.attr(PostSummonStatStageChangeAbAttr, [ Stat.ATK ], 1, true)
|
.attr(PostSummonStatStageChangeAbAttr, [ Stat.ATK ], 1, true)
|
||||||
.condition(getOncePerBattleCondition(Abilities.INTREPID_SWORD)),
|
.condition(getOncePerBattleCondition(Abilities.INTREPID_SWORD)),
|
||||||
@ -5698,10 +5697,8 @@ export function initAbilities() {
|
|||||||
.attr(UserFieldStatusEffectImmunityAbAttr, StatusEffect.POISON, StatusEffect.TOXIC)
|
.attr(UserFieldStatusEffectImmunityAbAttr, StatusEffect.POISON, StatusEffect.TOXIC)
|
||||||
.ignorable(),
|
.ignorable(),
|
||||||
new Ability(Abilities.HUNGER_SWITCH, 8)
|
new Ability(Abilities.HUNGER_SWITCH, 8)
|
||||||
//@ts-ignore
|
.attr(PostTurnFormChangeAbAttr, p => p.getFormKey() ? 0 : 1)
|
||||||
.attr(PostTurnFormChangeAbAttr, p => p.getFormKey ? 0 : 1) // TODO: fix ts-ignore
|
.attr(PostTurnFormChangeAbAttr, p => p.getFormKey() ? 1 : 0)
|
||||||
//@ts-ignore
|
|
||||||
.attr(PostTurnFormChangeAbAttr, p => p.getFormKey ? 1 : 0) // TODO: fix ts-ignore
|
|
||||||
.attr(UncopiableAbilityAbAttr)
|
.attr(UncopiableAbilityAbAttr)
|
||||||
.attr(UnswappableAbilityAbAttr)
|
.attr(UnswappableAbilityAbAttr)
|
||||||
.attr(NoTransformAbilityAbAttr)
|
.attr(NoTransformAbilityAbAttr)
|
||||||
|
@ -4,7 +4,7 @@ import { SpeciesFormKey } from "./pokemon-species";
|
|||||||
import { StatusEffect } from "./status-effect";
|
import { StatusEffect } from "./status-effect";
|
||||||
import { MoveCategory, allMoves } from "./move";
|
import { MoveCategory, allMoves } from "./move";
|
||||||
import { Type } from "./type";
|
import { Type } from "./type";
|
||||||
import { Constructor } from "#app/utils";
|
import { Constructor, nil } from "#app/utils";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
@ -185,7 +185,7 @@ export class SpeciesFormChange {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
findTrigger(triggerType: Constructor<SpeciesFormChangeTrigger>): SpeciesFormChangeTrigger | null {
|
findTrigger(triggerType: Constructor<SpeciesFormChangeTrigger>): SpeciesFormChangeTrigger | nil {
|
||||||
if (!this.trigger.hasTriggerType(triggerType)) {
|
if (!this.trigger.hasTriggerType(triggerType)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ export class SpeciesFormChange {
|
|||||||
const trigger = this.trigger;
|
const trigger = this.trigger;
|
||||||
|
|
||||||
if (trigger instanceof SpeciesFormChangeCompoundTrigger) {
|
if (trigger instanceof SpeciesFormChangeCompoundTrigger) {
|
||||||
return trigger.triggers.find(t => t.hasTriggerType(triggerType))!; // TODO: is this bang correct?
|
return trigger.triggers.find(t => t.hasTriggerType(triggerType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return trigger;
|
return trigger;
|
||||||
@ -202,11 +202,11 @@ export class SpeciesFormChange {
|
|||||||
|
|
||||||
export class SpeciesFormChangeCondition {
|
export class SpeciesFormChangeCondition {
|
||||||
public predicate: SpeciesFormChangeConditionPredicate;
|
public predicate: SpeciesFormChangeConditionPredicate;
|
||||||
public enforceFunc: SpeciesFormChangeConditionEnforceFunc | null;
|
public enforceFunc: SpeciesFormChangeConditionEnforceFunc | nil;
|
||||||
|
|
||||||
constructor(predicate: SpeciesFormChangeConditionPredicate, enforceFunc?: SpeciesFormChangeConditionEnforceFunc) {
|
constructor(predicate: SpeciesFormChangeConditionPredicate, enforceFunc?: SpeciesFormChangeConditionEnforceFunc) {
|
||||||
this.predicate = predicate;
|
this.predicate = predicate;
|
||||||
this.enforceFunc = enforceFunc!; // TODO: is this bang correct?
|
this.enforceFunc = enforceFunc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import BattleScene from "#app/battle-scene";
|
import BattleScene from "#app/battle-scene";
|
||||||
import { TextStyle, addTextObject } from "#app/ui/text";
|
import { TextStyle, addTextObject } from "#app/ui/text";
|
||||||
|
import { nil } from "#app/utils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
export enum EventType {
|
export enum EventType {
|
||||||
@ -64,19 +65,19 @@ export class TimedEventManager {
|
|||||||
let multiplier = 1;
|
let multiplier = 1;
|
||||||
const shinyEvents = timedEvents.filter((te) => te.eventType === EventType.SHINY && this.isActive(te));
|
const shinyEvents = timedEvents.filter((te) => te.eventType === EventType.SHINY && this.isActive(te));
|
||||||
shinyEvents.forEach((se) => {
|
shinyEvents.forEach((se) => {
|
||||||
multiplier *= se.shinyMultiplier!; // TODO: is this bang correct?
|
multiplier *= se.shinyMultiplier ?? 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
return multiplier;
|
return multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEventBannerFilename(): string {
|
getEventBannerFilename(): string {
|
||||||
return timedEvents.find((te: TimedEvent) => this.isActive(te))?.bannerKey!; // TODO: is this bang correct?
|
return timedEvents.find((te: TimedEvent) => this.isActive(te))?.bannerKey ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TimedEventDisplay extends Phaser.GameObjects.Container {
|
export class TimedEventDisplay extends Phaser.GameObjects.Container {
|
||||||
private event: TimedEvent | null;
|
private event: TimedEvent | nil;
|
||||||
private eventTimerText: Phaser.GameObjects.Text;
|
private eventTimerText: Phaser.GameObjects.Text;
|
||||||
private banner: Phaser.GameObjects.Image;
|
private banner: Phaser.GameObjects.Image;
|
||||||
private bannerShadow: Phaser.GameObjects.Rectangle;
|
private bannerShadow: Phaser.GameObjects.Rectangle;
|
||||||
@ -84,7 +85,7 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
constructor(scene: BattleScene, x: number, y: number, event?: TimedEvent) {
|
constructor(scene: BattleScene, x: number, y: number, event?: TimedEvent) {
|
||||||
super(scene, x, y);
|
super(scene, x, y);
|
||||||
this.event = event!; // TODO: is this bang correct?
|
this.event = event;
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ import { MoneyFormat } from "#enums/money-format";
|
|||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
export type nil = null | undefined;
|
||||||
|
|
||||||
export const MissingTextureKey = "__MISSING";
|
export const MissingTextureKey = "__MISSING";
|
||||||
|
|
||||||
export function toReadableString(str: string): string {
|
export function toReadableString(str: string): string {
|
||||||
@ -443,7 +445,7 @@ export function deltaRgb(rgb1: integer[], rgb2: integer[]): integer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function rgbHexToRgba(hex: string) {
|
export function rgbHexToRgba(hex: string) {
|
||||||
const color = hex.match(/^([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i)!; // TODO: is this bang correct?
|
const color = hex.match(/^([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i) ?? ["000000", "00", "00", "00"];
|
||||||
return {
|
return {
|
||||||
r: parseInt(color[1], 16),
|
r: parseInt(color[1], 16),
|
||||||
g: parseInt(color[2], 16),
|
g: parseInt(color[2], 16),
|
||||||
|
Loading…
Reference in New Issue
Block a user