License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Game.Scenario.Objective
Description
Synopsis
- data PrerequisiteConfig = PrerequisiteConfig {}
- data Objective
- objectiveGoal :: Lens' Objective (Document Syntax)
- objectiveTeaser :: Lens' Objective (Maybe Text)
- objectiveCondition :: Lens' Objective TSyntax
- objectiveId :: Lens' Objective (Maybe Text)
- objectiveOptional :: Lens' Objective Bool
- objectivePrerequisite :: Lens' Objective (Maybe PrerequisiteConfig)
- objectiveHidden :: Lens' Objective Bool
- objectiveAchievement :: Lens' Objective (Maybe AchievementInfo)
- newtype Announcement = ObjectiveCompleted Objective
- data ObjectiveCompletion
- initCompletion :: [Objective] -> ObjectiveCompletion
- completedIDs :: Getter ObjectiveCompletion (Set ObjectiveLabel)
- incompleteObjectives :: Fold ObjectiveCompletion Objective
- completedObjectives :: Fold ObjectiveCompletion Objective
- unwinnableObjectives :: Fold ObjectiveCompletion Objective
- allObjectives :: Fold ObjectiveCompletion Objective
- addCompleted :: Objective -> ObjectiveCompletion -> ObjectiveCompletion
- addUnwinnable :: Objective -> ObjectiveCompletion -> ObjectiveCompletion
- addIncomplete :: Objective -> ObjectiveCompletion -> ObjectiveCompletion
- extractIncomplete :: ObjectiveCompletion -> (ObjectiveCompletion, [Objective])
Scenario objectives
data PrerequisiteConfig Source #
Constructors
PrerequisiteConfig | |
Fields
|
Instances
An objective is a condition to be achieved by a player in a scenario.
Instances
FromJSON Objective Source # | |||||
Defined in Swarm.Game.Scenario.Objective | |||||
ToJSON Objective Source # | |||||
Generic Objective Source # | |||||
Defined in Swarm.Game.Scenario.Objective Associated Types
| |||||
Show Objective Source # | |||||
Eq Objective Source # | |||||
ToSample Objective Source # | |||||
ToJSON (SCC Objective) Source # | |||||
type Rep Objective Source # | |||||
Defined in Swarm.Game.Scenario.Objective type Rep Objective = D1 ('MetaData "Objective" "Swarm.Game.Scenario.Objective" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-scenario" 'False) (C1 ('MetaCons "Objective" 'PrefixI 'True) (((S1 ('MetaSel ('Just "_objectiveGoal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Document Syntax)) :*: S1 ('MetaSel ('Just "_objectiveTeaser") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text))) :*: (S1 ('MetaSel ('Just "_objectiveCondition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 TSyntax) :*: S1 ('MetaSel ('Just "_objectiveId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ObjectiveLabel)))) :*: ((S1 ('MetaSel ('Just "_objectiveOptional") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "_objectivePrerequisite") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe PrerequisiteConfig))) :*: (S1 ('MetaSel ('Just "_objectiveHidden") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "_objectiveAchievement") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe AchievementInfo)))))) |
objectiveGoal :: Lens' Objective (Document Syntax) Source #
An explanation of the goal of the objective, shown to the player during play. It is represented as a list of paragraphs.
objectiveTeaser :: Lens' Objective (Maybe Text) Source #
A very short (3-5 words) description of the goal for displaying on the left side of the Objectives modal.
objectiveCondition :: Lens' Objective TSyntax Source #
A winning condition for the objective, expressed as a
program of type cmd bool
. By default, this program will be
run to completion every tick (the usual limits on the number
of CESK steps per tick do not apply).
objectiveId :: Lens' Objective (Maybe Text) Source #
Optional name by which this objective may be referenced as a prerequisite for other objectives.
objectiveOptional :: Lens' Objective Bool Source #
Indicates whether the objective is not required in order to "win" the scenario. Useful for (potentially hidden) achievements. If the field is not supplied, it defaults to False (i.e. the objective is mandatory to "win").
objectivePrerequisite :: Lens' Objective (Maybe PrerequisiteConfig) Source #
Dependencies upon other objectives
objectiveHidden :: Lens' Objective Bool Source #
Whether the goal is displayed in the UI before completion. The goal will always be revealed after it is completed.
This attribute often goes along with an Achievement.
objectiveAchievement :: Lens' Objective (Maybe AchievementInfo) Source #
An optional achievement that is to be registered globally when this objective is completed.
newtype Announcement Source #
TODO: #1044 Could also add an ObjectiveFailed constructor...
Constructors
ObjectiveCompleted Objective |
Instances
ToJSON Announcement Source # | |||||
Defined in Swarm.Game.Scenario.Objective Methods toJSON :: Announcement -> Value # toEncoding :: Announcement -> Encoding # toJSONList :: [Announcement] -> Value # toEncodingList :: [Announcement] -> Encoding # omitField :: Announcement -> Bool # | |||||
Generic Announcement Source # | |||||
Defined in Swarm.Game.Scenario.Objective Associated Types
| |||||
Show Announcement Source # | |||||
Defined in Swarm.Game.Scenario.Objective Methods showsPrec :: Int -> Announcement -> ShowS # show :: Announcement -> String # showList :: [Announcement] -> ShowS # | |||||
type Rep Announcement Source # | |||||
Defined in Swarm.Game.Scenario.Objective type Rep Announcement = D1 ('MetaData "Announcement" "Swarm.Game.Scenario.Objective" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-scenario" 'True) (C1 ('MetaCons "ObjectiveCompleted" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Objective))) |
Objective completion tracking
data ObjectiveCompletion Source #
A record to keep track of the completion status of all a scenario's objectives. We do not export the constructor or record field labels of this type in order to ensure that its internal invariants cannot be violated.
Instances
FromJSON ObjectiveCompletion Source # | |||||
Defined in Swarm.Game.Scenario.Objective Methods parseJSON :: Value -> Parser ObjectiveCompletion # parseJSONList :: Value -> Parser [ObjectiveCompletion] # | |||||
ToJSON ObjectiveCompletion Source # | |||||
Defined in Swarm.Game.Scenario.Objective Methods toJSON :: ObjectiveCompletion -> Value # toEncoding :: ObjectiveCompletion -> Encoding # toJSONList :: [ObjectiveCompletion] -> Value # toEncodingList :: [ObjectiveCompletion] -> Encoding # omitField :: ObjectiveCompletion -> Bool # | |||||
Generic ObjectiveCompletion Source # | |||||
Defined in Swarm.Game.Scenario.Objective Associated Types
Methods from :: ObjectiveCompletion -> Rep ObjectiveCompletion x # to :: Rep ObjectiveCompletion x -> ObjectiveCompletion # | |||||
Show ObjectiveCompletion Source # | |||||
Defined in Swarm.Game.Scenario.Objective Methods showsPrec :: Int -> ObjectiveCompletion -> ShowS # show :: ObjectiveCompletion -> String # showList :: [ObjectiveCompletion] -> ShowS # | |||||
type Rep ObjectiveCompletion Source # | |||||
Defined in Swarm.Game.Scenario.Objective |
initCompletion :: [Objective] -> ObjectiveCompletion Source #
Initialize an objective completion tracking record from a list of (initially incomplete) objectives.
completedIDs :: Getter ObjectiveCompletion (Set ObjectiveLabel) Source #
A Getter
allowing one to read the set of completed objective
IDs for a given scenario. Note that this is a Getter
, not a
Lens
, to allow for read-only access without the possibility of
violating the internal invariants of ObjectiveCompletion
.
incompleteObjectives :: Fold ObjectiveCompletion Objective Source #
A Fold
giving read-only access to all the incomplete objectives
tracked by an ObjectiveCompletion
record. Note that Fold
is
like a read-only Traversal
, that is, it has multiple targets
but allows only reading them, not updating. In other words
Fold
is to Traversal
as Getter
is to Lens
.
To get an actual list of objectives, use the (^..)
operator, as
in objCompl ^.. incompleteObjectives
, where objCompl ::
ObjectiveCompletion
.
completedObjectives :: Fold ObjectiveCompletion Objective Source #
A Fold
giving read-only access to all the completed objectives
tracked by an ObjectiveCompletion
record. See the
documentation for incompleteObjectives
for more about Fold
.
unwinnableObjectives :: Fold ObjectiveCompletion Objective Source #
A Fold
giving read-only access to all the unwinnable objectives
tracked by an ObjectiveCompletion
record. See the
documentation for incompleteObjectives
for more about Fold
.
allObjectives :: Fold ObjectiveCompletion Objective Source #
A Fold
over all objectives (whether incomplete, complete, or
unwinnable) tracked by an ObjectiveCompletion
record. See the
documentation for incompleteObjectives
for more about Fold
.
addCompleted :: Objective -> ObjectiveCompletion -> ObjectiveCompletion Source #
Add a completed objective to an ObjectiveCompletion
record,
being careful to maintain its internal invariants.
addUnwinnable :: Objective -> ObjectiveCompletion -> ObjectiveCompletion Source #
Add an unwinnable objective to an ObjectiveCompletion
record,
being careful to maintain its internal invariants.
addIncomplete :: Objective -> ObjectiveCompletion -> ObjectiveCompletion Source #
Add an incomplete objective to an ObjectiveCompletion
record,
being careful to maintain its internal invariants.
extractIncomplete :: ObjectiveCompletion -> (ObjectiveCompletion, [Objective]) Source #
Returns the ObjectiveCompletion
with the incomplete goals
extracted to a separate tuple member. This is intended to be
used as input to a fold.