Skip to content

Commit

Permalink
Export some more data
Browse files Browse the repository at this point in the history
  • Loading branch information
bartavelle committed Jan 12, 2018
1 parent 01bb898 commit 6d5defc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Backends/GenericHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ _GamePlayers f s = case s of
convertMCom :: Maybe Com -> Todo
convertMCom mc = case mc of
Nothing -> TodoNothing
Just (CAP (AP age turn pid cards _) _) -> TodoAction age turn pid (toList cards)
Just (CAP (AP age turn pid cards gs) _) -> TodoAction age turn pid (toList cards) (toList (allowableActions age pid cards (gs ^. playermap)))
Just (CAC (AC age pid cards _ msg) _) -> TodoCard age pid (toList cards) msg

extractGameSummary :: GameS -> GameSummary
Expand Down
1 change: 1 addition & 0 deletions Startups/Cards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ instance FromJSON Cost where
parseJSON = withObject "cost" $ \o -> Cost <$> (fmap MS.fromOccurList (o .: "resources"))
<*> o .: "funding"

$(deriveElmDef defaultOptions ''Exchange)
$(deriveBoth defaultOptions ''CardType)
$(deriveBoth defaultOptions ''Effect)
$(deriveBoth defaultOptions ''Condition)
Expand Down
2 changes: 1 addition & 1 deletion Startups/Exported.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data PlayerStatus = Inactive
| InGame GameId GameSummary Todo [Message]
deriving (Show, Eq)

data Todo = TodoAction Age Turn PlayerId [Card]
data Todo = TodoAction Age Turn PlayerId [Card] [(PlayerAction, Exchange, Maybe SpecialInformation)]
| TodoCard Age PlayerId [Card] Message
| TodoNothing
deriving (Show, Eq)
Expand Down
18 changes: 12 additions & 6 deletions Startups/GameTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Control.Monad.Except
import Data.List.NonEmpty
import System.Random
import Data.Aeson
import Data.Aeson.TH
import Elm.Derive

type PlayerId = T.Text

Expand Down Expand Up @@ -62,9 +62,14 @@ neighbor NRight = pNeighborhood . _2
type Message = PrettyDoc

data PlayerAction = PlayerAction ActionType Card
deriving Eq
deriving (Show, Eq)
data ActionType = Play | Drop | BuildCompany
deriving Eq
deriving (Show, Eq)

-- | A data structure that represents special capabilities that are used
-- -- when playing a card.
data SpecialInformation = UseOpportunity
deriving (Show, Eq)

_NonEmpty :: Prism' [a] (NonEmpty a)
_NonEmpty = prism' toList nonEmpty
Expand Down Expand Up @@ -137,9 +142,10 @@ instance PrettyE PlayerAction where
Drop -> "dropped"
BuildCompany -> "increase the company stage"

$(deriveJSON baseOptions ''PlayerState)
$(deriveJSON baseOptions ''PlayerAction)
$(deriveJSON baseOptions ''ActionType)
$(deriveBoth baseOptions ''PlayerState)
$(deriveBoth baseOptions ''PlayerAction)
$(deriveBoth baseOptions ''ActionType)
$(deriveBoth baseOptions ''SpecialInformation)

instance ToJSON GameState where
toJSON (GameState pm dp _) = object [ "playermap" .= pm
Expand Down
5 changes: 0 additions & 5 deletions Startups/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ getCardVictory pid card stt = card ^.. cEffect . traverse . _AddVictory . to com
where
computeVictory (vtype, vpoints, vcond) = (vtype, countConditionTrigger pid vcond stt * vpoints)

-- | A data structure that represents special capabilities that are used
-- when playing a card.
data SpecialInformation = UseOpportunity
deriving Eq

-- | Gets the list of cheap resources, for each neighbor
getCheapExchanges :: PlayerState -> M.Map Neighbor (S.Set Resource)
getCheapExchanges ps = M.fromListWith (<>) $ do
Expand Down

0 comments on commit 6d5defc

Please sign in to comment.