rubywarrior 0.1.2 → 0.2.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.
- checksums.yaml +7 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +21 -3
- data/Gemfile +10 -0
- data/Gemfile.lock +55 -0
- data/LICENSE +4 -4
- data/{README.rdoc → README.md} +115 -93
- data/Rakefile +4 -9
- data/bin/rubywarrior +1 -1
- data/features/step_definitions/common_steps.rb +2 -2
- data/features/step_definitions/interaction_steps.rb +7 -7
- data/features/support/env.rb +1 -1
- data/lib/ruby_warrior/game.rb +5 -3
- data/lib/ruby_warrior/level.rb +5 -1
- data/lib/ruby_warrior/player_generator.rb +3 -3
- data/lib/ruby_warrior/profile.rb +1 -1
- data/lib/ruby_warrior/tower.rb +1 -1
- data/rubywarrior.gemspec +16 -0
- data/spec/ruby_warrior/abilities/attack_spec.rb +10 -10
- data/spec/ruby_warrior/abilities/base_spec.rb +19 -19
- data/spec/ruby_warrior/abilities/bind_spec.rb +5 -5
- data/spec/ruby_warrior/abilities/direction_of_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/distance_of_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/explode_spec.rb +7 -7
- data/spec/ruby_warrior/abilities/feel_spec.rb +1 -1
- data/spec/ruby_warrior/abilities/form_spec.rb +14 -14
- data/spec/ruby_warrior/abilities/health_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/listen_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/look_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/pivot_spec.rb +1 -1
- data/spec/ruby_warrior/abilities/rescue_spec.rb +8 -8
- data/spec/ruby_warrior/abilities/rest_spec.rb +7 -7
- data/spec/ruby_warrior/abilities/shoot_spec.rb +4 -4
- data/spec/ruby_warrior/abilities/throw_spec.rb +10 -10
- data/spec/ruby_warrior/abilities/walk_spec.rb +5 -5
- data/spec/ruby_warrior/core_additions_spec.rb +2 -2
- data/spec/ruby_warrior/floor_spec.rb +27 -27
- data/spec/ruby_warrior/game_spec.rb +36 -36
- data/spec/ruby_warrior/level_loader_spec.rb +19 -19
- data/spec/ruby_warrior/level_spec.rb +57 -57
- data/spec/ruby_warrior/player_generator_spec.rb +3 -3
- data/spec/ruby_warrior/position_spec.rb +43 -43
- data/spec/ruby_warrior/profile_spec.rb +59 -59
- data/spec/ruby_warrior/space_spec.rb +71 -71
- data/spec/ruby_warrior/tower_spec.rb +5 -5
- data/spec/ruby_warrior/turn_spec.rb +13 -13
- data/spec/ruby_warrior/ui_spec.rb +32 -32
- data/spec/ruby_warrior/units/archer_spec.rb +9 -9
- data/spec/ruby_warrior/units/base_spec.rb +42 -42
- data/spec/ruby_warrior/units/captive_spec.rb +9 -9
- data/spec/ruby_warrior/units/golem_spec.rb +9 -9
- data/spec/ruby_warrior/units/sludge_spec.rb +11 -11
- data/spec/ruby_warrior/units/thick_sludge_spec.rb +7 -7
- data/spec/ruby_warrior/units/warrior_spec.rb +23 -23
- data/spec/ruby_warrior/units/wizard_spec.rb +9 -9
- data/spec/spec_helper.rb +3 -2
- data/towers/beginner/level_002.rb +1 -1
- data/towers/beginner/level_003.rb +1 -1
- data/towers/beginner/level_005.rb +2 -2
- data/towers/beginner/level_006.rb +2 -2
- data/towers/intermediate/level_002.rb +1 -1
- data/towers/intermediate/level_003.rb +2 -2
- metadata +47 -67
@@ -1,31 +1,31 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Turn do
|
4
4
|
describe "with actions" do
|
5
5
|
before(:each) do
|
6
6
|
@turn = RubyWarrior::Turn.new({:walk! => nil, :attack! => nil})
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should have no action performed at first" do
|
10
|
-
@turn.action.
|
10
|
+
expect(@turn.action).to be_nil
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should be able to perform action and recall it" do
|
14
14
|
@turn.walk!
|
15
|
-
@turn.action.
|
15
|
+
expect(@turn.action).to eq([:walk!])
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should include arguments passed to action" do
|
19
19
|
@turn.walk! :forward
|
20
|
-
@turn.action.
|
20
|
+
expect(@turn.action).to eq([:walk!, :forward])
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should not be able to call multiple actions per turn" do
|
24
24
|
@turn.walk! :forward
|
25
|
-
|
25
|
+
expect { @turn.attack! }.to raise_error("Only one action can be performed per turn.")
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
describe "with senses" do
|
30
30
|
before(:each) do
|
31
31
|
@feel = RubyWarrior::Abilities::Feel.new(Object.new)
|
@@ -33,10 +33,10 @@ describe RubyWarrior::Turn do
|
|
33
33
|
@feel.stubs(:space).with(:backward).returns(Object.new)
|
34
34
|
@turn = RubyWarrior::Turn.new({:feel => @feel})
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should be able to call sense with any argument and return expected results" do
|
38
|
-
@turn.feel.
|
39
|
-
@turn.feel(:backward).
|
38
|
+
expect(@turn.feel).to eq(@feel.perform)
|
39
|
+
expect(@turn.feel(:backward)).to eq(@feel.perform(:backward))
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::UI do
|
4
4
|
before(:each) do
|
@@ -9,82 +9,82 @@ describe RubyWarrior::UI do
|
|
9
9
|
@config.out_stream = @out
|
10
10
|
@config.in_stream = @in
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should add puts to out stream" do
|
14
14
|
@ui.puts "hello"
|
15
|
-
@out.string.
|
15
|
+
expect(@out.string).to eq("hello\n")
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should add print to out stream without newline" do
|
19
19
|
@ui.print "hello"
|
20
|
-
@out.string.
|
20
|
+
expect(@out.string).to eq("hello")
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should fetch gets from in stream" do
|
24
24
|
@in.puts "bar"
|
25
25
|
@in.rewind
|
26
|
-
@ui.gets.
|
26
|
+
expect(@ui.gets).to eq("bar\n")
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should gets should return empty string if no input" do
|
30
30
|
@config.in_stream = nil
|
31
|
-
@ui.gets.
|
31
|
+
expect(@ui.gets).to eq("")
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it "should request text input" do
|
35
35
|
@in.puts "bar"
|
36
36
|
@in.rewind
|
37
|
-
@ui.request("foo").
|
38
|
-
@out.string.
|
37
|
+
expect(@ui.request("foo")).to eq("bar")
|
38
|
+
expect(@out.string).to eq("foo")
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should ask for yes/no and return true when yes" do
|
42
42
|
@ui.expects(:request).with('foo? [yn] ').returns('y')
|
43
|
-
@ui.ask("foo?").
|
43
|
+
expect(@ui.ask("foo?")).to eq(true)
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "should ask for yes/no and return false when no" do
|
47
47
|
@ui.stubs(:request).returns('n')
|
48
|
-
@ui.ask("foo?").
|
48
|
+
expect(@ui.ask("foo?")).to eq(false)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should ask for yes/no and return false for any input" do
|
52
52
|
@ui.stubs(:request).returns('aklhasdf')
|
53
|
-
@ui.ask("foo?").
|
53
|
+
expect(@ui.ask("foo?")).to eq(false)
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
it "should present multiple options and return selected one" do
|
57
57
|
@ui.expects(:request).with(includes('item')).returns('2')
|
58
|
-
@ui.choose('item', [:foo, :bar, :test]).
|
59
|
-
@out.string.
|
60
|
-
@out.string.
|
61
|
-
@out.string.
|
58
|
+
expect(@ui.choose('item', [:foo, :bar, :test])).to eq(:bar)
|
59
|
+
expect(@out.string).to include('[1] foo')
|
60
|
+
expect(@out.string).to include('[2] bar')
|
61
|
+
expect(@out.string).to include('[3] test')
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "choose should accept array as option" do
|
65
65
|
@ui.stubs(:request).returns('3')
|
66
|
-
@ui.choose('item', [:foo, :bar, [:tower, 'easy']]).
|
67
|
-
@out.string.
|
66
|
+
expect(@ui.choose('item', [:foo, :bar, [:tower, 'easy']])).to eq(:tower)
|
67
|
+
expect(@out.string).to include('[3] easy')
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
it "choose should return option without prompt if only one item" do
|
71
71
|
@ui.expects(:puts).never
|
72
72
|
@ui.expects(:gets).never
|
73
73
|
@ui.stubs(:request).returns('3')
|
74
|
-
@ui.choose('item', [:foo]).
|
74
|
+
expect(@ui.choose('item', [:foo])).to eq(:foo)
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
it "choose should return first value in array of option if only on item" do
|
78
|
-
@ui.choose('item', [[:foo, :bar]]).
|
78
|
+
expect(@ui.choose('item', [[:foo, :bar]])).to eq(:foo)
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it "should delay after puts when specified" do
|
82
82
|
@config.delay = 1.3
|
83
83
|
@ui.expects(:puts).with("foo")
|
84
84
|
@ui.expects(:sleep).with(1.3)
|
85
85
|
@ui.puts_with_delay("foo")
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
it "should not delay puts when delay isn't specified" do
|
89
89
|
@ui.expects(:puts).with("foo")
|
90
90
|
@ui.expects(:sleep).never
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Units::Archer do
|
4
4
|
before(:each) do
|
5
5
|
@archer = RubyWarrior::Units::Archer.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have look and shoot abilities" do
|
9
|
-
@archer.abilities.keys.to_set.
|
9
|
+
expect(@archer.abilities.keys.to_set).to eq([:shoot!, :look].to_set)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should have shoot power of 3" do
|
13
|
-
@archer.shoot_power.
|
13
|
+
expect(@archer.shoot_power).to eq(3)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should have 7 max health" do
|
17
|
-
@archer.max_health.
|
17
|
+
expect(@archer.max_health).to eq(7)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should appear as a on map" do
|
21
|
-
@archer.character.
|
21
|
+
expect(@archer.character).to eq("a")
|
22
22
|
end
|
23
23
|
end
|
@@ -1,70 +1,70 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Units::Base do
|
4
4
|
before(:each) do
|
5
5
|
@unit = RubyWarrior::Units::Base.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have an attack power which defaults to zero" do
|
9
|
-
@unit.attack_power.
|
9
|
+
expect(@unit.attack_power).to be_zero
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should consider itself dead when no position" do
|
13
|
-
@unit.position.
|
14
|
-
@unit.
|
13
|
+
expect(@unit.position).to be_nil
|
14
|
+
expect(@unit).to_not be_alive
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should consider itself alive with position" do
|
18
18
|
@unit.position = stub
|
19
|
-
@unit.
|
19
|
+
expect(@unit).to be_alive
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should default max health to 10" do
|
23
|
-
@unit.max_health.
|
23
|
+
expect(@unit.max_health).to be_zero
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it "should do nothing when earning points" do
|
27
|
-
|
27
|
+
expect { @unit.earn_points(10) }.to_not raise_error
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "should default health to max health" do
|
31
31
|
@unit.stubs(:max_health).returns(10)
|
32
|
-
@unit.health.
|
32
|
+
expect(@unit.health).to eq(10)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should subtract health when taking damage" do
|
36
36
|
@unit.stubs(:max_health).returns(10)
|
37
37
|
@unit.take_damage(3)
|
38
|
-
@unit.health.
|
38
|
+
expect(@unit.health).to eq(7)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should do nothing when taking damage if health isn't set" do
|
42
|
-
|
42
|
+
expect { @unit.take_damage(3) }.to_not raise_error
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
it "should set position to nil when running out of health" do
|
46
46
|
@unit.position = stub
|
47
47
|
@unit.stubs(:max_health).returns(10)
|
48
48
|
@unit.take_damage(10)
|
49
|
-
@unit.position.
|
49
|
+
expect(@unit.position).to be_nil
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
it "should print out line with name when speaking" do
|
53
53
|
RubyWarrior::UI.expects(:puts_with_delay).with("Base foo")
|
54
54
|
@unit.say "foo"
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should return name in to_s" do
|
58
|
-
@unit.name.
|
59
|
-
@unit.to_s.
|
58
|
+
expect(@unit.name).to eq('Base')
|
59
|
+
expect(@unit.to_s).to eq('Base')
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it "should prepare turn by calling play_turn with next turn object" do
|
63
63
|
@unit.stubs(:next_turn).returns('next_turn')
|
64
64
|
@unit.expects(:play_turn).with('next_turn')
|
65
65
|
@unit.prepare_turn
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should perform action when calling perform on turn" do
|
69
69
|
@unit.position = stub
|
70
70
|
RubyWarrior::Abilities::Walk.any_instance.expects(:perform).with(:backward)
|
@@ -74,7 +74,7 @@ describe RubyWarrior::Units::Base do
|
|
74
74
|
@unit.prepare_turn
|
75
75
|
@unit.perform_turn
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
it "should not perform action when dead (no position)" do
|
79
79
|
@unit.position = nil
|
80
80
|
RubyWarrior::Abilities::Walk.any_instance.stubs(:perform).raises("action should not be called")
|
@@ -84,42 +84,42 @@ describe RubyWarrior::Units::Base do
|
|
84
84
|
@unit.prepare_turn
|
85
85
|
@unit.perform_turn
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
it "should not raise an exception when calling perform_turn when there's no action" do
|
89
89
|
@unit.prepare_turn
|
90
|
-
|
90
|
+
expect { @unit.perform_turn }.to_not raise_error
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
it "should pass abilities to new turn when calling next_turn" do
|
94
|
-
RubyWarrior::Turn.expects(:new).with(:walk! => nil, :attack! => nil, :feel => nil).returns('turn')
|
94
|
+
RubyWarrior::Turn.expects(:new).with({:walk! => nil, :attack! => nil, :feel => nil}).returns('turn')
|
95
95
|
@unit.stubs(:abilities).returns(:walk! => nil, :attack! => nil, :feel => nil)
|
96
|
-
@unit.next_turn.
|
96
|
+
expect(@unit.next_turn).to eq('turn')
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
it "should add ability" do
|
100
100
|
RubyWarrior::Abilities::Walk.expects(:new).with(@unit).returns('walk')
|
101
101
|
@unit.add_abilities(:walk!)
|
102
|
-
@unit.abilities.
|
102
|
+
expect(@unit.abilities).to eq({ :walk! => 'walk' })
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
it "should appear as question mark on map" do
|
106
|
-
@unit.character.
|
106
|
+
expect(@unit.character).to eq("?")
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
it "should be released from bonds when taking damage" do
|
110
110
|
@unit.stubs(:max_health).returns(10)
|
111
111
|
@unit.bind
|
112
|
-
@unit.
|
112
|
+
expect(@unit).to be_bound
|
113
113
|
@unit.take_damage(2)
|
114
|
-
@unit.
|
114
|
+
expect(@unit).to_not be_bound
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
it "should be released from bonds when calling release" do
|
118
118
|
@unit.bind
|
119
119
|
@unit.unbind
|
120
|
-
@unit.
|
120
|
+
expect(@unit).to_not be_bound
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
it "should not perform action when bound" do
|
124
124
|
@unit.position = stub
|
125
125
|
@unit.bind
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Units::Captive do
|
4
4
|
before(:each) do
|
5
5
|
@captive = RubyWarrior::Units::Captive.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have 1 max health" do
|
9
|
-
@captive.max_health.
|
9
|
+
expect(@captive.max_health).to eq(1)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should appear as C on map" do
|
13
|
-
@captive.character.
|
13
|
+
expect(@captive.character).to eq("C")
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should be bound by default" do
|
17
|
-
@captive.
|
17
|
+
expect(@captive).to be_bound
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should not have explode ability by default (this should be added when needed)" do
|
21
|
-
@captive.abilities.
|
21
|
+
expect(@captive.abilities).to_not include(:explode!)
|
22
22
|
end
|
23
23
|
end
|
@@ -1,28 +1,28 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Units::Golem do
|
4
4
|
before(:each) do
|
5
5
|
@golem = RubyWarrior::Units::Golem.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should execute turn proc when playing turn" do
|
9
9
|
proc = Object.new
|
10
10
|
proc.expects(:call).with(:turn)
|
11
11
|
@golem.turn = proc
|
12
12
|
@golem.play_turn(:turn)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should set max health and update current health" do
|
16
16
|
@golem.max_health = 10
|
17
|
-
@golem.max_health.
|
18
|
-
@golem.health.
|
17
|
+
expect(@golem.max_health).to eq(10)
|
18
|
+
expect(@golem.health).to eq(10)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it "should have attack power of 3" do
|
22
|
-
@golem.attack_power.
|
22
|
+
expect(@golem.attack_power).to eq(3)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should appear as G on map" do
|
26
|
-
@golem.character.
|
26
|
+
expect(@golem.character).to eq("G")
|
27
27
|
end
|
28
28
|
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Units::Sludge do
|
4
4
|
before(:each) do
|
5
5
|
@sludge = RubyWarrior::Units::Sludge.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have attack action" do
|
9
|
-
@sludge.abilities.keys.
|
9
|
+
expect(@sludge.abilities.keys).to include(:attack!)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should have feel sense" do
|
13
|
-
@sludge.abilities.keys.
|
13
|
+
expect(@sludge.abilities.keys).to include(:feel)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should have attack power of 3" do
|
17
|
-
@sludge.attack_power.
|
17
|
+
expect(@sludge.attack_power).to eq(3)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should have 12 max health" do
|
21
|
-
@sludge.max_health.
|
21
|
+
expect(@sludge.max_health).to eq(12)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should appear as s on map" do
|
25
|
-
@sludge.character.
|
25
|
+
expect(@sludge.character).to eq("s")
|
26
26
|
end
|
27
27
|
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Units::ThickSludge do
|
4
4
|
before(:each) do
|
5
5
|
@sludge = RubyWarrior::Units::ThickSludge.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have 24 max health" do
|
9
|
-
@sludge.max_health.
|
9
|
+
expect(@sludge.max_health).to eq(24)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should appear as S on map" do
|
13
|
-
@sludge.character.
|
13
|
+
expect(@sludge.character).to eq("S")
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should have the name of 'Thick Sludge'" do
|
17
|
-
@sludge.name.
|
17
|
+
expect(@sludge.name).to eq("Thick Sludge")
|
18
18
|
end
|
19
19
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
class Player
|
4
4
|
def turn(warrior)
|
@@ -9,57 +9,57 @@ describe RubyWarrior::Units::Warrior do
|
|
9
9
|
before(:each) do
|
10
10
|
@warrior = RubyWarrior::Units::Warrior.new
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should default name to warrior" do
|
14
|
-
@warrior.name.
|
14
|
+
expect(@warrior.name).to eq("Warrior")
|
15
15
|
@warrior.name = ''
|
16
|
-
@warrior.name.
|
16
|
+
expect(@warrior.name).to eq("Warrior")
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should be able to set name" do
|
20
20
|
@warrior.name = "Joe"
|
21
|
-
@warrior.name.
|
22
|
-
@warrior.to_s.
|
21
|
+
expect(@warrior.name).to eq("Joe")
|
22
|
+
expect(@warrior.to_s).to eq("Joe")
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should have 20 max health" do
|
26
|
-
@warrior.max_health.
|
26
|
+
expect(@warrior.max_health).to eq(20)
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should have 0 score at beginning and be able to earn points" do
|
30
|
-
@warrior.score.
|
30
|
+
expect(@warrior.score).to be_zero
|
31
31
|
@warrior.earn_points(5)
|
32
|
-
@warrior.score.
|
32
|
+
expect(@warrior.score).to eq(5)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should call player.play_turn and pass turn to player" do
|
36
36
|
player = stub
|
37
37
|
player.expects(:play_turn).with('turn')
|
38
38
|
@warrior.stubs(:player).returns(player)
|
39
39
|
@warrior.play_turn('turn')
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should call Player.new the first time loading player, and return same object next time" do
|
43
43
|
Player.expects(:new).returns('player').times(1)
|
44
44
|
2.times do
|
45
|
-
@warrior.player.
|
45
|
+
expect(@warrior.player).to eq('player')
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "should have an attack power of 5" do
|
50
|
-
@warrior.attack_power.
|
50
|
+
expect(@warrior.attack_power).to eq(5)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "should have an shoot power of 3" do
|
54
|
-
@warrior.shoot_power.
|
54
|
+
expect(@warrior.shoot_power).to eq(3)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should appear as @ on map" do
|
58
|
-
@warrior.character.
|
58
|
+
expect(@warrior.character).to eq("@")
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
it "should be able to add golem abilities which are used on base golem" do
|
62
62
|
@warrior.add_golem_abilities :walk!
|
63
|
-
@warrior.base_golem.abilities.keys.
|
63
|
+
expect(@warrior.base_golem.abilities.keys).to eq([:walk!])
|
64
64
|
end
|
65
65
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Units::Wizard do
|
4
4
|
before(:each) do
|
5
5
|
@wizard = RubyWarrior::Units::Wizard.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have look and shoot abilities" do
|
9
|
-
@wizard.abilities.keys.to_set.
|
9
|
+
expect(@wizard.abilities.keys.to_set).to eq([:shoot!, :look].to_set)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should have shoot power of 11" do
|
13
|
-
@wizard.shoot_power.
|
13
|
+
expect(@wizard.shoot_power).to eq(11)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should have 3 max health" do
|
17
|
-
@wizard.max_health.
|
17
|
+
expect(@wizard.max_health).to eq(3)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should appear as w on map" do
|
21
|
-
@wizard.character.
|
21
|
+
expect(@wizard.character).to eq("w")
|
22
22
|
end
|
23
23
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
2
|
+
require 'rspec'
|
3
3
|
require File.dirname(__FILE__) + '/../lib/ruby_warrior'
|
4
4
|
|
5
|
-
|
5
|
+
RSpec.configure do |config|
|
6
6
|
config.mock_with :mocha
|
7
7
|
config.before(:each) do
|
8
8
|
RubyWarrior::Config.reset
|
9
9
|
end
|
10
|
+
config.raise_errors_for_deprecations!
|
10
11
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# --------
|
4
4
|
|
5
5
|
description "It is too dark to see anything, but you smell sludge nearby."
|
6
|
-
tip "Use warrior.feel.empty? to see if there
|
6
|
+
tip "Use warrior.feel.empty? to see if there is anything in front of you, and warrior.attack! to fight it. Remember, you can only do one action (ending in !) per turn."
|
7
7
|
clue "Add an if/else condition using warrior.feel.empty? to decide whether to warrior.attack! or warrior.walk!."
|
8
8
|
|
9
9
|
time_bonus 20
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
description "The air feels thicker than before. There must be a horde of sludge."
|
6
6
|
tip "Be careful not to die! Use warrior.health to keep an eye on your health, and warrior.rest! to earn 10% of max health back."
|
7
|
-
clue "When there
|
7
|
+
clue "When there is no enemy ahead of you call warrior.rest! until health is full before walking forward."
|
8
8
|
|
9
9
|
time_bonus 35
|
10
10
|
ace_score 71
|