Class: ExplodingDeck

Inherits:
Deck show all
Defined in:
lib/crystel.rb

Instance Attribute Summary

Attributes inherited from Deck

#groups, #position

Instance Method Summary collapse

Methods inherited from Deck

#card_at, #combine, #deal_in, #group_no, #index_of, #shuffle, #swap, #top

Constructor Details

#initializeExplodingDeck

Returns a new instance of ExplodingDeck.



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/crystel.rb', line 247

def initialize
  @position = []
  @groups = []
  ['exp', 'fvr', 'shf', 'atk', 'skp', 'tac', 'mlc', 'bdc', 'rrc', 'hpc'].each do |card|
    for x in 0...4
      @position.push(card)
    end
  end
  ['nop', 'fut'].each do |card|
    for x in 0...5
      @position.push(card)
    end
  end
  for x in 0...6
    @position.push('def')
  end
  shuffle
end

Instance Method Details

#deal(hands) ⇒ Object



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/crystel.rb', line 265

def deal(hands)
  deal_in
  @groups = []
  @position.delete('def')
  @position.delete('exp')
  for x in 0...hands
    @groups.push([])
    @groups[x].push('def')
    for y in 0...7
      @groups[x].push(@position.shift)
    end
  end
  for x in 0...(6-hands)
   @position.insert(rand(@position.size), 'def')
  end
  for x in 0...(hands-1)
  @position.insert(rand(@position.size), 'exp')
  end
  self
end