Skip to content

Commit

Permalink
Add Documentation to Lapsing Modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
xsn34kzx committed Sep 6, 2024
1 parent 6ad7fea commit d44341d
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/modifier/modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,21 @@ export class AddVoucherModifier extends ConsumableModifier {
}
}

/**
* Modifier used for party-wide or passive items that start an initial
* {@linkcode battleCount} equal to {@linkcode maxBattles} that, for every
* battle, decrements. Typically, when {@linkcode battleCount} reaches 0, the
* modifier will be removed. If a modifier of the same type is to be added, it
* will reset {@linkcode battleCount} back to {@linkcode maxBattles} of the
* existing modifier instead of adding that modifier directly.
* @extends PersistentModifier
* @abstract
* @see {@linkcode add}
*/
export abstract class LapsingPersistentModifier extends PersistentModifier {
/** The maximum amount of battles the modifier will exist for */
private maxBattles: number;
/** The current amount of battles the modifier will exist for */
private battleCount: number;

constructor(type: ModifierTypes.ModifierType, maxBattles: number, battleCount?: number, stackCount?: integer) {
Expand Down Expand Up @@ -341,6 +354,7 @@ export abstract class LapsingPersistentModifier extends PersistentModifier {
// Linear interpolation on hue
const hue = Math.floor(120 * (this.battleCount / this.maxBattles) + 5);

// Generates the color hex code with a constant saturation and lightness but varying hue
const typeHex = Utils.hslToHex(hue, 0.50, 0.90);
const strokeHex = Utils.hslToHex(hue, 0.70, 0.30);

Expand Down Expand Up @@ -374,6 +388,12 @@ export abstract class LapsingPersistentModifier extends PersistentModifier {
}
}

/**
* Modifier used for passive items, specifically lures, that
* temporarily increases the chance of a double battle.
* @extends LapsingPersistentModifier
* @see {@linkcode apply}
*/
export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier {
constructor(type: ModifierType, maxBattles:number, battleCount?: number, stackCount?: integer) {
super(type, maxBattles, battleCount, stackCount);
Expand All @@ -389,8 +409,8 @@ export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier

/**
* Modifies the chance of a double battle occurring
* @param args A single element array containing the double battle chance as a NumberHolder
* @returns {boolean} Returns true if the modifier was applied
* @param args [0] {@linkcode Utils.NumberHolder} for double battle chance
* @returns true if the modifier was applied
*/
apply(args: any[]): boolean {
const doubleBattleChance = args[0] as Utils.NumberHolder;
Expand All @@ -410,16 +430,18 @@ export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier
* @see {@linkcode apply}
*/
export class TempStatStageBoosterModifier extends LapsingPersistentModifier {
/** The stat whose stat stage multiplier will be temporarily increased */
private stat: TempBattleStat;
private multiplierBoost: number;
/** The amount by which the stat stage itself or its multiplier will be increased by */
private boost: number;

constructor(type: ModifierType, stat: TempBattleStat, maxBattles: number, battleCount?: number, stackCount?: number) {
super(type, maxBattles, battleCount, stackCount);

this.stat = stat;
// Note that, because we want X Accuracy to maintain its original behavior,
// it will increment as it did previously, directly to the stat stage.
this.multiplierBoost = (stat !== Stat.ACC) ? 0.3 : 1;
this.boost = (stat !== Stat.ACC) ? 0.3 : 1;
}

match(modifier: Modifier): boolean {
Expand Down Expand Up @@ -450,12 +472,12 @@ export class TempStatStageBoosterModifier extends LapsingPersistentModifier {
}

/**
* Increases the incoming stat stage matching {@linkcode stat} by {@linkcode multiplierBoost}.
* Increases the incoming stat stage matching {@linkcode stat} by {@linkcode boost}.
* @param args [0] {@linkcode TempBattleStat} N/A
* [1] {@linkcode Utils.NumberHolder} that holds the resulting value of the stat stage multiplier
*/
apply(args: any[]): boolean {
(args[1] as Utils.NumberHolder).value += this.multiplierBoost;
(args[1] as Utils.NumberHolder).value += this.boost;
return true;
}
}
Expand Down

0 comments on commit d44341d

Please sign in to comment.