2023-04-20 15:46:05 -04:00
|
|
|
import * as Utils from "../utils";
|
2023-04-11 19:08:03 -04:00
|
|
|
|
2023-04-03 23:38:31 -04:00
|
|
|
export enum StatusEffect {
|
|
|
|
NONE,
|
|
|
|
POISON,
|
|
|
|
TOXIC,
|
|
|
|
PARALYSIS,
|
|
|
|
SLEEP,
|
|
|
|
FREEZE,
|
2023-04-16 18:40:32 -04:00
|
|
|
BURN,
|
|
|
|
FAINT
|
2023-04-03 23:38:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Status {
|
2023-04-11 19:08:03 -04:00
|
|
|
public effect: StatusEffect;
|
2023-04-03 23:38:31 -04:00
|
|
|
public turnCount: integer;
|
2023-04-11 19:08:03 -04:00
|
|
|
public cureTurn: integer;
|
|
|
|
|
2024-01-02 21:31:59 -05:00
|
|
|
constructor(effect: StatusEffect, turnCount: integer = 0, cureTurn?: integer) {
|
2023-04-11 19:08:03 -04:00
|
|
|
this.effect = effect;
|
2023-04-28 15:03:42 -04:00
|
|
|
this.turnCount = turnCount === undefined ? 0 : turnCount;
|
2024-01-02 21:31:59 -05:00
|
|
|
this.cureTurn = cureTurn;
|
2023-04-11 19:08:03 -04:00
|
|
|
}
|
2023-04-03 23:38:31 -04:00
|
|
|
|
2023-04-11 19:08:03 -04:00
|
|
|
incrementTurn(): void {
|
|
|
|
this.turnCount++;
|
2023-04-03 23:38:31 -04:00
|
|
|
}
|
2023-04-11 19:08:03 -04:00
|
|
|
|
|
|
|
isPostTurn(): boolean {
|
|
|
|
return this.effect === StatusEffect.POISON || this.effect === StatusEffect.TOXIC || this.effect === StatusEffect.BURN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-24 14:30:21 -04:00
|
|
|
export function getStatusEffectObtainText(statusEffect: StatusEffect, sourceText?: string): string {
|
|
|
|
const sourceClause = sourceText ? ` ${statusEffect !== StatusEffect.SLEEP ? 'by' : 'from'} ${sourceText}` : '';
|
2023-04-11 19:08:03 -04:00
|
|
|
switch (statusEffect) {
|
|
|
|
case StatusEffect.POISON:
|
2023-04-24 14:30:21 -04:00
|
|
|
return `\nwas poisoned${sourceClause}!`;
|
2023-04-11 19:08:03 -04:00
|
|
|
case StatusEffect.TOXIC:
|
2023-04-24 14:30:21 -04:00
|
|
|
return `\nwas badly poisoned${sourceClause}!`;
|
2023-04-11 19:08:03 -04:00
|
|
|
case StatusEffect.PARALYSIS:
|
2023-04-24 14:30:21 -04:00
|
|
|
return ` was paralyzed${sourceClause}!\nIt may be unable to move!`;
|
2023-04-11 19:08:03 -04:00
|
|
|
case StatusEffect.SLEEP:
|
2023-04-24 14:30:21 -04:00
|
|
|
return `\nfell asleep${sourceClause}!`;
|
2023-04-11 19:08:03 -04:00
|
|
|
case StatusEffect.FREEZE:
|
2023-04-24 14:30:21 -04:00
|
|
|
return `\nwas frozen solid${sourceClause}!`;
|
2023-04-11 19:08:03 -04:00
|
|
|
case StatusEffect.BURN:
|
2023-04-24 14:30:21 -04:00
|
|
|
return `\nwas burned${sourceClause}!`;
|
2023-04-11 19:08:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getStatusEffectActivationText(statusEffect: StatusEffect): string {
|
|
|
|
switch (statusEffect) {
|
|
|
|
case StatusEffect.POISON:
|
|
|
|
case StatusEffect.TOXIC:
|
|
|
|
return ' is hurt\nby poison!';
|
|
|
|
case StatusEffect.PARALYSIS:
|
|
|
|
return ' is paralyzed!\nIt can\'t move!';
|
|
|
|
case StatusEffect.SLEEP:
|
|
|
|
return ' is fast asleep.';
|
|
|
|
case StatusEffect.FREEZE:
|
|
|
|
return ' is\nfrozen solid!';
|
|
|
|
case StatusEffect.BURN:
|
|
|
|
return ' is hurt\nby its burn!';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getStatusEffectOverlapText(statusEffect: StatusEffect): string {
|
|
|
|
switch (statusEffect) {
|
|
|
|
case StatusEffect.POISON:
|
|
|
|
case StatusEffect.TOXIC:
|
|
|
|
return ' is\nalready poisoned!';
|
|
|
|
case StatusEffect.PARALYSIS:
|
|
|
|
return ' is\nalready paralyzed!';
|
|
|
|
case StatusEffect.SLEEP:
|
|
|
|
return ' is\nalready asleep!';
|
|
|
|
case StatusEffect.FREEZE:
|
|
|
|
return ' is\nalready frozen!';
|
|
|
|
case StatusEffect.BURN:
|
|
|
|
return ' is\nalready burned!';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2023-04-20 19:44:56 -04:00
|
|
|
export function getStatusEffectHealText(statusEffect: StatusEffect): string {
|
2023-04-11 19:08:03 -04:00
|
|
|
switch (statusEffect) {
|
|
|
|
case StatusEffect.POISON:
|
|
|
|
case StatusEffect.TOXIC:
|
|
|
|
return ' was\ncured of its poison!';
|
|
|
|
case StatusEffect.PARALYSIS:
|
|
|
|
return ' was\nhealed of paralysis!';
|
|
|
|
case StatusEffect.SLEEP:
|
|
|
|
return ' woke up!';
|
|
|
|
case StatusEffect.FREEZE:
|
|
|
|
return ' was\ndefrosted!';
|
|
|
|
case StatusEffect.BURN:
|
2023-04-20 22:26:38 -04:00
|
|
|
return ' was\nhealed of its burn!';
|
2023-04-11 19:08:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
2023-04-18 22:09:37 -04:00
|
|
|
}
|
|
|
|
|
2023-04-20 19:44:56 -04:00
|
|
|
export function getStatusEffectDescriptor(statusEffect: StatusEffect): string {
|
2023-04-19 16:52:14 -04:00
|
|
|
switch (statusEffect) {
|
|
|
|
case StatusEffect.POISON:
|
|
|
|
case StatusEffect.TOXIC:
|
|
|
|
return 'poisoning';
|
|
|
|
case StatusEffect.PARALYSIS:
|
|
|
|
return 'paralysis';
|
|
|
|
case StatusEffect.SLEEP:
|
|
|
|
return 'sleep';
|
|
|
|
case StatusEffect.FREEZE:
|
|
|
|
return 'freezing';
|
|
|
|
case StatusEffect.BURN:
|
|
|
|
return 'burn';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-20 19:44:56 -04:00
|
|
|
export function getStatusEffectCatchRateMultiplier(statusEffect: StatusEffect): number {
|
2023-04-18 22:09:37 -04:00
|
|
|
switch (statusEffect) {
|
|
|
|
case StatusEffect.POISON:
|
|
|
|
case StatusEffect.TOXIC:
|
|
|
|
case StatusEffect.PARALYSIS:
|
|
|
|
case StatusEffect.BURN:
|
|
|
|
return 1.5;
|
|
|
|
case StatusEffect.SLEEP:
|
|
|
|
case StatusEffect.FREEZE:
|
|
|
|
return 2.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2024-05-04 22:16:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a random non-volatile StatusEffect
|
|
|
|
*/
|
|
|
|
export function generateRandomStatusEffect(): StatusEffect {
|
|
|
|
return Utils.randIntRange(1, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a random non-volatile StatusEffect between the two provided
|
|
|
|
* @param statusEffectA The first StatusEffect
|
|
|
|
* @param statusEffectA The second StatusEffect
|
|
|
|
*/
|
|
|
|
export function getRandomStatusEffect(statusEffectA: StatusEffect, statusEffectB: StatusEffect): StatusEffect {
|
|
|
|
if (statusEffectA === StatusEffect.NONE || statusEffectA === StatusEffect.FAINT) {
|
|
|
|
return statusEffectB;
|
|
|
|
}
|
|
|
|
if (statusEffectB === StatusEffect.NONE || statusEffectB === StatusEffect.FAINT) {
|
|
|
|
return statusEffectA;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Utils.randIntRange(0, 2) ? statusEffectA : statusEffectB;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a random non-volatile StatusEffect between the two provided
|
|
|
|
* @param statusA The first Status
|
|
|
|
* @param statusB The second Status
|
|
|
|
*/
|
|
|
|
export function getRandomStatus(statusA: Status, statusB: Status): Status {
|
|
|
|
if (statusA === undefined || statusA.effect === StatusEffect.NONE || statusA.effect === StatusEffect.FAINT) {
|
|
|
|
return statusB;
|
|
|
|
}
|
|
|
|
if (statusB === undefined || statusB.effect === StatusEffect.NONE || statusB.effect === StatusEffect.FAINT) {
|
|
|
|
return statusA;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Utils.randIntRange(0, 2) ? statusA : statusB;
|
2023-04-03 23:38:31 -04:00
|
|
|
}
|