Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IUnitTypeBehavior

Define some behavior at the unit level type and unit instance level. For example, can a player buy a unit, should the unit move or attack etc

Hierarchy

Index

Properties

buildCondition

buildCondition: function

define unit creation policy with respect of current resources, or other factors of the board. Can the player build this unit at this moment ? (ie has sufficient resources ? ). For example: player.resources.find(r=>r.name==='gold').value>50 && player=>player.resources.find(r=>r.name==='gold')

Type declaration

id

id: string

the id of the referenced unit type or Player or whatever (IUnit)

stateModifiers

stateModifiers: IStateModifier[]

each of this modifiers will end up in a subscription in the game and notified when requested event happen so they have the chance to modify the state somehow

unitCanBeCreatedHere

unitCanBeCreatedHere: function

define unit creation policy with respect of a place in the board

Type declaration

    • (playerId: string, box: IBox): boolean
    • Parameters

      • playerId: string
      • box: IBox

      Returns boolean

unitCanMoveHere

unitCanMoveHere: function

IN the case units move automatically, define movement policies - for example, can there be two units in the same box ?

Type declaration

unitManualMove

unitManualMove: function

if the unit moves manually (don't use the framework's automatic moves), then it returns the box where it should move this turn. If it doesn't move manually (uses the framework automatic move), then return false

Type declaration

unitShouldAttackThisTurn

unitShouldAttackThisTurn: function

in the case units attack automatically, same logic as [[unitShouldMove]] but for attacking

Type declaration

unitShouldMoveThisTurn

unitShouldMoveThisTurn: function

before automatically moving a unit, the framework ask its type if it's OK so unit type definition can customize how it moves. For allow the framework to automatically move the unit, return true (default) For moving to a custom box return that box. Notice that implementers are responsible of respecting the game rules (for example cannot move to a non-traspassable box For not moving at all, just return the same box argument.

Note: this is not about IA, this is about unit movement policy. Remember units movement and attack arer automatically users, including IA cannot decide anything about it.

Type declaration

Generated using TypeDoc