From 926ca5cdd20a39e3e05aaa3486cb166718dab5ca Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 26 Jan 2023 22:16:10 +0100 Subject: intermeditae commit --- go/game/playerControl.go | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'go/game/playerControl.go') 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()) +} -- cgit v1.2.3