aboutsummaryrefslogtreecommitdiff
path: root/go/game/stack.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/stack.go')
-rw-r--r--go/game/stack.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/go/game/stack.go b/go/game/stack.go
index 45ba4072..9132ae13 100644
--- a/go/game/stack.go
+++ b/go/game/stack.go
@@ -18,7 +18,6 @@ func (s *Stack) IsEmpty() bool {
}
func (s *Stack) Push(a Action) {
- s.gameState.broadcastNotification(NewDeclaredActionNotification(a))
s.Actions = append(s.Actions, a)
}
@@ -27,16 +26,21 @@ func (s *Stack) Pop() {
if l == 0 {
log.Fatalf("Can not pop from empty stack")
}
+
a := s.Actions[l-1]
s.Actions = s.Actions[:l-1]
- a.Resolve(s.gameState)
- s.gameState.broadcastNotification(NewResolvedActionNotification(a))
+
+ err := s.gameState.ValidateAction(a)
+ if err == nil {
+ a.Resolve(s.gameState)
+ }
+ log.Println("Resolved", a, err)
+ s.gameState.broadcastNotification(NewResolvedActionNotification(a, err))
}
func (s *Stack) Resolve() {
for !s.IsEmpty() {
- log.Println("Resolve Stack")
- s.gameState.AllPassing()
+ s.gameState.AllPassing(false)
s.Pop()
}
}