From 4e2ab55d345fd5e5c5d2d5bc56948611b15564d5 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 27 Dec 2024 12:40:19 +0100 Subject: introduce game.State interface abstraction This allows to not use the internal game state directly from client code. --- go/game/trigger.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'go/game/trigger.go') diff --git a/go/game/trigger.go b/go/game/trigger.go index 4af863e5..eb0cc424 100644 --- a/go/game/trigger.go +++ b/go/game/trigger.go @@ -86,12 +86,12 @@ type Trigger interface { Source() interface{} String() string Card() *Card - trigger(*State, Event) ([]*TriggeredAction, bool) + trigger(*LocalState, Event) ([]*TriggeredAction, bool) } type triggerBase struct { source interface{} - condition func(*State, Event) (bool, bool) + condition func(*LocalState, Event) (bool, bool) resolveFunc ActionResolveFunc costFunc ActionCostFunc desc string @@ -112,7 +112,7 @@ func (t *triggerBase) Card() *Card { return nil } -func (t *triggerBase) trigger(s *State, e Event) ([]*TriggeredAction, bool) { +func (t *triggerBase) trigger(s *LocalState, e Event) ([]*TriggeredAction, bool) { triggered, remove := t.condition(s, e) if !triggered { return nil, remove @@ -123,7 +123,7 @@ func (t *triggerBase) trigger(s *State, e Event) ([]*TriggeredAction, bool) { func newTargetedTrigger(p Permanent, singleshot bool, resolveFunc ActionResolveFunc, desc string) Trigger { t := triggerBase{source: p, resolveFunc: resolveFunc, desc: desc} - t.condition = func(_ *State, event Event) (bool, bool) { + t.condition = func(_ *LocalState, event Event) (bool, bool) { c := event.eventType == EventTypes.Target && slices.Contains(event.affected, p.(interface{})) remove := singleshot && c @@ -134,7 +134,7 @@ func newTargetedTrigger(p Permanent, singleshot bool, resolveFunc ActionResolveF func newDeathTrigger(p Permanent, singleshot bool, resolveFunc ActionResolveFunc, permCond func(Permanent) bool, desc string) Trigger { t := triggerBase{source: p, resolveFunc: resolveFunc, desc: desc} - t.condition = func(_ *State, event Event) (bool, bool) { + t.condition = func(_ *LocalState, event Event) (bool, bool) { if !(event.eventType == EventTypes.Sacrifice || event.eventType == EventTypes.Destruction) { return false, false } -- cgit v1.2.3