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/effect.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/effect.go')
| -rw-r--r-- | go/game/effect.go | 20 |
1 files changed, 10 insertions, 10 deletions
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} } |
