diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-01-26 22:16:10 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:44 +0100 |
| commit | 926ca5cdd20a39e3e05aaa3486cb166718dab5ca (patch) | |
| tree | 3d7bc8a0e1e0be1ce8d92d5503bdede878e718e9 /go/game/player.go | |
| parent | 8720ebf9c74d9e11001772b5c00c293fa3a8b9e5 (diff) | |
| download | muhqs-game-926ca5cdd20a39e3e05aaa3486cb166718dab5ca.tar.gz muhqs-game-926ca5cdd20a39e3e05aaa3486cb166718dab5ca.zip | |
intermeditae commit
Diffstat (limited to 'go/game/player.go')
| -rw-r--r-- | go/game/player.go | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/go/game/player.go b/go/game/player.go index 017e8407..608fc7e9 100644 --- a/go/game/player.go +++ b/go/game/player.go @@ -2,7 +2,6 @@ package game import ( "image/color" - "log" ) const ( @@ -13,7 +12,7 @@ type Player struct { Id int Name string Turn int - Ressource int + Resource int DrawPerTurn int Hand *Hand DiscardPile *DiscardPile @@ -24,29 +23,39 @@ type Player struct { Ctrl PlayerControl } -func NewPlayer(id int, name string, - deck *Deck, store *Store, +func NewPlayer(id int, name string, deck *Deck, gameState *State, color color.Color, ) *Player { + store := NewStore() + deck.MoveInto(store) + p := Player{ - id, name, - 0, 0, MAX_DRAW, - NewHand(), NewDiscardPile(), deck, store, - gameState, color, nil, + Id: id, + Name: name, + Turn: 0, + Resource: 0, + DrawPerTurn: MAX_DRAW, + Hand: NewHand(), + DiscardPile: NewDiscardPile(), + Deck: NewDeckFromDeckList(gameState.Map.StartDeckList), + Store: store, + gameState: gameState, + Color: color, + Ctrl: nil, } return &p } func (p *Player) resourceGain() int { if p.Name == "The kraken" { - return p.gameState.Map.RessourceGain * (len(p.gameState.Players) - 1) + return p.gameState.Map.ResourceGain * (len(p.gameState.Players) - 1) } else { - return p.gameState.Map.RessourceGain + return p.gameState.Map.ResourceGain } } func (p *Player) Upkeep() { - p.Ressource += p.resourceGain() + p.Resource += p.resourceGain() // TODO: handle upkeep triggers @@ -56,7 +65,8 @@ func (p *Player) Upkeep() { } // TODO: let players decide if they want to pay the upkeep - p.Ressource -= unit.Upkeep + p.Resource -= unit.Upkeep + // TODO: better refresh unit actions unit.AvailAttackActions = 1 unit.AvailMoveActions = 1 @@ -65,8 +75,7 @@ func (p *Player) Upkeep() { func (p *Player) ActionPhase() { for { - a := PromptAction(p.Ctrl) - log.Printf("Received %T action from %s\n", a, p.Name) + a := promptAction(p.Ctrl) if _, ok := a.(*PassPriorityAction); ok { return } @@ -76,11 +85,17 @@ func (p *Player) ActionPhase() { } func (p *Player) buy(c *Card) { - p.Ressource -= c.BuyCost + p.Resource -= c.BuyCost p.DiscardPile.AddCard(c) } func (p *Player) BuyPhase() { + a := promptBuy(p.Ctrl) + if _, ok := a.(*PassPriorityAction); ok { + return + } + p.gameState.DeclareAction(a) + p.gameState.Stack.Resolve() // TODO: select card to buy } |
