diff options
Diffstat (limited to 'go/game/targets.go')
| -rw-r--r-- | go/game/targets.go | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/go/game/targets.go b/go/game/targets.go index 58f19dc1..c5acf514 100644 --- a/go/game/targets.go +++ b/go/game/targets.go @@ -22,7 +22,7 @@ type ( } Target struct { - s *State + s *LocalState desc string requirement TargetRequirement constraint TargetConstraintFunc @@ -69,7 +69,7 @@ func (t *Targets) String() string { return s[:len(s)-1] + "]" } -func newTargetWithSel(s *State, desc TargetDesc, action Action, sel []interface{}) *Target { +func newTargetWithSel(s *LocalState, desc TargetDesc, action Action, sel []interface{}) *Target { t := &Target{ s: s, desc: desc.target, @@ -81,11 +81,11 @@ func newTargetWithSel(s *State, desc TargetDesc, action Action, sel []interface{ return t } -func newTarget(s *State, desc TargetDesc, action Action) *Target { +func newTarget(s *LocalState, desc TargetDesc, action Action) *Target { return newTargetWithSel(s, desc, action, []interface{}{}) } -func newConstraintTarget(s *State, desc TargetDesc, constraint TargetConstraintFunc, action Action, +func newConstraintTarget(s *LocalState, desc TargetDesc, constraint TargetConstraintFunc, action Action, ) *Target { return &Target{ s: s, @@ -103,7 +103,7 @@ func newTargetDesc(desc string) TargetDesc { return TargetDesc{desc, "1"} } -func newPileDropTargets(s *State, a *PileDropAction) *Targets { +func newPileDropTargets(s *LocalState, a *PileDropAction) *Targets { pile := a.pile targets := newTargets() @@ -123,7 +123,7 @@ func newPileDropTargets(s *State, a *PileDropAction) *Targets { return targets } -func newArtifactMoveTargets(s *State, a *ArtifactMoveAction) *Targets { +func newArtifactMoveTargets(s *LocalState, a *ArtifactMoveAction) *Targets { targets := newTargets() targets.ts = make([]*Target, 0, 2) @@ -202,7 +202,7 @@ func (t *Target) Options() (options []interface{}) { return options } -func (t *Target) CheckSelection(s *State) error { +func (t *Target) CheckSelection(s *LocalState) error { if t.RequireSelection() { return fmt.Errorf("Number of selected targets and required ones does not match") } @@ -251,7 +251,7 @@ func (t *Targets) Cur() *Target { return t.ts[t.idx] } func (t *Targets) Next() { t.idx++ } func (t *Targets) Targets() []*Target { return t.ts } -func (t *Targets) CheckTargets(s *State) error { +func (t *Targets) CheckTargets(s *LocalState) error { for _, target := range t.ts { if err := target.CheckSelection(s); err != nil { return err @@ -318,7 +318,7 @@ func noPreviousSelectionConstraint(targets *Targets, idx int) TargetConstraintFu } } -func targetConstraint(desc string, s *State, action Action) TargetConstraintFunc { +func targetConstraint(desc string, s *LocalState, action Action) TargetConstraintFunc { if !strings.Contains(desc, " or ") { return singleTargetConstraint(desc, s, action) } @@ -332,7 +332,7 @@ func targetConstraint(desc string, s *State, action Action) TargetConstraintFunc return disjunction(constraints...) } -func singleTargetConstraint(desc string, s *State, action Action) TargetConstraintFunc { +func singleTargetConstraint(desc string, s *LocalState, action Action) TargetConstraintFunc { constraints := []TargetConstraintFunc{} if strings.Contains(desc, "permanent") { constraints = append(constraints, parsePermanentTargetConstraint(desc, s, action)...) @@ -454,7 +454,7 @@ var ( cardTargetConstraint TargetConstraintFunc = typeTargetConstraint[*Card]("*Card") ) -func parsePermanentTargetConstraint(desc string, s *State, action Action) []TargetConstraintFunc { +func parsePermanentTargetConstraint(desc string, s *LocalState, action Action) []TargetConstraintFunc { constraints := []TargetConstraintFunc{permanentTargetConstraint} if strings.Contains(desc, "enemy permanent") { @@ -477,7 +477,7 @@ func parsePermanentTargetConstraint(desc string, s *State, action Action) []Targ return constraints } -func parseUnitTargetConstraint(desc string, s *State, action Action) []TargetConstraintFunc { +func parseUnitTargetConstraint(desc string, s *LocalState, action Action) []TargetConstraintFunc { constraints := []TargetConstraintFunc{unitTargetConstraint} if strings.Contains(desc, "enemy unit") { @@ -496,7 +496,7 @@ func parseUnitTargetConstraint(desc string, s *State, action Action) []TargetCon return constraints } -func parseArtifactTargetConstraint(constraint string, s *State, action Action) []TargetConstraintFunc { +func parseArtifactTargetConstraint(constraint string, s *LocalState, action Action) []TargetConstraintFunc { constraints := []TargetConstraintFunc{artifactTargetConstraint} return constraints } @@ -544,18 +544,18 @@ func availableTileConstraint(action Action, card *Card) TargetConstraintFunc { } } -func moveConstraint(s *State, action Action, u *Unit) TargetConstraintFunc { +func moveConstraint(s *LocalState, action Action, u *Unit) TargetConstraintFunc { return func(t interface{}) (err error) { // Some actions allow also unit targets as though they were tiles tile := relaxedTileTarget(action, t) - if slices.Contains(u.MoveRangeTiles(s.Map), tile) { + if slices.Contains(u.MoveRangeTiles(s.Map()), tile) { return nil } return fmt.Errorf("tile %v is not in %v's movement range", tile, u) } } -func parseTileTargetConstraint(desc string, s *State, action Action) []TargetConstraintFunc { +func parseTileTargetConstraint(desc string, s *LocalState, action Action) []TargetConstraintFunc { constraints := []TargetConstraintFunc{} if moveAction, ok := action.(*MoveAction); ok { @@ -624,7 +624,7 @@ func parseTileTargetConstraint(desc string, s *State, action Action) []TargetCon return constraints } -func parseCardTargetConstraint(desc string, s *State, action Action) []TargetConstraintFunc { +func parseCardTargetConstraint(desc string, s *LocalState, action Action) []TargetConstraintFunc { constraints := []TargetConstraintFunc{cardTargetConstraint} player := action.Source().(*Player) @@ -634,7 +634,7 @@ func parseCardTargetConstraint(desc string, s *State, action Action) []TargetCon if strings.Contains(desc, "opponent") { originDesc = "a opponent's" origins = []*Player{} - for _, p := range s.Players { + for _, p := range s.Players() { if p.IsEnemy(player) { origins = append(origins, p) } @@ -663,7 +663,7 @@ func parseCardTargetConstraint(desc string, s *State, action Action) []TargetCon case "hand": pocs = append(pocs, p.Hand) case "store": - if p.gameState.Map.HasStores() { + if p.gameState.Map().HasStores() { for _, s := range p.AvailableStores() { pocs = append(pocs, s) } @@ -694,23 +694,23 @@ func (t *Target) candidates() []interface{} { strings.Contains(t.desc, "artifact") || strings.Contains(t.desc, "permanent") { - return utils.TypedSliceToInterfaceSlice(t.s.Permanents) + return utils.TypedSliceToInterfaceSlice(t.s.Permanents()) } else if strings.Contains(t.desc, "tile") { - return utils.TypedSliceToInterfaceSlice(t.s.Map.AllTiles()) + return utils.TypedSliceToInterfaceSlice(t.s.Map().AllTiles()) } else if strings.Contains(t.desc, "card") { cards := NewPileOfCards() switch t.desc { case "hand card": - for _, p := range t.s.Players { + for _, p := range t.s.Players() { cards.AddPoc(p.Hand) } case "store card": - if t.s.Map.HasStores() { - for _, store := range t.s.Map.Stores { + if t.s.Map().HasStores() { + for _, store := range t.s.Stores() { cards.AddPoc(store) } } else { - for _, p := range t.s.Players { + for _, p := range t.s.Players() { cards.AddPoc(p.Store) } } |
