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 TSyntax) Bool
- 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
- tutorialsDirname :: FilePath
- getTutorials :: ScenarioCollection -> ScenarioCollection
- loadScenarios :: (Has (Accum (Seq SystemFailure)) sig m, Has (Lift IO) sig m) => ScenarioInputs -> m ScenarioCollection
- loadScenarioInfo :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => FilePath -> m ScenarioInfo
- saveScenarioInfo :: FilePath -> ScenarioInfo -> IO ()
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 TSyntax) Bool |
Instances
Show CodeSizeDeterminators Source # | |
Defined in Swarm.Game.Scenario.Scoring.CodeSize Methods showsPrec :: Int -> CodeSizeDeterminators -> ShowS # show :: CodeSizeDeterminators -> String # showList :: [CodeSizeDeterminators] -> ShowS # |
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.
Tutorials
tutorialsDirname :: FilePath Source #
Subdirectory of the scenarios directory where tutorials are stored.
getTutorials :: ScenarioCollection -> ScenarioCollection Source #
Extract just the collection of tutorial scenarios from the entire scenario collection.
Loading and saving scenarios
loadScenarios :: (Has (Accum (Seq SystemFailure)) sig m, Has (Lift IO) sig m) => ScenarioInputs -> 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.