Skip to content

Commit

Permalink
Move Tactician active/inactive state into its card definition
Browse files Browse the repository at this point in the history
  • Loading branch information
bilts committed Jan 16, 2012
1 parent 64baaee commit a40c279
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 6 additions & 3 deletions cards.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,15 @@ makeCard 'Tactician', duration, {
durationCards: +5

playEffect: (state) ->
# If this is the first time we've played Tactician this turn, reset our count
@activeTacticians = 0 if state.current.countInPlay('Tactician') == 1

cardsInHand = state.current.hand.length
# If any cards can be discarded...
if cardsInHand > 0
# Discard the hand and activate the tactician.
state.log("...discarding the whole hand.")
state.current.tacticians++
@activeTacticians++
discards = state.current.hand
state.current.discard = state.current.discard.concat(discards)
state.current.hand = []
Expand All @@ -704,8 +707,8 @@ makeCard 'Tactician', duration, {
# The cleanupEffect of a dead Tactician is to discard it instead of putting it in the
# duration area. It's not a duration card in this case.
cleanupEffect: (state) ->
if state.current.tacticians > 0
state.current.tacticians--
if @activeTacticians > 0
@activeTacticians--
else
state.log("#{state.current.ai} discards an inactive Tactician.")
transferCard(c.Tactician, state.current.duration, state.current.discard)
Expand Down
3 changes: 0 additions & 3 deletions gameState.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class PlayerState
@duration = []
@setAside = []
@gainedThisTurn = []
@tacticians = 0 # number of Tacticians that will go to the duration area
@mayReturnTreasury = yes
@turnsTaken = 0

Expand Down Expand Up @@ -401,7 +400,6 @@ class PlayerState
other.gainLocation = @gainLocation
other.actionStack = @actionStack.slice(0)
other.actionsPlayed = @actionsPlayed
other.tacticians = @tacticians
other.ai = @ai
other.logFunc = @logFunc
other.turnsTaken = @turnsTaken
Expand Down Expand Up @@ -908,7 +906,6 @@ class State
@current.buys = 1
@current.coins = 0
@current.potions = 0
@current.tacticians = 0
@current.actionsPlayed = 0
@current.mayReturnTreasury = yes
@copperValue = 1
Expand Down

0 comments on commit a40c279

Please sign in to comment.