Skip to content

Commit

Permalink
Merge branch 'beta' into hijinks
Browse files Browse the repository at this point in the history
  • Loading branch information
damocleas authored Feb 6, 2025
2 parents 81c70f8 + a7aebb0 commit 7f276a1
Show file tree
Hide file tree
Showing 132 changed files with 1,183 additions and 964 deletions.
4 changes: 2 additions & 2 deletions docs/enemy-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ As part of the move selection process, the enemy Pokémon must compute a **targe
A move's UBS and TBS are computed with the respective functions in the `Move` class:

```ts
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer;
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer;
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): number;
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number;
```

Logically, these functions are very similar – they add up their respective benefit scores from each of the move's attributes (as determined by `attr.getUserBenefitScore`, and `attr.getTargetBenefitScore`, respectively) and return the total benefit score. However, there are two key functional differences in how the UBS and TBS of a move are handled:
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,5 @@
},
"engines": {
"node": ">=20.0.0"
},
"imports": {
"#enums/*": "./enums/*",
"#app": "./src/main.js",
"#app/*": "./src/*",
"#test/*": "./src/test/*"
}
}
4 changes: 2 additions & 2 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function initLoggedInUser(): void {
loggedInUser = { username: "Guest", lastSessionSlot: -1, discordId: "", googleId: "", hasAdminRole: false };
}

