@civ-clone/core-unit
TypeScript icon, indicating that this package has built-in type declarations

0.1.17 • Public • Published

core-unit

Contains the core models relating to Units.

The primary model, Unit, stores related state objects (Player, City, Tile, Yields, Actions) and convenience methods for accessing and modifying these.

A key component of a Unit is its ability to perform Actions. This package includes a DelayedAction class which can easily wrap any Actions that take time to be carried out (BuildIrrigation, Fortify, etc.).

There's also a UnitRegistry which can be used to retrieve Units by City, Player or Tile.

Various base Yields are included to represent the values of the Unit.

When this package is included in your build of civ-clone, it will automatically provide the AdditionalData key units for City, Player and Tileobjects as a convenience method.

Includes the following Rules:

  • Action for controlling which Actions are available to the Unit.
  • Activate triggers actions when a Unit is Unit.activated.
  • Busy for tracking if DelayedActions are complete.
  • CannotSupportUnit triggered when a City cannot support a Unit for whatever reason.
  • Created when Units are created.
  • Defeated " " defeated.
  • Destroyed " " destroyed.
  • Moved " " moved.
  • MovementCost which controls the cost of moving the Unit.
  • ValidateMove to confirm if the Action was successful or not.
  • Visibility for applying the results of the Units Visibility Yield to the PlayerWorld.
  • Yield controls the various Yields applicable for the Unit (Attack, Defence, Movement, Visibility).

Package Sidebar

Install

npm i @civ-clone/core-unit

Weekly Downloads

1

Version

0.1.17

License

MIT

Unpacked Size

74.7 kB

Total Files

110

Last publish

Collaborators

  • dom111