swarm-0.7.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellNone
LanguageHaskell2010

Swarm.Game.Scenario.Objective

Description

 
Synopsis

Scenario objectives

data PrerequisiteConfig Source #

Constructors

PrerequisiteConfig 

Fields

  • previewable :: Bool

    Typically, only the currently "active" objectives are displayed to the user in the Goals dialog. An objective is "active" if all of its prerequisites are met.

    However, some objectives may be "high-level", in that they may explain the broader intention behind potentially multiple prerequisites.

    Set this option to True to display this goal in the "upcoming" section even if the objective has currently unmet prerequisites.

  • logic :: Prerequisite ObjectiveLabel

    Boolean expression of dependencies upon other objectives. Variables in this expression are the "id"s of other objectives, and become "true" if the corresponding objective is completed. The "condition" of the objective at hand shall not be evaluated until its prerequisite expression evaluates as True.

    Note that the achievement of these objective dependencies is persistent; once achieved, they still count even if their "condition" might not still hold. The condition is never re-evaluated once true.

Instances

Instances details
FromJSON PrerequisiteConfig Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

ToJSON PrerequisiteConfig Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Generic PrerequisiteConfig Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Associated Types

type Rep PrerequisiteConfig 
Instance details

Defined in Swarm.Game.Scenario.Objective

type Rep PrerequisiteConfig = D1 ('MetaData "PrerequisiteConfig" "Swarm.Game.Scenario.Objective" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-scenario" 'False) (C1 ('MetaCons "PrerequisiteConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "previewable") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "logic") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Prerequisite ObjectiveLabel))))
Show PrerequisiteConfig Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Eq PrerequisiteConfig Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

type Rep PrerequisiteConfig Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

type Rep PrerequisiteConfig = D1 ('MetaData "PrerequisiteConfig" "Swarm.Game.Scenario.Objective" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-scenario" 'False) (C1 ('MetaCons "PrerequisiteConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "previewable") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "logic") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Prerequisite ObjectiveLabel))))

data Objective Source #

An objective is a condition to be achieved by a player in a scenario.

Instances

Instances details
FromJSON Objective Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

ToJSON Objective Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Generic Objective Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Associated Types

type Rep Objective 
Instance details

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))))))
Show Objective Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Eq Objective Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

ToSample Objective Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

ToJSON (SCC Objective) Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

type Rep Objective Source # 
Instance details

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...

Instances

Instances details
ToJSON Announcement Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Generic Announcement Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

Associated Types

type Rep Announcement 
Instance details

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)))
Show Announcement Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective

type Rep Announcement Source # 
Instance details

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.

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.