From f9ab2cfdb25eb3fcd85868a2e375326a9c8b6022 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 15 Feb 2023 13:13:06 +0100 Subject: 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 --- go/game/state.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'go/game/state.go') diff --git a/go/game/state.go b/go/game/state.go index 31c8ad01..5c2fd053 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -111,7 +111,7 @@ func (s *State) IsValidPlay(a *PlayAction) error { } if a.Card.IsPermanent() { - spawn := a.Targets().ts[0].sel[0].(*Tile) + spawn := a.Target().sel[0].(*Tile) if !slices.Contains(s.AvailableSpawnTiles(a.Source().(*Player), a.Card), spawn) { return fmt.Errorf("Spawn %v is not a valid spawn tile for %s", spawn.Position.String(), a.Card.Name) @@ -127,7 +127,7 @@ func (s *State) IsValidMove(a *MoveAction) error { } u := a.Source().(*Unit) - tile := relaxedTileTarget(a, a.Targets().ts[0].sel[0]) + tile := relaxedTileTarget(a, a.Target().sel[0]) if !slices.Contains(u.MoveRangeTiles(s.Map), tile) { return fmt.Errorf("Unit %s@%v can not move to %s", @@ -152,7 +152,7 @@ func (s *State) IsValidAttack(a *AttackAction) error { return fmt.Errorf("%s can not attack", unit.card.Name) } - target := a.Targets().ts[0].sel[0].(Permanent) + target := a.Target().sel[0].(Permanent) if !IsPositionInRange(unit.tile.Position, target.Tile().Position, unit.Attack.MaxRange()) { return fmt.Errorf("Attack target on %s is not in attack range %d of %s on %s", target.Tile().Position.String(), unit.Attack.MaxRange(), unit.card.Name, @@ -471,3 +471,15 @@ func (s *State) AvailableSpawnTiles(p *Player, c *Card) []*Tile { return tiles } + +func (s *State) redistributeMapStoreCards() { + poc := NewPileOfCards() + for _, store := range s.Map.Stores { + store.MoveInto(poc) + } + s.Map.distributeStoreCards(poc, s.Rand) + + for _, p := range s.Players { + p.clearKnownStore() + } +} -- cgit v1.2.3