Start with a Card module and a stub of Game
This commit is contained in:
commit
f7b3f21a83
3 changed files with 158 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.hi
|
||||||
|
*.o
|
118
Card.hs
Normal file
118
Card.hs
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
module Card where
|
||||||
|
|
||||||
|
data Flower =
|
||||||
|
Pine
|
||||||
|
| Plum
|
||||||
|
| Cherry
|
||||||
|
| Wisteria
|
||||||
|
| Iris
|
||||||
|
| Peony
|
||||||
|
| BushClover
|
||||||
|
| SusukiGrass
|
||||||
|
| Chrysanthemum
|
||||||
|
| Maple
|
||||||
|
| Willow
|
||||||
|
| Paulownia
|
||||||
|
deriving (Eq)
|
||||||
|
|
||||||
|
data Ribbon =
|
||||||
|
Red
|
||||||
|
| Blue
|
||||||
|
| Poetry
|
||||||
|
|
||||||
|
data Animal =
|
||||||
|
BushWarbler
|
||||||
|
| Cuckoo
|
||||||
|
| EightPlankBridge
|
||||||
|
| Butterflies
|
||||||
|
| Boar
|
||||||
|
| Geese
|
||||||
|
| SakeCup
|
||||||
|
| Deer
|
||||||
|
| Swallow
|
||||||
|
|
||||||
|
data Light =
|
||||||
|
Crane
|
||||||
|
| CampCurtain
|
||||||
|
| FullMoon
|
||||||
|
| RainMan
|
||||||
|
| ChinesePhoenix
|
||||||
|
|
||||||
|
data Value =
|
||||||
|
Plain
|
||||||
|
| Sand
|
||||||
|
| Lightning
|
||||||
|
| Ribbon Ribbon
|
||||||
|
| Animal Animal
|
||||||
|
| Light Light
|
||||||
|
|
||||||
|
data Card = Card {
|
||||||
|
flower::Flower
|
||||||
|
, value::Value
|
||||||
|
}
|
||||||
|
|
||||||
|
deck :: [ Card ]
|
||||||
|
deck = [
|
||||||
|
Card Pine Plain
|
||||||
|
, Card Pine Plain
|
||||||
|
, Card Pine (Ribbon Poetry)
|
||||||
|
, Card Pine (Light Crane)
|
||||||
|
|
||||||
|
, Card Plum Plain
|
||||||
|
, Card Plum Plain
|
||||||
|
, Card Plum (Ribbon Poetry)
|
||||||
|
, Card Plum (Animal BushWarbler)
|
||||||
|
|
||||||
|
, Card Cherry Plain
|
||||||
|
, Card Cherry Plain
|
||||||
|
, Card Cherry (Ribbon Poetry)
|
||||||
|
, Card Cherry (Light CampCurtain)
|
||||||
|
|
||||||
|
, Card Wisteria Plain
|
||||||
|
, Card Wisteria Plain
|
||||||
|
, Card Wisteria (Ribbon Red)
|
||||||
|
, Card Wisteria (Animal Cuckoo)
|
||||||
|
|
||||||
|
, Card Iris Plain
|
||||||
|
, Card Iris Plain
|
||||||
|
, Card Iris (Ribbon Red)
|
||||||
|
, Card Iris (Animal EightPlankBridge)
|
||||||
|
|
||||||
|
, Card Peony Plain
|
||||||
|
, Card Peony Plain
|
||||||
|
, Card Peony (Ribbon Blue)
|
||||||
|
, Card Peony (Animal Butterflies)
|
||||||
|
|
||||||
|
, Card BushClover Plain
|
||||||
|
, Card BushClover Plain
|
||||||
|
, Card BushClover (Ribbon Red)
|
||||||
|
, Card BushClover (Animal Boar)
|
||||||
|
|
||||||
|
, Card SusukiGrass Plain
|
||||||
|
, Card SusukiGrass Plain
|
||||||
|
, Card SusukiGrass (Animal Geese)
|
||||||
|
, Card SusukiGrass (Light FullMoon)
|
||||||
|
|
||||||
|
, Card Chrysanthemum Plain
|
||||||
|
, Card Chrysanthemum Plain
|
||||||
|
, Card Chrysanthemum (Ribbon Blue)
|
||||||
|
, Card Chrysanthemum (Animal SakeCup)
|
||||||
|
|
||||||
|
, Card Maple Plain
|
||||||
|
, Card Maple Plain
|
||||||
|
, Card Maple (Ribbon Blue)
|
||||||
|
, Card Maple (Animal Deer)
|
||||||
|
|
||||||
|
, Card Willow Lightning
|
||||||
|
, Card Willow (Ribbon Red)
|
||||||
|
, Card Willow (Animal Swallow)
|
||||||
|
, Card Willow (Light RainMan)
|
||||||
|
|
||||||
|
, Card Paulownia Plain
|
||||||
|
, Card Paulownia Plain
|
||||||
|
, Card Paulownia Sand
|
||||||
|
, Card Paulownia (Light ChinesePhoenix)
|
||||||
|
]
|
||||||
|
|
||||||
|
pair :: Card -> Card -> Bool
|
||||||
|
pair card1 card2 = flower card1 == flower card2
|
38
Game.hs
Normal file
38
Game.hs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
module Game where
|
||||||
|
|
||||||
|
import Card
|
||||||
|
|
||||||
|
data Yaku =
|
||||||
|
Junk Int
|
||||||
|
| Ribbons Int
|
||||||
|
| SpecialRibbons Int
|
||||||
|
| Animals Int
|
||||||
|
| InoShikaCho
|
||||||
|
| Sake Int
|
||||||
|
| Lights Int
|
||||||
|
|
||||||
|
data Taken = Taken {
|
||||||
|
junk :: [ Flower ]
|
||||||
|
, animals :: [ Animal ]
|
||||||
|
, ribbons :: [ Ribbon ]
|
||||||
|
, lights :: [ Light ]
|
||||||
|
}
|
||||||
|
|
||||||
|
data Player = Player {
|
||||||
|
hand :: [ Card ]
|
||||||
|
, taken :: Taken
|
||||||
|
}
|
||||||
|
|
||||||
|
score :: Yaku -> Int
|
||||||
|
score (Junk n) = 1 + n
|
||||||
|
score (Ribbons n) = 1 + n
|
||||||
|
score (SpecialRibbons 0) = 3
|
||||||
|
score (SpecialRibbons _) = 9
|
||||||
|
score (Animals n) = 1 + n
|
||||||
|
score InoShikaCho = 5
|
||||||
|
score (Sake 0) = 5
|
||||||
|
score (Sake _) = 15
|
||||||
|
score (Lights 0) = 5
|
||||||
|
score (Lights 1) = 8
|
||||||
|
score (Lights 2) = 10
|
||||||
|
score (Lights 3) = 15
|
Loading…
Reference in a new issue