rubywarrior 0.1.3 → 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.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/{CHANGELOG.rdoc → CHANGELOG.md} +11 -4
  3. data/Gemfile +4 -2
  4. data/Gemfile.lock +44 -25
  5. data/LICENSE +4 -4
  6. data/{README.rdoc → README.md} +115 -93
  7. data/bin/rubywarrior +1 -1
  8. data/features/step_definitions/common_steps.rb +2 -2
  9. data/features/step_definitions/interaction_steps.rb +2 -2
  10. data/lib/ruby_warrior/game.rb +4 -2
  11. data/lib/ruby_warrior/player_generator.rb +2 -2
  12. data/rubywarrior.gemspec +16 -0
  13. data/spec/ruby_warrior/abilities/attack_spec.rb +9 -9
  14. data/spec/ruby_warrior/abilities/base_spec.rb +18 -18
  15. data/spec/ruby_warrior/abilities/bind_spec.rb +4 -4
  16. data/spec/ruby_warrior/abilities/direction_of_spec.rb +2 -2
  17. data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +2 -2
  18. data/spec/ruby_warrior/abilities/distance_of_spec.rb +2 -2
  19. data/spec/ruby_warrior/abilities/explode_spec.rb +6 -6
  20. data/spec/ruby_warrior/abilities/form_spec.rb +13 -13
  21. data/spec/ruby_warrior/abilities/health_spec.rb +2 -2
  22. data/spec/ruby_warrior/abilities/listen_spec.rb +2 -2
  23. data/spec/ruby_warrior/abilities/look_spec.rb +2 -2
  24. data/spec/ruby_warrior/abilities/rescue_spec.rb +7 -7
  25. data/spec/ruby_warrior/abilities/rest_spec.rb +6 -6
  26. data/spec/ruby_warrior/abilities/shoot_spec.rb +3 -3
  27. data/spec/ruby_warrior/abilities/throw_spec.rb +9 -9
  28. data/spec/ruby_warrior/abilities/walk_spec.rb +4 -4
  29. data/spec/ruby_warrior/core_additions_spec.rb +1 -1
  30. data/spec/ruby_warrior/floor_spec.rb +26 -26
  31. data/spec/ruby_warrior/game_spec.rb +34 -34
  32. data/spec/ruby_warrior/level_loader_spec.rb +18 -18
  33. data/spec/ruby_warrior/level_spec.rb +56 -56
  34. data/spec/ruby_warrior/player_generator_spec.rb +2 -2
  35. data/spec/ruby_warrior/position_spec.rb +42 -42
  36. data/spec/ruby_warrior/profile_spec.rb +57 -57
  37. data/spec/ruby_warrior/space_spec.rb +70 -70
  38. data/spec/ruby_warrior/tower_spec.rb +4 -4
  39. data/spec/ruby_warrior/turn_spec.rb +12 -12
  40. data/spec/ruby_warrior/ui_spec.rb +31 -31
  41. data/spec/ruby_warrior/units/archer_spec.rb +8 -8
  42. data/spec/ruby_warrior/units/base_spec.rb +41 -41
  43. data/spec/ruby_warrior/units/captive_spec.rb +8 -8
  44. data/spec/ruby_warrior/units/golem_spec.rb +8 -8
  45. data/spec/ruby_warrior/units/sludge_spec.rb +10 -10
  46. data/spec/ruby_warrior/units/thick_sludge_spec.rb +6 -6
  47. data/spec/ruby_warrior/units/warrior_spec.rb +22 -22
  48. data/spec/ruby_warrior/units/wizard_spec.rb +8 -8
  49. data/spec/spec_helper.rb +1 -0
  50. metadata +32 -33
@@ -4,20 +4,20 @@ 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.should == [:shoot!, :look].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.should == 3
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.should == 7
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.should == "a"
21
+ expect(@archer.character).to eq("a")
22
22
  end
23
23
  end
@@ -4,67 +4,67 @@ 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.should be_zero
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.should be_nil
14
- @unit.should_not be_alive
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.should be_alive
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.should be_zero
23
+ expect(@unit.max_health).to be_zero
24
24
  end
25
-
25
+
26
26
  it "should do nothing when earning points" do
27
- lambda { @unit.earn_points(10) }.should_not raise_error
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.should == 10
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.should == 7
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
- lambda { @unit.take_damage(3) }.should_not raise_error
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.should be_nil
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.should == 'Base'
59
- @unit.to_s.should == 'Base'
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
- lambda { @unit.perform_turn }.should_not raise_error
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.should == '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.should == { :walk! => 'walk' }
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.should == "?"
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.should be_bound
112
+ expect(@unit).to be_bound
113
113
  @unit.take_damage(2)
114
- @unit.should_not be_bound
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.should_not be_bound
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
@@ -4,20 +4,20 @@ 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.should == 1
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.should == "C"
13
+ expect(@captive.character).to eq("C")
14
14
  end
15
-
15
+
16
16
  it "should be bound by default" do
17
- @captive.should be_bound
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.should_not include(:explode!)
21
+ expect(@captive.abilities).to_not include(:explode!)
22
22
  end
23
23
  end
@@ -4,25 +4,25 @@ 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.should == 10
18
- @golem.health.should == 10
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.should == 3
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.should == "G"
26
+ expect(@golem.character).to eq("G")
27
27
  end
