Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snorkels-hs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Linus Heckemann CS2014
snorkels-hs
Commits
b52fc7fc
Commit
b52fc7fc
authored
8 years ago
by
Unai Zalakain
Browse files
Options
Downloads
Patches
Plain Diff
Call the winner reporting function only once for all the local players
parent
cf3a02d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Snorkels/Game.hs
+6
-0
6 additions, 0 deletions
src/Snorkels/Game.hs
src/Snorkels/Play.hs
+3
-1
3 additions, 1 deletion
src/Snorkels/Play.hs
with
9 additions
and
1 deletion
src/Snorkels/Game.hs
+
6
−
0
View file @
b52fc7fc
...
...
@@ -2,6 +2,7 @@ module Snorkels.Game ( LocalConfig (..)
,
ComputerConfig
(
..
)
,
PlayerType
(
..
)
,
Game
(
..
)
,
isLocal
,
getSurvivors
,
advancePlayer
,
getNextPlayer
...
...
@@ -38,6 +39,11 @@ data Game = Game {
}
isLocal
::
PlayerType
->
Bool
isLocal
(
LocalPlayer
_
)
=
True
isLocal
_
=
False
getSurvivors
::
Game
->
[
Player
]
getSurvivors
game
=
case
filter
hasSurvived
players
of
[]
->
[
game
&
currentPlayer
]
...
...
This diff is collapsed.
Click to expand it.
src/Snorkels/Play.hs
+
3
−
1
View file @
b52fc7fc
...
...
@@ -42,9 +42,11 @@ playRound playFunc game = do g <- playFunc game Nothing
reportWinnerAround
::
Game
->
IO
()
reportWinnerAround
game
=
case
getWinner
game
of
Just
winner
->
mapM_
(
reportToPT
winner
)
pts
Just
winner
->
do
mapM_
(
reportToPT
winner
)
nonlocals
maybe
(
return
()
)
(
reportToPT
winner
)
(
listToMaybe
locals
)
Nothing
->
return
()
where
pts
=
Map
.
elems
$
game
&
playerTypes
(
locals
,
nonlocals
)
=
partition
isLocal
pts
reportToPT
winner
pt
=
reportWinner
pt
game
winner
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment