aboutsummaryrefslogtreecommitdiff
path: root/go/game/playerControl.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/playerControl.go')
-rw-r--r--go/game/playerControl.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/go/game/playerControl.go b/go/game/playerControl.go
index 6d5e8e14..5e1552f0 100644
--- a/go/game/playerControl.go
+++ b/go/game/playerControl.go
@@ -6,6 +6,8 @@ const (
DeclaredActionNotification = iota
ResolvedActionNotification
PriorityNotification
+ UpkeepPrompt
+ BuyPrompt
)
func (n PlayerNotification) IsPriorityNotification() bool {
@@ -14,19 +16,28 @@ func (n PlayerNotification) IsPriorityNotification() bool {
type PlayerNotification struct {
Notification PlayerNotificationType
- Action Action
+ Context interface{}
+ Error error
}
func NewPriorityNotification() PlayerNotification {
- return PlayerNotification{PriorityNotification, nil}
+ return PlayerNotification{PriorityNotification, nil, nil}
}
-func NewDeclaredActionNotification(a Action) PlayerNotification {
- return PlayerNotification{DeclaredActionNotification, a}
+func NewDeclaredActionNotification(a Action, err error) PlayerNotification {
+ return PlayerNotification{DeclaredActionNotification, a, err}
}
-func NewResolvedActionNotification(a Action) PlayerNotification {
- return PlayerNotification{ResolvedActionNotification, a}
+func NewResolvedActionNotification(a Action, err error) PlayerNotification {
+ return PlayerNotification{ResolvedActionNotification, a, err}
+}
+
+func NewUpkeepPrompt(u *Unit) PlayerNotification {
+ return PlayerNotification{ResolvedActionNotification, u, nil}
+}
+
+func NewBuyPrompt() PlayerNotification {
+ return PlayerNotification{BuyPrompt, nil, nil}
}
type PlayerControl interface {
@@ -62,7 +73,15 @@ func NewChanPlayerControl() *ChanPlayerControl {
return &ChanPlayerControl{a, n}
}
-func PromptAction(ctrl PlayerControl) Action {
+func prompt(ctrl PlayerControl, notification PlayerNotification) Action {
ctrl.SendNotification(NewPriorityNotification())
return ctrl.RecvAction()
}
+
+func promptBuy(ctrl PlayerControl) Action {
+ return prompt(ctrl, NewBuyPrompt())
+}
+
+func promptAction(ctrl PlayerControl) Action {
+ return prompt(ctrl, NewPriorityNotification())
+}