summaryrefslogtreecommitdiff
path: root/src/Mahjong/Pai.hs
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2016-05-22 21:50:48 -0500
committerTuowen Zhao <ztuowen@gmail.com>2016-05-22 21:50:48 -0500
commit7c467a66bf44626c181c7a0b22224ce73af45d31 (patch)
tree78d123fab201572ed3678f95f3729c5fd0aeaf04 /src/Mahjong/Pai.hs
parent9a9206e0cbfba6073786a98096c6e5467ebaa86b (diff)
downloadhmj-7c467a66bf44626c181c7a0b22224ce73af45d31.tar.gz
hmj-7c467a66bf44626c181c7a0b22224ce73af45d31.tar.bz2
hmj-7c467a66bf44626c181c7a0b22224ce73af45d31.zip
listen cal
Diffstat (limited to 'src/Mahjong/Pai.hs')
-rw-r--r--src/Mahjong/Pai.hs42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/Mahjong/Pai.hs b/src/Mahjong/Pai.hs
deleted file mode 100644
index 067196e..0000000
--- a/src/Mahjong/Pai.hs
+++ /dev/null
@@ -1,42 +0,0 @@
-module Pai where
-
-import Data.Char (toUpper)
-import Data.List (sort)
-import Data.Maybe
-import Control.Monad
-
-data MCol = Man | Pin | Sou | Cha
- deriving (Eq,Ord)
-data MCard = MCard MCol Int
- deriving (Eq,Ord)
-
-charMcol = [(Man,'M'),(Pin,'P'),(Sou,'S'),(Cha,'C')]
-instance Show MCol where
- show x = [snd a | a <-charMcol, fst a == x]
-
-instance Read MCol where
- readsPrec p r = [(fst a,t)|(c,t) <- lex r, a <- charMcol, map toUpper c == [snd a]]
-
-instance Show MCard where
- show (MCard a b) = show b ++ show a
-
-instance Read MCard where
- readsPrec p r = [ (MCard col n,u) | (c1,t)<- lex r,
- let n = (read c1)::Int,
- (c2,u) <-lex t,
- let col=(read c2)::MCol]
-
-isCha c@(MCard col n) = (col == Cha)
-isLaoTou c@(MCard col n) = ((n == 1) || (n == 9)) && (not $ isCha c)
-is19 c@(MCard col n) = (isCha c) || (isLaoTou c)
-
-orderedPai = sort $ [MCard c n | c<-[Man,Pin,Sou], n <-[1..9]] ++ (map (MCard Cha) [1..7])
-
-nextPai p = if xs /= [] then Just $ head xs
- else Nothing
- where (x:xs) = dropWhile (/= p) orderedPai
-
-nextPai' p@(MCard c n) = do
- nx <- nextPai p
- guard ((c /= Cha) && (n /= 9))
- return nx