Class: Cards
- Inherits:
-
Object
show all
- Includes:
- Enumerable, FromHash
- Defined in:
- lib/ascension/cards.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
Returns the value of attribute game.
5
6
7
|
# File 'lib/ascension/cards.rb', line 5
def game
@game
end
|
Returns the value of attribute side.
5
6
7
|
# File 'lib/ascension/cards.rb', line 5
def side
@side
end
|
Instance Method Details
8
9
10
|
# File 'lib/ascension/cards.rb', line 8
def <<(c)
cards << c
end
|
49
50
51
|
# File 'lib/ascension/cards.rb', line 49
def [](i)
cards[i]
end
|
#[]=(i, card) ⇒ Object
46
47
48
|
# File 'lib/ascension/cards.rb', line 46
def []=(i,card)
cards[i] = card
end
|
#banish(card) ⇒ Object
42
43
44
45
|
# File 'lib/ascension/cards.rb', line 42
def banish(card)
remove(card)
game.void << card
end
|
36
37
38
|
# File 'lib/ascension/cards.rb', line 36
def clear!
self.cards = []
end
|
15
16
17
|
# File 'lib/ascension/cards.rb', line 15
def each(&b)
cards.each(&b)
end
|
#empty? ⇒ Boolean
21
22
23
|
# File 'lib/ascension/cards.rb', line 21
def empty?
size == 0
end
|
27
28
29
|
# File 'lib/ascension/cards.rb', line 27
def first
cards.first
end
|
#get_one(name) ⇒ Object
55
56
57
58
59
60
|
# File 'lib/ascension/cards.rb', line 55
def get_one(name)
res = find { |x| x.name == name }
raise "couldn't find #{name}" unless res
self.cards -= [res]
res
end
|
61
62
63
|
# File 'lib/ascension/cards.rb', line 61
def hydrate!
self.cards = map { |x| x.hydrated }
end
|
#include?(c) ⇒ Boolean
39
40
41
|
# File 'lib/ascension/cards.rb', line 39
def include?(c)
cards.include?(c)
end
|
#index(obj) ⇒ Object
33
34
35
|
# File 'lib/ascension/cards.rb', line 33
def index(obj)
cards.index(obj)
end
|
30
31
32
|
# File 'lib/ascension/cards.rb', line 30
def pop
cards.pop
end
|
#remove(c) ⇒ Object
11
12
13
14
|
# File 'lib/ascension/cards.rb', line 11
def remove(c)
raise "#{c} not here" unless cards.include?(c)
self.cards -= [c]
end
|
18
19
20
|
# File 'lib/ascension/cards.rb', line 18
def shuffle!
self.cards = cards.sort_by { |x| rand() }
end
|
24
25
26
|
# File 'lib/ascension/cards.rb', line 24
def size
cards.size
end
|
#to_s_cards ⇒ Object
52
53
54
|
# File 'lib/ascension/cards.rb', line 52
def to_s_cards
map { |x| x.name }.join(" | ")
end
|