module Wordify.Rules.Tile (Tile(Letter, Blank), tileValue, isPlayable, tileLetter) where
data Tile = Letter Char Int | Blank (Maybe Char) deriving (Show, Eq, Ord)
tileValue :: Tile -> Int
tileValue (Letter _ val) = val
tileValue (Blank _) = 0
tileLetter :: Tile -> Maybe Char
tileLetter (Letter char _) = Just char
tileLetter (Blank (Just char)) = Just char
tileLetter (Blank Nothing) = Nothing
isPlayable :: Tile -> Tile -> Bool
isPlayable (Letter a b) (Letter x y) = (a == x) && (b == y)
isPlayable (Blank (Just _)) (Blank Nothing) = True
isPlayable _ _ = False