     drawn = state.current.dig(state,
       (state, card) -> card.isTreasure
     )
-    if drawn[0]?
+    if drawn.length > 0
       treasure = drawn[0]
       state.log("...playing #{treasure}.")
       state.current.inPlay.push(treasure)

    drawn = state.current.dig(state,
      (state, card) -> card.isTreasure
    )    
    if drawn[0]?
      treasure = drawn[0]
      trash = state.current.ai.choose('trash', state, [treasure, null])
      if trash?

  playEffect: (state) ->
    state.attackOpponents (opp) ->
      state.discardFromDeck(opp, 1)
      state.gainCard(opp, c.Curse, 'draw')
      state.log("...putting the Curse on top of the deck.")
}

makeCard 'Thief', attack, {
