19. Function Reference

This chapter summarises the main functions—primarily from main.js—to serve as a reading roadmap when you dive into the source.

19.1 Screen Flow & Layout

Function Role Key Arguments Location
updateMapSize() Recomputes map width/height from depth and BlockDim size modifiers. main.js lines 456–474
resizeCanvasToStage() Resizes the canvas to match the stage element for responsive rendering. main.js lines 477–483
enterInGameLayout() / leaveInGameLayout() Applies layout classes when entering the game view, adjusts toolbar height, and cleans up afterward. main.js lines 505–522
showSelectionScreen(opts) Common handler for returning from exploration to the selection screen. Refills HP and restores modes. opts.stopLoop, opts.refillHp, etc. main.js lines 538–571

19.2 BlockDim UI & Selection

Function Role Notes Location
initBlockDimUI() Initialises the BlockDim tab—renders lists and sets up keyboard handling. Restores the previous selection and calls renderHistoryAndBookmarks(). main.js lines 1095–1121
onBlockDimChanged() Rebuilds the spec and refreshes the preview when lists or the NESTED value change. Works with composeSpec() and seedFromSelection(). main.js lines 1123–1148
randomizeBdimBlocks() Randomly picks 1st/2nd/3rd blocks and updates the preview immediately. Supports the preserveScroll option to keep list position. main.js lines 1150–1168
weightedRandomizeBdimBlocks(target, type) Performs weighted random selection based on total level and preferred type. Uses Gaussian weighting and up to 64 trials to find a candidate. main.js lines 1171–1233
renderHistoryAndBookmarks() Draws the history/bookmark lists, binding events for reuse and deletion. Limits visible rows via setScrollableList(). main.js lines 1250–1300
applyBdimSelection(entry) Applies a saved preset to the UI and triggers onBlockDimChanged(). Shared by both history and bookmarks. main.js lines 1325–1333

19.3 MiniExp UI & Lifecycle

Function Role Notes Location
renderMiniExpCategories(manifest) Generates category buttons and manages selection state. Automatically deselects games not in the active category. main.js lines 6534–6562
renderMiniExpList(manifest) Switches between card/list layouts based on the view mode and wires up selection. Works with category filters and invokes renderMiniExpRecords(). main.js lines 6571–6620
initMiniExpUI() Initialises the manifest and renders categories, lists, and placeholders. Updates the placeholder instantly when a game is preselected. main.js lines 6622–6642
startSelectedMiniGame() Loads the selected MiniExp module and starts its runtime. Validates the create() return value, resets buttons and shortcuts. main.js lines 6829–6861
quitMiniGame() Handles shutdown (stop()getScore()destroy()) and updates records. Resets UI state and refreshes EXP badges and records. main.js lines 6863–6905

19.4 Mod Maker Helpers

Function Role Related Work Location
renderModMaker() Renders the entire module UI and syncs metadata, structures, and generators. Calls ensureModMakerDefaults(), renderStructureGrid(), buildModMakerOutput(). main.js lines 2404–2529
buildModMakerOutput() Builds JSON compatible with registerDungeonAddon() and validates it. Checks for duplicate structure IDs and anchor ranges. main.js lines 2532–2555
createBlockField(label, value, onChange, options) Generates form elements that re-render the UI automatically on change. Supports options.multiline and options.deferRender. main.js lines 2381–2402

19.5 Domain Effects & Badge Hooks

Target Role Adjustment Tips Location
DOMAIN_EFFECT_DEFINITIONS Configuration for domain crystal icons, colours, damage modifiers, and status effects. Edit multipliers or flags such as reverseDamage and allowPotionThrow to customise behaviour. main.js lines 4851–5004
getDomainEffectAggregate(targetType, x, y) Combines overlapping domain crystals to calculate attack/defence modifiers and status auras. Modify radius or aggregation logic as needed. Returns values including allowPotionThrow and statusAilments. main.js lines 5179–5287
refreshGeneratorHazardSuppression() Evaluates suppression thresholds for darkness, poison mist, and noise, updating UI state. Adjust level thresholds or behaviour; call updateDungeonTypeOverlay() afterward. main.js lines 6764–6788
updateDungeonTypeOverlay() Renders the top-right dungeon overlay with hazard and generator badges. Edit labels or CSS classes here. Suppression uses the dungeon-overlay__badge--suppressed class. main.js lines 6940–7042