diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-08-22 11:56:46 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-22 11:56:46 +0200 |
| commit | 0667db9e5a765cbd1eec90b63fb8cd0a6e0a2dc7 (patch) | |
| tree | 155a8e692b6eed924e4b735bd8e1444cd08ba83d | |
| parent | 157a8601c10b06ab14a216372b0c06fc47f4de31 (diff) | |
| download | muhqs-game-0667db9e5a765cbd1eec90b63fb8cd0a6e0a2dc7.tar.gz muhqs-game-0667db9e5a765cbd1eec90b63fb8cd0a6e0a2dc7.zip | |
implement banner
| -rw-r--r-- | go/game/areaEffect.go | 31 | ||||
| -rw-r--r-- | go/game/cardImplementations.go | 41 | ||||
| -rw-r--r-- | go/game/effect.go | 15 |
3 files changed, 80 insertions, 7 deletions
diff --git a/go/game/areaEffect.go b/go/game/areaEffect.go index ea97b31c..9260f8a7 100644 --- a/go/game/areaEffect.go +++ b/go/game/areaEffect.go @@ -26,6 +26,21 @@ func (e *dynamicAreaEffect) onLeaving(p Permanent) { } } +func newCombinedAreaEffect(aoes []areaEffect) *dynamicAreaEffect { + return &dynamicAreaEffect{ + _onEntering: func(p Permanent) { + for _, aoe := range aoes { + aoe.onEntering(p) + } + }, + _onLeaving: func(p Permanent) { + for _, aoe := range aoes { + aoe.onLeaving(p) + } + }, + } +} + func newGrantFullActionEffect(cardPath string, f ActionFuncPrototype, desc, tag string, ) *dynamicAreaEffect { onEntering := func(p Permanent) { @@ -49,3 +64,19 @@ func newGrantFullActionEffect(cardPath string, f ActionFuncPrototype, desc, tag return newDynamicAreaEffect(onEntering, onLeaving) } + +func newAdjustmentAreaEffect(adjust func(Permanent, int), delta int) *dynamicAreaEffect { + onEntering := func(p Permanent) { + u := p.(*Unit) + e := newAdjustmentEffect(adjust, u, delta) + e.apply(u.controller.gameState) + } + + onLeaving := func(p Permanent) { + u := p.(*Unit) + e := newAdjustmentEffect(adjust, u, delta) + e.end(u.controller.gameState) + } + + return newDynamicAreaEffect(onEntering, onLeaving) +} diff --git a/go/game/cardImplementations.go b/go/game/cardImplementations.go index 9fa56e12..16205ca5 100644 --- a/go/game/cardImplementations.go +++ b/go/game/cardImplementations.go @@ -186,16 +186,30 @@ func (*pikemanImpl) onETB(s *LocalState, p Permanent) { p.(*Unit).Attack.flexAttack = pikeAttack() } -type spearImpl struct{ cardImplementationBase } +// ====== Equipments Set ====== -func (*spearImpl) onPile(p Permanent) { - // FIXME: support multiple flexAttacks - p.(*Unit).Attack.flexAttack = pikeAttack() +var bannerAoE areaEffect = newCombinedAreaEffect([]areaEffect{ + newAdjustmentAreaEffect(adjustAttack, 1), + newAdjustmentAreaEffect(adjustMovement, 1), +}) + +type bannerImpl struct { + cardImplementationBase + aoe areaEffect } -func (*spearImpl) onUnpile(p Permanent) { - // FIXME: restore flexAttack - p.(*Unit).Attack.flexAttack = nil +func (i *bannerImpl) onEntering(t *Tile) { + s := t.Permanent.Controller().gameState + for _, tile := range TilesInRange(s.Map(), t.Permanent, 1) { + tile.addEffect(i.aoe) + } +} + +func (i *bannerImpl) onLeaving(t *Tile) { + s := t.Permanent.Controller().gameState + for _, tile := range TilesInRange(s.Map(), t.Permanent, 1) { + tile.removeEffect(i.aoe) + } } type maceImpl struct { @@ -233,6 +247,18 @@ func (*poisonDaggerImpl) onPile(p Permanent) { func (*poisonDaggerImpl) onUnpile(p Permanent) { } +type spearImpl struct{ cardImplementationBase } + +func (*spearImpl) onPile(p Permanent) { + // FIXME: support multiple flexAttacks + p.(*Unit).Attack.flexAttack = pikeAttack() +} + +func (*spearImpl) onUnpile(p Permanent) { + // FIXME: restore flexAttack + p.(*Unit).Attack.flexAttack = nil +} + // ====== Magic Set ====== type attackImpl struct{ cardImplementationBase } @@ -740,6 +766,7 @@ func init() { "base/tax_collector": &taxCollectorImpl{}, "base/wormtongue": &wormtongueImpl{}, + "equipments/banner": &bannerImpl{}, "equipments/mace": &maceImpl{triggers: make(map[Permanent]Trigger)}, "equipments/poison_dagger": &poisonDaggerImpl{}, "equipments/spear": &spearImpl{}, diff --git a/go/game/effect.go b/go/game/effect.go index 4d89eea5..184f2013 100644 --- a/go/game/effect.go +++ b/go/game/effect.go @@ -24,6 +24,21 @@ func (e *dynamicEffect) end(s *LocalState) { e._end(s) } +func newCombinedEffect(effects []effect) *dynamicEffect { + return &dynamicEffect{ + _apply: func(s *LocalState) { + for _, e := range effects { + e.apply(s) + } + }, + _end: func(s *LocalState) { + for _, e := range effects { + e.end(s) + } + }, + } +} + func newAdjustmentEffect(adjust func(Permanent, int), u *Unit, delta int) effect { apply := func(*LocalState) { adjust(u, delta) } end := func(*LocalState) { adjust(u, -delta) } |
