diff options
Diffstat (limited to 'go/game/action.go')
| -rw-r--r-- | go/game/action.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/go/game/action.go b/go/game/action.go index 08e42f64..934f5645 100644 --- a/go/game/action.go +++ b/go/game/action.go @@ -129,6 +129,14 @@ type MoveAction struct { const moveActionTargetDesc = "available tile" +func (a *MoveAction) targetTile() *Tile { + if t, ok := a.targets.sel[0].(*Tile); ok { + return t + } + + return a.targets.sel[0].(*Unit).Tile() +} + func NewMoveAction(u *Unit) *MoveAction { a := &MoveAction{ ActionBase{ @@ -140,7 +148,7 @@ func NewMoveAction(u *Unit) *MoveAction { a.targets = newTargets(u.Controller().gameState, []string{moveActionTargetDesc}, a) a.resolveFunc = func(s *State) { - tile := a.targets.sel[0].(*Tile) + tile := a.targetTile() u.move(s, tile) } @@ -161,7 +169,7 @@ func (a *MoveAction) String() string { return fmt.Sprintf("move %s", u.Movement.String()) } - t := a.targets.sel[0].(*Tile) + t := a.targetTile() return fmt.Sprintf("%v: %v -> %v", u.Controller().Name, u.Card().Name, t.Position) } |
