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/playerControl.go | |
| parent | 8720ebf9c74d9e11001772b5c00c293fa3a8b9e5 (diff) | |
| download | muhqs-game-926ca5cdd20a39e3e05aaa3486cb166718dab5ca.tar.gz muhqs-game-926ca5cdd20a39e3e05aaa3486cb166718dab5ca.zip | |
intermeditae commit
Diffstat (limited to 'go/game/playerControl.go')
| -rw-r--r-- | go/game/playerControl.go | 33 |
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()) +} |
