packages feed

haskellscrabble 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+28/−3 lines, 3 filesdep +splitPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependencies added: split

API changes (from Hackage documentation)

+ Wordify.Rules.Board: prettyPrint :: Board -> String

Files

haskellscrabble.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                haskellscrabble-version:             0.1.0.0+version:             0.1.0.1 synopsis:            A scrabble library capturing the core game logic of scrabble. description:         A scrabble library which enforces legal transitions between moves. Intended to facilitate the development of a playable game. homepage:            http://www.github.com/happy0/haskellscrabble@@ -35,7 +35,7 @@   other-modules:       Wordify.Rules.Game.Internal    build-depends:       base < 4.8, containers, array, random, mtl, transformers, QuickCheck, -                       parsec, unordered-containers, semigroups, errors, safe+                       parsec, unordered-containers, semigroups, errors, safe, split   hs-source-dirs:      src    test-suite tests
src/Wordify/Rules/Board.hs view
@@ -1,5 +1,5 @@ module Wordify.Rules.Board(Board, allSquares, emptyBoard, placeTile, occupiedSquareAt,- lettersAbove, lettersBelow, lettersLeft, lettersRight, unoccupiedSquareAt) where+ lettersAbove, lettersBelow, lettersLeft, lettersRight, unoccupiedSquareAt, prettyPrint) where    import Wordify.Rules.Square   import Wordify.Rules.Pos@@ -10,6 +10,8 @@   import Data.Sequence as Seq   import Wordify.Rules.Board.Internal   import Control.Applicative+  import Data.List.Split+  import Data.List    {- |     Returns all the squares on the board, ordered by column then row.@@ -55,6 +57,29 @@   {- | All letters immediately right of a given square until a non-occupied square -}   lettersRight :: Board -> Pos -> Seq (Pos,Square)   lettersRight board pos = walkFrom board pos right++  {- | Pretty prints a board to a human readable string representation -}+  prettyPrint :: Board -> String+  prettyPrint board = rowsWithLabels ++ columnLabelSeparator ++ columnLabels+    where+      rows = transpose $ chunksOf 15 $ map (squareToString . snd) $ allSquares board+      rowsWithLabels = concatMap (\(rowNo, row) -> (rowStr rowNo) ++ concat row ++ "\n") $ Prelude.zip [1 .. ] rows++      rowStr :: Int -> String+      rowStr number = if number < 10 then ((show number) ++ " | ") else (show number) ++ "| "+      columnLabelSeparator = "  " ++ (Prelude.take (15 * 5) $ repeat '-') ++ "\n"+      columnLabels = "      " ++ (concat $ Prelude.take (15 *2) $ intersperse "    " $ map ( : []) ['A' .. ])++      squareToString square = +        case (tileIfOccupied square) of+          Just sq -> maybe " [_] " (\lt -> " [" ++ lt : "] ") $ tileLetter sq+          Nothing -> +            case square of+              (Normal _) -> "  N  "+              (DoubleLetter _) -> "  DL "+              (TripleLetter _) -> "  TL "+              (DoubleWord _) -> "  DW "+              (TripleWord _) -> "  TW "    {-     Walks the tiles from a given position in a given direction
src/Wordify/Rules/Pos/Internal.hs view