Customization
The server options and hooks change the rules; the client options and hooks change only what is shown. The server owns the outcome either way.Server options (TurnBattleServerOptions)
Given to provideTurnBattleServer(options):
Server hooks
Implemented in any module under theturnBattle key (TurnBattleServerHooks), or given in the hooks option:
TurnBattleHandle gives hooks the battle id, player, players, versus, spectators(), troop and state().
Client options (TurnBattleClientOptions)
Given to provideTurnBattleClient(options):
A battler is an RPGJS spritesheet registered like any other (
defineModule<RpgClient>({ spritesheets: [...] })) and referenced by id; its battle hints sit in a battle field of the spritesheet, or in the battlers option. A spritesheet of the map works as is (Presets.RMSpritesheet, with stand and walk): without an idle texture, the battler stands facing its side, and the battle animations it lacks (attack, hurt, dead…) use that pose. Give it battle textures (idle, attack, skill, hurt, dead, victory) or map them with battle.anims for a livelier fight. A battler whose spritesheet is not registered, or whose image does not load, does not block the battle: the error is logged in the console and nothing is drawn for that battler (its name, HP and the HUD stay).
Texts
The texts of the battle areturnBattle.* keys of the RPGJS i18n service (TURN_BATTLE_I18N holds the English and French defaults, exported by both entries). The client shows the menus, HUD, aria-labels and errors with them; the server uses turnBattle.player and turnBattle.hero for a player or hero without a name. Texts with values are one key filled with params (turnBattle.spCost: "{cost} MP"), so a translation can order the words its own way. A game overrides them, or adds a language, with the i18n of its own module:
Controls
The battle uses the keyboard controls of the game (keyboardControls of the client config: up, down, left, right, action, escape, and tabNext to change the speed) and the gamepad mapping of the built-in GUIs: A confirms, B or Start goes back, the d-pad or the stick moves through the menu, R changes the speed. Every command also has a button for touch screens. The help line of the menu (turnBattle.keys) names no key, since the keys are configurable.
Client hooks
Under theturnBattle key (TurnBattleClientHooks): onStart(scene, view), onPlay(beat, scene, steps), onEnd(result). onPlay runs before each beat: use steps (the default choreography cut into steps: announce, charge, strike, fall, returnHome…) to play it your way and return false; otherwise the default choreography plays. The hooks change what is shown, never the outcome: the server owns the rules.
Not included
Multiplayer lobbies, launching a battle from a link, random encounters, map battle zones and the media-based battlers of Studio are not part of this package: they are game-level features built onstartTurnBattle and watchTurnBattle. Start a battle shows how to build random encounters, zones and challenges with them.