License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- type HasRobotStepState sig m = (Has (State GameState) sig m, Has (State Robot) sig m, Has (Throw Exn) sig m)
- deriveHeading :: HasRobotStepState sig m => Direction -> m Heading
- lookInDirection :: HasRobotStepState sig m => Direction -> m (Cosmic Location, Maybe Entity)
- updateEntityAt :: Has (State GameState) sig m => Cosmic Location -> (Maybe Entity -> Maybe Entity) -> m ()
- isPrivilegedBot :: (Has (State GameState) sig m, Has (State Robot) sig m) => m Bool
- hasCapability :: (Has (State Robot) sig m, Has (State GameState) sig m) => Capability -> m Bool
- hasCapabilityFor :: (Has (State Robot) sig m, Has (State GameState) sig m, Has (Throw Exn) sig m) => Capability -> Term -> m ()
- holdsOrFail' :: Has (Throw Exn) sig m => Const -> Bool -> [Text] -> m ()
- isJustOrFail' :: Has (Throw Exn) sig m => Const -> Maybe a -> [Text] -> m a
- cmdExn :: Const -> [Text] -> Exn
- getNow :: Has (Lift IO) sig m => m TimeSpec
- flagRedraw :: Has (State GameState) sig m => m ()
- getNeighborLocs :: Cosmic Location -> [Cosmic Location]
- zoomWorld :: Has (State GameState) sig m => SubworldName -> StateC (World Int Entity) Identity b -> m (Maybe b)
- entityAt :: Has (State GameState) sig m => Cosmic Location -> m (Maybe Entity)
- robotWithID :: Has (State GameState) sig m => RID -> m (Maybe Robot)
- robotWithName :: Has (State GameState) sig m => Text -> m (Maybe Robot)
- uniform :: (Has (State GameState) sig m, UniformRange a) => (a, a) -> m a
- weightedChoice :: Has (State GameState) sig m => (a -> Integer) -> [a] -> m (Maybe a)
- randomName :: Has (State GameState) sig m => m Text
- data MoveFailureMode
- data MoveFailureDetails = MoveFailureDetails Entity MoveFailureMode
- checkMoveFailureUnprivileged :: HasRobotStepState sig m => Cosmic Location -> m (Maybe MoveFailureDetails)
- checkMoveFailure :: HasRobotStepState sig m => Cosmic Location -> m (Maybe MoveFailureDetails)
Documentation
type HasRobotStepState sig m = (Has (State GameState) sig m, Has (State Robot) sig m, Has (Throw Exn) sig m) Source #
deriveHeading :: HasRobotStepState sig m => Direction -> m Heading Source #
lookInDirection :: HasRobotStepState sig m => Direction -> m (Cosmic Location, Maybe Entity) Source #
updateEntityAt :: Has (State GameState) sig m => Cosmic Location -> (Maybe Entity -> Maybe Entity) -> m () Source #
Modify the entity (if any) at a given location.
Capabilities
isPrivilegedBot :: (Has (State GameState) sig m, Has (State Robot) sig m) => m Bool Source #
Exempts the robot from various command constraints when it is either a system robot or playing in creative mode
hasCapability :: (Has (State Robot) sig m, Has (State GameState) sig m) => Capability -> m Bool Source #
Test whether the current robot has a given capability (either because it has a device which gives it that capability, or it is a system robot, or we are in creative mode).
hasCapabilityFor :: (Has (State Robot) sig m, Has (State GameState) sig m, Has (Throw Exn) sig m) => Capability -> Term -> m () Source #
Ensure that either a robot has a given capability, OR we are in creative mode.
Exceptions
Some utility functions
flagRedraw :: Has (State GameState) sig m => m () Source #
Set a flag telling the UI that the world needs to be redrawn.
World queries
zoomWorld :: Has (State GameState) sig m => SubworldName -> StateC (World Int Entity) Identity b -> m (Maybe b) Source #
entityAt :: Has (State GameState) sig m => Cosmic Location -> m (Maybe Entity) Source #
Get the entity (if any) at a given location.
robotWithID :: Has (State GameState) sig m => RID -> m (Maybe Robot) Source #
Get the robot with a given ID.
robotWithName :: Has (State GameState) sig m => Text -> m (Maybe Robot) Source #
Get the robot with a given name.
Randomness
uniform :: (Has (State GameState) sig m, UniformRange a) => (a, a) -> m a Source #
Generate a uniformly random number using the random generator in the game state.
weightedChoice :: Has (State GameState) sig m => (a -> Integer) -> [a] -> m (Maybe a) Source #
Given a weighting function and a list of values, choose one of
the values randomly (using the random generator in the game
state), with the probability of each being proportional to its
weight. Return Nothing
if the list is empty.
randomName :: Has (State GameState) sig m => m Text Source #
Generate a random robot name in the form adjective_name
.
Moving
checkMoveFailureUnprivileged :: HasRobotStepState sig m => Cosmic Location -> m (Maybe MoveFailureDetails) Source #
Make sure nothing is in the way. No exception for system robots
checkMoveFailure :: HasRobotStepState sig m => Cosmic Location -> m (Maybe MoveFailureDetails) Source #
Make sure nothing is in the way. Note that system robots implicitly ignore and base throws on failure.