-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pause on objective completion #2096
Conversation
For reference, this is how I debugged this with an output to file that showed the state of the objective display queue: Show patch and debug output--- b/src/swarm-engine/Swarm/Game/Step.hs
+++ a/src/swarm-engine/Swarm/Game/Step.hs
@@ -341,9 +341,22 @@ hypotheticalWinCheck em g ws oc = do
_ -> return ()
queue <- messageInfo . announcementQueue Swarm.Util.<%= (>< Seq.fromList (map ObjectiveCompleted $ completionAnnouncementQueue finalAccumulator))
- shouldPause <- use $ temporal . pauseOnCompletion
- when (newWinState /= Ongoing || (notNull queue && shouldPause == PauseOnAnyObjective)) $
+ shouldPause <- use $ temporal . pauseOnCompletion
+ let willPause = newWinState /= Ongoing || (notNull queue && shouldPause == PauseOnAnyObjective)
+ -- TODO: remove this debug ouput
+ sendIO $
+ appendFile "log_win.txt" $
+ intercalate
+ " \t"
+ [ show $ getTickNumber ts
+ , if newWinState == Ongoing then "ongoing" else "won"
+ , if notNull queue then "queued" else "empty"
+ , show shouldPause
+ , if willPause then "AutoPause" else "Running"
+ ] <> "\n"
+
+ when willPause $
temporal . runStatus .= AutoPause
mapM_ handleException $ exceptions finalAccumulator
|
bc6e804
to
43c9879
Compare
src/swarm-engine/Swarm/Game/Step.hs
Outdated
queue <- messageInfo . announcementQueue Swarm.Util.<%= (>< Seq.fromList (map ObjectiveCompleted $ completionAnnouncementQueue finalAccumulator)) | ||
shouldPause <- use $ temporal . pauseOnCompletion | ||
|
||
when (newWinState /= Ongoing || (notNull queue && shouldPause == PauseOnAnyObjective)) $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to make sure I understand the logic here. What is the purpose of the notNull queue
check? How does the newWinState
check and the other check fit together? (And can you turn your answer into some comments in the code here?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named the parts using let
. Is it clearer now? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, much better, thanks!
--hide-goal Do not show goal modal window that pauses the game.
--hide-goal
--autoplay
--autoplay --hide-goal
autoplay_goals