Actions
This module handles mapping a string input to an action function
Actions
Static Members
▸
action(selection, uniqueDesignation, totalActions, msg, userID)
Map to the action functions in the Game module
action(selection:
string, uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
selection (string)
A unique name for the action
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Runs a function directly
Utils
This module handles various utility functions
Utils
Static Members
▸
populateControlPanel(uniqueDesignation)
Reads values from database and populates the control panel forms
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Inserts values directly into the DOM
Gets armor data based on name
Parameters
armorName (string)
The name of the armor
Returns
object
:
The armor's data
Game
This module handles primary game logic
Game
Static Members
Wraps an array index around the end of an array like a loop
Parameters
n (number)
An offset from current index
Returns
number
:
The correct array index wrapped around
▸
findFace(current, direction, amount)
Finds the correct face number in either direction and amount
Parameters
current (number)
The current face number, 0-5
direction (string)
Either 'right' or 'left'
amount (number)
The numer of faces to increment
Returns
number
:
The correct hex face number
Converts a face number (0-5) to a two-letter cardinal direction
Parameters
face (number)
A face number 0-5
Returns
string
:
A two-letter direction. e.g. N, NW, SW, etc.
▸
getShooterPositionModifier(position)
Returns the proper accuracy modifier based on shooter's position
Parameters
position (string)
Either standing, kneeling, or prone
Returns
number
:
A number to be added to the accuracy
▸
getTargetModifiers(target)
Returns the proper accuracy modifier based on target's position
Parameters
target (object)
The enemy unit to import
Returns
number
:
A number to be added to the accuracy
▸
findNeighbor(currentCoords, facing, neighbor)
Looks ahead and finds a hex based on a given face
Parameters
currentCoords (object)
A point object of the current position
facing (number)
The face number the unit is looking towards, 0-5
neighbor (string)
The direction to find. 'forward', 'backward', or two-letter direction
Returns
object
:
A Honeycomb hex
▸
getUnitsInRadius(coords, range)
Gets a list of all all unit names in a radius from a coordinate
getUnitsInRadius(coords:
array, range: any):
array
Parameters
coords (array)
A point occupied by the target
Returns
array
:
An array of unit names
▸
face1LeftMoving(uniqueDesignation)
Changes facing 1 to the left if in moving
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
aiming(uniqueDesignation, totalActions, msg, userID)
Calculates aiming and aim mods
Parameters
uniqueDesignation (string)
The name of the unit
totalActions (number)
The number of actions used for the aim
msg (any)
A message from the submitAction execution
Returns
undefined
:
Modifies the database directly
▸
applyDamage(uniqueDesignation, damage)
Updates a unit's damage and wounds
Parameters
uniqueDesignation (string)
The unit's name
damage (object)
The constructed damage object
Returns
undefined
:
Updates the unit directly
▸
checkMedicalAid(unit, dt, aid)
checks the medical aid and recovery chart and submits to action list if needed
Parameters
unit (object)
The unit being checked
dt (number)
Unit's damage total
aid (string)
The aid type. 'no aid', 'first aid', hospital', 'trauma center'
Returns
undefined
:
Submit's through a global function
▸
medicalAid(uniqueDesignation, totalActions, msg, userID)
Checks the recovery roll
Parameters
uniqueDesignation (string)
The name of the unit
totalActions (number)
The number of actions used for the aim
msg (any)
A message from the submitAction execution
Returns
undefined
:
Modifies the database directly
▸
checkIncapacitated(unit, newPD)
Checks for incapacitation
Parameters
unit (object)
The full object for the unit
newPD (number)
Just pass the new physical damage here to avoid race conditions with updating database
Returns
boolean
:
True if incapacitated
▸
moveToHex(uniqueDesignation, totalActions, msg, userID)
Moves a unit to a hex based on user input
Parameters
uniqueDesignation (string)
The name of the unit
totalActions (number)
The number of actions used
Returns
undefined
:
Moves the unit
▸
toStanding(uniqueDesignation, totalActions, msg, userID)
Changes the position to standing
Parameters
uniqueDesignation (string)
The unit's name
totalActions (number)
The amount of actions used
Returns
undefined
:
Updates the unit directly
▸
toKneeling(uniqueDesignation, totalActions, msg, userID)
Changes the position to kneeling
Parameters
uniqueDesignation (string)
The unit's name
totalActions (number)
The amount of actions used
Returns
undefined
:
Updates the unit directly
▸
toProne(uniqueDesignation, totalActions, msg, userID)
Changes the position to prone
Parameters
uniqueDesignation (string)
The unit's name
totalActions (number)
The amount of actions used
Returns
undefined
:
Updates the unit directly
▸
face1RightMoving(uniqueDesignation)
Changes facing 1 to the right if in moving
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
runningForward(uniqueDesignation, totalActions, msg, userID)
Moves the unit forward 1 hex
runningForward(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
runningBackward(uniqueDesignation, totalActions, msg, userID)
Moves the unit backward 1 hex
runningBackward(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
crawlingForward(uniqueDesignation, totalActions, msg, userID)
Moves the unit forward 1 hex if crawling
crawlingForward(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
crawlingBackward(uniqueDesignation, totalActions, msg, userID)
Moves the unit backward 1 hex if crawling
crawlingBackward(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
crouchingForward(uniqueDesignation, totalActions, msg, userID)
Moves the unit forward 1 hex if crouching
crouchingForward(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
crouchingBackward(uniqueDesignation, totalActions, msg, userID)
Moves the unit backward 1 hex if crouching
crouchingBackward(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
face1LeftImmobile(uniqueDesignation, totalActions, msg, userID)
Changes facing 1 to the left if immobile
face1LeftImmobile(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
face1RightImmobile(uniqueDesignation, totalActions, msg, userID)
Changes facing 1 to the right if immobile
face1RightImmobile(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
face2LeftImmobile(uniqueDesignation, totalActions, msg, userID)
Changes facing 2 to the left if immobile
face2LeftImmobile(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
face2RightImmobile(uniqueDesignation, totalActions, msg, userID)
Changes facing 2 to the right if immobile
face2RightImmobile(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
assumeFiringStance(uniqueDesignation, totalActions, msg, userID)
Changes unit's stance to firing
assumeFiringStance(uniqueDesignation:
string, totalActions: any, msg: any, userID: any):
undefined
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
Tables
This module handles table lookups
Tables
Static Members
Calculates the force multiplier of shooting an automatic weaon burst
Parameters
rof (number)
The weapon's rate of fire
range (number)
The distance in as an index value of the range table
Returns
number
:
The force multiplier
▸
oddsOfHitting(accuracy, range)
The odds of hitting a target
Parameters
accuracy (number)
The unit's accuracy number
range (number)
The distance in inches
Returns
number
:
The percentage chance of hitting
▸
getIndexOfRange(distance)
Gets the correct index for aim mods array
Parameters
distance (number)
The number of inches to target
Returns
number
:
The index of the weapon's aim mods array
▸
getPenetrationLine(armorProtectionFactor, weaponPenetration)
Gets the correct penetration line given pf and weapon pen
Parameters
armorProtectionFactor (number)
Armor PF
weaponPenetration (number)
Weapon's pen
Returns
number
:
The correct penetration line
Finds the type of damage if the shot is glancing
Parameters
penLine (number)
The weapon penetration line to use
Returns
string
:
The type of damage. No damage, low velocity damage, or over penetrating damage
▸
getHitLocation(damageType, weaponDC, cover)
Gets the correct hit location and damage
Parameters
damageType (string)
Either lvd or opn
weaponDC (number)
Weapon's damage class found in the weapon object
cover (boolean)
If the target has cover or not
Returns
object
:
The damage and hit object
▸
hitResult(armor, weapon, cover, weapon-null)
The main hit result called from the interface
Parameters
armor (object)
The target's armor data
cover (boolean)
If the target has cover or not
weapon-null (object)
The shooter's weapon data
Returns
object
:
The damage and hit object
Listeners
This module handles all event listeners
Listeners
Config
Configuration file for setting up the map, document, and database connection
Config
Unit
This module handles creating, controlling, and updating units
Unit
Static Members
▸
create(hex, sidc, options)
Creates the graphical elements of a unit, adds to DOM, and adds events
Parameters
hex (object)
A Honeycomb hex object
sidc (string)
A milsymbol code for the type of svg symbol to create. e.g. 'SHG-UCFM-------'
options (object)
Milsymbol options to pass into the its constructor. e.g. {'size': 0,'uniqueDesignation': 'dingo','additionalInformation': '','infoFields': false}
Returns
undefined
:
Modifies DOM directly
▸
distanceBetweenUnits(sourceName, targetName, targetName-null)
Gets the distance in number of hexes between units
distanceBetweenUnits(sourceName:
string, targetName: any, targetName-null:
string):
number
Parameters
sourceName (string)
The first unit's name
targetName-null (string)
The second unit's name
Returns
number
:
A number of hexes between sourceName and targetName
▸
removeUnitById(uniqueDesignation)
Destroys a unit. Out of date as it uses the old unitList and does not interact with the database
Parameters
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies DOM directly
▸
getUnitCoords(uniqueDesignation)
Find the point coordinates for a given unit stored in its data attribute.
Parameters
uniqueDesignation (string)
The name of the unit
Returns
object
:
A Honeycomb hex coordinates object. e.g. { x: 0, y: 0 }
▸
getUnitHex(uniqueDesignation)
Find the hex for a given unit
Parameters
uniqueDesignation (string)
The name of the unit
Returns
object
:
A Honeycomb hex object
▸
setUnitCoords(hex, uniqueDesignation)
Sets the coordinates for a unit
Parameters
hex (object)
A Honeycomb hex object
uniqueDesignation (string)
The name of the unit
Returns
object
:
A Honeycomb hex coordinates object. e.g. { x: 0, y: 0 }
▸
createSymbolContainer(uniqueDesignation)
Creates a DOM element to hold graphics and data
Parameters
uniqueDesignation (string)
The name of the unit
Returns
object
:
A div element with id set to unique designation and class to unit
▸
positionUnit(hex, unit)
Positions the unit according to the irregular size of individual milsymbols
Parameters
hex (object)
A Honeycomb hex object
unit (object)
The div container for the unit
Returns
object
:
A modified div container DOM element
▸
animateUnitToHex(point, uniqueDesignation)
Moves a unit to a new hex
Parameters
point (object)
A Honeycomb point object. e.g. {x:0, y:1}
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the DOM directly
▸
changeFacing(face, uniqueDesignation)
Changes a unit's facing
Parameters
face (number)
A number 0-5 representing the face of the hexagon as documented in Honeycomb
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the DOM directly
▸
update(updates, uniqueDesignation)
Updates the unit in the database for an arbitrary number of properties
Parameters
updates (object)
A JSON snippet of all properties to change. e.g. {facing: 1, currentHex:
[
6, 9
]
}
uniqueDesignation (string)
The name of the unit
Returns
undefined
:
Modifies the database directly
▸
toggleHexSelection(hex)
Toggles the highlighting of a selected hex on/off
Parameters
hex (object)
A Honeycomb hex object
Returns
undefined
:
Modifies the DOM directly
Timer
This module handles game time in increments of phase and impulse
Timer
Static Members
Advances the game timer one impulse
Returns
undefined
:
Modifies the database directly
▸
calculateActionTime(combatActions, unit, time)
Adds a specified number of actions to the current game time to determine the correct phase and impulse in the future
Parameters
combatActions (number)
A number of combat actions
unit (object)
The database value of the unit
time (object)
The database value of the game time
Returns
object
:
Returns an object with a correct time object as well as remaining actions {time: next, remaining: actions}
▸
getTimeAndUnit(uniqueDesignation)
Returns a specified unit as well as the current time
getTimeAndUnit(uniqueDesignation: any):
array
Parameters
Returns
array
:
Returns an array of the unit object and time object
Reads all stored actions in database action list then executes any that match current game time
Returns
undefined
:
Modifies the database directly
▸
addToActionList(action)
Adds an action object to the database's action list
Parameters
action (object)
An action object to store. e.g. {uniqueDesignation: 'snake', time: {phase: 1, impulse: 2}, action: 'face-1-left-moving'}
Returns
undefined
:
Modifies the database directly
▸
submitAction(actionName, uniqueDesignation, ca, msg, userID)
Constructs the proper object to submit to addToActionList
Parameters
actionName (string)
The action's name
uniqueDesignation (string)
The unit's name
Returns
undefined
:
Runs addToActionList directly
Database
This module handles database interaction and database references
Database
Static Members
▸
singleUnit(uniqueDesignation)
A reference to a single unit in the database
Parameters
uniqueDesignation (string)
The name of the unit
Returns
object
:
A reference to the unit in the database
Map
This module handles creating the hex grid and individual hex methods
Map
Static Members
▸
getHexFromCoords(pageX, pageY)
Finds a hex given a coordinate
Parameters
pageX (object)
A pointer screen coordinates for X
pageY (object)
A pointer screen coordinates for Y
Returns
hex
:
A Honeycomb hex object
▸
getHexFromPoint(point, point-null)
Gets a hex object if given an point
Parameters
point-null (array)
An array (or object) of coordinates
Returns
object
:
A hex
▸
coordsRange(coords, range)
Gets a list of all all hexes in a radius from a coordinate
Parameters
coords (array)
A point occupied by the target
range (number)
A number of hexes as radius from coordinates
Returns
array
:
An array of hex objects
Index
Index
Author: Matthew Butler <matthewtbutler@gmail.com>
The main entry point of the application