{-# LANGUAGE MultiParamTypeClasses #-}
module BishBosh.StateProperty.Mutator(
Mutator(..),
placePiece,
placeFirstPiece,
placeAllPieces,
removePiece
) where
import qualified BishBosh.Cartesian.Coordinates as Cartesian.Coordinates
import qualified BishBosh.Component.Piece as Component.Piece
import qualified BishBosh.Property.Empty as Property.Empty
class Mutator mutator x y where
defineCoordinates
:: Maybe Component.Piece.Piece
-> Cartesian.Coordinates.Coordinates x y
-> mutator x y
-> mutator x y
placePiece
:: Mutator mutator x y
=> Component.Piece.Piece
-> Cartesian.Coordinates.Coordinates x y
-> mutator x y
-> mutator x y
placePiece :: Piece -> Coordinates x y -> mutator x y -> mutator x y
placePiece Piece
piece = Maybe Piece -> Coordinates x y -> mutator x y -> mutator x y
forall (mutator :: * -> * -> *) x y.
Mutator mutator x y =>
Maybe Piece -> Coordinates x y -> mutator x y -> mutator x y
defineCoordinates (Maybe Piece -> Coordinates x y -> mutator x y -> mutator x y)
-> Maybe Piece -> Coordinates x y -> mutator x y -> mutator x y
forall a b. (a -> b) -> a -> b
$ Piece -> Maybe Piece
forall a. a -> Maybe a
Just Piece
piece
placeFirstPiece :: (
Property.Empty.Empty (mutator x y),
Mutator mutator x y
)
=> Component.Piece.Piece
-> Cartesian.Coordinates.Coordinates x y
-> mutator x y
placeFirstPiece :: Piece -> Coordinates x y -> mutator x y
placeFirstPiece Piece
piece Coordinates x y
coordinates = Piece -> Coordinates x y -> mutator x y -> mutator x y
forall (mutator :: * -> * -> *) x y.
Mutator mutator x y =>
Piece -> Coordinates x y -> mutator x y -> mutator x y
placePiece Piece
piece Coordinates x y
coordinates mutator x y
forall a. Empty a => a
Property.Empty.empty
placeAllPieces :: (
Property.Empty.Empty (mutator x y),
Mutator mutator x y
)
=> [(Component.Piece.Piece, Cartesian.Coordinates.Coordinates x y)]
-> mutator x y
placeAllPieces :: [(Piece, Coordinates x y)] -> mutator x y
placeAllPieces = ((Piece, Coordinates x y) -> mutator x y -> mutator x y)
-> mutator x y -> [(Piece, Coordinates x y)] -> mutator x y
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ((Piece -> Coordinates x y -> mutator x y -> mutator x y)
-> (Piece, Coordinates x y) -> mutator x y -> mutator x y
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Piece -> Coordinates x y -> mutator x y -> mutator x y
forall (mutator :: * -> * -> *) x y.
Mutator mutator x y =>
Piece -> Coordinates x y -> mutator x y -> mutator x y
placePiece) mutator x y
forall a. Empty a => a
Property.Empty.empty
removePiece
:: Mutator mutator x y
=> Cartesian.Coordinates.Coordinates x y
-> mutator x y
-> mutator x y
removePiece :: Coordinates x y -> mutator x y -> mutator x y
removePiece = Maybe Piece -> Coordinates x y -> mutator x y -> mutator x y
forall (mutator :: * -> * -> *) x y.
Mutator mutator x y =>
Maybe Piece -> Coordinates x y -> mutator x y -> mutator x y
defineCoordinates Maybe Piece
forall a. Maybe a
Nothing