Skip to content

Commit

Permalink
Merge branch 'master' of github.com:norm2782/HaskBan
Browse files Browse the repository at this point in the history
  • Loading branch information
roman committed Aug 25, 2010
2 parents 0d92e5e + a09de75 commit 0e51e5b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions HaskBan/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ module HaskBan.Logic where
isPath :: Point -> SokoMap -> Bool
isPath = isCellType (Path Empty)

isTarget :: Point -> SokoMap -> Bool
isTarget p sm = isCellType (Target Box) p sm ||
isCellType (Target Empty) p sm

isCellType :: CellType -> Point -> SokoMap -> Bool
isCellType cType point sMap = (sMap ! point) == cType

-- Verify if the player can move to the point that is provided.
-- In case the new pointis a box, the next position needs to be
-- checked as well. Hence, the original translation function is provided as well.
canMoveTo :: SokoMap -> Point -> Translation -> Bool
canMoveTo sMap point transl = (isPath point sMap) ||
(isBox point sMap && not (isWall trPt sMap)
&& not (isBox trPt sMap))
canMoveTo sMap point transl = (isPath point sMap) ||
(isTarget point sMap) ||
(isBox point sMap && not (isWall trPt sMap)
&& not (isBox trPt sMap))
where trPt = transl point


0 comments on commit 0e51e5b

Please sign in to comment.