Battle data
Data lives in the RPGJS database. The native fields are shared with every battle system (name, description, spCost and power of a skill, hpValue and spValue of an item); the tactical field carries what only a tactical battle needs. Helpers add the _type and type the record: tacticalSkill and tacticalItem make ordinary RPGJS skills and items (players learn and carry them), tacticalUnit, tacticalRole and tacticalEncounter the records of the tactical battle.
units, skills, items, roles and encounters server options first, then the database (see Customization).
Skill
Native fields:spCost (SP cost), power (damage or healing power) and coefficient (the parameters of the user that scale the damage, read by the map’s damageSkill formula when both units carry parameters). The tactical field:
range, shape, visual and color are required. shape is single, cross, square or pierce; visual is slash, shockwave, arrow, volley, fire or frost.
Unit (tactical)
A battler is a client spritesheet.
walkingSheet(id, image) (from @rpgjs/tactical-rpg/client) turns a 4 × 4 walking sheet into one:
Item
Native fields:hpValue, spValue restored to a unit next to the user (or the user itself). An item that restores HP or SP is refused on a unit with nothing to get back from it (tactical.error.full): it is kept, and the unit can still act. The tactical field may give an effect: a Visual Effect played from the user to that unit.
Role (tactical)
attack: melee (charge), ranged (arrow) or magic (bolt); glyph (one-character badge, default ◆); color.
Encounter (tactical)
board takes columns, rows, cellSize (a 9 × 7 grid by default, whose cells are the tiles of the map: 64 pixels when the map has no tile size), origin and blocked (cells written "x,y"). rules takes canAttack, canUseSkills, canUseItems, canGuard and canEscape.
The hero of a player
Ahero: true placement is the hero of a player of the battle (seat: the index of the player in its side; without it, the hero placements take the players of the side in order, and two placements on one seat are refused). It is read from the RpgPlayer: its name, HP and SP, its parameters (equipment and states included, used by the damage formulas of the map), the skills it knows that have a tactical field, and the items of its inventory that restore HP or SP. Its role comes from the hero server option, else from the tactical.role of the class of the player (warrior otherwise); its battler is the graphic of the player.
When the battle ends, its HP, SP and the items it spent are written back on the player (never in PvP, never for a player who left). A seat that no player takes leaves its hero out, and a player who would have no unit (no hero placement for them, no unit dealt to them) is refused: startTacticalBattle rejects.