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/effect.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'go/game/effect.go') diff --git a/go/game/effect.go b/go/game/effect.go index 1fc6d5b0..1fd2a630 100644 --- a/go/game/effect.go +++ b/go/game/effect.go @@ -1,26 +1,26 @@ package game type effect interface { - apply(*State) - end(*State) + apply(*LocalState) + end(*LocalState) } type dynamicEffect struct { - _apply func(*State) - _end func(*State) + _apply func(*LocalState) + _end func(*LocalState) } -func (e *dynamicEffect) apply(s *State) { +func (e *dynamicEffect) apply(s *LocalState) { e._apply(s) } -func (e *dynamicEffect) end(s *State) { +func (e *dynamicEffect) end(s *LocalState) { e._end(s) } func newAdjustmentEffect(adjust func(Permanent, int), u *Unit, delta int) effect { - apply := func(*State) { adjust(u, delta) } - end := func(*State) { adjust(u, -delta) } + apply := func(*LocalState) { adjust(u, delta) } + end := func(*LocalState) { adjust(u, -delta) } return &dynamicEffect{apply, end} } @@ -41,7 +41,7 @@ func newHealthModificationEffect(u *Unit, delta int) effect { } func newTmpEffect(p Permanent, effect string) effect { - apply := func(*State) { p.addTmpEffect(effect) } - end := func(*State) { p.removeTmpEffect(effect) } + apply := func(*LocalState) { p.addTmpEffect(effect) } + end := func(*LocalState) { p.removeTmpEffect(effect) } return &dynamicEffect{apply, end} } -- cgit v1.2.3