Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syllabus enumeration #2016

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/swarm-scenario/Swarm/Game/Scenario.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Swarm.Game.Scenario (
scenarioVersion,
scenarioName,
scenarioAuthor,
scenarioPedagogy,
scenarioDescription,
scenarioCreative,
scenarioSeed,
Expand Down Expand Up @@ -90,6 +91,7 @@ import Swarm.Game.Location
import Swarm.Game.Recipe
import Swarm.Game.ResourceLoading (getDataFileNameSafe)
import Swarm.Game.Robot (TRobot, trobotLocation, trobotName)
import Swarm.Game.Scenario.Coach
import Swarm.Game.Scenario.Objective
import Swarm.Game.Scenario.Objective.Validation
import Swarm.Game.Scenario.RobotLookup
Expand Down Expand Up @@ -142,6 +144,7 @@ data ScenarioMetadata = ScenarioMetadata
{ _scenarioVersion :: Int
, _scenarioName :: Text
, _scenarioAuthor :: Maybe Text
, _scenarioPedagogy :: Maybe Pedagogy
}
deriving (Show, Generic)

Expand All @@ -166,6 +169,9 @@ scenarioName :: Lens' ScenarioMetadata Text
-- | The author of the scenario.
scenarioAuthor :: Lens' ScenarioMetadata (Maybe Text)

-- | Pedagogical information about the scenario.
scenarioPedagogy :: Lens' ScenarioMetadata (Maybe Pedagogy)

-- | Non-structural gameplay content of the scenario;
-- how it is to be played.
data ScenarioOperation = ScenarioOperation
Expand Down Expand Up @@ -404,6 +410,7 @@ instance FromJSONE ScenarioInputs Scenario where
<$> liftE (v .: "version")
<*> liftE (v .: "name")
<*> liftE (v .:? "author")
<*> liftE (v .:? "pedagogy")

playInfo <-
ScenarioOperation
Expand Down
29 changes: 29 additions & 0 deletions src/swarm-scenario/Swarm/Game/Scenario/Coach.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- |
-- SPDX-License-Identifier: BSD-3-Clause
module Swarm.Game.Scenario.Coach where

import Data.Aeson
import Data.Set (Set)
import GHC.Generics (Generic)

data TutorialConcept
= Sensing
| ErrorHandling
| Recursion
| CodeReuse
| Movement
| EntityManagement
| BuildingRobots
deriving (Show, Eq, Ord, Generic, FromJSON, ToJSON)

-- |
-- Intended primarily for Tutorials, though other challenge scenarios
-- may also supply these annotations.
-- This record might eventually contain other metadata like
-- "difficulty" or "par time".

{- HLINT ignore "Use newtype instead of data" -}
data Pedagogy = Pedagogy
{ concepts :: Set TutorialConcept
}
deriving (Show, Generic, FromJSON, ToJSON)
1 change: 1 addition & 0 deletions swarm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ library swarm-scenario
Swarm.Game.Robot
Swarm.Game.Robot.Walk
Swarm.Game.Scenario
Swarm.Game.Scenario.Coach
Swarm.Game.Scenario.Objective
Swarm.Game.Scenario.Objective.Graph
Swarm.Game.Scenario.Objective.Logic
Expand Down