Class: Side

Inherits:
Object show all
Includes:
FromHash
Defined in:
lib/ascension.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gameObject

Returns the value of attribute game.



131
132
133
# File 'lib/ascension.rb', line 131

def game
  @game
end

Instance Method Details

#acquire_free(card) ⇒ Object



151
152
153
154
155
# File 'lib/ascension.rb', line 151

def acquire_free(card)
  discard << card
  game.center_wc.remove(card)
  fire_event Event::CardPurchased.new(:card => card)
end

#defeat(monster) ⇒ Object



161
162
163
164
165
166
167
168
169
# File 'lib/ascension.rb', line 161

def defeat(monster)
  game.void << monster
  game.center.remove(monster) unless monster.name =~ /cultist/i && !game.center.include?(monster)
  
  fire_event Event::MonsterKilled.new(:card => monster, :center => true)
  
  monster.apply_abilities(self)
  played.pool.power -= monster.power_cost
end

#draw_hand!Object



141
142
143
# File 'lib/ascension.rb', line 141

def draw_hand!
  5.times { draw_one! }
end

#draw_one!Object



144
145
146
# File 'lib/ascension.rb', line 144

def draw_one!
  hand << deck.draw_one
end

#end_turn!Object



180
181
182
183
184
185
186
# File 'lib/ascension.rb', line 180

def end_turn!
  played.discard!
  hand.discard!
  constructs.apply!
  draw_hand!
  
end

#engage(card) ⇒ Object



170
171
172
173
174
175
176
# File 'lib/ascension.rb', line 170

def engage(card)
  if card.monster?
    defeat(card)
  else
    purchase(card)
  end
end

#engageable_cardsObject



177
178
179
# File 'lib/ascension.rb', line 177

def engageable_cards
  game.center_wc.engageable_cards(self) 
end

#fire_event(event) ⇒ Object



192
193
194
# File 'lib/ascension.rb', line 192

def fire_event(event)
  events << event
end

#other_sideObject



195
196
197
# File 'lib/ascension.rb', line 195

def other_side
  game.sides.reject { |x| x == self }.first
end

#play(card) ⇒ Object



147
148
149
150
# File 'lib/ascension.rb', line 147

def play(card)
  played << card
  hand.remove(card)
end


198
199
200
201
202
203
204
# File 'lib/ascension.rb', line 198

def print_status!
  puts "Center " + game.center.to_s_cards
  puts "Hand " + hand.to_s_cards
  puts "Played " + played.to_s_cards
  puts "Constructs " + constructs.to_s_cards unless constructs.empty?
  puts "Pool " + played.pool.to_s
end

#purchase(card) ⇒ Object



156
157
158
159
160
# File 'lib/ascension.rb', line 156

def purchase(card)
  acquire_free(card)
  #card.apply_abilities(self)
  played.pool.runes -= card.rune_cost
end

#total_cardsObject



187
188
189
# File 'lib/ascension.rb', line 187

def total_cards
  [hand,played,deck,discard].map { |x| x.size }.sum
end