export function updateUserInfo(): Promise<[boolean, integer]> {
return new Promise<[boolean, integer]>(resolve => {
export function updateUserInfo(): Promise<[boolean, number]> {
return new Promise<[boolean, number]>(resolve => {
if (bypassLogin) {
loggedInUser = { username: "Guest", lastSessionSlot: -1, discordId: "", googleId: "", hasAdminRole: false };
let lastSessionSlot = -1;
Expand Down
98 changes: 49 additions & 49 deletions src/battle-scene.ts

Large diffs are not rendered by default.

115 changes: 57 additions & 58 deletions src/data/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export class Ability implements Localizable {
private nameAppend: string;
public name: string;
public description: string;
public generation: integer;
public generation: number;
public isBypassFaint: boolean;
public isIgnorable: boolean;
public attrs: AbAttr[];
public conditions: AbAttrCondition[];

constructor(id: Abilities, generation: integer) {
constructor(id: Abilities, generation: number) {
this.id = id;

this.nameAppend = "";
Expand Down Expand Up @@ -221,9 +221,9 @@ export class PostBattleInitAbAttr extends AbAttr {
}

export class PostBattleInitFormChangeAbAttr extends PostBattleInitAbAttr {
private formFunc: (p: Pokemon) => integer;
private formFunc: (p: Pokemon) => number;

constructor(formFunc: ((p: Pokemon) => integer)) {
constructor(formFunc: ((p: Pokemon) => number)) {
super(true);

this.formFunc = formFunc;
Expand Down Expand Up @@ -491,9 +491,9 @@ class TypeImmunityStatStageChangeAbAttr extends TypeImmunityAbAttr {

class TypeImmunityAddBattlerTagAbAttr extends TypeImmunityAbAttr {
private tagType: BattlerTagType;
private turnCount: integer;
private turnCount: number;

constructor(immuneType: Type, tagType: BattlerTagType, turnCount: integer, condition?: AbAttrCondition) {
constructor(immuneType: Type, tagType: BattlerTagType, turnCount: number, condition?: AbAttrCondition) {
super(immuneType, condition);

this.tagType = tagType;
Expand Down Expand Up @@ -605,7 +605,7 @@ export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr {
}

export class PostStatStageChangeAbAttr extends AbAttr {
applyPostStatStageChange(pokemon: Pokemon, simulated: boolean, statsChanged: BattleStat[], stagesChanged: integer, selfTarget: boolean, args: any[]): boolean | Promise<boolean> {
applyPostStatStageChange(pokemon: Pokemon, simulated: boolean, statsChanged: BattleStat[], stagesChanged: number, selfTarget: boolean, args: any[]): boolean | Promise<boolean> {
return false;
}
}
Expand Down Expand Up @@ -866,10 +866,10 @@ export class PostDefendTerrainChangeAbAttr extends PostDefendAbAttr {
}

export class PostDefendContactApplyStatusEffectAbAttr extends PostDefendAbAttr {
public chance: integer;
public chance: number;
private effects: StatusEffect[];

constructor(chance: integer, ...effects: StatusEffect[]) {
constructor(chance: number, ...effects: StatusEffect[]) {
super();

this.chance = chance;
Expand Down Expand Up @@ -905,11 +905,11 @@ export class EffectSporeAbAttr extends PostDefendContactApplyStatusEffectAbAttr
}

export class PostDefendContactApplyTagChanceAbAttr extends PostDefendAbAttr {
private chance: integer;
private chance: number;
private tagType: BattlerTagType;
private turnCount: integer | undefined;
private turnCount: number | undefined;

constructor(chance: integer, tagType: BattlerTagType, turnCount?: integer) {
constructor(chance: number, tagType: BattlerTagType, turnCount?: number) {
super();

this.tagType = tagType;
Expand Down Expand Up @@ -959,9 +959,9 @@ export class PostDefendCritStatStageChangeAbAttr extends PostDefendAbAttr {
}

export class PostDefendContactDamageAbAttr extends PostDefendAbAttr {
private damageRatio: integer;
private damageRatio: number;

constructor(damageRatio: integer) {
constructor(damageRatio: number) {
super();

this.damageRatio = damageRatio;
Expand Down Expand Up @@ -993,9 +993,9 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr {
* @extends {PostDefendAbAttr}
*/
export class PostDefendPerishSongAbAttr extends PostDefendAbAttr {
private turns: integer;
private turns: number;

constructor(turns: integer) {
constructor(turns: number) {
super();

this.turns = turns;
Expand Down Expand Up @@ -1101,11 +1101,11 @@ export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr {
}

export class PostDefendMoveDisableAbAttr extends PostDefendAbAttr {
private chance: integer;
private chance: number;
private attacker: Pokemon;
private move: Move;

constructor(chance: integer) {
constructor(chance: number) {
super();

this.chance = chance;
Expand Down Expand Up @@ -1688,10 +1688,10 @@ export class PostAttackStealHeldItemAbAttr extends PostAttackAbAttr {

export class PostAttackApplyStatusEffectAbAttr extends PostAttackAbAttr {
private contactRequired: boolean;
private chance: integer;
private chance: number;
private effects: StatusEffect[];

constructor(contactRequired: boolean, chance: integer, ...effects: StatusEffect[]) {
constructor(contactRequired: boolean, chance: number, ...effects: StatusEffect[]) {
super();

this.contactRequired = contactRequired;
Expand All @@ -1715,18 +1715,18 @@ export class PostAttackApplyStatusEffectAbAttr extends PostAttackAbAttr {
}

export class PostAttackContactApplyStatusEffectAbAttr extends PostAttackApplyStatusEffectAbAttr {
constructor(chance: integer, ...effects: StatusEffect[]) {
constructor(chance: number, ...effects: StatusEffect[]) {
super(true, chance, ...effects);
}
}

export class PostAttackApplyBattlerTagAbAttr extends PostAttackAbAttr {
private contactRequired: boolean;
private chance: (user: Pokemon, target: Pokemon, move: Move) => integer;
private chance: (user: Pokemon, target: Pokemon, move: Move) => number;
private effects: BattlerTagType[];


constructor(contactRequired: boolean, chance: (user: Pokemon, target: Pokemon, move: Move) => integer, ...effects: BattlerTagType[]) {
constructor(contactRequired: boolean, chance: (user: Pokemon, target: Pokemon, move: Move) => number, ...effects: BattlerTagType[]) {
super();

this.contactRequired = contactRequired;
Expand Down Expand Up @@ -1863,9 +1863,9 @@ class PostVictoryStatStageChangeAbAttr extends PostVictoryAbAttr {
}

export class PostVictoryFormChangeAbAttr extends PostVictoryAbAttr {
private formFunc: (p: Pokemon) => integer;
private formFunc: (p: Pokemon) => number;

constructor(formFunc: ((p: Pokemon) => integer)) {
constructor(formFunc: ((p: Pokemon) => number)) {
super(true);

this.formFunc = formFunc;
Expand Down Expand Up @@ -2081,9 +2081,9 @@ export class PostSummonUnnamedMessageAbAttr extends PostSummonAbAttr {

export class PostSummonAddBattlerTagAbAttr extends PostSummonAbAttr {
private tagType: BattlerTagType;
private turnCount: integer;
private turnCount: number;

constructor(tagType: BattlerTagType, turnCount: integer, showAbility?: boolean) {
constructor(tagType: BattlerTagType, turnCount: number, showAbility?: boolean) {
super(showAbility);

this.tagType = tagType;
Expand Down Expand Up @@ -2209,9 +2209,9 @@ export class PostSummonClearAllyStatStagesAbAttr extends PostSummonAbAttr {
* @see {applyPostSummon}
*/
export class DownloadAbAttr extends PostSummonAbAttr {
private enemyDef: integer;
private enemySpDef: integer;
private enemyCountTally: integer;
private enemyDef: number;
private enemySpDef: number;
private enemyCountTally: number;
private stats: BattleStat[];

/**
Expand Down Expand Up @@ -2295,9 +2295,9 @@ export class PostSummonTerrainChangeAbAttr extends PostSummonAbAttr {
}

export class PostSummonFormChangeAbAttr extends PostSummonAbAttr {
private formFunc: (p: Pokemon) => integer;
private formFunc: (p: Pokemon) => number;

constructor(formFunc: ((p: Pokemon) => integer)) {
constructor(formFunc: ((p: Pokemon) => number)) {
super(true);

this.formFunc = formFunc;
Expand Down Expand Up @@ -2715,9 +2715,9 @@ export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr {
* @see {@linkcode applyPreSwitchOut}
*/
export class PreSwitchOutFormChangeAbAttr extends PreSwitchOutAbAttr {
private formFunc: (p: Pokemon) => integer;
private formFunc: (p: Pokemon) => number;

constructor(formFunc: ((p: Pokemon) => integer)) {
constructor(formFunc: ((p: Pokemon) => number)) {
super();

this.formFunc = formFunc;
Expand Down Expand Up @@ -2861,7 +2861,7 @@ export class PreSetStatusEffectImmunityAbAttr extends PreSetStatusAbAttr {
* @returns A boolean indicating the result of the status application.
*/
applyPreSetStatus(pokemon: Pokemon, passive: boolean, simulated: boolean, effect: StatusEffect, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (this.immuneEffects.length < 1 || this.immuneEffects.includes(effect)) {
if (effect !== StatusEffect.FAINT && this.immuneEffects.length < 1 || this.immuneEffects.includes(effect)) {
cancelled.value = true;
return true;
}
Expand Down Expand Up @@ -3338,10 +3338,10 @@ export class PostWeatherChangeFormChangeAbAttr extends PostWeatherChangeAbAttr {

export class PostWeatherChangeAddBattlerTagAttr extends PostWeatherChangeAbAttr {
private tagType: BattlerTagType;
private turnCount: integer;
private turnCount: number;
private weatherTypes: WeatherType[];

constructor(tagType: BattlerTagType, turnCount: integer, ...weatherTypes: WeatherType[]) {
constructor(tagType: BattlerTagType, turnCount: number, ...weatherTypes: WeatherType[]) {
super();

this.tagType = tagType;
Expand Down Expand Up @@ -3382,9 +3382,9 @@ export class PostWeatherLapseAbAttr extends AbAttr {
}

export class PostWeatherLapseHealAbAttr extends PostWeatherLapseAbAttr {
private healFactor: integer;
private healFactor: number;

constructor(healFactor: integer, ...weatherTypes: WeatherType[]) {
constructor(healFactor: number, ...weatherTypes: WeatherType[]) {
super(...weatherTypes);

this.healFactor = healFactor;
Expand All @@ -3405,9 +3405,9 @@ export class PostWeatherLapseHealAbAttr extends PostWeatherLapseAbAttr {
}

export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr {
private damageFactor: integer;
private damageFactor: number;

constructor(damageFactor: integer, ...weatherTypes: WeatherType[]) {
constructor(damageFactor: number, ...weatherTypes: WeatherType[]) {
super(...weatherTypes);

this.damageFactor = damageFactor;
Expand Down Expand Up @@ -3436,10 +3436,10 @@ export class PostTerrainChangeAbAttr extends AbAttr {

export class PostTerrainChangeAddBattlerTagAttr extends PostTerrainChangeAbAttr {
private tagType: BattlerTagType;
private turnCount: integer;
private turnCount: number;
private terrainTypes: TerrainType[];

constructor(tagType: BattlerTagType, turnCount: integer, ...terrainTypes: TerrainType[]) {
constructor(tagType: BattlerTagType, turnCount: number, ...terrainTypes: TerrainType[]) {
super();

this.tagType = tagType;
Expand Down Expand Up @@ -3692,9 +3692,9 @@ export class PostTurnHealAbAttr extends PostTurnAbAttr {
}

export class PostTurnFormChangeAbAttr extends PostTurnAbAttr {
private formFunc: (p: Pokemon) => integer;
private formFunc: (p: Pokemon) => number;

constructor(formFunc: ((p: Pokemon) => integer)) {
constructor(formFunc: ((p: Pokemon) => number)) {
super(true);

this.formFunc = formFunc;
Expand Down Expand Up @@ -3916,9 +3916,9 @@ export class PostItemLostApplyBattlerTagAbAttr extends PostItemLostAbAttr {
}

export class StatStageChangeMultiplierAbAttr extends AbAttr {
private multiplier: integer;
private multiplier: number;

constructor(multiplier: integer) {
constructor(multiplier: number) {
super(true);

this.multiplier = multiplier;
Expand Down Expand Up @@ -4225,9 +4225,9 @@ export class PostFaintClearWeatherAbAttr extends PostFaintAbAttr {
}

export class PostFaintContactDamageAbAttr extends PostFaintAbAttr {
private damageRatio: integer;
private damageRatio: number;

constructor(damageRatio: integer) {
constructor(damageRatio: number) {
super();

this.damageRatio = damageRatio;
Expand Down Expand Up @@ -4404,9 +4404,9 @@ export class ReduceBerryUseThresholdAbAttr extends AbAttr {
* Used for Heavy Metal (doubling weight) and Light Metal (halving weight)
*/
export class WeightMultiplierAbAttr extends AbAttr {
private multiplier: integer;
private multiplier: number;

constructor(multiplier: integer) {
constructor(multiplier: number) {
super();

this.multiplier = multiplier;
Expand Down Expand Up @@ -4700,12 +4700,12 @@ export class FormBlockDamageAbAttr extends ReceivedMoveDamageMultiplierAbAttr {
* @extends AbAttr
*/
export class BypassSpeedChanceAbAttr extends AbAttr {
public chance: integer;
public chance: number;

/**
* @param {integer} chance probability of ability being active.
* @param {number} chance probability of ability being active.
*/
constructor(chance: integer) {
constructor(chance: number) {
super(true);
this.chance = chance;
}
Expand Down Expand Up @@ -5235,7 +5235,7 @@ export function applyPreStatStageChangeAbAttrs(attrType: Constructor<PreStatStag
}

export function applyPostStatStageChangeAbAttrs(attrType: Constructor<PostStatStageChangeAbAttr>,
pokemon: Pokemon, stats: BattleStat[], stages: integer, selfTarget: boolean, simulated: boolean = false, ...args: any[]): Promise<void> {
pokemon: Pokemon, stats: BattleStat[], stages: number, selfTarget: boolean, simulated: boolean = false, ...args: any[]): Promise<void> {
return applyAbAttrsInternal<PostStatStageChangeAbAttr>(attrType, pokemon, (attr, _passive) => attr.applyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), args, false, simulated);
}

Expand Down Expand Up @@ -6289,9 +6289,8 @@ export function initAbilities() {
.attr(NoTransformAbilityAbAttr)
.partial(), // While setting the tag, the getbattlestat should ignore all modifiers to stats except stat stages
new Ability(Abilities.GOOD_AS_GOLD, 9)
.attr(MoveImmunityAbAttr, (pokemon, attacker, move) => pokemon !== attacker && move.category === MoveCategory.STATUS)
.ignorable()
.partial(), // Lots of weird interactions with moves and abilities such as negating status moves that target the field
.attr(MoveImmunityAbAttr, (pokemon, attacker, move) => pokemon !== attacker && move.category === MoveCategory.STATUS && ![ MoveTarget.ENEMY_SIDE, MoveTarget.BOTH_SIDES, MoveTarget.USER_SIDE ].includes(move.moveTarget))
.ignorable(),
new Ability(Abilities.VESSEL_OF_RUIN, 9)
.attr(FieldMultiplyStatAbAttr, Stat.SPATK, 0.75)
.attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonVesselOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: i18next.t(getStatKey(Stat.SPATK)) }))
Expand Down
Loading

0 comments on commit 7f276a1

Please sign in to comment.