diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-15 13:13:06 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:49 +0100 |
| commit | f9ab2cfdb25eb3fcd85868a2e375326a9c8b6022 (patch) | |
| tree | b96f16e6cf4a6dcf93b9557a7219179ab2f46c8d /go/game/cardImplementations.go | |
| parent | 805cbf397589e5cb861f866713c2eb4bec9ce40b (diff) | |
| download | muhqs-game-f9ab2cfdb25eb3fcd85868a2e375326a9c8b6022.tar.gz muhqs-game-f9ab2cfdb25eb3fcd85868a2e375326a9c8b6022.zip | |
intermediate commit
* fix a lot of target and action bugs
* check target selection before adding it to the prompt
* use the store view for stores on the map
* fix card highlighting in CardGrid
* Only prompt for Upkeep-/DiscardActions if appropriate
* Add helper for areaEffects granting new FullActions
* Add Target() helper selecting the first target to the Action interface
* Fix BuyAction and DiscardAction targets
* Remember the stores a player has seen
Diffstat (limited to 'go/game/cardImplementations.go')
| -rw-r--r-- | go/game/cardImplementations.go | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/go/game/cardImplementations.go b/go/game/cardImplementations.go index a9da5fb1..038ce2d6 100644 --- a/go/game/cardImplementations.go +++ b/go/game/cardImplementations.go @@ -34,9 +34,9 @@ type missionaryImpl struct{ cardImplementationBase } func (*missionaryImpl) fullActions(u *Unit) []*FullAction { resolvePrototype := func(a Action) ActionResolveFunc { u := a.Source().(*Unit) - target := a.Targets().ts[0].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() } @@ -66,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) } } @@ -129,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().ts[0].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(newTarget(s, newTargetDesc("adjacent water tile"), a)) + a.targets = newTargets(newTarget(s, newTargetDesc("adjacent free water tile"), a)) return []*FullAction{a} } @@ -167,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 } @@ -330,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) } } } @@ -344,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{}, |
