Player

Player

The player character. Extends Agent to participate in the normal piece/cell/board model, but carries extra state (health, inventory, navigation context).

changeHealth(delta): positive delta = damage (health decreases) negative delta = heal (health increases) returns current health after the change

Constructor

new Player()

Source:

Classes

Player

Methods

changeHealth()

Description:
  • Apply a health delta. Positive = damage, negative = heal. Returns current health. If health reaches 0, the game-over callback fires.

Source:

enforceWeakness()

Description:
  • If the player is WEAK, enforce the single-item inventory limit.

Source:

heal()

Description:
  • Heal the player by amount. Consumes healer item if successful.

Source:

matchesFlagOrItem()

Description:
  • Check if a token matches a flag label or an item in the player's bag. Used to evaluate scenario trigger conditions.

Source:

onFrame()

Description:
  • Called each animation tick. Counts down the damage/heal flash and triggers a re-render when they expire.

Source:

testResistance()

Description:
  • Test a resistance flag with a 15% chance of losing it permanently.

Source:

weaken()

Description:
  • Apply the WEAK flag and drop all but the selected item.

Source: