diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-04 18:51:31 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:46:40 +0200 |
| commit | 8c3456f5a120a00f8a4e89065d7d50f2c1b4ad0d (patch) | |
| tree | 6e201152c264184bcd5aad784386654e921c8634 /go/game/action.go | |
| parent | 083ec284a9ef286729e544df9340a12760f03ab7 (diff) | |
| download | muhqs-game-8c3456f5a120a00f8a4e89065d7d50f2c1b4ad0d.tar.gz muhqs-game-8c3456f5a120a00f8a4e89065d7d50f2c1b4ad0d.zip | |
improve permanent pile support
* Fix alot of bugs caused by permanents without tiles
* Implement a permanent choice to select the permanents in a pile
* Fix how pile hooks are called
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) } |
