aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go/game/state.go47
1 files changed, 40 insertions, 7 deletions
diff --git a/go/game/state.go b/go/game/state.go
index 25385f31..6c77a42f 100644
--- a/go/game/state.go
+++ b/go/game/state.go
@@ -571,13 +571,38 @@ func (s *LocalState) addNewEquipment(card *Card, pos Position, owner *Player) *E
return e
}
-func (s *LocalState) removePermanent(p Permanent) {
+// MovePermanent moves a permanent without doing anything else.
+// This method does not perform any checks or trigger effects.
+// Its purpose is to modify the game state in situations where rules are not enforced (ui.FreeMapControl).
+func (s *LocalState) MovePermanent(p Permanent, t *Tile) {
+ if cp := p.ContainingPerm(); cp != nil {
+ removePermanentFromPile(cp, p)
+ } else {
+ p.Tile().Permanent = nil
+ }
+
+ if cp := t.Permanent; cp != nil {
+ addPermanentToPile(cp, p)
+ } else {
+ t.Permanent = p
+ p.SetTile(t)
+ }
+}
+
+// RemovePermanent removes a Permanent from the game state.
+// This method does not perform checks or triggers effects.
+func (s *LocalState) RemovePermanent(p Permanent) {
for i, perm := range s.permanents {
if perm == p {
s.permanents[i] = s.permanents[len(s.permanents)-1]
s.permanents = s.permanents[:len(s.permanents)-1]
}
}
+
+ switch p := p.(type) {
+ case *Unit:
+ s.units = removePtr(s.units, p)
+ }
}
func removePtr[P *Unit](collection []P, ptr P) []P {
@@ -594,12 +619,7 @@ func (s *LocalState) destroyPermanent(p Permanent) {
t := TileOrContainingPermTile(p)
_leaveTile(p)
- s.removePermanent(p)
-
- switch p := p.(type) {
- case *Unit:
- s.units = removePtr(s.units, p)
- }
+ s.RemovePermanent(p)
if pile := p.Pile(); len(pile) > 0 {
dropAction := newPileDropAction(p, t, pile)
@@ -794,3 +814,16 @@ func (s *LocalState) endOfTurn() {
s.events = append(s.events, newEotEvent())
s.stateBasedActions()
}
+
+// ResolveAction resolves an action without using the stack.
+func (s *LocalState) ResolveAction(a Action) {
+ a.resolve(s)
+}
+
+func (s *LocalState) SetPhase(p PhaseType) {
+ s.activePhase = p
+}
+
+func (s *LocalState) SetActivePlayer(p *Player) {
+ s.activePlayerId = p.Id
+}