flavis 6 лет назад
Родитель
Сommit
8f692d36ac
2 измененных файлов: 8 добавлений и 4 удалений
  1. +1
    -0
      src/Skat/AI/Online.hs
  2. +7
    -4
      src/Skat/Bidding.hs

+ 1
- 0
src/Skat/AI/Online.hs Просмотреть файл

@@ -145,6 +145,7 @@ newtype ChosenResponse = ChosenResponse Card
newtype BidResponse = BidResponse Int newtype BidResponse = BidResponse Int
newtype YesNo = YesNo Bool newtype YesNo = YesNo Bool
newtype GameResponse = GameResponse Game newtype GameResponse = GameResponse Game
deriving Show
newtype ChosenCards = ChosenCards [Card] newtype ChosenCards = ChosenCards [Card]
instance ToJSON Query where instance ToJSON Query where


+ 7
- 4
src/Skat/Bidding.hs Просмотреть файл

@@ -9,6 +9,7 @@ import Data.Aeson hiding (Null)
import Skat.Card import Skat.Card
import Data.List (sortOn) import Data.List (sortOn)
import Data.Ord (Down(..)) import Data.Ord (Down(..))
import Control.Monad


-- | different game types -- | different game types
data Game = Colour Colour Modifier data Game = Colour Colour Modifier
@@ -34,6 +35,7 @@ instance FromJSON Game where
"nullhand" -> return NullHand "nullhand" -> return NullHand
"nullouvert" -> return NullOuvert "nullouvert" -> return NullOuvert
"nullouverthand" -> return NullOuvertHand "nullouverthand" -> return NullOuvertHand
_ -> mzero


-- | modifiers for grand and colour games -- | modifiers for grand and colour games
data Modifier = Einfach data Modifier = Einfach
@@ -51,14 +53,15 @@ data Modifier = Einfach
instance FromJSON Modifier where instance FromJSON Modifier where
parseJSON = withObject "Modifier" $ \v -> do parseJSON = withObject "Modifier" $ \v -> do
hnd <- v .: "hand" hnd <- v .: "hand"
if read hnd then do
schneider <- v .: "schneider"
schwarz <- v .: "schwarz"
ouvert <- v .: "ouvert"
if hnd then do
schneider <- v .:? "schneider" .!= False
schwarz <- v .:? "schwarz" .!= False
ouvert <- v .:? "ouvert" .!= False
case (schneider, schwarz, ouvert) of case (schneider, schwarz, ouvert) of
(_, _, True) -> return Ouvert (_, _, True) -> return Ouvert
(True, False, _) -> return HandSchneiderAngesagt (True, False, _) -> return HandSchneiderAngesagt
(_, True, _) -> return HandSchwarzAngesagt (_, True, _) -> return HandSchwarzAngesagt
_ -> return Hand
else return Einfach else return Einfach


-- | calculate the value of a game with given cards -- | calculate the value of a game with given cards


Загрузка…
Отмена
Сохранить