Methods
_buildCellHoverText(cell) → {string|null}
- Description:
Build the HTML legend for a hovered cell: terrain, then agent (if any), then the topmost item (unless the terrain has HIDES_ITEMS). Mirrors Java's CellInfoPanel.renderCellInfo().
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
cell |
Cell |
Returns:
- Type
- string | null
_buildItemListText(cell) → {string|null}
- Description:
Build the HTML text for the item-list popup, mirroring Java's MessageManager.displayItemsAtCurrentCell(). Returns null if the cell has no items.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
cell |
Cell |
Returns:
- Type
- string | null
_cellEl()
- Description:
Look up the
.cellspan at (x, y). Cannot indexboardEl.childrendirectly —#boardalso contains non-cell children (e.g.#loading-overlay), which would throw off a positional index.
- Source:
_getPlayerAdjacentRects()
- Description:
Returns viewport DOMRects for the 8 cells adjacent to the player. Mirrors Java's current.getAdjacentCells(null) check in positionDoesNotOverlap().
- Source:
_positionPopup()
- Description:
Position a popup using the 8-position strategy from Java's MessageManager. Tries positions in the same order as Java, picks the first valid one.
- Source:
_rectsOverlap()
- Description:
AABB overlap test — mirrors Java's CellMessagePanel.overlaps().
- Source:
_renderPieceLabel(piece, outside) → {string}
- Description:
Render a colored symbol + name label for one piece.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
piece |
Piece | |
outside |
boolean |
Returns:
- Type
- string
_showFadePopup(boardEl, popupLayer, text, cellX, cellY, optionsopt) → {HTMLElement|null}
- Description:
Show a fade-out popup anchored near a cell. Uses an 8-position strategy (matching Java's MessageManager) to find the first position that stays in the viewport, avoids other popups, and avoids the player's adjacent cells. Returns the popup element so callers can remove it early if needed.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
boardEl |
HTMLElement | ||
popupLayer |
HTMLElement | ||
text |
string | ||
cellX |
number | ||
cellY |
number | ||
options |
Object |
<optional> |
Returns:
- Type
- HTMLElement | null
_showModalPopup()
- Description:
Show a modal (blocking) positional popup. Freezes the game until ESC/Enter. Positioning mirrors Java's CellMessageModalPanel.center(): starts right of cell, then clamps to viewport bounds.
- Source:
closeAllDialogs()
- Description:
Close any currently-open dialog(s). Only one modal dialog should ever be open at a time — call this before showing a new one so a dialog left open by a prior flow (e.g. the game ending while a scroll/help dialog was up) doesn't linger open underneath and resurface later.
- Source:
initCellHoverPopup()
- Description:
Show a brief legend popup when the player hovers over a cell. Mirrors the Java CellInfoPanel behaviour: 600 ms delay to show, auto-hides after 2100 ms or on mouseout/mousedown.
- Source:
initDialogs(onWinCloseopt)
- Description:
Connect the events bus to the modal-message dialog. Call once during app init.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
onWinClose |
function |
<optional> |
called when win dialog is closed |
initInventoryPanel()
- Description:
Inventory panel — renders the player's bag as a list of clickable items. The selected item is highlighted. Clicking an item selects it.
- Source:
initMessageLog()
- Description:
Message log — appends game messages to the #message-list element and auto-scrolls to the bottom.
- Source:
initStatsPanel()
- Description:
Stats panel — keeps the HP bar, HP text, XP, gold, and flags display in sync with the player model via the events bus.
- Source:
showConfirm(message, onConfirm, optsopt)
- Description:
Show a yes/no confirmation dialog.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
message |
string | ||
onConfirm |
function | ||
opts |
Object |
<optional> |
showLoadDialog(onLoad)
- Description:
Show load dialog with a list of saves to choose from. The
onLoadcallback receives the chosen slot name.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
onLoad |
function |
showMenu(optsopt) → {Promise.<(string|null)>}
- Description:
Show the main menu. Returns a Promise that resolves with the chosen action. Possible resolved values: "new-game" | "load-game" | "help" | null (dismissed)
Rendered as a plain overlay div rather than a native
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<optional> |
Properties
|
Returns:
- Type
- Promise.<(string|null)>
showModalMessage(message, onCloseopt)
- Description:
Show a short modal message (used for win conditions, key events, etc.). If the message looks like a URL (.html extension), shows the win dialog. Otherwise shows a confirm dialog with "OK" only.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
message |
string | ||
onClose |
function |
<optional> |
showSaveDialog(onSave)
- Description:
Show save dialog. The
onSavecallback receives the chosen slot name.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
onSave |
function |
showScenarioDialog(scenarios) → {Promise.<({id:string, start:string}|null)>}
- Description:
Show scenario selection list.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
scenarios |
Array.<{id:string, start:string, name:string, description:string, creator:string}> |
Returns:
- Type
- Promise.<({id:string, start:string}|null)>
showScrollDialog(url, title)
- Description:
Show a scroll's HTML page in a simple modal dialog.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | full URL of the HTML page to display |
title |
string | scroll name shown in the dialog header |
showWinDialog(url, onCloseopt)
- Description:
Show the win screen with an iframe pointing to the win URL.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
url |
string | relative or absolute URL for the win HTML page |
|
onClose |
function |
<optional> |