diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-08 17:50:10 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:50:10 +0200 |
| commit | 45df9bf319d38db916ca983b8c92bb912f5ce9ee (patch) | |
| tree | d7966002dad4a20bc3ef385bd152554fe278a6df /go/game/cardImplementations.go | |
| parent | eb10f6f4940ecd09fd7d881fe5e1735ff146f919 (diff) | |
| download | muhqs-game-45df9bf319d38db916ca983b8c92bb912f5ce9ee.tar.gz muhqs-game-45df9bf319d38db916ca983b8c92bb912f5ce9ee.zip | |
intermediate commit
Diffstat (limited to 'go/game/cardImplementations.go')
| -rw-r--r-- | go/game/cardImplementations.go | 61 |
1 files changed, 19 insertions, 42 deletions
diff --git a/go/game/cardImplementations.go b/go/game/cardImplementations.go index 3a7a729a..038ce2d6 100644 --- a/go/game/cardImplementations.go +++ b/go/game/cardImplementations.go @@ -34,15 +34,18 @@ type missionaryImpl struct{ cardImplementationBase } func (*missionaryImpl) fullActions(u *Unit) []*FullAction { resolvePrototype := func(a Action) ActionResolveFunc { u := a.Source().(*Unit) - target := a.Targets().sel[0].(*Unit) + target := a.Target().sel[0].(*Unit) return func(s *State) { - target.addMarks(UnitMarks.Faith, 2) + target.adjustMarks(UnitMarks.Faith, 2) if target.Marks(UnitMarks.Faith) > target.Card().BuyCost { target.controller = u.Controller() } } } - return []*FullAction{NewFullAction(u, resolvePrototype, "put faith ...")} + s := u.Controller().gameState + a := NewFullAction(u, resolvePrototype, "put faith ...") + a.targets = newTargets(newTarget(s, newTargetDesc("unit"), a)) + return []*FullAction{a} } type swordImpl struct{ cardImplementationBase } @@ -63,59 +66,33 @@ func (*misinformationImpl) onPlay(s *State, c *Card, _ *Player, _ *Targets) { // ====== Nautics Set ====== -type fishTrapAoE struct{} - -func (*fishTrapAoE) onEntering(p Permanent) { - if p.Card().Name != "nautics/fisher" { - return - } - - fisher := p.(*Unit) - fishTrapAction := func(a Action) ActionResolveFunc { +var fishTrapAoE areaEffect = newGrantFullActionEffect("nautics/fisher", + func(a Action) ActionResolveFunc { u := a.Source().(*Unit) return func(s *State) { controller := u.Controller() controller.gainResource(2) } - } - - fa := NewFullAction(fisher, fishTrapAction, "gain 2 resource") - fa.tag = "fishTrapAction" - fisher.FullActions = append(fisher.FullActions, fa) -} - -func (*fishTrapAoE) onLeaving(p Permanent) { - if p.Card().Name != "nautics/fisher" { - return - } - - fisher := p.(*Unit) - for i, fa := range fisher.FullActions { - if fa.tag != "fishTrapAction" { - continue - } - fisher.FullActions[i] = fisher.FullActions[len(fisher.FullActions)-1] - fisher.FullActions = fisher.FullActions[:len(fisher.FullActions)-1] - break - } -} + }, "gain 2 resource", "fishTrapAction") type fishTrapImpl struct { cardImplementation - aoe fishTrapAoE + aoe areaEffect } +func (*fishTrapImpl) stateBasedActions(s *State, p Permanent) {} + func (i *fishTrapImpl) onEntering(t *Tile) { s := t.Permanent.Controller().gameState for _, tile := range TilesInRange(s.Map, t.Permanent, 1) { - tile.addEffect(&i.aoe) + tile.addEffect(i.aoe) } } func (i *fishTrapImpl) onLeaving(t *Tile) { s := t.Permanent.Controller().gameState for _, tile := range TilesInRange(s.Map, t.Permanent, 1) { - tile.removeEffect(&i.aoe) + tile.removeEffect(i.aoe) } } @@ -126,12 +103,12 @@ func (*fisherImpl) fullActions(u *Unit) []*FullAction { resolvePrototype := func(a Action) ActionResolveFunc { u := a.Source().(*Unit) return func(s *State) { - t := a.Targets().sel[0].(*Tile) + t := a.Target().sel[0].(*Tile) s.AddNewArtifact(NewCard("nautics/fish_trap"), t.Position, u.Controller()) } } a := NewFullAction(u, resolvePrototype, "create fish trap") - a.targets = newTargets(s, []string{"adjacent water tile"}, a) + a.targets = newTargets(newTarget(s, newTargetDesc("adjacent free water tile"), a)) return []*FullAction{a} } @@ -164,7 +141,7 @@ func (*sailorImpl) onUnpile(containing Permanent) { type tidesChangeImpl struct{ cardImplementation } func (*tidesChangeImpl) onPlay(s *State, _ *Card, _ *Player, _ *Targets) { - s.Map.redistributeStoreCards(s.Rand) + s.redistributeMapStoreCards() } type dejaVuImpl struct{ cardImplementation } @@ -327,7 +304,7 @@ func (*unholyCannonballImpl) onPlay(s *State, _ *Card, kraken *Player, _ *Target kraken.gainResource(5) } else { for _, u := range enemiesInRange2 { - u.addMarks(UnitStates.Panic, 1) + u.adjustMarks(UnitStates.Panic, 1) } } } @@ -341,7 +318,7 @@ func init() { "base/misinformation": &misinformationImpl{}, "nautics/captain": &captainImpl{}, - "nautics/fish_trap": &fishTrapImpl{}, + "nautics/fish_trap": &fishTrapImpl{aoe: fishTrapAoE}, "nautics/fisher": &fisherImpl{}, "nautics/sailor": &sailorImpl{}, |
