Battle handles all battle simulation using discord.js's embed.

Hierarchy

  • BaseBattle
    • Battle

Constructors

  • Parameters

    • i: CommandInteraction<CacheType>

      discord.js's CommandInteraction

    • fighters: Fighter[]

      array of Fighter's object

    Returns Battle

Properties

boss?: Fighter
fighters: Fighter[]
gameStats: Map<string, PlayerGameStat> = ...
i: CommandInteraction<CacheType>
interval: number = 4000

Time interval to change to next frame (in milliseconds by default is 6000)

logBattle: boolean = false

Logs battle to stdout

onFighterDead?: ((fighter) => void)

Type declaration

    • (fighter): void
    • Parameters

      Returns void

playerDiedText?: ((fighter) => string)

Type declaration

    • (fighter): string
    • Parameters

      Returns string

round: number = 0
showBattle: boolean = true

Show battle embed

Methods

  • Gets total damage dealt for a particular fighter

    Parameters

    • id: string

    Returns undefined | number

  • Get remaining HP for a particular fighter

    Parameters

    • id: string

    Returns undefined | number

  • adds progress bar to battleEmbed

    Parameters

    • embed: EmbedBuilder
    • name: string
    • hp: number
    • maxHP: number

    Returns void

  • Parameters

    • options: string | EmbedBuilder

    Returns Promise<void>

  • Starts the battle simulation. It will throw error if the array of Fighters is less than 2. This method will return the Fighter object who won the battle.

    Returns Promise<Fighter>

    Fighter

  • Change the battle to raid mode. Raid mode only have one opponent that is the boss. If the boss dies, the battle ends.

    Parameters

    • boss: Fighter

      {Fighter} - Boss to be defeated

    Returns Battle

  • Sets the battle scene interval.

    Parameters

    • ms: number

      {number} - time in milliseconds

    Returns Battle

  • Executes callback when Fighter dead during battle.

    Parameters

    • cb: ((fighter) => void)
        • (fighter): void
        • Parameters

          Returns void

    Returns void

  • Changes the discord.js message sent when player dies in the battle.

    Parameters

    • text: ((fighter) => string)
        • (fighter): string
        • Parameters

          Returns string

    Returns void

  • Returns Promise<unknown>

  • Updates embed and log if enabled.

    Parameters

    • embed: EmbedBuilder

    Returns Promise<void>

Generated using TypeDoc