@@ -111,23 +111,6 @@ resolveExchange pid exch = mconcat . M.elems <$> itraverse resolveExchange' exc
111
111
playermap . ix pid . pFunds -= cost
112
112
pure (reslist, AddMap (M. singleton neighname cost))
113
113
114
- -- | Compute the money that a card gives to a player
115
- getCardFunding :: GameStateOnly m => PlayerId -> Card -> m Funding
116
- getCardFunding pid card = do
117
- stt <- use playermap
118
- -- note how we exploit the fact that ^. behaves like foldMap here
119
- let funding = card ^. cEffect . traverse . _GainFunding . to computeFunding
120
- computeFunding (n, cond) = countConditionTrigger pid cond stt * n
121
- return funding
122
-
123
- -- | Compute the victory points a card awards.
124
- getCardVictory :: GameStateOnly m => PlayerId -> Card -> m [(VictoryType , VictoryPoint )]
125
- getCardVictory pid card = do
126
- stt <- use playermap
127
- let victory = card ^.. cEffect . traverse . _AddVictory . to computeVictory
128
- computeVictory (vtype, vpoints, vcond) = (vtype, countConditionTrigger pid vcond stt * vpoints)
129
- return victory
130
-
131
114
-- | Try to play a card, with some extra resources, provided that the
132
115
-- player has enough.
133
116
playCard :: NonInteractive m => Age -> PlayerId -> MS. MultiSet Resource -> Card -> m ()
@@ -225,7 +208,7 @@ playTurn age turn rawcardmap = do
225
208
-- then add the money gained from cards
226
209
ifor results $ \ pid (hand, _, card) -> do
227
210
void $ for card $ \ c -> do
228
- f <- getCardFunding pid c
211
+ f <- getCardFunding pid c <$> use playermap
229
212
playermap . ix pid . pFunds += f
230
213
return hand
231
214
-- TODO recycling capability
@@ -279,8 +262,9 @@ victoryPoints = use playermap >>= itraverse computeScore
279
262
scienceTypes = playerState ^.. cardEffects . _RnD
280
263
scienceJokers = length (playerState ^.. cardEffects . _ScientificBreakthrough)
281
264
research = (RnDVictory , scienceScore scienceTypes scienceJokers)
282
- cardPoints <- mapM (getCardVictory pid) (playerState ^. pCards)
283
- return $ M. fromListWith (+) $ poaching : funding : research : concat cardPoints
265
+ stt <- use playermap
266
+ let cardPoints = playerState ^.. pCards . traverse . to (\ c -> getCardVictory pid c stt) . folded
267
+ return $ M. fromListWith (+) $ poaching : funding : research : cardPoints
284
268
285
269
-- | The main game function, runs a game. The state must be initialized in
286
270
-- the same way as the 'initGame' function.
0 commit comments