 
 makeCard 'Farming Village', action, {
   cost: 4
-  actions: 2
-  
-  playEffect: (state) ->
-    cardsDrawn = 0;
-    while cardsDrawn < 1
-      drawn = state.current.getCardsFromDeck(1)
-      if drawn.length == 0
-        break
+  actions: +2
+  playEffect: (state) ->
+    drawn = state.current.dig(state,
+      (state, card) -> card.isAction or card.isTreasure
+    )
+    if drawn.length > 0
       card = drawn[0]
-      if card.isAction or card.isTreasure
-        cardsDrawn += 1
-        state.current.hand.push(card)
-        state.log("...drawing a #{card}.")
-      else
-        state.current.setAside.push(card)
-    state.current.discard = state.current.discard.concat(state.current.setAside)
-    state.current.setAside = []
+      state.log("...#{state.current.ai} draws #{card}.")
+      state.current.hand.push(card)
+}
+
+makeCard 'Golem', action, {
+  cost: 4
+  costPotion: 1
+  playEffect: (state) ->
+    drawn = state.current.dig(state,
+      (state, card) -> card.isAction and card.name isnt 'Golem',
+      2
+    )
+    if drawn.length > 0
+      firstAction = state.current.ai.choose('action', state, drawn)
+      drawn.remove(firstAction)
+      secondAction = drawn[0]
+      actions = [firstAction, secondAction]
+      for card in actions
+        if card?
+          state.log("...#{state.current.ai} plays #{card}.")
+          state.current.inPlay.push(card)
+          state.current.playLocation = 'inPlay'
+          state.resolveAction(card)
 }
 
 makeCard "Feast", action, {


makeCard 'Adventurer', action, {
  cost: 6

  playEffect: (state) ->
    treasuresDrawn = 0
    while treasuresDrawn < 2
      # Take cards one at a time, and either put them in hand or set them
      # aside depending on their type.
      drawn = state.current.getCardsFromDeck(1)
      if drawn.length == 0
        break
      card = drawn[0]
      if card.isTreasure
        treasuresDrawn += 1
        state.current.hand.push(card)
        state.log("...drawing a #{card}.")
      else
        state.current.setAside.push(card)
    state.current.discard = state.current.discard.concat(state.current.setAside)
    state.current.setAside = []
}

makeCard 'Alchemist', action, {

        {cards: 3}
      ])
      applyBenefit(state, benefit)
}

makeCard 'Silk Road', c.Estate, {
  cost: 4
  getVP: (state) -> Math.floor(state.current.countCardTypeInDeck('Victory') / 4)
}

# Revealing Tunnel for Gold as it is discarded is automatic.
# TODO: add code to gamestate for reactToDiscard
makeCard 'Tunnel', c.Estate, {
  isReaction: true
  cost: 3
  vp: 2

  reactToDiscard: (state, player) ->
    if state.phase isnt 'cleanup'
      state.gainCard(player, c.Gold)
    
}

makeCard 'Vineyard', c.Estate, {
