Better argument order
This commit is contained in:
parent
c12bef50b3
commit
d7fa0ffd9d
1 changed files with 4 additions and 4 deletions
|
@ -207,7 +207,7 @@ rotate g = g & block .~ nextB
|
||||||
where nextB = fromMaybe blk $ getFirst . mconcat $ bs
|
where nextB = fromMaybe blk $ getFirst . mconcat $ bs
|
||||||
bs = map ($ blk) safeFuncs
|
bs = map ($ blk) safeFuncs
|
||||||
safeFuncs = map (mkSafe .) funcs
|
safeFuncs = map (mkSafe .) funcs
|
||||||
mkSafe b = if isValidBlockPosition b brd then First (Just b) else First Nothing
|
mkSafe b = if isValidBlockPosition brd b then First (Just b) else First Nothing
|
||||||
funcs = [rotate', rotate' . translate Left, rotate' . translate Right]
|
funcs = [rotate', rotate' . translate Left, rotate' . translate Right]
|
||||||
blk = g ^. block
|
blk = g ^. block
|
||||||
brd = g ^. board
|
brd = g ^. board
|
||||||
|
@ -237,7 +237,7 @@ nextBlock g = do
|
||||||
-- | Try to shift current block; if shifting not possible, leave block where it is
|
-- | Try to shift current block; if shifting not possible, leave block where it is
|
||||||
shift :: Direction -> Game -> Game
|
shift :: Direction -> Game -> Game
|
||||||
shift d g = g & block %~ shiftBlock
|
shift d g = g & block %~ shiftBlock
|
||||||
where shiftBlock b = if isValidBlockPosition (translate d b) (g ^. board)
|
where shiftBlock b = if isValidBlockPosition (g ^. board) (translate d b)
|
||||||
then translate d b
|
then translate d b
|
||||||
else b
|
else b
|
||||||
|
|
||||||
|
@ -256,8 +256,8 @@ gravitate :: Game -> Game
|
||||||
gravitate = shift Down
|
gravitate = shift Down
|
||||||
|
|
||||||
-- | Checks if block's potential new location is valid
|
-- | Checks if block's potential new location is valid
|
||||||
isValidBlockPosition :: Block -> Board -> Bool
|
isValidBlockPosition :: Board -> Block -> Bool
|
||||||
isValidBlockPosition blk brd = all validCoord $ blk ^. to coords
|
isValidBlockPosition brd = all validCoord . coords
|
||||||
where validCoord = (&&) <$> isFree brd <*> isInBounds
|
where validCoord = (&&) <$> isFree brd <*> isInBounds
|
||||||
|
|
||||||
-- | Shuffle a sequence (random permutation)
|
-- | Shuffle a sequence (random permutation)
|
||||||
|
|
Loading…
Add table
Reference in a new issue