Safe Haskell | Safe |
---|---|
Language | Haskell98 |
- data FormedWords
- type FormedWord = Seq (Pos, Square)
- type PlacedSquares = Map Pos Square
- allWords :: FormedWords -> [FormedWord]
- mainWord :: FormedWords -> FormedWord
- adjacentWords :: FormedWords -> [FormedWord]
- playerPlaced :: FormedWords -> [(Pos, Square)]
- playerPlacedMap :: FormedWords -> Map Pos Square
- scoreWord :: PlacedSquares -> FormedWord -> Int
- overallScore :: FormedWords -> Int
- bingoBonusApplied :: FormedWords -> Bool
- prettyPrintIntersections :: PlacedSquares -> FormedWord -> String
- makeString :: FormedWord -> String
- wordStrings :: FormedWords -> [String]
- wordsWithScores :: FormedWords -> (Int, [(String, Int)])
- wordsFormedMidGame :: Board -> Map Pos Tile -> Either ScrabbleError FormedWords
- wordFormedFirstMove :: Board -> Map Pos Tile -> Either ScrabbleError FormedWords
Documentation
type FormedWord = Seq (Pos, Square) Source
type PlacedSquares = Map Pos Square Source
allWords :: FormedWords -> [FormedWord] Source
All the words formed by a play.
mainWord :: FormedWords -> FormedWord Source
Returns the main word formed by the played tiles. The main word is the linear stretch of tiles formed by the tiles placed.
adjacentWords :: FormedWords -> [FormedWord] Source
Returns the list of words which were adjacent to the main word formed.
playerPlaced :: FormedWords -> [(Pos, Square)] Source
Returns the list of positions mapped to the squares that the player placed their tiles on.
playerPlacedMap :: FormedWords -> Map Pos Square Source
scoreWord :: PlacedSquares -> FormedWord -> Int Source
Scores an individual word.
Note: overallscore should be used to obtain the overall score as it takes into account any bingo bonuses.
overallScore :: FormedWords -> Int Source
Calculates the overall score of the play.
If a player managed to place all 7 of their letters, then they receive a bingo bonus of 50 points.
bingoBonusApplied :: FormedWords -> Bool Source
Returns true if the player placed all 7 of their letters while forming these words, incurring a + 50 score bonus.
prettyPrintIntersections :: PlacedSquares -> FormedWord -> String Source
Pretty prints the places a given formed word intersects with letters that were already on the board
using brackets. E.g. T(HI)S would denote that the player placed a T
and an S
on to the board, using
the already placed word HI
to form the new word THIS
.
makeString :: FormedWord -> String Source
wordStrings :: FormedWords -> [String] Source
Returns the words formed by the play as strings.
wordsWithScores :: FormedWords -> (Int, [(String, Int)]) Source
Scores the words formed by the tiles placed. The first item in the tuple is the overall score, while the second item is the list of scores for all the words formed.
wordsFormedMidGame :: Board -> Map Pos Tile -> Either ScrabbleError FormedWords Source
Returns the words formed by the tiles played on the board. A played word must be connected to a tile already on the board (or intersect tiles on the board), and be formed linearly. Any blank tiles must be labeled.
wordFormedFirstMove :: Board -> Map Pos Tile -> Either ScrabbleError FormedWords Source
Returns the word formed by the first move on the board. The word must cover the star tile, and be linear. Any blank tiles must be labeled.