Skip to content

Commit

Permalink
Add achievement for losing
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jan 2, 2023
1 parent e8757bc commit 5c16451
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ hypotheticalWinCheck g ws oc = do
_ -> ws

winCondition .= WinConditions newWinState (completions finalAccumulator)

case newWinState of
Unwinnable _ -> do
currentTime <- sendIO getZonedTime
gameAchievements
%= M.insertWith
(<>)
LoseScenario
(Attainment (GameplayAchievement LoseScenario) Nothing currentTime)
_ -> return ()

announcementQueue %= (>< Seq.fromList (map ObjectiveCompleted $ completionAnnouncementQueue finalAccumulator))

mapM_ handleException $ exceptions finalAccumulator
Expand Down
1 change: 1 addition & 0 deletions src/Swarm/TUI/Model/Achievement/Definitions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ data GameplayAchievement
| RobotIntoWater
| AttemptSelfDestructBase
| DestroyedBase
| LoseScenario
deriving (Eq, Ord, Show, Bounded, Enum, Generic)

instance FromJSON GameplayAchievement
Expand Down
7 changes: 7 additions & 0 deletions src/Swarm/TUI/Model/Achievement/Description.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,10 @@ describe (GameplayAchievement DestroyedBase) =
"Actually destroy your base."
Moderate
True
describe (GameplayAchievement LoseScenario) =
AchievementInfo
"Silver Lining"
(Just $ Freeform "Here's your consolation prize.")
"Lose at a scenario."
Easy
True

0 comments on commit 5c16451

Please sign in to comment.