Safe Haskell | Safe |
---|
Synopsis
- data State = State {
- maze :: Maze
- playersState :: [Player]
- level :: Int
- type Maze = [Corridor]
- type Corridor = [Piece]
- data Piece
- data FoodType
- data Player
- data PacState = PacState {
- pacState :: PlayerState
- timeMega :: Double
- openClosed :: Mouth
- pacmanMode :: PacMode
- data GhoState = GhoState {}
- type PlayerState = (Int, Coords, Double, Orientation, Int, Int)
- type Coords = (Int, Int)
- data Orientation
- data Mouth
- data PacMode
- data GhostMode
- data Color
- data Play = Move Int Orientation
- type Instructions = [Instruction]
- data Instruction
- coloredString :: String -> Color -> String
- placePlayersOnMap :: [Player] -> Maze -> Maze
- printMaze :: Maze -> String
- printPlayerStats :: Player -> String
- getPlayerID :: Player -> Int
- getPlayerPoints :: Player -> Int
- setPlayerCoords :: Player -> Coords -> Player
- getPieceOrientation :: Piece -> Orientation
- getPacmanMode :: Player -> PacMode
- getPlayerState :: Player -> PlayerState
- getPlayerOrientation :: Player -> Orientation
- replaceElemInMaze :: Coords -> Piece -> Maze -> Maze
- replaceNElem :: Int -> a -> [a] -> [a]
- getPlayerCoords :: Player -> Coords
Documentation
The data State is composed by a maze (:: Maze), a playersState (:: [Player]) and a level (:: Int).
The data Piece can be a Food with a data FoodType (Big or Little), a PacPlayer with a data Player (Pacman or Ghost), a Empty Piece or a Wall piece.
The data Player either is Pacman (PacState) or Ghost (GhoState).
The data PacState is composed by a pacState (:: PlayerState), a timeMega (:: Double), a openClosed (:: Mouth), and a pacmanMode (:: PacMode).
PacState | |
|
The data GhoState is composed by: a ghostState (:: PlayerState) and a ghostMode (:: GhostMode).
type PlayerState = (Int, Coords, Double, Orientation, Int, Int) #
The type PlayerState is present in the datas PacState and GhoState, The PlayerState is given by: ID (:: Int) -> identifier for the player, where the ID is unique for each player; Coords (:: (Int,Int)) -> coordenates in a maze of the Player; Velocity (:: Double) -> velocity of the player; Orientation (:: Orientation) -> direction faced by the player; Points (:: Int) -> score of the Player; Lives (:: Int) -> number of player lifes;
The type Coords represents the coordinates of a player in a maze where the first coord represents the number of Corridors and the second the number of pieces on each Corridor.
data Orientation #
The data Orientation determines the direction a Player is facing (Left, Right, Up, Down and Null)
Instances
Eq Orientation # | |
Defined in Types (==) :: Orientation -> Orientation -> Bool (/=) :: Orientation -> Orientation -> Bool | |
Show Orientation # | |
Defined in Types showsPrec :: Int -> Orientation -> ShowS show :: Orientation -> String showList :: [Orientation] -> ShowS |
The data Mouth is used for the data pacState and it can either be Closed or Open.
The data Pacmode is formed by the datas: Dying -> Represents when the pacman dies; Normal -> The pacman can be killed by ghosts when the GhostMode is Alive); Mega -> This is the only time where pacman can defeat ghosts (when PacMode switches to Mega, all the ghosts GhostMode switch to Dead); Pacman is switched to Mega when he eats a Food Big.
The data Play is formed by a player ID (:: Int) and a Orientation. The ID espeficies the player we want to move and the Orientation the direction where we want to move that player.
Move Int Orientation |
type Instructions = [Instruction] #
data Instruction #
Instances
Eq Instruction # | |
Defined in Types (==) :: Instruction -> Instruction -> Bool (/=) :: Instruction -> Instruction -> Bool | |
Show Instruction # | |
Defined in Types showsPrec :: Int -> Instruction -> ShowS show :: Instruction -> String showList :: [Instruction] -> ShowS |
coloredString :: String -> Color -> String #
placePlayersOnMap :: [Player] -> Maze -> Maze #
Takes as inputs a list of Players and a Maze and then returns a new Maze with the Players in the respective Coords.
printPlayerStats :: Player -> String #
Outputs the String with the ID, the Points and the Lives info for a player given in the input
getPlayerID :: Player -> Int #
Take as input a Player and returns the respective Player ID
getPlayerPoints :: Player -> Int #
Take as input a Player and returns his points
setPlayerCoords :: Player -> Coords -> Player #
Takes as inputs a Player and Coords and then replaces the Player Coords by the new Coords returning a Player with the given new coords
getPieceOrientation :: Piece -> Orientation #
Take as input a Piece and returns that Piece Orientation. If the Piece doesn't have any Orientation returns Null
getPacmanMode :: Player -> PacMode #
Take as input a Player Pacman and returns his PacMode
getPlayerState :: Player -> PlayerState #
Takes as input a Player and returns his PlayerState
getPlayerOrientation :: Player -> Orientation #
Take as input a Player and returns that player Orientation
replaceElemInMaze :: Coords -> Piece -> Maze -> Maze #
Takes as inputs a Coords, a Piece and a Maze and then returns the Maze with the given piece at the given Coords replaced.
replaceNElem :: Int -> a -> [a] -> [a] #
Takes as input a Int (n), a element with any type (t) and a list of elements t type ([t]), and returns the list of elements t type ([t]) where is replaced the n position element (starting at 0) by the inputed element with t type in the given list of elements t type. If the list haves n or more elements then the returned output is the same list .
getPlayerCoords :: Player -> Coords #
Take as input a Player and returns that player Coords