diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-12-27 12:40:19 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:58 +0100 |
| commit | 4e2ab55d345fd5e5c5d2d5bc56948611b15564d5 (patch) | |
| tree | c6998ac54687c442ad0baa541edd0fbf917b1308 /go/game/trigger.go | |
| parent | 5aa8e7ddbc41aed55e7918e6afaec0b5c07fa510 (diff) | |
| download | muhqs-game-4e2ab55d345fd5e5c5d2d5bc56948611b15564d5.tar.gz muhqs-game-4e2ab55d345fd5e5c5d2d5bc56948611b15564d5.zip | |
introduce game.State interface abstraction
This allows to not use the internal game state directly from client
code.
Diffstat (limited to 'go/game/trigger.go')
| -rw-r--r-- | go/game/trigger.go | 10 |
1 files changed, 5 insertions, 5 deletions
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 } |
