Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Player

Hierarchy

  • Player

Index

Constructors

constructor

  • new Player(__namedParameters: PlayerOptions, isHuman: boolean, random: () => number, logger?: Partial<PlayerLogger>): Player
  • Parameters

    • __namedParameters: PlayerOptions
    • isHuman: boolean
    • random: () => number
        • (): number
        • Returns number

    • Optional logger: Partial<PlayerLogger>

    Returns Player

Properties

Protected Readonly AttackPower

AttackPower: NormalSpecial<number>

Private AttackStage

AttackStage: NormalSpecial<number>

Protected Readonly CriticalDamagePct

CriticalDamagePct: number

Private DefenseStage

DefenseStage: NormalSpecial<number>

Protected Readonly DefenseStat

DefenseStat: NormalSpecial<number>

Readonly Level

Level: number

Protected Readonly MaxHealth

MaxHealth: number

Protected Readonly Moves

Moves: Move[]

Protected Readonly SpeedStat

SpeedStat: number

Protected Readonly SuperPotionsLimit

SuperPotionsLimit: number

Protected Readonly Types

Types: Type[]

Private Optional confusion

confusion: undefined | { actor: Player; turnsLeft: number }

If defined, encodes the state of the current confusion. If undefined, no confusion is active.

Private health

health: number

Private Optional logger

logger: undefined | Partial<PlayerLogger>

Private paralysisSpeedEffectWaived

paralysisSpeedEffectWaived: boolean

Private paralyzed

paralyzed: boolean

Determines whether paralyzed.

Does not have any term limits.

Private poisoned

poisoned: boolean

Determines whether poisoned.

Does not have any term limits.

Private random

random: () => number

Type declaration

    • (): number
    • Returns number

sleepingTurnsLeft

sleepingTurnsLeft: number

Determines the number of turns for which sleep remains active.

Private stageBoostCounter

stageBoostCounter: number

Private superPotionsLeft

superPotionsLeft: number

Methods

Private RNG

  • RNG(a: number, b: number): number
  • Parameters

    • a: number
    • b: number

    Returns number

adjustStage

  • adjustStage(difference: number, stageAttr: "AttackStage" | "DefenseStage", type: "Normal" | "Special"): void
  • Parameters

    • difference: number
    • stageAttr: "AttackStage" | "DefenseStage"
    • type: "Normal" | "Special"

    Returns void

Private baseAttackDefense

  • baseAttackDefense(move: MoveLike, actor: Player): { AttackPower: number; AttackStage: number; DefenseStage: number; DefenseStat: number }
  • Something to do with power of an attack

    Gives appropriate constants based on whether the move is special. Does not factor in bonuses.

    Parameters

    • move: MoveLike
    • actor: Player

    Returns { AttackPower: number; AttackStage: number; DefenseStage: number; DefenseStat: number }

    • AttackPower: number
    • AttackStage: number
    • DefenseStage: number
    • DefenseStat: number

Private baseDamage

  • baseDamage(move: MoveLike, actor: Player, scale: boolean): number
  • A non-deterministic multiplicative constant for use in damage calculations

    Parameters

    • move: MoveLike
    • actor: Player
    • scale: boolean

    Returns number

Private calcCriticalDamage

  • calcCriticalDamage(move: MoveLike, actor: Player): number

Private calcDamage

  • calcDamage(move: MoveLike, actor: Player): number

confuse

  • confuse(actor: Player): void

deParalyze

  • deParalyze(): void

forceResetStages

  • forceResetStages(): void

getSpeed

  • getSpeed(): number

Private getStageBoostBonus

  • getStageBoostBonus(): number

Private getWeakness

  • getWeakness(attackingType: Type): Resistance
  • Parameters

    • attackingType: Type

    Returns Resistance

makeSleep

  • makeSleep(): void

paralyze

  • paralyze(): void

playTurn

  • playTurn(takeSuperPotion: boolean, opponent: Player): { opponentAlive: boolean; thisAlive: true } | { opponentAlive: true; thisAlive: false }
  • Parameters

    • takeSuperPotion: boolean

      Whether the die indicates to take the super potion. It actually happening depends on the current state of the player.

    • opponent: Player

    Returns { opponentAlive: boolean; thisAlive: true } | { opponentAlive: true; thisAlive: false }

poison

  • poison(): void

receiveDamage

  • receiveDamage(damage: number): boolean
  • Parameters

    • damage: number

    Returns boolean

    Whether still alive

receiveDamagingMove

  • receiveDamagingMove(move: MoveLike, actor: Player): boolean
  • Parameters

    • move: MoveLike
    • actor: Player

    Returns boolean

    Whether still alive

reset

  • reset(random: () => number, logger?: Partial<PlayerLogger>): void
  • Parameters

    • random: () => number
        • (): number
        • Returns number

    • Optional logger: Partial<PlayerLogger>

    Returns void

Private sleepParalysisPoisonGroup

  • sleepParalysisPoisonGroup(): number | boolean
  • Whether any in the condition group consisting of sleep, paralysis, poisoning is active.

    Because only one of these can be active at any given time, and it is a lock, not an override

    Returns number | boolean

unConfuse

  • unConfuse(): void

waiveParalysisSpeedEffect

  • waiveParalysisSpeedEffect(): void

Private Static getMultiplier

  • getMultiplier(stage: number): number
  • Do the following computation:

    if (stage < 0) return 1 / this.getMultiplier(-stage);
    switch (stage) {
    case 0:
    return 1;
    case 1:
    return 1.5;
    case 2:
    return 2;
    case 3:
    return 2.5;
    case 4:
    return 3;
    case 5:
    return 3.5;
    case 6:
    return 4;
    }
    

    Parameters

    • stage: number

      Between -6 and 6

    Returns number