Methods
canEnter(direction, from, to) → {boolean}
- Description:
Can this agent enter the destination terrain from its current cell? Mirrors Terrain.canEnter — both must return true for movement to occur.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
direction |
Direction | |
from |
Cell | |
to |
Cell |
Returns:
- Type
- boolean
changeHealth(value) → {number}
- Description:
Apply a health change to this agent. For the player: adjusts HP and returns current HP. For other agents: used as a percentage-hit-chance adjustment; returns 0 on death.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number | positive = heal, negative = damage |
Returns:
- Type
- number
onDie(event, cell)
- Description:
This agent has died.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
cell |
Cell |
onHit(event, attackerCell, agentLoc, agent)
- Description:
This agent has collided with another agent (player↔agent only; agents do not collide with each other).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
attackerCell |
Cell | |
agentLoc |
Cell | |
agent |
Agent |
onHitBy(event, agentLoc, agent, dir)
- Description:
This agent has been hit by another agent. Typically cancels the mover's move event unless this agent steps aside.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
agentLoc |
Cell | |
agent |
Agent | |
dir |
Direction |
onHitByItem(event, itemLoc, item, dir)
- Description:
This agent has been hit by a thrown or wielded item.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
itemLoc |
Cell | |
item |
Item | |
dir |
Direction |
onTurn(event, board, cell)
- Description:
Called once per game turn so the agent can take an action (move, attack, etc.). Non-player agents implement AI here. No-op by default (static agents).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
board |
Board | |
cell |
Cell |