License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Game.Scenario.Status
Description
High-level status of scenario play. Representation of progress, logic for updating.
Synopsis
- data ParameterizableLaunchParams code (f :: Type -> Type) = LaunchParams {
- seedVal :: f (Maybe Seed)
- initialCode :: f (Maybe code)
- type SerializableLaunchParams = ParameterizableLaunchParams FilePath Identity
- data ScenarioStatus
- emptyLaunchParams :: forall (f :: Type -> Type) a. Applicative f => ParameterizableLaunchParams a f
- getLaunchParams :: ScenarioStatus -> SerializableLaunchParams
- newtype ScenarioPath = ScenarioPath {}
- data ScenarioWith a = ScenarioWith {
- _getScenario :: Scenario
- _getScenarioInfo :: a
- getScenario :: forall a f. Functor f => (Scenario -> f Scenario) -> ScenarioWith a -> f (ScenarioWith a)
- getScenarioInfo :: forall a1 a2 f. Functor f => (a1 -> f a2) -> ScenarioWith a1 -> f (ScenarioWith a2)
- data ScenarioInfoT a = ScenarioInfo {}
- type ScenarioInfo = ScenarioInfoT FilePath
- scenarioPath :: Lens' ScenarioInfo FilePath
- scenarioStatus :: Lens' ScenarioInfo ScenarioStatus
- scenarioIsCompleted :: ScenarioInfo -> Bool
- updateScenarioInfoOnFinish :: CodeSizeDeterminators -> ZonedTime -> TickNumber -> Bool -> ScenarioInfo -> ScenarioInfo
Documentation
data ParameterizableLaunchParams code (f :: Type -> Type) Source #
These launch parameters are used in a number of ways:
- Serializing the seed/script path for saves
- Holding parse status from form fields, including error info
- Carrying fully-validated launch parameters.
Type parameters are utilized to support all of these use cases.
Constructors
LaunchParams | |
Fields
|
Instances
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
FromJSON ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods parseJSON :: Value -> Parser ScenarioStatus # parseJSONList :: Value -> Parser [ScenarioStatus] # | |||||
ToJSON ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods toJSON :: ScenarioStatus -> Value # toEncoding :: ScenarioStatus -> Encoding # toJSONList :: [ScenarioStatus] -> Value # toEncodingList :: [ScenarioStatus] -> Encoding # omitField :: ScenarioStatus -> Bool # | |||||
Generic ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status Associated Types
Methods from :: ScenarioStatus -> Rep ScenarioStatus x # to :: Rep ScenarioStatus x -> ScenarioStatus # | |||||
Read ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods readsPrec :: Int -> ReadS ScenarioStatus # readList :: ReadS [ScenarioStatus] # | |||||
Show ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods showsPrec :: Int -> ScenarioStatus -> ShowS # show :: ScenarioStatus -> String # showList :: [ScenarioStatus] -> ShowS # | |||||
Eq ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods (==) :: ScenarioStatus -> ScenarioStatus -> Bool # (/=) :: ScenarioStatus -> ScenarioStatus -> Bool # | |||||
Ord ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods compare :: ScenarioStatus -> ScenarioStatus -> Ordering # (<) :: ScenarioStatus -> ScenarioStatus -> Bool # (<=) :: ScenarioStatus -> ScenarioStatus -> Bool # (>) :: ScenarioStatus -> ScenarioStatus -> Bool # (>=) :: ScenarioStatus -> ScenarioStatus -> Bool # max :: ScenarioStatus -> ScenarioStatus -> ScenarioStatus # min :: ScenarioStatus -> ScenarioStatus -> ScenarioStatus # | |||||
type Rep ScenarioStatus Source # | |||||
Defined in Swarm.Game.Scenario.Status type Rep ScenarioStatus = D1 ('MetaData "ScenarioStatus" "Swarm.Game.Scenario.Status" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-engine" 'False) (C1 ('MetaCons "NotStarted" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Played" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SerializableLaunchParams) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ProgressMetric) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 BestRecords)))) |
emptyLaunchParams :: forall (f :: Type -> Type) a. Applicative f => ParameterizableLaunchParams a f Source #
newtype ScenarioPath Source #
The normalized path to a scenario, amenable to lookup
Constructors
ScenarioPath | |
Fields |
Instances
IsString ScenarioPath Source # | |
Defined in Swarm.Game.Scenario.Status Methods fromString :: String -> ScenarioPath # | |
Show ScenarioPath Source # | |
Defined in Swarm.Game.Scenario.Status Methods showsPrec :: Int -> ScenarioPath -> ShowS # show :: ScenarioPath -> String # showList :: [ScenarioPath] -> ShowS # | |
Eq ScenarioPath Source # | |
Defined in Swarm.Game.Scenario.Status |
data ScenarioWith a Source #
Constructors
ScenarioWith | |
Fields
|
Instances
Functor ScenarioWith Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods fmap :: (a -> b) -> ScenarioWith a -> ScenarioWith b # (<$) :: a -> ScenarioWith b -> ScenarioWith a # | |||||
Generic (ScenarioWith a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Associated Types
Methods from :: ScenarioWith a -> Rep (ScenarioWith a) x # to :: Rep (ScenarioWith a) x -> ScenarioWith a # | |||||
type Rep (ScenarioWith a) Source # | |||||
Defined in Swarm.Game.Scenario.Status type Rep (ScenarioWith a) = D1 ('MetaData "ScenarioWith" "Swarm.Game.Scenario.Status" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-engine" 'False) (C1 ('MetaCons "ScenarioWith" 'PrefixI 'True) (S1 ('MetaSel ('Just "_getScenario") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Scenario) :*: S1 ('MetaSel ('Just "_getScenarioInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))) |
getScenario :: forall a f. Functor f => (Scenario -> f Scenario) -> ScenarioWith a -> f (ScenarioWith a) Source #
getScenarioInfo :: forall a1 a2 f. Functor f => (a1 -> f a2) -> ScenarioWith a1 -> f (ScenarioWith a2) Source #
data ScenarioInfoT a 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
Functor ScenarioInfoT Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods fmap :: (a -> b) -> ScenarioInfoT a -> ScenarioInfoT b # (<$) :: a -> ScenarioInfoT b -> ScenarioInfoT a # | |||||
FromJSON a => FromJSON (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods parseJSON :: Value -> Parser (ScenarioInfoT a) # parseJSONList :: Value -> Parser [ScenarioInfoT a] # omittedField :: Maybe (ScenarioInfoT a) # | |||||
ToJSON a => ToJSON (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods toJSON :: ScenarioInfoT a -> Value # toEncoding :: ScenarioInfoT a -> Encoding # toJSONList :: [ScenarioInfoT a] -> Value # toEncodingList :: [ScenarioInfoT a] -> Encoding # omitField :: ScenarioInfoT a -> Bool # | |||||
Generic (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Associated Types
Methods from :: ScenarioInfoT a -> Rep (ScenarioInfoT a) x # to :: Rep (ScenarioInfoT a) x -> ScenarioInfoT a # | |||||
Read a => Read (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods readsPrec :: Int -> ReadS (ScenarioInfoT a) # readList :: ReadS [ScenarioInfoT a] # readPrec :: ReadPrec (ScenarioInfoT a) # readListPrec :: ReadPrec [ScenarioInfoT a] # | |||||
Show a => Show (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods showsPrec :: Int -> ScenarioInfoT a -> ShowS # show :: ScenarioInfoT a -> String # showList :: [ScenarioInfoT a] -> ShowS # | |||||
Eq a => Eq (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods (==) :: ScenarioInfoT a -> ScenarioInfoT a -> Bool # (/=) :: ScenarioInfoT a -> ScenarioInfoT a -> Bool # | |||||
Ord a => Ord (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status Methods compare :: ScenarioInfoT a -> ScenarioInfoT a -> Ordering # (<) :: ScenarioInfoT a -> ScenarioInfoT a -> Bool # (<=) :: ScenarioInfoT a -> ScenarioInfoT a -> Bool # (>) :: ScenarioInfoT a -> ScenarioInfoT a -> Bool # (>=) :: ScenarioInfoT a -> ScenarioInfoT a -> Bool # max :: ScenarioInfoT a -> ScenarioInfoT a -> ScenarioInfoT a # min :: ScenarioInfoT a -> ScenarioInfoT a -> ScenarioInfoT a # | |||||
type Rep (ScenarioInfoT a) Source # | |||||
Defined in Swarm.Game.Scenario.Status type Rep (ScenarioInfoT a) = D1 ('MetaData "ScenarioInfoT" "Swarm.Game.Scenario.Status" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-engine" 'False) (C1 ('MetaCons "ScenarioInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "_scenarioPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "_scenarioStatus") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ScenarioStatus))) |
type ScenarioInfo = ScenarioInfoT FilePath Source #
scenarioPath :: Lens' ScenarioInfo FilePath Source #
The path of the scenario, relative to data/scenarios
.
scenarioStatus :: Lens' ScenarioInfo ScenarioStatus Source #
The status of the scenario.
scenarioIsCompleted :: ScenarioInfo -> Bool Source #
Check if a given scenario has been completed.
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.