ascension 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ conditions, events
2
+
@@ -0,0 +1,87 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "card" do
4
+ describe "ascetic" do
5
+ let(:unsaved_ascetic) do
6
+ Parse.get("Ascetic of the Lidless Eye")
7
+ end
8
+ let(:unsaved_game) do
9
+ res = Game.new
10
+ res.sides << Side.new
11
+ res.center.fill!
12
+ res
13
+ end
14
+ let(:unsaved_side) do
15
+ res = unsaved_game.sides.first
16
+ res.draw_hand!
17
+ res.hand << unsaved_ascetic
18
+ res
19
+ end
20
+
21
+ describe "basic" do
22
+ let(:game) { unsaved_game }
23
+ let(:side) { unsaved_side }
24
+ let(:ascetic) { unsaved_ascetic }
25
+
26
+ it 'smoke' do
27
+ side.hand.size.should == 6
28
+ end
29
+
30
+ it 'playing ascetic' do
31
+ side.play ascetic
32
+ side.played.size.should == 1
33
+ side.hand.size.should == 7
34
+ end
35
+ end
36
+
37
+ if true
38
+ describe "after save" do
39
+ let(:game) do
40
+ unsaved_game
41
+ unsaved_side
42
+ unsaved_game.mongo.save!
43
+ unsaved_game.mongo.get_fresh
44
+ end
45
+
46
+ let(:side) do
47
+ game.sides.first
48
+ end
49
+
50
+ let(:ascetic) do
51
+ side.hand.find { |x| x.name == "Ascetic of the Lidless Eye" }
52
+ end
53
+
54
+ it 'hydrate smoke' do
55
+ side.hand.size.should == 6
56
+ end
57
+
58
+ it 'hydrate' do
59
+ side.play ascetic
60
+ side.played.size.should == 1
61
+ side.hand.size.should == 7
62
+ end
63
+ end
64
+ end
65
+
66
+ describe "hydrated card" do
67
+ let(:raw_ascetic) do
68
+ Card::Hero.new(:name => "Ascetic of the Lidless Eye")
69
+ end
70
+ let(:hydrated_ascetic) do
71
+ raw_ascetic.hydrated
72
+ end
73
+
74
+ it 'has abilities' do
75
+ hydrated_ascetic.abilities.size.should == 1
76
+ end
77
+
78
+ it 'has same card id' do
79
+ hydrated_ascetic.card_id.should == raw_ascetic.card_id
80
+ end
81
+
82
+ it 'foo' do
83
+ #raise Parse.get("Shade ot Black Watch").abilities.inspect
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "center" do
4
+ let(:game) do
5
+ res = Game.new
6
+ res.deck = CenterDeck.starting
7
+ res.center.fill!
8
+ res
9
+ end
10
+ let(:center) do
11
+ game.center
12
+ end
13
+
14
+ it "has 6 cards" do
15
+ center.size.should == 6
16
+ end
17
+
18
+ it 'should replace cards in same spot' do
19
+ rest = center[1..-1]
20
+ center.remove center[0]
21
+ center[1..-1].should == rest
22
+ center[0].should be
23
+ center.size.should == 6
24
+ end
25
+ end
@@ -0,0 +1,97 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "ChoiceInstance" do
4
+ before do
5
+ $playing_on_command_line = false
6
+ end
7
+
8
+ after do
9
+ $playing_on_command_line = true
10
+ end
11
+
12
+ let(:unsaved_shado) do
13
+ Parse.get("Shade ot Black Watch")
14
+ end
15
+ let(:unsaved_game) do
16
+ res = Game.new
17
+ res.sides << Side.new(:game => res)
18
+ res.center.fill!
19
+ res
20
+ end
21
+ let(:unsaved_side) do
22
+ res = unsaved_game.sides.first
23
+ res.deck.cards = res.deck.sort_by { |x| x.name } + [unsaved_shado]
24
+ res.draw_hand!
25
+ res
26
+ end
27
+
28
+ it 'smoke' do
29
+ 2.should == 2
30
+ end
31
+
32
+ describe "Basic" do
33
+ let(:game) { unsaved_game }
34
+ let(:side) { unsaved_side }
35
+
36
+ it "stuff" do
37
+ side.play unsaved_shado
38
+ side.choices.size.should == 1
39
+ side.choices.first.choosable_cards.size.should == 4
40
+ end
41
+
42
+ it 'hand cards' do
43
+ side.hand.map { |x| x.name }.should == ["Shade ot Black Watch","Militia","Militia","Apprentice","Apprentice"]
44
+ end
45
+ end
46
+
47
+ describe "full" do
48
+ let(:game) do
49
+ unsaved_side.play unsaved_shado
50
+ unsaved_game.mongo.save!
51
+ unsaved_game.mongo.get_fresh
52
+ end
53
+ let(:side) do
54
+ game.sides.first
55
+ end
56
+ let(:choice) do
57
+ side.choices.first
58
+ end
59
+ let(:chosen_card) do
60
+ side.hand.first
61
+ end
62
+
63
+ it 'smoke' do
64
+ side.choices.size.should == 1
65
+ choice.choosable_cards.size.should == 4
66
+ side.hand.size.should == 4
67
+ end
68
+
69
+ it 'choose' do
70
+ choice.execute! chosen_card
71
+ side.hand.size.should == 3
72
+ end
73
+
74
+ describe "with seer" do
75
+ let(:unsaved_shado) do
76
+ Parse.get("Seer of the Forked Path")
77
+ end
78
+
79
+ it 'seer abilities' do
80
+ unsaved_shado.abilities.size.should == 2
81
+ end
82
+
83
+ it 'smoke' do
84
+ side.choices.size.should == 1
85
+ choice.choosable_cards.size.should == 6
86
+ side.hand.size.should == 5
87
+ end
88
+
89
+ end
90
+
91
+
92
+ end
93
+
94
+
95
+ end
96
+
97
+
@@ -0,0 +1,413 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ class Array
4
+ def safe_find(&b)
5
+ find(&b).tap { |x| raise 'foo' unless x }
6
+ end
7
+ end
8
+
9
+ describe 'initial game state' do
10
+ before do
11
+ @game = Game.new
12
+ end
13
+ it 'fills center' do
14
+ @game.center.fill!
15
+ @game.center.size.should == 6
16
+ end
17
+ end
18
+
19
+ describe 'game' do
20
+ it 'smoke' do
21
+ 2.should == 2
22
+ end
23
+ def hand; @side.hand; end
24
+ before do
25
+ @game = Game.new
26
+ @side = Side.new(:game => @game)
27
+ @game.sides << @side
28
+ @side.draw_hand!
29
+ end
30
+ it 'hand has 5 cards' do
31
+ @side.hand.size.should == 5
32
+ end
33
+ it 'playing a card adds to pool' do
34
+ card = hand.find { |x| x.runes == 1 }
35
+ @side.play(card)
36
+ @side.played.pool.runes.should == 1
37
+ end
38
+ end
39
+
40
+ describe 'ability' do
41
+ describe 'banish' do
42
+ before do
43
+ @game = Game.new
44
+ @side = Side.new(:game => @game)
45
+ @game.sides << @side
46
+ @game.center.fill!
47
+ stub(Ability::CardChoice).chooser do
48
+ lambda { |c| c.options.first }
49
+ end
50
+ @card = @game.center.first
51
+
52
+ Ability::BanishCenter.new.call(@side)
53
+ end
54
+ it 'should be gone from center' do
55
+ @game.center.should_not be_include(@card)
56
+ end
57
+ it 'should be in void' do
58
+ @game.void.should be_include(@card)
59
+ end
60
+ it 'deck should be one less' do
61
+ @game.deck.size.should == 93
62
+ end
63
+ it 'center should be full' do
64
+ @game.center.size.should == 6
65
+ end
66
+ end
67
+
68
+ describe 'defeat' do
69
+ before do
70
+ @game = Game.new
71
+ @side = Side.new(:game => @game)
72
+ @game.sides << @side
73
+ @game.deck[-1] = Card::Monster.cultist_standin
74
+ @game.deck[-2] = Card::Monster.cultist_standin2
75
+ @game.deck[-2].power_cost = 5
76
+ @game.center.fill!
77
+ stub(Ability::CardChoice).chooser do
78
+ lambda { |c| c.options.safe_find { |x| x.base_obj.name == 'Cultist Standin' } }
79
+ end
80
+ @card = @game.center.first
81
+ end
82
+ describe "no constraint" do
83
+ before do
84
+ @choice = Ability::KillMonster.new.call(@side)
85
+ end
86
+ it 'should be gone from center' do
87
+ #raise @game.center.map { |x| x.name }.inspect
88
+ @game.center.should_not be_include(@card)
89
+ end
90
+ it 'should be in void' do
91
+ @game.void.should be_include(@card)
92
+ end
93
+ it 'deck should be one less' do
94
+ @game.deck.size.should == 93
95
+ end
96
+ it 'center should be full' do
97
+ @game.center.size.should == 6
98
+ end
99
+ it 'should add honor' do
100
+ @side.honor.should == @card.honor_earned
101
+ end
102
+ it 'should have 2 options' do
103
+ @choice.choosable_cards.size.should == 3
104
+ end
105
+ end
106
+ describe "power constraint" do
107
+ before do
108
+ @choice = Ability::KillMonster.new(:max_power => 4).call(@side)
109
+ end
110
+ it 'should have 1 option' do
111
+ @choice.choosable_cards.size.should == 2
112
+ end
113
+ end
114
+ end
115
+
116
+ describe 'acquire' do
117
+ before do
118
+ @game = Game.new
119
+ @side = Side.new(:game => @game)
120
+ @game.sides << @side
121
+ @game.deck[-1].rune_cost = 5
122
+ @game.center.fill!
123
+ stub(Ability::CardChoice).chooser do
124
+ lambda { |c| c.options.first }
125
+ end
126
+ @card = @game.center.first
127
+ end
128
+ describe "no constraint" do
129
+ before do
130
+ @choice = Ability::AcquireHero.new.call(@side)
131
+ end
132
+ it 'should be gone from center' do
133
+ @game.center.should_not be_include(@card)
134
+ end
135
+ it 'should be in void' do
136
+ @side.discard.should be_include(@card)
137
+ end
138
+ it 'deck should be one less' do
139
+ @game.deck.size.should == 93
140
+ end
141
+ it 'center should be full' do
142
+ @game.center.size.should == 6
143
+ end
144
+ it 'should have 6 options' do
145
+ @choice.choosable_cards.size.should == 8
146
+ end
147
+ end
148
+ describe "rune constraint" do
149
+ before do
150
+ @choice = Ability::AcquireHero.new(:max_rune_cost => 4).call(@side)
151
+ end
152
+ it 'should have 5 options' do
153
+ @choice.choosable_cards.size.should == 7
154
+ end
155
+ end
156
+ end
157
+
158
+ describe 'copy hero' do
159
+ before do
160
+ @game, @side = *new_game_with_side
161
+ stub(Ability::CardChoice).chooser do
162
+ lambda { |c| c.options.first }
163
+ end
164
+ @side.played << Card::Hero.apprentice
165
+ @choice = Ability::CopyHero.new.call(@side)
166
+ end
167
+ it 'should add rune' do
168
+ @side.played.pool.runes.should == 2
169
+ end
170
+ end
171
+
172
+ describe 'discard construct' do
173
+ before do
174
+ @game, @side = *new_game_with_sides
175
+ @other_side = @side.other_side
176
+ @other_side.constructs << Card::Construct.shadow_star
177
+
178
+ stub(Ability::CardChoice).chooser do
179
+ lambda { |c| c.options.first }
180
+ end
181
+ @choice = Ability::DiscardConstruct.new.call(@side)
182
+ end
183
+ it 'should remove construct' do
184
+ @other_side.constructs.size.should == 0
185
+ end
186
+ it 'should add to discard' do
187
+ @other_side.discard.size.should == 1
188
+ end
189
+ end
190
+
191
+ describe 'keep one construct' do
192
+ before do
193
+ @game, @side = *new_game_with_sides
194
+ @other_side = @side.other_side
195
+ 3.times { @other_side.constructs << Card::Construct.shadow_star }
196
+
197
+ stub(Ability::CardChoice).chooser do
198
+ lambda { |c| c.options.first }
199
+ end
200
+ @choice = Ability::KeepOneConstruct.new.call(@side)
201
+ end
202
+ it 'should remove construct' do
203
+ @other_side.constructs.size.should == 1
204
+ end
205
+ it 'should add to discard' do
206
+ @other_side.discard.size.should == 2
207
+ end
208
+ end
209
+
210
+ describe 'take card from opponents hand' do
211
+ before do
212
+ @game, @side = *new_game_with_sides
213
+ @other_side = @side.other_side
214
+ 2.times { @other_side.hand << Card::Hero.apprentice }
215
+
216
+ stub(Ability::CardChoice).chooser do
217
+ lambda { |c| c.options.first }
218
+ end
219
+ @choice = Ability::TakeOpponentsCard.new.call(@side)
220
+ end
221
+ it 'should remove from opponent' do
222
+ @other_side.hand.size.should == 1
223
+ end
224
+ it 'should add to my hand' do
225
+ @side.hand.size.should == 1
226
+ end
227
+ end
228
+ end
229
+
230
+ describe 'all' do
231
+ before do
232
+ @game = Game.new
233
+ @side = Side.new(:game => @game)
234
+ @game.sides << @side
235
+ end
236
+
237
+ describe 'center with constants' do
238
+ before do
239
+ @game.center.fill!
240
+ end
241
+ it 'size test' do
242
+ @game.center_wc.size.should == 9
243
+ end
244
+ end
245
+
246
+ describe 'buying cards' do
247
+ before do
248
+ @game.center.fill!
249
+ @side.draw_hand!
250
+
251
+ @side.hand.play_all!
252
+ @side.played.pool.runes.should == @side.played.map { |x| x.runes }.sum
253
+
254
+ @card = @game.center.first
255
+ @side.purchase(@card)
256
+ end
257
+
258
+ it 'discarded' do
259
+ @side.discard.size.should == 1
260
+ end
261
+ it 'took runes' do
262
+ @side.played.pool.runes.should == @side.played.map { |x| x.runes }.sum - 2
263
+ end
264
+ it 'was replaced' do
265
+ @game.center.should_not be_include(@card)
266
+ @game.center.size.should == 6
267
+ @game.deck.size.should == 93
268
+ end
269
+ end
270
+
271
+ describe "finishing a turn" do
272
+ before do
273
+ @game.center.fill!
274
+ @side.draw_hand!
275
+ @side.hand.play_all!
276
+ @side.end_turn!
277
+ end
278
+ it 'should discard when done' do
279
+ @side.discard.size.should == 5
280
+ @side.hand.size.should == 5
281
+ @side.deck.size.should == 0
282
+ end
283
+ it 'pool should clear' do
284
+ @side.played.pool.runes.should == 0
285
+ end
286
+ it 'drawing from empty deck' do
287
+ @side.purchase(@game.center.first)
288
+ @side.end_turn!
289
+ @side.total_cards.should == 11
290
+ @side.discard.size.should == 0
291
+ @side.deck.size.should == 6
292
+ end
293
+ end
294
+
295
+ describe 'defeat a monster' do
296
+ before do
297
+ @side.played << Card::Hero.heavy_infantry
298
+ @side.played.pool.power.should == 2
299
+ @side.defeat(Card::Monster.cultist_standin)
300
+ end
301
+ it 'should deplete pool' do
302
+ @side.played.pool.power.should == 0
303
+ end
304
+ it 'should add honor' do
305
+ @side.honor.should == 1
306
+ end
307
+ end
308
+
309
+ describe 'draw ability' do
310
+ before do
311
+ @side.played << Card::Hero.arha
312
+ end
313
+ it 'should draw to hand' do
314
+ @side.hand.size.should == 1
315
+ @side.deck.size.should == 9
316
+ end
317
+ end
318
+
319
+ describe "playing a construct" do
320
+ before do
321
+ @side.played << Card::Construct.shadow_star
322
+ end
323
+ it 'moves to constructs' do
324
+ @side.constructs.size.should == 1
325
+ @side.played.size.should == 0
326
+ end
327
+ it 'adds power to pool' do
328
+ @side.played.pool.power.should == 1
329
+ end
330
+ end
331
+
332
+ describe 'starting turn with constructs' do
333
+ before do
334
+ @side.constructs << Card::Construct.shadow_star
335
+ @side.constructs.apply!
336
+ end
337
+ it 'should add power to pool' do
338
+ @side.played.pool.power.should == 1
339
+ end
340
+ end
341
+
342
+ describe 'events outer' do
343
+ before do
344
+ @trigger = lambda do |event, side|
345
+ if event.first
346
+ side.honor += 1
347
+ end
348
+ end
349
+ @side.constructs << Card::Construct.new(:triggers => [@trigger])
350
+
351
+ @side.played << Card::Hero.apprentice
352
+ end
353
+ it 'should add honor' do
354
+ @side.honor.should == 1
355
+ end
356
+ end
357
+
358
+
359
+
360
+ end
361
+
362
+ describe 'pool' do
363
+ before do
364
+ @pool = Pool.new(:runes => 3, :mechana_runes => 1)
365
+ @mechana_card = Card::Construct.new(:realm => :mechana, :rune_cost => 3)
366
+ @normal_card = Card::Construct.new(:realm => :lifebound, :rune_cost => 3)
367
+ @big_card = Card::Construct.new(:rune_cost => 8)
368
+ end
369
+ describe 'purchase mechana' do
370
+ before do
371
+ @pool.deplete_runes(@mechana_card)
372
+ end
373
+ it 'should use mechana runes' do
374
+ @pool.mechana_runes.should == 0
375
+ end
376
+ it 'should leave std rune' do
377
+ @pool.runes.should == 1
378
+ end
379
+ end
380
+ describe 'purchase normal' do
381
+ before do
382
+ @pool.deplete_runes(@normal_card)
383
+ end
384
+ it 'should leave mechana runes' do
385
+ @pool.mechana_runes.should == 1
386
+ end
387
+ it 'should use all std runes' do
388
+ @pool.runes.should == 0
389
+ end
390
+ end
391
+ describe "can't purchase" do
392
+ it 'should error' do
393
+ lambda { @pool.deplete_runes(@big_card) }.should raise_error
394
+ end
395
+ end
396
+ end
397
+
398
+ describe 'basic events' do
399
+ before do
400
+ @events = Event::Events.new
401
+ @card = Card::Hero.apprentice
402
+ @event = Event::CardPlayed.new(:card => @card)
403
+ @events << @event.clone
404
+ @events << @event.clone
405
+ end
406
+ it 'event 1 should have first marked' do
407
+ @events[0].first.should == true
408
+ end
409
+ it 'event 2 should not have first marked' do
410
+ #puts @events.events.map { |x| x.first }.inspect
411
+ @events[1].first.should == false
412
+ end
413
+ end