Permalink
Browse files

added Feodum

  • Loading branch information...
1 parent ec53654 commit a555c8b1d954bc21940812f06ff48760288285b6 @rspeer committed Aug 8, 2012
Showing with 29 additions and 14 deletions.
  1. +3 −0 basicAI.coffee
  2. +24 −8 cards.coffee
  3. +1 −5 gameState.coffee
  4. +1 −1 testSimulation.coffee
View
@@ -721,6 +721,7 @@ class BasicAI
"Border Village"
"Mandarin"
"Ill-Gotten Gains" if this.coinLossMargin(state) > 0
+ "Feodum"
"Estate"
"Curse"
"Apprentice"
@@ -741,6 +742,7 @@ class BasicAI
"Duchy" if this.goingGreen(state) < 3
"Border Village"
"Mandarin"
+ "Feodum"
"Bishop"
"Ill-Gotten Gains" if this.coinLossMargin(state) > 0
"Curse"
@@ -870,6 +872,7 @@ class BasicAI
"Border Village"
"Mandarin"
"Ill-Gotten Gains" if this.coinLossMargin(state) > 0
+ "Feodum"
"Salvager"
]
View
@@ -138,10 +138,12 @@ basicCard = {
# - What happens when the card is bought?
buyEffect: (state) ->
# - What happens when the card is gained?
- gainEffect: (state) ->
+ gainEffect: (state, player) ->
# - What happens (besides the simple effects defined above) when the card is
# played?
playEffect: (state) ->
+ # - What happens when this card is trashed?
+ trashEffect: (state, player) ->
# - What happens when this card is in play and another card is gained?
gainInPlayEffect: (state, card) ->
# - What happens when this card is in play and another card is specifically
@@ -196,6 +198,9 @@ basicCard = {
onGain: (state, player) ->
this.gainEffect(state, player)
+
+ onTrash: (state, player) ->
+ this.trashEffect(state, player)
# A card's string representation is its name.
#
@@ -396,6 +401,14 @@ makeCard 'Farmland', c.Estate, {
state.gainCard(state.current, newCard)
}
+makeCard 'Feodum', c.Estate, {
+ cost: 4
+ getVP: (player) -> Math.floor(player.countInDeck('Silver') / 3)
+ trashEffect: (state, player) ->
+ state.gainCard(player, c.Silver)
+ state.gainCard(player, c.Silver)
+ state.gainCard(player, c.Silver)
+}
makeCard 'Gardens', c.Estate, {
cost: 4
@@ -522,9 +535,9 @@ makeCard 'Cache', treasure, {
cost: 5
coins: 3
- gainEffect: (state) ->
- state.gainCard(state.current, c.Copper)
- state.gainCard(state.current, c.Copper)
+ gainEffect: (state, player) ->
+ state.gainCard(player, c.Copper)
+ state.gainCard(player, c.Copper)
}
makeCard "Fool's Gold", treasure, {
@@ -587,10 +600,11 @@ makeCard 'Ill-Gotten Gains', treasure, {
if state.current.ai.choose('gainCopper', state, [yes, no])
state.gainCard(state.current, c.Copper, 'hand')
- gainEffect: (state) ->
- # For each player but the current: gain a curse.
- for i in [1...state.nPlayers]
- state.gainCard(state.players[i], c.Curse)
+ gainEffect: (state, player) ->
+ # For each player but the gainer: gain a curse.
+ for i in [0...state.nPlayers]
+ if state.players[i] != player
+ state.gainCard(state.players[i], c.Curse)
}
makeCard 'Loan', treasure, {
@@ -917,6 +931,8 @@ makeCard 'Graverobber', c.Remodel, {
if newCard isnt null
if oldCard is null
state.log("...gaining #{newCard} from the trash and putting it on top of the deck.")
+ state.supply[newCard] += 1
+ state.trash.remove(newCard)
state.gainCard(state.current, newCard, 'draw', true)
else
state.gainCard(state.current, newCard, 'discard')
View
@@ -1166,17 +1166,13 @@ class State
card.reactToDiscard(this, player)
# `doTrash` causes the player to trash a particular card.
- #
- # For bookkeeping,
- # it puts it in the `@trash` list; if we start using `@trash` consistently,
- # we can count the total number of cards in the game, making sure that it's
- # constant and cards aren't being dropped on the floor.
doTrash: (player, card) ->
if card not in player.hand
this.warn("#{player.ai} has no #{card} to trash")
return
this.log("#{player.ai} trashes #{card}.")
player.hand.remove(card)
+ card.onTrash(this, player)
@trash.push(card)
# `doPutOnDeck` puts a particular card from the player's hand on top of
View
@@ -52,7 +52,7 @@ this['2-player smoke test'] = (test) ->
ais = (loadStrategy('strategies/SillyAI.coffee') for i in [1..2])
noLog = (message) ->
for i in [0...100]
- st = new gameState.State().setUpWithOptions(ais, {log: console.warn, require: ['Graverobber', 'Ironworks']})
+ st = new gameState.State().setUpWithOptions(ais, {log: console.warn, require: []})
until st.gameIsOver()
st.doPlay()
test.done()

0 comments on commit a555c8b

Please sign in to comment.