Constructor
new Player(name, scenarioURL, boardID, startX, startY)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | |
scenarioURL |
string | base URL of the current scenario |
boardID |
string | path stem of the current board |
startX |
number | default entry column |
startY |
number | default entry row |
Classes
Methods
changeHealth(delta) → {number}
- Description:
Apply a health delta. Positive = damage, negative = heal. Returns current health. If health reaches 0, the game-over callback fires.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
delta |
number |
Returns:
current health
- Type
- number
enforceWeakness(event, loc, item) → {boolean}
- Description:
If the player is WEAK, enforce the single-item inventory limit.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
loc |
Cell | |
item |
Item |
Returns:
true if weakness enforcement fired
- Type
- boolean
heal(event, healer, amount, board)
- Description:
Heal the player by amount. Consumes healer item if successful.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
healer |
Item | |
amount |
number | positive = healing |
board |
Board |
matchesFlagOrItem(token) → {boolean}
- Description:
Check if a token matches a flag label or an item in the player's bag. Used to evaluate scenario trigger conditions.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
token |
string |
Returns:
- Type
- boolean
onFrame(cell)
- Description:
Called each animation tick. Counts down the damage/heal flash and triggers a re-render when they expire.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
cell |
Cell |
teleport()
- Description:
Called by Teleporter (and similar terrain) when the player steps on it. Mirrors Java Player.teleport(): cancels the enter event, removes the player from the current cell, plays a Fade animation on the adjacent cell in the movement direction, then calls Game.teleportTo() when the fade completes.
- Source:
testResistance(resistance) → {boolean}
- Description:
Test a resistance flag with a 15% chance of losing it permanently.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
resistance |
number | flag constant (e.g. FIRE_RESISTANT) |
Returns:
- Type
- boolean
weaken(cell)
- Description:
Apply the WEAK flag and drop all but the selected item.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
cell |
Cell |