Try a stub of a C-style version of types
This commit is contained in:
parent
f7b3f21a83
commit
7de6040289
2 changed files with 66 additions and 0 deletions
51
CCard.hs
Normal file
51
CCard.hs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
module CCard where
|
||||||
|
|
||||||
|
import Data.Word (Word64)
|
||||||
|
import Data.Bits (setBit, (.|.))
|
||||||
|
|
||||||
|
newtype Card = Card Int
|
||||||
|
type Pack = Word64
|
||||||
|
|
||||||
|
data Flower =
|
||||||
|
Pine
|
||||||
|
| Plum
|
||||||
|
| Cherry
|
||||||
|
| Wisteria
|
||||||
|
| Iris
|
||||||
|
| Peony
|
||||||
|
| BushClover
|
||||||
|
| SusukiGrass
|
||||||
|
| Chrysanthemum
|
||||||
|
| Maple
|
||||||
|
| Willow
|
||||||
|
| Paulownia
|
||||||
|
deriving (Eq, Ord, Enum, Show)
|
||||||
|
|
||||||
|
flower :: Card -> Flower
|
||||||
|
flower (Card n) = toEnum $ n `div` 4
|
||||||
|
|
||||||
|
set :: [Int] -> Pack
|
||||||
|
set = foldl setBit 0
|
||||||
|
|
||||||
|
inoshikacho :: Pack
|
||||||
|
inoshikacho = set [23, 27, 39]
|
||||||
|
|
||||||
|
animals :: Pack
|
||||||
|
animals = set [7, 15, 19, 30, 35, 42] .|. inoshikacho
|
||||||
|
|
||||||
|
blue :: Pack
|
||||||
|
blue = set [22, 37, 41]
|
||||||
|
|
||||||
|
poetry :: Pack
|
||||||
|
poetry = set [2, 6, 10]
|
||||||
|
|
||||||
|
ribbons = set [14, 18, 26, 41] .|. blue .|. poetry
|
||||||
|
|
||||||
|
lights :: Pack
|
||||||
|
lights = set [3, 11, 31, 43, 47]
|
||||||
|
|
||||||
|
pair :: Card -> Card -> Bool
|
||||||
|
pair card1 card2 = flower card1 == flower card2
|
||||||
|
|
||||||
|
cards :: [Card]
|
||||||
|
cards = map Card [0..47]
|
15
KoiKoi.hs
Normal file
15
KoiKoi.hs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
module KoiKoi where
|
||||||
|
|
||||||
|
import CCard
|
||||||
|
|
||||||
|
data Player = Player {
|
||||||
|
hand :: Pack
|
||||||
|
, captured :: Pack
|
||||||
|
}
|
||||||
|
|
||||||
|
data State = State {
|
||||||
|
players :: (Player, Player)
|
||||||
|
, river :: Pack
|
||||||
|
, deck :: [ Card ]
|
||||||
|
, turn :: Bool
|
||||||
|
}
|
Loading…
Reference in a new issue