Safe Haskell | None |
---|
Warning: Nomyx internals (not required to compose rules and play the game) This module implements game engine. the module manages the effects of rules over each others. This module is not required
- data GameEvent
- data LoggedGame = LoggedGame {
- _game :: Game
- _gameLog :: [TimedEvent]
- type GameName = String
- data Game = Game {
- _gameName :: GameName
- _gameDesc :: GameDesc
- _rules :: [RuleInfo]
- _players :: [PlayerInfo]
- _variables :: [Var]
- _events :: [EventHandler]
- _outputs :: [Output]
- _victory :: Maybe VictoryCond
- _logs :: [Log]
- _currentTime :: UTCTime
- data GameDesc = GameDesc {}
- execGameEvent :: GameEvent -> StateT LoggedGame IO ()
- execGameEvent' :: Maybe (RuleCode -> IO Rule) -> GameEvent -> StateT LoggedGame IO ()
- execWithGame :: UTCTime -> State LoggedGame () -> LoggedGame -> LoggedGame
- execWithGame' :: UTCTime -> StateT LoggedGame IO () -> LoggedGame -> IO LoggedGame
- game :: Lens LoggedGame Game
- emptyGame :: GameName -> GameDesc -> UTCTime -> Game
- getLoggedGame :: Game -> (RuleCode -> IO Rule) -> [TimedEvent] -> IO LoggedGame
- gameName :: Lens Game GameName
- players :: Lens Game [PlayerInfo]
- getVictorious :: Game -> [PlayerNumber]
- data Var = forall a . (Typeable a, Show a) => Var {
- _vRuleNumber :: RuleNumber
- _vName :: String
- vData :: a
- data SubmitRule = SubmitRule RuleName RuleDesc RuleCode
- activeRules :: Game -> [RuleInfo]
- pendingRules :: Game -> [RuleInfo]
- rejectedRules :: Game -> [RuleInfo]
- data EventHandler where
- EH :: Typeable e => {
- _eventNumber :: EventNumber
- _ruleNumber :: RuleNumber
- event :: Event e
- handler :: (EventNumber, EventData e) -> Nomex ()
- _evStatus :: Status
- EH :: Typeable e => {
- data Status
- getEventHandler :: EventNumber -> LoggedGame -> EventHandler
- events :: Lens Game [EventHandler]
- getChoiceEvents :: State Game [EventNumber]
- getTextEvents :: State Game [EventNumber]
- data UInputData
- = URadioData Int
- | UCheckboxData [Int]
- | UTextData String
- | UTextAreaData String
- | UButtonData
- data Output = Output {}
- data Log = Log {}
- evalOutput :: Game -> Output -> String
- isOutput :: String -> Game -> Bool
- getTimes :: EventHandler -> Maybe UTCTime
- currentTime :: Lens Game UTCTime
- tracePN :: Monad m => Int -> String -> m ()
- replaceWith :: (a -> Bool) -> a -> [a] -> [a]
Game management
a list of possible events affecting a game
data LoggedGame Source
A game being non serializable, we have to store events in parralel in order to rebuild the state latter.
LoggedGame | |
|
The state of the game:
Game | |
|
execGameEvent :: GameEvent -> StateT LoggedGame IO ()Source
execGameEvent' :: Maybe (RuleCode -> IO Rule) -> GameEvent -> StateT LoggedGame IO ()Source
execWithGame :: UTCTime -> State LoggedGame () -> LoggedGame -> LoggedGameSource
A helper function to use the state transformer GameState. It additionally sets the current time.
execWithGame' :: UTCTime -> StateT LoggedGame IO () -> LoggedGame -> IO LoggedGameSource
getLoggedGame :: Game -> (RuleCode -> IO Rule) -> [TimedEvent] -> IO LoggedGameSource
players :: Lens Game [PlayerInfo]Source
getVictorious :: Game -> [PlayerNumber]Source
Variables management
stores the variable's data
forall a . (Typeable a, Show a) => Var | |
|
Rules management
data SubmitRule Source
activeRules :: Game -> [RuleInfo]Source
pendingRules :: Game -> [RuleInfo]Source
rejectedRules :: Game -> [RuleInfo]Source
Events management
data EventHandler whereSource
EH :: Typeable e => EventNumber -> RuleNumber -> Event e -> ((EventNumber, EventData e) -> Nomex ()) -> Status -> EventHandler | |
|
events :: Lens Game [EventHandler]Source
Inputs management
data UInputData Source
Outputs management
evalOutput :: Game -> Output -> StringSource
Time
Misc
:: (a -> Bool) | Value to search |
-> a | Value to replace it with |
-> [a] | Input list |
-> [a] | Output list |
Replaces all instances of a value in a list by another value.