aboutsummaryrefslogtreecommitdiff
path: root/go/game/player.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-01-31 00:16:53 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2023-01-31 00:16:53 +0100
commitd76117cc913c738002c7562189ada75748645ff1 (patch)
tree0b0acd248870eb57eee272fa60905fdfc578dd14 /go/game/player.go
parent37204e799318a8140372b1fa8e5265e02af3fe96 (diff)
downloadmuhqs-game-d76117cc913c738002c7562189ada75748645ff1.tar.gz
muhqs-game-d76117cc913c738002c7562189ada75748645ff1.zip
intermediate commit
Diffstat (limited to 'go/game/player.go')
-rw-r--r--go/game/player.go37
1 files changed, 27 insertions, 10 deletions
diff --git a/go/game/player.go b/go/game/player.go
index 608fc7e9..7a72e111 100644
--- a/go/game/player.go
+++ b/go/game/player.go
@@ -2,6 +2,7 @@ package game
import (
"image/color"
+ "log"
)
const (
@@ -60,7 +61,7 @@ func (p *Player) Upkeep() {
// TODO: handle upkeep triggers
for _, unit := range p.gameState.Units {
- if unit.Controller != p {
+ if unit.controller != p {
continue
}
@@ -76,7 +77,7 @@ func (p *Player) Upkeep() {
func (p *Player) ActionPhase() {
for {
a := promptAction(p.Ctrl)
- if _, ok := a.(*PassPriorityAction); ok {
+ if _, ok := a.(*PassPriority); ok {
return
}
p.gameState.DeclareAction(a)
@@ -84,19 +85,13 @@ func (p *Player) ActionPhase() {
}
}
-func (p *Player) buy(c *Card) {
- p.Resource -= c.BuyCost
- p.DiscardPile.AddCard(c)
-}
-
func (p *Player) BuyPhase() {
a := promptBuy(p.Ctrl)
- if _, ok := a.(*PassPriorityAction); ok {
+ if _, ok := a.(*PassPriority); ok {
return
}
p.gameState.DeclareAction(a)
p.gameState.Stack.Resolve()
- // TODO: select card to buy
}
func (p *Player) DiscardCard(c *Card) {
@@ -104,7 +99,24 @@ func (p *Player) DiscardCard(c *Card) {
}
func (p *Player) DiscardPhase() {
- // TODO: select cards to discard
+ cards := p.PromptHandCardSelection(0, p.Deck.Size())
+ for _, c := range cards {
+ p.DiscardCard(c)
+ }
+}
+
+func (p *Player) PromptHandCardSelection(min, max int) []*Card {
+ p.Ctrl.SendNotification(NewHandCardSelectionPrompt(min, max))
+ switch a := p.Ctrl.RecvAction().(type) {
+ case *HandCardSelection:
+ // TODO: validate cards
+ return a.cards
+ case *PassPriority:
+ return nil
+ default:
+ log.Fatalf("Unexpected response type %T for hand card selection", a)
+ }
+ return nil
}
func (p *Player) Draw() {
@@ -120,3 +132,8 @@ func (p *Player) DrawN(n int) {
drawnCards := p.Deck.Draw(n)
p.Hand.AddCards(drawnCards)
}
+
+func (p *Player) IsEnemy(other *Player) bool {
+ // TODO: support coop / teams
+ return p != other
+}