Take KoiKoi-specific objects out of Cards module
This commit is contained in:
parent
3ffabc578e
commit
3f43d960f4
1 changed files with 7 additions and 27 deletions
34
CCard.hs
34
CCard.hs
|
@ -1,7 +1,7 @@
|
||||||
module CCard where
|
module CCard where
|
||||||
|
|
||||||
import Data.Word (Word64)
|
import Data.Word (Word64)
|
||||||
import Data.Bits (setBit, (.|.), (.&.), shift, xor, testBit)
|
import Data.Bits (setBit, shift, testBit)
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
|
|
||||||
data Flower =
|
data Flower =
|
||||||
|
@ -34,39 +34,19 @@ data Card =
|
||||||
| Paulownia0 | Paulownia1 | Sand | Phoenix
|
| Paulownia0 | Paulownia1 | Sand | Phoenix
|
||||||
deriving (Eq, Ord, Enum, Show)
|
deriving (Eq, Ord, Enum, Show)
|
||||||
|
|
||||||
type Pack = Word64
|
|
||||||
|
|
||||||
flower :: Card -> Flower
|
flower :: Card -> Flower
|
||||||
flower = toEnum . (`div` 4) . fromEnum
|
flower = toEnum . (`div` 4) . fromEnum
|
||||||
|
|
||||||
set :: [Card] -> Pack
|
type Pack = Word64
|
||||||
set = foldl setBit 0 . map fromEnum
|
|
||||||
|
packOfCards :: [Card] -> Pack
|
||||||
|
packOfCards = foldl setBit 0 . map fromEnum
|
||||||
|
|
||||||
contains :: Pack -> Card -> Bool
|
contains :: Pack -> Card -> Bool
|
||||||
contains pack = testBit pack . fromEnum
|
contains pack = testBit pack . fromEnum
|
||||||
|
|
||||||
inoshikacho :: Pack
|
add :: Pack -> Card -> Pack
|
||||||
inoshikacho = set [Butterflies, Boar, Deer]
|
add pack = setBit pack . fromEnum
|
||||||
|
|
||||||
animals :: Pack
|
|
||||||
animals = set [BushWarbler, Cuckoo, EightPlankBridge, Geese, SakeCup, Swallow] .|. inoshikacho
|
|
||||||
|
|
||||||
blue :: Pack
|
|
||||||
blue = set [PeonyBlue, ChrysanthemumBlue, MapleBlue]
|
|
||||||
|
|
||||||
poetry :: Pack
|
|
||||||
poetry = set [PinePoetry, PlumPoetry, CherryPoetry]
|
|
||||||
|
|
||||||
ribbons = set [WisteriaRed, IrisRed, BushCloverRed, WillowRed] .|. blue .|. poetry
|
|
||||||
|
|
||||||
lights :: Pack
|
|
||||||
lights = set [Crane, CampCurtain, FullMoon, RainMan, Phoenix]
|
|
||||||
|
|
||||||
plain :: Pack
|
|
||||||
plain = pack `xor` (lights .|. ribbons .|. animals) .&. pack
|
|
||||||
|
|
||||||
pack :: Pack
|
|
||||||
pack = 1 `shift` (fromEnum Phoenix + 1) - 1
|
|
||||||
|
|
||||||
pair :: Card -> Card -> Bool
|
pair :: Card -> Card -> Bool
|
||||||
pair card1 card2 = flower card1 == flower card2
|
pair card1 card2 = flower card1 == flower card2
|
||||||
|
|
Loading…
Reference in a new issue