aboutsummaryrefslogtreecommitdiff
path: root/go/game/unit.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/unit.go')
-rw-r--r--go/game/unit.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/go/game/unit.go b/go/game/unit.go
index 1bf3afa1..d1192dc0 100644
--- a/go/game/unit.go
+++ b/go/game/unit.go
@@ -5,6 +5,7 @@ import (
)
const (
+ DEFAULT_AVAIL_STREET_ACTIONS = 1
DEFAULT_AVAIL_MOVE_ACTIONS = 1
DEFAULT_AVAIL_ATTACK_ACTIONS = 1
)
@@ -18,6 +19,7 @@ type Unit struct {
FullActions []*FullAction
FreeActions []*FreeAction
// Effects []Effects
+ AvailStreetActions int
AvailMoveActions int
additionalMoveActions int
AvailAttackActions int
@@ -77,6 +79,7 @@ func (u *Unit) UpkeepCost() int {
}
func (u *Unit) resetBaseActions() {
+ u.AvailStreetActions = DEFAULT_AVAIL_STREET_ACTIONS + u.additionalMoveActions
u.AvailMoveActions = DEFAULT_AVAIL_MOVE_ACTIONS + u.additionalMoveActions
u.AvailAttackActions = DEFAULT_AVAIL_ATTACK_ACTIONS + u.additionalAttackActions
}
@@ -86,11 +89,10 @@ func (u *Unit) onUpkeep() {
u.resetBaseActions()
}
-func (u *Unit) MoveRangeTiles(m *Map) []*Tile {
+func (u *Unit) MoveRangeTiles() []*Tile {
tiles := []*Tile{}
- // TODO: build graph only containing possible tile in movement range
- graph := m.generateMapGraphFor(u)
- // graph := m.generateMovementRangeGraphFor(u)
+ m := u.controller.gameState.Map()
+ graph := m.generateMovementRangeGraphFor(u)
origin := TileOrContainingPermTile(u).Position
for _, pos := range PositionsInRange(origin, u.Movement.Range, false) {
tile := m.TileAt(pos)
@@ -124,7 +126,7 @@ func (u *Unit) AttackableTiles() []*Tile {
return tilesInRange
}
- // House tiles are not attackable from $anges > 1
+ // House tiles are not attackable from ranges > 1
aTiles := []*Tile{}
for _, t := range tilesInRange {
if DistanceBetweenPositions(t.Position, u.tile.Position) > 1 && t.Type == TileTypes.House {
@@ -181,6 +183,10 @@ func (u *Unit) AvailSlowActions() (actions []Action) {
actions = append(actions, NewMoveAction(u))
}
+ if u.AvailStreetActions > 0 && u.Movement != INVALID_MOVEMENT() && u.Tile().Type == TileTypes.Street {
+ actions = append(actions, NewStreetAction(u))
+ }
+
m := u.Controller().gameState.Map()
if u.AvailAttackActions > 0 && !INVALID_ATTACK(u.Attack) &&
len(u.AttackableEnemyPermanents()) > 0 {