patience 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/lib/patience/card.rb +2 -1
- data/lib/patience/event_handlers/click.rb +10 -2
- data/lib/patience/event_handlers/drag.rb +1 -1
- data/lib/patience/event_handlers/drop.rb +23 -19
- data/lib/patience/foundation.rb +4 -1
- data/lib/patience/pile.rb +13 -0
- data/lib/patience/rank.rb +3 -7
- data/lib/patience/scenes/game_scene.rb +2 -2
- data/lib/patience/sprites/card_deck.png +0 -0
- data/lib/patience/sprites/empty_stock.png +0 -0
- data/lib/patience/sprites/foundation_bg.png +0 -0
- data/lib/patience/sprites/fully_empty_stock.png +0 -0
- data/lib/patience/sprites/pile_background.png +0 -0
- data/lib/patience/sprites/table_bg.png +0 -0
- data/lib/patience/stock.rb +1 -1
- data/lib/patience/suit.rb +2 -2
- data/lib/patience/tableau.rb +5 -3
- data/lib/patience/version.rb +1 -1
- data/lib/patience/waste.rb +2 -1
- data/test/patience/event_handlers/test_click.rb +6 -6
- data/test/patience/event_handlers/test_drop.rb +7 -8
- data/test/patience/test_foundation.rb +4 -4
- data/test/patience/test_processable.rb +6 -11
- data/test/patience/test_rank.rb +8 -0
- data/test/patience/test_stock.rb +2 -2
- data/test/patience/test_tableau.rb +10 -10
- data/test/patience/test_version.rb +1 -1
- data/test/patience/test_waste.rb +2 -2
- metadata +7 -4
data/CHANGELOG.md
CHANGED
data/lib/patience/card.rb
CHANGED
@@ -98,7 +98,8 @@ module Patience
|
|
98
98
|
sprite.collide?(other_card.sprite) and self.not.eql?(other_card)
|
99
99
|
end
|
100
100
|
|
101
|
-
def_delegators :@sprite, :pos, :pos=, :x, :y, :to_rect
|
101
|
+
def_delegators :@sprite, :pos, :pos=, :x, :y, :to_rect,
|
102
|
+
:sprite_width, :sprite_height
|
102
103
|
def_delegator :"@sprite.to_rect", :contain?, :hit?
|
103
104
|
|
104
105
|
class DefunctRank < StandardError; end
|
@@ -65,7 +65,9 @@ module Patience
|
|
65
65
|
# Adds a card from Stock to Waste, if Stock was clicked.
|
66
66
|
def stock
|
67
67
|
if stock?
|
68
|
+
|
68
69
|
if pile.empty?
|
70
|
+
return if @areas[:waste].cards.size == 1
|
69
71
|
pile_background = 'patience/sprites/pile_background.png'
|
70
72
|
pile.background = Ray::Sprite.new path_of(pile_background)
|
71
73
|
refill_stock
|
@@ -74,9 +76,15 @@ module Patience
|
|
74
76
|
end
|
75
77
|
|
76
78
|
if pile.empty?
|
77
|
-
|
78
|
-
|
79
|
+
if @areas[:waste].cards.size == 1
|
80
|
+
fully_empty_stock = 'patience/sprites/fully_empty_stock.png'
|
81
|
+
pile.background = Ray::Sprite.new path_of(fully_empty_stock)
|
82
|
+
else
|
83
|
+
empty_stock = 'patience/sprites/empty_stock.png'
|
84
|
+
pile.background = Ray::Sprite.new path_of(empty_stock)
|
85
|
+
end
|
79
86
|
end
|
87
|
+
|
80
88
|
end
|
81
89
|
end
|
82
90
|
|
@@ -21,7 +21,7 @@ module Patience
|
|
21
21
|
# Changes position of the card's sprite, considering the offset.
|
22
22
|
def move(mouse_pos)
|
23
23
|
@tail_cards.keys.each_with_index do |card, i|
|
24
|
-
card.pos = mouse_pos + @offset + [0, i*
|
24
|
+
card.pos = mouse_pos + @offset + [0, i*19]
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -17,14 +17,14 @@ module Patience
|
|
17
17
|
attr_reader :scenario
|
18
18
|
|
19
19
|
def initialize(click, areas)
|
20
|
-
@cards
|
21
|
-
@areas
|
22
|
-
@pile
|
20
|
+
@cards = click.cards
|
21
|
+
@areas = areas
|
22
|
+
@pile = click.pile
|
23
23
|
@card_to_drop = click.card
|
24
24
|
|
25
25
|
@card_beneath = find_card_beneath
|
26
26
|
@pile_beneath = find_pile_beneath
|
27
|
-
@area
|
27
|
+
@area = find_area_beneath
|
28
28
|
|
29
29
|
@scenario = -> {
|
30
30
|
if tableau?
|
@@ -51,21 +51,25 @@ module Patience
|
|
51
51
|
detect_in(@areas, :pile) do |pile|
|
52
52
|
# If dropped card is a king or an ace, don't
|
53
53
|
# check, whether a pile includes card beneath.
|
54
|
-
pile != @pile
|
55
|
-
(king_or_ace
|
54
|
+
pile != @pile && pile.overlaps?(@card_to_drop) &&
|
55
|
+
(if king_or_ace
|
56
|
+
pile.empty? || (@card_beneath && @card_beneath.rank.queen?)
|
57
|
+
else
|
58
|
+
pile.cards.include?(@card_beneath)
|
59
|
+
end)
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
63
|
# Finds a card beneath the dropped card.
|
60
64
|
def find_card_beneath
|
61
|
-
all_tail_cards = @areas.values.
|
65
|
+
all_tail_cards = @areas.values.flat_map do |area|
|
62
66
|
area.piles.map { |pile| pile.cards.last }
|
63
|
-
end.
|
67
|
+
end.compact
|
64
68
|
|
65
69
|
# Iterate only over tail cards.
|
66
70
|
all_tail_cards.find do |card|
|
67
71
|
area = detect_in(@areas, :area) { |area| area.cards.include?(card)}
|
68
|
-
card.face_up?
|
72
|
+
card.face_up? && card.overlaps?(@card_to_drop) &&
|
69
73
|
(case area
|
70
74
|
when Tableau then tableau_conditions?(card)
|
71
75
|
when Foundation then foundation_conditions?(card)
|
@@ -76,15 +80,15 @@ module Patience
|
|
76
80
|
# Returns true, if card's rank is higher by 1 than the rank of
|
77
81
|
# the card which is dropped and the card's suit has different color.
|
78
82
|
def tableau_conditions?(card)
|
79
|
-
card.rank.higher_by_one_than?(@card_to_drop.rank)
|
83
|
+
card.rank.higher_by_one_than?(@card_to_drop.rank) &&
|
80
84
|
card.suit.different_color?(@card_to_drop.suit)
|
81
85
|
end
|
82
86
|
|
83
87
|
# Returns true, if card's rank is lower by 1 than the rank of the
|
84
88
|
# card, which is dropped and the card's suit must be the same color.
|
85
89
|
def foundation_conditions?(card)
|
86
|
-
@card_to_drop.rank.higher_by_one_than?(card.rank)
|
87
|
-
card.suit
|
90
|
+
@card_to_drop.rank.higher_by_one_than?(card.rank) &&
|
91
|
+
card.suit == @card_to_drop.suit
|
88
92
|
end
|
89
93
|
|
90
94
|
# Removes card from its pile and adds to the pile beneath.
|
@@ -100,17 +104,17 @@ module Patience
|
|
100
104
|
# Returns true, if dropped card meets
|
101
105
|
# requirements for dropping into Tableau.
|
102
106
|
def can_put_in_tableau?
|
103
|
-
(@pile_beneath.empty?
|
104
|
-
(@card_beneath
|
105
|
-
@pile_beneath.last_card?(@card_beneath)
|
107
|
+
(@pile_beneath.empty? && @card_to_drop.rank.king?) ||
|
108
|
+
(@card_beneath && @card_to_drop.rank.not.ace? &&
|
109
|
+
@pile_beneath.last_card?(@card_beneath) &&
|
106
110
|
tableau_conditions?(@card_beneath))
|
107
111
|
end
|
108
112
|
|
109
113
|
# Returns true, if dropped card meets
|
110
114
|
# requirements for dropping into Foundation.
|
111
115
|
def can_put_in_foundation?
|
112
|
-
(@pile_beneath.empty?
|
113
|
-
(@card_beneath
|
116
|
+
(@pile_beneath.empty? && @card_to_drop.rank.ace?) ||
|
117
|
+
(@card_beneath && foundation_conditions?(@card_beneath))
|
114
118
|
end
|
115
119
|
|
116
120
|
# Adds dropped card to one of Tableau's piles, if it's
|
@@ -120,9 +124,9 @@ module Patience
|
|
120
124
|
@cards.keys.each_with_index do |card, i|
|
121
125
|
add_to_pile_beneath(card)
|
122
126
|
if @pile_beneath.size == 1 # It was empty one line before.
|
123
|
-
card.pos = @pile_beneath.pos + [0, i*
|
127
|
+
card.pos = @pile_beneath.pos + [0, i*19]
|
124
128
|
else
|
125
|
-
card.pos = @pile_beneath.cards[-2].pos + [0,
|
129
|
+
card.pos = @pile_beneath.cards[-2].pos + [0, 19]
|
126
130
|
end
|
127
131
|
@pile.cards.last.face_up unless @pile.empty?
|
128
132
|
end
|
data/lib/patience/foundation.rb
CHANGED
@@ -11,7 +11,7 @@ module Patience
|
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
super([], 4)
|
14
|
-
self.pos = [
|
14
|
+
self.pos = [356, 23]
|
15
15
|
end
|
16
16
|
|
17
17
|
protected
|
@@ -20,8 +20,11 @@ module Patience
|
|
20
20
|
# of every pile in this area, starting from the pos argument.
|
21
21
|
def pos=(pos)
|
22
22
|
x, y, step_x = pos[0], pos[1], 110
|
23
|
+
foundation_bg = path_of('patience/sprites/foundation_bg.png')
|
24
|
+
|
23
25
|
piles.each do |pile|
|
24
26
|
pile.pos = [x, y]
|
27
|
+
pile.background = Ray::Sprite.new foundation_bg
|
25
28
|
x += step_x # Margin between piles along the axis X.
|
26
29
|
end
|
27
30
|
end
|
data/lib/patience/pile.rb
CHANGED
@@ -30,7 +30,20 @@ module Patience
|
|
30
30
|
|
31
31
|
# Appends card to the pile considering position of that pile.
|
32
32
|
def <<(other_card)
|
33
|
+
bg_w = self.background.sub_rect.w
|
34
|
+
bg_h = self.background.sub_rect.h
|
35
|
+
sprite_w = other_card.sprite_width
|
36
|
+
sprite_h = other_card.sprite_height
|
37
|
+
|
33
38
|
other_card.pos = self.pos
|
39
|
+
|
40
|
+
if bg_w > sprite_w && bg_h > sprite_h
|
41
|
+
w = bg_w - sprite_w
|
42
|
+
h = bg_h - sprite_h
|
43
|
+
|
44
|
+
other_card.pos += [w/2, h/2]
|
45
|
+
end
|
46
|
+
|
34
47
|
cards << other_card
|
35
48
|
end
|
36
49
|
|
data/lib/patience/rank.rb
CHANGED
@@ -39,13 +39,9 @@ module Patience
|
|
39
39
|
@num <=> other_rank.to_i
|
40
40
|
end
|
41
41
|
|
42
|
-
def ace
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
def king?
|
47
|
-
@num == 13
|
48
|
-
end
|
42
|
+
def ace?; @num == 1; end
|
43
|
+
def king?; @num == 13; end
|
44
|
+
def queen?; @num == 12; end
|
49
45
|
|
50
46
|
def higher_by_one_than?(other_rank)
|
51
47
|
@num - other_rank.to_i == 1
|
@@ -4,7 +4,7 @@ module Patience
|
|
4
4
|
class GameScene < Ray::Scene
|
5
5
|
|
6
6
|
def setup
|
7
|
-
@
|
7
|
+
@bg_sprite = Ray::Sprite.new path_of('patience/sprites/table_bg.png')
|
8
8
|
@cursor = Cursor.new
|
9
9
|
@deck = Deck.new
|
10
10
|
@deck.cards.shuffle!
|
@@ -54,7 +54,7 @@ module Patience
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def render(win)
|
57
|
-
win.
|
57
|
+
win.draw @bg_sprite
|
58
58
|
@areas.values.to_a.each { |area| area.draw_on(win) }
|
59
59
|
# Draw the card, which is being dragged.
|
60
60
|
if @cursor.drawable?
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/patience/stock.rb
CHANGED
data/lib/patience/suit.rb
CHANGED
@@ -59,13 +59,13 @@ module Patience
|
|
59
59
|
# Returns true, if the color of suit is
|
60
60
|
# the same as the color of other suit.
|
61
61
|
def same_color?(other_suit)
|
62
|
-
(black?
|
62
|
+
(black? && other_suit.black?) || (red? && other_suit.red?)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Returns true if the color of suit
|
66
66
|
# of differs from other suit's color.
|
67
67
|
def different_color?(other_suit)
|
68
|
-
(black?
|
68
|
+
(black? && other_suit.red?) || (red? && other_suit.black?)
|
69
69
|
end
|
70
70
|
|
71
71
|
end
|
data/lib/patience/tableau.rb
CHANGED
@@ -17,7 +17,7 @@ module Patience
|
|
17
17
|
def initialize(cards)
|
18
18
|
super(cards, 7)
|
19
19
|
@piles.each_with_index { |pile, i| pile.cards += @cards.shuffle_off!(i+1) }
|
20
|
-
self.pos = [31,
|
20
|
+
self.pos = [31, 175]
|
21
21
|
end
|
22
22
|
|
23
23
|
protected
|
@@ -25,14 +25,16 @@ module Patience
|
|
25
25
|
# Disposes Tableau in the window by specifying coordinates
|
26
26
|
# of every pile in this area, starting from the pos argument.
|
27
27
|
def pos=(pos)
|
28
|
-
x, y, step_x, step_y = pos[0], pos[1], 110,
|
28
|
+
x, y, step_x, step_y = pos[0], pos[1], 110, 10
|
29
|
+
|
29
30
|
piles.each { |pile|
|
30
31
|
pile.pos = [x, y]
|
31
32
|
x += step_x # Margin between piles along the axis X.
|
32
33
|
y2 = 0 # Y position of the first card.
|
34
|
+
|
33
35
|
pile.cards.each_with_index do |card, i|
|
34
36
|
card.sprite.y += y2
|
35
|
-
y2 += step_y #
|
37
|
+
y2 += step_y # Y axis margin.
|
36
38
|
card.face_down unless pile.last_card?(card)
|
37
39
|
end
|
38
40
|
}
|
data/lib/patience/version.rb
CHANGED
data/lib/patience/waste.rb
CHANGED
@@ -14,14 +14,14 @@ module Patience
|
|
14
14
|
|
15
15
|
def setup
|
16
16
|
@mouse_pos_missclick = Ray::Vector2[0, 0]
|
17
|
-
@mouse_pos_hit = Ray::Vector2[32,
|
17
|
+
@mouse_pos_hit = Ray::Vector2[32, 175]
|
18
18
|
@deck = Deck.new
|
19
19
|
@areas = { :tableau => Tableau.new(@deck.shuffle_off! 28),
|
20
20
|
:waste => Waste.new,
|
21
21
|
:stock => Stock.new(@deck.shuffle_off! 10) }
|
22
22
|
@dummy_click_miss = Dummy.new(@mouse_pos_missclick, @areas)
|
23
23
|
@dummy_click_hit = Dummy.new(@mouse_pos_hit, @areas)
|
24
|
-
@stock_hit = Dummy.new(Ray::Vector2[32,
|
24
|
+
@stock_hit = Dummy.new(Ray::Vector2[32, 28], @areas)
|
25
25
|
end
|
26
26
|
|
27
27
|
def fill_attributes_up(click)
|
@@ -55,21 +55,21 @@ module Patience
|
|
55
55
|
|
56
56
|
test 'A card can be selected by click' do
|
57
57
|
# Hit
|
58
|
-
tableau_click = Dummy.new(Ray::Vector2[472,
|
58
|
+
tableau_click = Dummy.new(Ray::Vector2[472, 176], @areas)
|
59
59
|
assert_nil tableau_click.card
|
60
60
|
assert_nil tableau_click.cards
|
61
61
|
tableau_click.pile = @areas[:tableau].piles[4]
|
62
62
|
|
63
63
|
[Card.new(3, 1), Card.new(2, 4)].each do |card|
|
64
64
|
@areas[:tableau].piles[4] << card
|
65
|
-
card.pos = @areas[:tableau].piles[4].cards[-2].pos + [0,
|
65
|
+
card.pos = @areas[:tableau].piles[4].cards[-2].pos + [0, 19]
|
66
66
|
end
|
67
67
|
|
68
68
|
tableau_click.cards = tableau_click.send(:collect_cards).map(&:first)
|
69
69
|
assert tableau_click.cards
|
70
|
-
assert_instance_of Card::Rank::
|
70
|
+
assert_instance_of Card::Rank::Three, tableau_click.cards[0].rank
|
71
71
|
assert_instance_of Card::Rank::Three, tableau_click.cards[1].rank
|
72
|
-
assert_instance_of Card::Rank::
|
72
|
+
assert_instance_of Card::Rank::Four, tableau_click.cards[2].rank
|
73
73
|
|
74
74
|
# Miss
|
75
75
|
assert_nil @dummy_click_miss.card
|
@@ -15,7 +15,6 @@ module Patience
|
|
15
15
|
@mouse_pos = Ray::Vector2[361, 243]
|
16
16
|
@deck = Deck.new
|
17
17
|
@areas = { :tableau => Tableau.new(@deck.shuffle_off! 28),
|
18
|
-
:waste => Waste.new,
|
19
18
|
:foundation => Foundation.new }
|
20
19
|
@click = EventHandler::Click.new(@mouse_pos, @areas)
|
21
20
|
@drop = Dummy.new(@click, @areas)
|
@@ -90,13 +89,13 @@ module Patience
|
|
90
89
|
end
|
91
90
|
|
92
91
|
test 'A dropped card can be called off' do
|
93
|
-
assert_equal Ray::Vector2[361,
|
92
|
+
assert_equal Ray::Vector2[361, 205], @drop.card_to_drop.pos
|
94
93
|
|
95
94
|
@drop.card_to_drop.pos = Ray::Vector2[0, 0]
|
96
95
|
assert_equal Ray::Vector2[0, 0], @drop.card_to_drop.pos
|
97
96
|
|
98
97
|
@drop.send(:call_off)
|
99
|
-
assert_equal Ray::Vector2[361,
|
98
|
+
assert_equal Ray::Vector2[361, 205], @drop.card_to_drop.pos
|
100
99
|
end
|
101
100
|
|
102
101
|
test 'A dropped card can be added to the pile beneath' do
|
@@ -153,22 +152,22 @@ module Patience
|
|
153
152
|
end
|
154
153
|
|
155
154
|
test 'A dropped card can be put in Foundation' do
|
156
|
-
@click = EventHandler::Click.new(Ray::Vector2[32,
|
155
|
+
@click = EventHandler::Click.new(Ray::Vector2[32, 176], @areas)
|
157
156
|
@drop = Dummy.new(@click, @areas)
|
158
|
-
@drop.card_to_drop.pos = Ray::Vector2[
|
157
|
+
@drop.card_to_drop.pos = Ray::Vector2[467, 24]
|
159
158
|
fill_attributes_up(@drop)
|
160
159
|
@drop.send(:put_in_foundation)
|
161
|
-
assert_equal 1, @areas[:foundation].piles[
|
160
|
+
assert_equal 1, @areas[:foundation].piles[1].size
|
162
161
|
|
163
162
|
last_card = @areas[:tableau].piles[2].cards.last
|
164
163
|
@areas[:tableau].piles[2].cards.delete(last_card)
|
165
164
|
@areas[:tableau].piles[2].cards.last.flip!
|
166
165
|
@click = EventHandler::Click.new(Ray::Vector2[252, 192], @areas)
|
167
166
|
@drop = Dummy.new(@click, @areas)
|
168
|
-
@drop.card_to_drop.pos = Ray::Vector2[
|
167
|
+
@drop.card_to_drop.pos = Ray::Vector2[467, 24]
|
169
168
|
fill_attributes_up(@drop)
|
170
169
|
@drop.send(:put_in_foundation)
|
171
|
-
assert_equal 2, @areas[:foundation].piles[
|
170
|
+
assert_equal 2, @areas[:foundation].piles[1].size
|
172
171
|
end
|
173
172
|
|
174
173
|
end
|
@@ -16,13 +16,13 @@ module Patience
|
|
16
16
|
end
|
17
17
|
|
18
18
|
test 'Overall position of foundation can be gotten' do
|
19
|
-
assert_equal Ray::Vector2[
|
20
|
-
assert_equal Ray::Vector2[
|
19
|
+
assert_equal Ray::Vector2[356, 23], @foundation.pos
|
20
|
+
assert_equal Ray::Vector2[356, 23], @foundation.piles.first.pos
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'Particular position of a pile in foundation can be gotten' do
|
24
|
-
assert_equal Ray::Vector2[
|
25
|
-
assert_equal Ray::Vector2[
|
24
|
+
assert_equal Ray::Vector2[466, 23], @foundation.piles[1].pos
|
25
|
+
assert_equal Ray::Vector2[576, 23], @foundation.piles[2].pos
|
26
26
|
end
|
27
27
|
|
28
28
|
test 'Foundation can be disposed in the window' do
|
@@ -17,7 +17,7 @@ module Patience
|
|
17
17
|
def setup
|
18
18
|
@dummy = Dummy.new
|
19
19
|
@mouse_pos_miss = Ray::Vector2[0, 0]
|
20
|
-
@mouse_pos_hit = Ray::Vector2[
|
20
|
+
@mouse_pos_hit = Ray::Vector2[45, 176]
|
21
21
|
@deck = Deck.new
|
22
22
|
@areas = { :tableau => Tableau.new(@deck.shuffle_off! 28),
|
23
23
|
:stock => Stock.new(@deck.shuffle_off! 24),
|
@@ -63,7 +63,7 @@ module Patience
|
|
63
63
|
assert_equal Tableau, @dummy.find_area_in(@areas) { |area|
|
64
64
|
area.hit?(@mouse_pos_hit)
|
65
65
|
}.class
|
66
|
-
mouse_pos_hit_stock = Ray::Vector2[
|
66
|
+
mouse_pos_hit_stock = Ray::Vector2[32, 65]
|
67
67
|
assert_equal Stock, @dummy.find_area_in(@areas) { |area|
|
68
68
|
area.hit?(mouse_pos_hit_stock)
|
69
69
|
}.class
|
@@ -83,7 +83,7 @@ module Patience
|
|
83
83
|
end
|
84
84
|
|
85
85
|
test 'Processable can find a card' do
|
86
|
-
mouse_pos_hit_stock = Ray::Vector2[
|
86
|
+
mouse_pos_hit_stock = Ray::Vector2[32, 65]
|
87
87
|
assert_equal Card, @dummy.find_card_in(@areas) { |card|
|
88
88
|
card.hit?(@mouse_pos_hit)
|
89
89
|
}.class
|
@@ -131,7 +131,7 @@ module Patience
|
|
131
131
|
|
132
132
|
test 'Processable can count an offset' do
|
133
133
|
@dummy.find_all(@areas, @mouse_pos_hit)
|
134
|
-
assert_equal Ray::Vector2[-
|
134
|
+
assert_equal Ray::Vector2[-14, -1],
|
135
135
|
@dummy.pick_up(@areas[:tableau].cards[0], @mouse_pos_hit)
|
136
136
|
end
|
137
137
|
|
@@ -140,18 +140,13 @@ module Patience
|
|
140
140
|
assert @dummy.stock?
|
141
141
|
end
|
142
142
|
|
143
|
-
test 'Processable can check, if Waste has been hit' do
|
144
|
-
@dummy.find_all(@areas, Ray::Vector2[160, 40])
|
145
|
-
assert @dummy.waste?
|
146
|
-
end
|
147
|
-
|
148
143
|
test 'Processable can check, if Tableau has been hit' do
|
149
|
-
@dummy.find_all(@areas, Ray::Vector2[32,
|
144
|
+
@dummy.find_all(@areas, Ray::Vector2[32, 176])
|
150
145
|
assert @dummy.tableau?
|
151
146
|
end
|
152
147
|
|
153
148
|
test 'Processable can check, if Foundation has been hit' do
|
154
|
-
@dummy.find_all(@areas, Ray::Vector2[
|
149
|
+
@dummy.find_all(@areas, Ray::Vector2[577, 24])
|
155
150
|
assert @dummy.foundation?
|
156
151
|
end
|
157
152
|
|
data/test/patience/test_rank.rb
CHANGED
@@ -84,5 +84,13 @@ module Patience
|
|
84
84
|
refute ace_rank.king?
|
85
85
|
end
|
86
86
|
|
87
|
+
test "A rank can be checked, if it's a queen" do
|
88
|
+
ace_rank = Patience::Card::Rank::Ace.new
|
89
|
+
queen_rank = Patience::Card::Rank::Queen.new
|
90
|
+
|
91
|
+
assert queen_rank.queen?
|
92
|
+
refute ace_rank.queen?
|
93
|
+
end
|
94
|
+
|
87
95
|
end
|
88
96
|
end
|
data/test/patience/test_stock.rb
CHANGED
@@ -28,8 +28,8 @@ module Patience
|
|
28
28
|
end
|
29
29
|
|
30
30
|
test 'The overall position of Stock can be gotten' do
|
31
|
-
assert_equal Ray::Vector2[31,
|
32
|
-
assert_equal Ray::Vector2[31,
|
31
|
+
assert_equal Ray::Vector2[31, 27], @stock.pos
|
32
|
+
assert_equal Ray::Vector2[31, 27], @stock.piles.first.pos
|
33
33
|
end
|
34
34
|
|
35
35
|
test 'Stock can be disposed in the window' do
|
@@ -26,14 +26,14 @@ module Patience
|
|
26
26
|
end
|
27
27
|
|
28
28
|
test 'The overall position of Tableau can be gotten' do
|
29
|
-
assert_equal Ray::Vector2[31,
|
30
|
-
assert_equal Ray::Vector2[31,
|
29
|
+
assert_equal Ray::Vector2[31, 175], @tableau.pos
|
30
|
+
assert_equal Ray::Vector2[31, 175], @tableau.piles.first.pos
|
31
31
|
end
|
32
32
|
|
33
33
|
test 'Particular position of a pile in Tableau can be gotten' do
|
34
|
-
assert_equal Ray::Vector2[141,
|
35
|
-
assert_equal Ray::Vector2[251,
|
36
|
-
assert_equal Ray::Vector2[691,
|
34
|
+
assert_equal Ray::Vector2[141, 175], @tableau.piles[1].pos
|
35
|
+
assert_equal Ray::Vector2[251, 175], @tableau.piles[2].pos
|
36
|
+
assert_equal Ray::Vector2[691, 175], @tableau.piles.last.pos
|
37
37
|
end
|
38
38
|
|
39
39
|
test 'Tableau can be disposed in the window' do
|
@@ -46,11 +46,11 @@ module Patience
|
|
46
46
|
end
|
47
47
|
|
48
48
|
test 'Cards in Tableau have a margin along the Y axis' do
|
49
|
-
assert_equal Ray::Vector2[31,
|
50
|
-
assert_equal Ray::Vector2[251,
|
51
|
-
assert_equal Ray::Vector2[471,
|
52
|
-
assert_equal Ray::Vector2[581,
|
53
|
-
assert_equal Ray::Vector2[691,
|
49
|
+
assert_equal Ray::Vector2[31, 175], @tableau.piles[0].cards[0].pos
|
50
|
+
assert_equal Ray::Vector2[251, 185], @tableau.piles[2].cards[1].pos
|
51
|
+
assert_equal Ray::Vector2[471, 185], @tableau.piles[4].cards[1].pos
|
52
|
+
assert_equal Ray::Vector2[581, 195], @tableau.piles[5].cards[2].pos
|
53
|
+
assert_equal Ray::Vector2[691, 235], @tableau.piles.last.cards.last.pos
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
data/test/patience/test_waste.rb
CHANGED
@@ -20,8 +20,8 @@ module Patience
|
|
20
20
|
end
|
21
21
|
|
22
22
|
test 'Overall position of Waste can be gotten' do
|
23
|
-
assert_equal Ray::Vector2[141,
|
24
|
-
assert_equal Ray::Vector2[141,
|
23
|
+
assert_equal Ray::Vector2[141, 27], @waste.pos
|
24
|
+
assert_equal Ray::Vector2[141, 27], @waste.piles.first.pos
|
25
25
|
end
|
26
26
|
|
27
27
|
test 'Waste can be disposed in the window' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patience
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ray
|
16
|
-
requirement: &
|
16
|
+
requirement: &85106680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *85106680
|
25
25
|
description: Klondike solitaire game which is built with help of Ray game library.
|
26
26
|
email: kyrylosilin@gmail.com
|
27
27
|
executables:
|
@@ -36,8 +36,11 @@ files:
|
|
36
36
|
- lib/patience/event_handlers/drop.rb
|
37
37
|
- lib/patience/event_handlers/click.rb
|
38
38
|
- lib/patience/event_handlers/drag.rb
|
39
|
+
- lib/patience/sprites/table_bg.png
|
39
40
|
- lib/patience/sprites/empty_stock.png
|
41
|
+
- lib/patience/sprites/fully_empty_stock.png
|
40
42
|
- lib/patience/sprites/card_deck.png
|
43
|
+
- lib/patience/sprites/foundation_bg.png
|
41
44
|
- lib/patience/sprites/pile_background.png
|
42
45
|
- lib/patience/card.rb
|
43
46
|
- lib/patience/suit.rb
|