What is expected behavior of the cw2 engine model
Offers basic TurnBased game much like aw, highly customizable to be able to reuse the model for multiple different aw like turn based games.
This is done by not hard coding values, only behavior that talks to interfaces instead of the real imp. Adding game specific functionality should be done by adjusting config, data files or writing new behavior or sub classing but not by changing the model!
We can separate concerns by putting similar behavior into systems, all turnBased games have these systems in common they do 1 thing and do it well.
- Move System
- Hides the implementation of a move within a map.
- PathFinder creates best path from tile A to tile B. based on terrain heuristics.
- MoveStrategy, each Mover has a way of moving around, it may have move limitations.
- Normal MovementStrategy:
Movement value -> uses the terrain moveCost
Normal MovementStrategy +
moving from water -> only allow movement onto water, shoals, or ports
moving into water -> only allow movement from water, shoals, or ports
- Weathers affect global moving costs ie
Snow: All movers have -1 mobility.
- Making a move
Pre Move conditions:
enough supplies left to move?
One step at a time, can't just loop over the tiles because that's at cpu speed, instead in the controller a timer will call move after x ms.
Look 1Tile ahead
has unit on nextTile is it allied else -> destinationReached(trapper)
change unit orientation so that it always faces to the next tile
change location each step
subtracts the movecost from unit supplies
at last tile -> destinationReached()
- Turn system: Current turn, turn limit, convert to day
- Battle/Fight system
Attacker can attack Defender
Fight takes information from attacker, defender, terrain and calculates a result
After the Fight a counterattack can be performed
Example when a unit it out of supplies:
and it is a ground unit it stops moving(normal behavior, no need to add code)
and it is a naval unit it sinks
and it is a air unit it drops out of the sky,
basically the last 2 make a unit die this needs to be added but how?
- can fire, attack and be destroyed
- health of which is deducted upon being fired on by other units
- has movement restricted by a certain number of tiles
- has an amount of commands that are active when conditions are met.
- has a unitState this is the action is it currently performing. a unit can only perform 1 action at a time. can't capture and move at the same time
- some can transport other units of a given ArmyBranch
- holds ammo count, maxammo, range
- does not hold the damage it can inflict! why not?
Property is a Terrain
- id,name,description,defenceBonus,height,moveCosts for each Mover
- is immutable(no setters)
City is a Property
- vision Amount of tiles this terrain can 'see' in each direction
- location The location this Property is on, owner Player owning this Property.
- Cities are properties that have an income.
- can heal damageables of a specific armyBranch
- can supply supplyables of a specific armybranch
- can be captured by a Capturer, when captured gives funds to the player that owns it
is within the default mapPlayer
- Unit/Properties are not drawn when tile is Fogged.
- Hidden: Allows terrains/units to remain fogged until Mover is adjacent, even if it is not fogged, it is still not drawn.
stealth? detected? == setHidden
- There are 2 type of players:
mapPlayer: a player in the map: has a startLocation, can be neutral, has a defaultColor. These will be in a map file.
gamePlayer: a player in the game is a mapPlayer + has a name, budget, army,list of properties
it can update itself on the start and end of a turn
- A player has 1 HQ Property
- properties like MAP_NAME, MAX_NUM_PLAYERS, AUTHOR, ETC...
- handles looping through tiles from a centerTile in different ways (circle, square, adjacent)
- can lookup Directions between 2 tiles.
What is not included:
Mist, co, Triggers, campaigns, hidden and submerged damage