aboutsummaryrefslogtreecommitdiff
path: root/go/game/player.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/player.go')
-rw-r--r--go/game/player.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/go/game/player.go b/go/game/player.go
index 89423b93..b4b7bd8b 100644
--- a/go/game/player.go
+++ b/go/game/player.go
@@ -21,13 +21,13 @@ type Player struct {
DiscardPile *DiscardPile
Deck *Deck
Store *Store
- gameState *State
+ gameState *LocalState
Color color.Color
Ctrl PlayerControl
knownStores map[Position]bool
}
-func NewPlayer(id int, name string, deck *Deck, gameState *State) *Player {
+func NewPlayer(id int, name string, deck *Deck, gameState *LocalState, color color.Color) *Player {
store := NewStore()
deck.MoveInto(store)
@@ -39,9 +39,10 @@ func NewPlayer(id int, name string, deck *Deck, gameState *State) *Player {
DrawPerTurn: MAX_DRAW,
Hand: NewHand(),
DiscardPile: NewDiscardPile(),
- Deck: NewDeckFromDeckList(gameState.Map.StartDeckList),
+ Deck: NewDeckFromDeckList(gameState.Map().StartDeckList),
Store: store,
gameState: gameState,
+ Color: color,
Ctrl: nil,
knownStores: make(map[Position]bool),
}
@@ -50,9 +51,9 @@ func NewPlayer(id int, name string, deck *Deck, gameState *State) *Player {
func (p *Player) resourceGain() int {
if p.Name == "The kraken" {
- return p.gameState.Map.ResourceGain * (len(p.gameState.Players) - 1)
+ return p.gameState.Map().ResourceGain * (len(p.gameState.Players()) - 1)
} else {
- return p.gameState.Map.ResourceGain
+ return p.gameState.Map().ResourceGain
}
}
@@ -62,7 +63,7 @@ func (p *Player) UpkeepGain() int {
func (p *Player) UpkeepCost() int {
cost := 0
- for _, u := range p.gameState.Units {
+ for _, u := range p.gameState.units {
if u.Controller() != p {
continue
}
@@ -89,7 +90,7 @@ func (p *Player) upkeep() {
// Skip upkeep prompt if player does not controll any units
controllsUnits := false
- for _, u := range p.gameState.Units {
+ for _, u := range p.gameState.units {
if u.Controller() == p {
controllsUnits = true
break
@@ -106,7 +107,7 @@ func (p *Player) upkeep() {
}
p.gameState.declareAction(a)
- p.gameState.Stack.resolve()
+ p.gameState.stack.resolve()
}
func (p *Player) actionPhase() {
@@ -116,13 +117,13 @@ func (p *Player) actionPhase() {
return
}
p.gameState.declareAction(a)
- p.gameState.Stack.resolve()
+ p.gameState.stack.resolve()
}
}
func (p *Player) buyPhase() {
s := p.gameState
- if p.Store.Size() == 0 && s.Map.HasStores() && len(p.knownStores) == 0 {
+ if p.Store.Size() == 0 && s.Map().HasStores() && len(p.knownStores) == 0 {
return
}
a := promptBuy(p.Ctrl)
@@ -133,7 +134,7 @@ func (p *Player) buyPhase() {
if a.Targets().HasSelections() {
s.declareAction(a)
- s.Stack.resolve()
+ s.stack.resolve()
}
}
@@ -196,7 +197,7 @@ func (p *Player) IsEnemy(other *Player) bool {
}
func (p *Player) AvailableStores() (stores []*Store) {
- m := p.gameState.Map
+ m := p.gameState.Map()
for pos, store := range m.Stores {
t := m.TileAt(pos)
if t.Permanent != nil && t.Permanent.Controller() == p {