28
28
  end
@@ -4,24 +4,24 @@ 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.should include(:attack!)
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.should include(:feel)
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.should == 3
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.should == 12
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.should == "s"
25
+ expect(@sludge.character).to eq("s")
26
26
  end
27
27
  end
@@ -4,16 +4,16 @@ 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.should == 24
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.should == "S"
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.should == "Thick Sludge"
17
+ expect(@sludge.name).to eq("Thick Sludge")
18
18
  end
19
19
  end
@@ -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.should == "Warrior"
14
+ expect(@warrior.name).to eq("Warrior")
15
15
  @warrior.name = ''
16
- @warrior.name.should == "Warrior"
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.should == "Joe"
22
- @warrior.to_s.should == "Joe"
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.should == 20
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.should be_zero
30
+ expect(@warrior.score).to be_zero
31
31
  @warrior.earn_points(5)
32
- @warrior.score.should == 5
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.should == '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.should == 5
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.should == 3
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.should == "@"
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.should == [:walk!]
63
+ expect(@warrior.base_golem.abilities.keys).to eq([:walk!])
64
64
  end
65
65
  end
@@ -4,20 +4,20 @@ 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.should == [:shoot!, :look].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.should == 11
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.should == 3
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.should == "w"
21
+ expect(@wizard.character).to eq("w")
22
22
  end
23
23
  end
data/spec/spec_helper.rb CHANGED
@@ -7,4 +7,5 @@ RSpec.configure do |config|
7
7
  config.before(:each) do
8
8
  RubyWarrior::Config.reset
9
9
  end
10
+ config.raise_errors_for_deprecations!
10
11
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubywarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Bates
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-28 00:00:00.000000000Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: You play as a warrior climbing a tall tower. On each floor you need to
15
14
  write a Ruby script to instruct the warrior to battle enemies, rescue captives,
@@ -20,6 +19,22 @@ executables:
20
19
  extensions: []
21
20
  extra_rdoc_files: []
22
21
  files:
22
+ - CHANGELOG.md
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE
26
+ - README.md
27
+ - Rakefile
28
+ - bin/rubywarrior
29
+ - features/command_options.feature
30
+ - features/levels.feature
31
+ - features/profiles.feature
32
+ - features/step_definitions/common_steps.rb
33
+ - features/step_definitions/interaction_steps.rb
34
+ - features/support/env.rb
35
+ - features/support/mockio.rb
36
+ - features/towers.feature
37
+ - lib/ruby_warrior.rb
23
38
  - lib/ruby_warrior/abilities/attack.rb
24
39
  - lib/ruby_warrior/abilities/base.rb
25
40
  - lib/ruby_warrior/abilities/bind.rb
@@ -60,7 +75,7 @@ files:
60
75
  - lib/ruby_warrior/units/thick_sludge.rb
61
76
  - lib/ruby_warrior/units/warrior.rb
62
77
  - lib/ruby_warrior/units/wizard.rb
63
- - lib/ruby_warrior.rb
78
+ - rubywarrior.gemspec
64
79
  - spec/fixtures/short-tower/level_001.rb
65
80
  - spec/fixtures/short-tower/level_002.rb
66
81
  - spec/fixtures/walking_player.rb
@@ -103,14 +118,8 @@ files:
103
118
  - spec/ruby_warrior/units/warrior_spec.rb
104
119
  - spec/ruby_warrior/units/wizard_spec.rb
105
120
  - spec/spec_helper.rb
106
- - features/command_options.feature
107
- - features/levels.feature
108
- - features/profiles.feature
109
- - features/step_definitions/common_steps.rb
110
- - features/step_definitions/interaction_steps.rb
111
- - features/support/env.rb
112
- - features/support/mockio.rb
113
- - features/towers.feature
121
+ - templates/README.erb
122
+ - templates/player.rb
114
123
  - towers/beginner/level_001.rb
115
124
  - towers/beginner/level_002.rb
116
125
  - towers/beginner/level_003.rb
@@ -129,37 +138,27 @@ files:
129
138
  - towers/intermediate/level_007.rb
130
139
  - towers/intermediate/level_008.rb
131
140
  - towers/intermediate/level_009.rb
132
- - templates/player.rb
133
- - templates/README.erb
134
- - bin/rubywarrior
135
- - CHANGELOG.rdoc
136
- - Gemfile
137
- - Gemfile.lock
138
- - LICENSE
139
- - Rakefile
140
- - README.rdoc
141
141
  homepage: https://github.com/ryanb/ruby-warrior
142
- licenses: []
143
- post_install_message:
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
144
146
  rdoc_options: []
145
147
  require_paths:
146
148
  - lib
147
149
  required_ruby_version: !ruby/object:Gem::Requirement
148
- none: false
149
150
  requirements:
150
- - - ! '>='
151
+ - - ">="
151
152
  - !ruby/object:Gem::Version
152
153
  version: '0'
153
154
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
155
  requirements:
156
- - - ! '>='
156
+ - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: 1.3.4
159
159
  requirements: []
160
- rubyforge_project: rubywarrior
161
- rubygems_version: 1.8.10
162
- signing_key:
163
- specification_version: 3
164
- summary: Game written in Ruby for learning Ruby and artificial intelligence.
160
+ rubygems_version: 3.5.3
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Game written in Ruby for learning Ruby.
165
164
  test_files: []