License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Swarm.Game.ScenarioInfo
Description
Saving and loading info about scenarios (status, path, etc.) as well as loading recursive scenario collections.
Synopsis
- data ScenarioStatus
- _NotStarted :: Prism' ScenarioStatus ()
- data ScenarioInfo = ScenarioInfo {}
- scenarioPath :: Lens' ScenarioInfo FilePath
- scenarioStatus :: Lens' ScenarioInfo ScenarioStatus
- data CodeSizeDeterminators = CodeSizeDeterminators (Maybe ProcessedTerm) Bool
- updateScenarioInfoOnFinish :: CodeSizeDeterminators -> ZonedTime -> TickNumber -> Bool -> ScenarioInfo -> ScenarioInfo
- type ScenarioInfoPair = (Scenario, ScenarioInfo)
- data ScenarioCollection = SC {}
- scenarioCollectionToList :: ScenarioCollection -> [ScenarioItem]
- flatten :: ScenarioItem -> [ScenarioInfoPair]
- scenarioItemByPath :: FilePath -> Traversal' ScenarioCollection ScenarioItem
- normalizeScenarioPath :: MonadIO m => ScenarioCollection -> FilePath -> m FilePath
- data ScenarioItem
- scenarioItemName :: ScenarioItem -> Text
- _SISingle :: Prism' ScenarioItem ScenarioInfoPair
- loadScenarios :: (Has (Accum (Seq SystemFailure)) sig m, Has (Lift IO) sig m) => EntityMap -> WorldMap -> m ScenarioCollection
- loadScenarioInfo :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => FilePath -> m ScenarioInfo
- saveScenarioInfo :: FilePath -> ScenarioInfo -> IO ()
- module Swarm.Game.Scenario
Scenario info
data ScenarioStatus Source #
A ScenarioStatus
stores the status of a scenario along with
appropriate metadata: NotStarted
, or Played
.
The Played
status has two sub-states: Attempted
or Completed
.
Instances
_NotStarted :: Prism' ScenarioStatus () Source #
data ScenarioInfo Source #
A ScenarioInfo
record stores metadata about a scenario: its
canonical path and status.
By way of the ScenarioStatus
record, it stores the
most recent status and best-ever status.
Constructors
ScenarioInfo | |
Fields |
Instances
scenarioPath :: Lens' ScenarioInfo FilePath Source #
The path of the scenario, relative to data/scenarios
.
scenarioStatus :: Lens' ScenarioInfo ScenarioStatus Source #
The status of the scenario.
data CodeSizeDeterminators Source #
Constructors
CodeSizeDeterminators (Maybe ProcessedTerm) Bool |
Instances
Show CodeSizeDeterminators Source # | |
Defined in Swarm.Game.Scenario.Scoring.CodeSize Methods showsPrec :: Int -> CodeSizeDeterminators -> ShowS # show :: CodeSizeDeterminators -> String # showList :: [CodeSizeDeterminators] -> ShowS # |
updateScenarioInfoOnFinish :: CodeSizeDeterminators -> ZonedTime -> TickNumber -> Bool -> ScenarioInfo -> ScenarioInfo Source #
Update the current ScenarioInfo
record when quitting a game.
Note that when comparing "best" times, shorter is not always better! As long as the scenario is not completed (e.g. some do not have win condition) we consider having fun longer to be better.
type ScenarioInfoPair = (Scenario, ScenarioInfo) Source #
Scenario collection
data ScenarioCollection Source #
A scenario collection is a tree of scenarios, keyed by name, together with an optional order.
Invariant: every item in the
scOrder
exists as a key in the scMap
.
Instances
Show ScenarioCollection Source # | |
Defined in Swarm.Game.ScenarioInfo Methods showsPrec :: Int -> ScenarioCollection -> ShowS # show :: ScenarioCollection -> String # showList :: [ScenarioCollection] -> ShowS # |
scenarioCollectionToList :: ScenarioCollection -> [ScenarioItem] Source #
Convert a scenario collection to a list of scenario items.
flatten :: ScenarioItem -> [ScenarioInfoPair] Source #
scenarioItemByPath :: FilePath -> Traversal' ScenarioCollection ScenarioItem Source #
Access and modify ScenarioItem
s in collection based on their path.
normalizeScenarioPath :: MonadIO m => ScenarioCollection -> FilePath -> m FilePath Source #
Canonicalize a scenario path, making it usable as a unique key.
data ScenarioItem Source #
A scenario item is either a specific scenario, or a collection of scenarios (e.g. the scenarios contained in a subdirectory).
Constructors
SISingle ScenarioInfoPair | |
SICollection Text ScenarioCollection |
Instances
Show ScenarioItem Source # | |
Defined in Swarm.Game.ScenarioInfo Methods showsPrec :: Int -> ScenarioItem -> ShowS # show :: ScenarioItem -> String # showList :: [ScenarioItem] -> ShowS # |
scenarioItemName :: ScenarioItem -> Text Source #
Retrieve the name of a scenario item.
Loading and saving scenarios
loadScenarios :: (Has (Accum (Seq SystemFailure)) sig m, Has (Lift IO) sig m) => EntityMap -> WorldMap -> m ScenarioCollection Source #
Load all the scenarios from the scenarios data directory.
loadScenarioInfo :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => FilePath -> m ScenarioInfo Source #
Load saved info about played scenario from XDG data directory.
saveScenarioInfo :: FilePath -> ScenarioInfo -> IO () Source #
Save info about played scenario to XDG data directory.
Re-exports
module Swarm.Game.Scenario