aboutsummaryrefslogtreecommitdiff
path: root/go/game/state.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-17 00:29:26 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:50:11 +0200
commit28defc1cad1a96a2954780efa01396db8bb2fe31 (patch)
treeb6bf6e43d48a7bc7f0ccce7d6f4253e1e15e6492 /go/game/state.go
parent8f81177d191b3e6d80212e1fa370d37db2fe38ce (diff)
downloadmuhqs-game-28defc1cad1a96a2954780efa01396db8bb2fe31.tar.gz
muhqs-game-28defc1cad1a96a2954780efa01396db8bb2fe31.zip
implement unit and artifact switch action
Simplify the Choice Widget and make it a TextBox variant. Drive-by fixes: * ui.Collection: prioritize newer widgets during active widget selection * game.FullAction: fix incorrect cost function. Full actions cost all available actions. Also fix the cost check
Diffstat (limited to 'go/game/state.go')
-rw-r--r--go/game/state.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/go/game/state.go b/go/game/state.go
index 7fa6e1bf..4af56b10 100644
--- a/go/game/state.go
+++ b/go/game/state.go
@@ -362,6 +362,17 @@ func (s *State) MoveUnit(u *Unit, t *Tile) {
u.move(s, t)
}
+func (s *State) switchPermanents(p1 Permanent, p2 Permanent) {
+ t1 := TileOrContainingPermTile(p1)
+ t2 := TileOrContainingPermTile(p2)
+
+ leaveTile(p1)
+ leaveTile(p2)
+
+ enterTileOrPile(p1, t2)
+ enterTileOrPile(p2, t1)
+}
+
func (s *State) FilterUnits(filter func(*Unit) bool) []*Unit {
units := []*Unit{}
for _, u := range s.Units {