-- for placing the control pieces.
, (y,action) <- zip [ yMin+4,yMin+8..] actions]
-ctrlCoord = map (\(x,y,_,_) -> (x,y)) ctrlPieces
+ctrlCoords :: [(Int,Int)]
+ctrlCoords = map (\(x,y,_,_) -> (x,y)) ctrlPieces
boardToPiece :: [PlayHead] -> Board -> [(Int,Int,Player,GUICell)]
boardToPiece ph = (++ ctrlPieces) . map placePiece .
validArea = filter (onBoard . fromGUICoords) $
map (\(x,y,_,_) -> (x,y)) $ boardToPiece [] $ makeBoard []
+outGUIBoard :: (Int,Int) -> Bool
+outGUIBoard (xf,yf) = xf < xMin || xf > xMax || yf < yMin || yf > yMax
+
na = NoteAttr {
naArt = Accent13,
naDur = 1 % 1,
, GUICell { cellAction = Inert } <- p = False
| Nothing <- getPieceAt game (x,y) = False
| otherwise = True
- canMoveTo _ _ _ (x,y) = (x,y) `elem` validArea
-
- move guiBoard@(GUIBoard game) p iPos@(_,yi) (xf,yf)
- | iPos `elem` ctrlCoord = [ RemovePiece fPos'
- , AddPiece fPos' Player (nCell { cellAction = ctrlAction })
- ]
+ canMoveTo _ _ _ fPos = fPos `elem` validArea
+ || outGUIBoard fPos
+
+ move guiBoard@(GUIBoard game) p iPos@(_,yi) fPos@(xf,yf)
+ | iPos `elem` ctrlCoords = [ RemovePiece fPos'
+ , AddPiece fPos' Player
+ (nCell { cellAction = ctrlAction }) ]
+ | outGUIBoard fPos = [ RemovePiece iPos
+ , AddPiece iPos Player nCell ]
| otherwise = [ MovePiece iPos fPos'
- , AddPiece iPos Player nCell]
+ , AddPiece iPos Player nCell ]
where fPos'
| (xf `mod` 2 == 0 && yf `mod` 2 == 0)
|| (xf `mod` 2 /= 0 && yf `mod` 2 /= 0) = (xf,yf)