rubywarrior 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0da1053639652ef190b19b22a47786adf5a31ed90e4f6575c177b71756cd66ab
4
+ data.tar.gz: 2f8ca01cc724b1e18fce98f2e8e16ad79978bbf05a7156937970ada0ddebeb03
5
+ SHA512:
6
+ metadata.gz: 2f554896bf063ac3fd423c22387aca81599df1fd580644e2dbdec1f15668dc0a53890ffcd803fa6172ca09450b23247de04112d889ffed1651c2f03e131c6fb7
7
+ data.tar.gz: 983eae03da65cd4e1ba8c918fe147164b4a3b48dce0b5855695798548d570929a5d3037c1468642349bc612d252c4f5c6cd6e05a913629801422b66951cca41e
@@ -1,4 +1,11 @@
1
- 0.1.3 (April 28, 2012)
1
+ ## 0.2.0 (March 26, 2024)
2
+
3
+ * Support Ruby 3.3 (thanks fpsvogel)
4
+
5
+ * Improve message when using --skip option (thanks dcki)
6
+
7
+
8
+ ## 0.1.3 (April 28, 2012)
2
9
 
3
10
  * Making specs pass with latest RSpec.
4
11
 
@@ -9,7 +16,7 @@
9
16
  * Other minor bug fixes (see commit history for details)
10
17
 
11
18
 
12
- 0.1.2 (September 23, 2010)
19
+ ## 0.1.2 (September 23, 2010)
13
20
 
14
21
  * Adding intermediate level 9 with distance_of ability
15
22
 
@@ -22,7 +29,7 @@
22
29
  * Mention direction when ability is performed
23
30
 
24
31
 
25
- 0.1.1 (Jan 3, 2010)
32
+ ## 0.1.1 (Jan 3, 2010)
26
33
 
27
34
  * Speeding up play speed a little
28
35
 
@@ -33,6 +40,6 @@
33
40
  * Keep track of last level played in profile and go back to normal mode when level is added
34
41
 
35
42
 
36
- 0.1.0 (Jan 2, 2010)
43
+ ## 0.1.0 (Jan 2, 2010)
37
44
 
38
45
  * initial release
data/Gemfile CHANGED
@@ -1,8 +1,10 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
+
3
+ gem 'base64'
2
4
 
3
5
  group :test do
4
6
  gem 'rake'
5
- gem 'rspec', '~> 2.8.0'
7
+ gem 'rspec', '~> 3.13.0'
6
8
  gem 'cucumber'
7
9
  gem 'mocha'
8
10
  end
data/Gemfile.lock CHANGED
@@ -1,36 +1,55 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
- builder (3.0.0)
5
- cucumber (1.1.9)
4
+ base64 (0.2.0)
5
+ builder (3.2.4)
6
+ cucumber (2.99.0)
6
7
  builder (>= 2.1.2)
7
- diff-lcs (>= 1.1.2)
8
- gherkin (~> 2.9.0)
9
- json (>= 1.4.6)
10
- term-ansicolor (>= 1.0.6)
11
- diff-lcs (1.1.3)
12
- gherkin (2.9.3)
13
- json (>= 1.4.6)
14
- json (1.7.0)
15
- metaclass (0.0.1)
16
- mocha (0.11.3)
17
- metaclass (~> 0.0.1)
18
- rake (0.9.2.2)
19
- rspec (2.8.0)
20
- rspec-core (~> 2.8.0)
21
- rspec-expectations (~> 2.8.0)
22
- rspec-mocks (~> 2.8.0)
23
- rspec-core (2.8.0)
24
- rspec-expectations (2.8.0)
25
- diff-lcs (~> 1.1.2)
26
- rspec-mocks (2.8.0)
27
- term-ansicolor (1.0.7)
8
+ cucumber-core (~> 1.5.0)
9
+ cucumber-wire (~> 0.0.1)
10
+ diff-lcs (>= 1.1.3)
11
+ gherkin (~> 4.0)
12
+ multi_json (>= 1.7.5, < 2.0)
13
+ multi_test (>= 0.1.2)
14
+ cucumber-core (1.5.0)
15
+ gherkin (~> 4.0)
16
+ cucumber-wire (0.0.1)
17
+ diff-lcs (1.5.1)
18
+ gherkin (4.1.3)
19
+ mocha (2.1.0)
20
+ ruby2_keywords (>= 0.0.5)
21
+ multi_json (1.15.0)
22
+ multi_test (1.1.0)
23
+ prettier_print (1.2.1)
24
+ rake (13.1.0)
25
+ rspec (3.13.0)
26
+ rspec-core (~> 3.13.0)
27
+ rspec-expectations (~> 3.13.0)
28
+ rspec-mocks (~> 3.13.0)
29
+ rspec-core (3.13.0)
30
+ rspec-support (~> 3.13.0)
31
+ rspec-expectations (3.13.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.13.0)
34
+ rspec-mocks (3.13.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.13.0)
37
+ rspec-support (3.13.1)
38
+ ruby2_keywords (0.0.5)
39
+ syntax_tree (6.2.0)
40
+ prettier_print (>= 1.2.0)
28
41
 
29
42
  PLATFORMS
43
+ arm64-darwin-23
30
44
  ruby
31
45
 
32
46
  DEPENDENCIES
47
+ base64
33
48
  cucumber
34
49
  mocha
35
50
  rake
36
- rspec (~> 2.8.0)
51
+ rspec (~> 3.13.0)
52
+ syntax_tree
53
+
54
+ BUNDLED WITH
55
+ 2.5.3
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
- Copyright (c) 2010 Ryan Bates
2
-
1
+ Copyright (c) 2024 Ryan Bates
2
+
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
5
5
  "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@ without limitation the rights to use, copy, modify, merge, publish,
7
7
  distribute, sublicense, and/or sell copies of the Software, and to
8
8
  permit persons to whom the Software is furnished to do so, subject to
9
9
  the following conditions:
10
-
10
+
11
11
  The above copyright notice and this permission notice shall be
12
12
  included in all copies or substantial portions of the Software.
13
-
13
+
14
14
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -1,50 +1,58 @@
1
- = Ruby Warrior
1
+ # Ruby Warrior
2
2
 
3
- This is a game designed to teach the Ruby language and artificial intelligence in a fun, interactive way.
3
+ This is a game designed to teach the Ruby language in a fun and interactive way.
4
4
 
5
5
  You play as a warrior climbing a tall tower to reach the precious Ruby at the top level. On each floor you need to write a Ruby script to instruct the warrior to battle enemies, rescue captives, and reach the stairs. You have some idea of what each floor contains, but you never know for certain what will happen. You must give the Warrior enough artificial intelligence up-front to find his own way.
6
6
 
7
- NOTE: The player directory structure changed on July 18, 2009. If you have an old profile using the "level-00*" structure then move the contents of the last level into the parent directory.
7
+ > Note: The player directory structure changed on July 18, 2009. If you have an old profile using the `level-00*` structure then move the contents of the last level into the parent directory.
8
8
 
9
9
 
10
- == Getting Started
10
+ ## Getting Started
11
11
 
12
12
  First install the gem.
13
13
 
14
- gem install rubywarrior
14
+ ```sh
15
+ gem install rubywarrior
16
+ ```
15
17
 
16
- Then run the "rubywarrior" command to setup your profile. This will create a rubywarrior directory in your current location where you will find a player.rb file in your profile's directory containing this:
18
+ > As of version 0.2.0, this gem has been updated to work with Ruby 3.3. If you have difficulty running it in an older version of Ruby, try using an older version of the gem.
17
19
 
18
- class Player
19
- def play_turn(warrior)
20
- # your code goes here
21
- end
20
+ Then run the `rubywarrior` command to setup your profile. This will create a rubywarrior directory in your current location where you will find a player.rb file in your profile's directory containing this:
21
+
22
+ ```rb
23
+ class Player
24
+ def play_turn(warrior)
25
+ # your code goes here
22
26
  end
27
+ end
28
+ ```
23
29
 
24
- Your objective is to fill this "play_turn" method with commands to instruct the warrior what to do. With each level your abilities will grow along with the difficulty. See the README in your profile's directory for details on what abilities your warrior has available on the current level.
30
+ Your objective is to fill this `play_turn` method with commands to instruct the warrior what to do. With each level your abilities will grow along with the difficulty. See the README in your profile's directory for details on what abilities your warrior has available on the current level.
25
31
 
26
32
  Here is a simple example which will instruct the warrior to attack if he feels an enemy, otherwise he will walk forward.
27
33
 
28
- class Player
29
- def play_turn(warrior)
30
- if warrior.feel.enemy?
31
- warrior.attack!
32
- else
33
- warrior.walk!
34
- end
34
+ ```rb
35
+ class Player
36
+ def play_turn(warrior)
37
+ if warrior.feel.enemy?
38
+ warrior.attack!
39
+ else
40
+ warrior.walk!
35
41
  end
36
42
  end
43
+ end
44
+ ```
37
45
 
38
- Once you are done editing player.rb, save the file and run the "rubywarrior" command again to start playing the level. The play happens through a series of turns. On each one, your "play_turn" method is called along with any enemy's.
46
+ Once you are done editing `player.rb`, save the file and run the `rubywarrior` command again to start playing the level. The play happens through a series of turns. On each one, your `play_turn` method is called along with any enemy's.
39
47
 
40
48
  You cannot change your code in the middle of a level. You must take into account everything that may happen on that level and give your warrior the proper instructions from the start.
41
49
 
42
- Losing all of your health will cause you to fail the level. You are not punished by this, you simply need to go back to your player.rb, improve your code, and try again.
50
+ Losing all of your health will cause you to fail the level. You are not punished by this, you simply need to go back to your `player.rb`, improve your code, and try again.
43
51
 
44
- Once you pass a level (by reaching the stairs), the profile README will be updated for the next level. Alter the player.rb file and run rubywarrior again to play the next level.
52
+ Once you pass a level (by reaching the stairs), the profile README will be updated for the next level. Alter the `player.rb` file and run `rubywarrior` again to play the next level.
45
53
 
46
54
 
47
- == Scoring
55
+ ## Scoring
48
56
 
49
57
  Your objective is to not only reach the stairs, but to get the highest score you can. There are many ways you can earn points on a level.
50
58
 
@@ -58,127 +66,141 @@ A total score is kept as you progress through the levels. When you pass a level,
58
66
  Don't be too concerned about scoring perfectly in the beginning. After you reach the top of the tower you will be able to re-run the tower and fine-tune your warrior to get the highest score. See the Epic Mode below for details.
59
67
 
60
68
 
61
- == Perspective
69
+ ## Perspective
62
70
 
63
71
  Even though this is a text-based game, think of it as two-dimensional where you are viewing from overhead. Each level is always rectangular in shape and is made up of a number of squares. Only one unit can be on a given square at a time, and your objective is to find the square with the stairs. Here is an example level map and key.
64
72
 
65
- ----
66
- |C s>|
67
- | S s|
68
- |C @ |
69
- ----
70
-
71
- > = Stairs
72
- @ = Warrior (20 HP)
73
- s = Sludge (12 HP)
74
- S = Thick Sludge (24 HP)
75
- C = Captive (1 HP)
73
+ ```
74
+ ----
75
+ |C s>|
76
+ | S s|
77
+ |C @ |
78
+ ----
76
79
 
80
+ > = Stairs
81
+ @ = Warrior (20 HP)
82
+ s = Sludge (12 HP)
83
+ S = Thick Sludge (24 HP)
84
+ C = Captive (1 HP)
85
+ ```
77
86
 
78
- == Commanding the Warrior
87
+
88
+ ## Commanding the Warrior
79
89
 
80
90
  When you first start, your warrior will only have a few abilities, but with each level your abilities will grow. A warrior has two kinds of abilities: actions and senses.
81
91
 
82
92
  An action is something that effects the game in some way. You can easily tell an action because it ends in an exclamation mark. Only one action can be performed per turn, so choose wisely. Here are some examples of actions.
83
93
 
84
- warrior.walk!
85
- Move in given direction (forward by default).
94
+ ```
95
+ warrior.walk!
96
+ Move in given direction (forward by default).
86
97
 
87
- warrior.attack!
88
- Attack the unit in given direction (forward by default).
98
+ warrior.attack!
99
+ Attack the unit in given direction (forward by default).
89
100
 
90
- warrior.rest!
91
- Gain 10% of max health back, but do nothing more.
101
+ warrior.rest!
102
+ Gain 10% of max health back, but do nothing more.
92
103
 
93
- warrior.bind!
94
- Bind unit in given direction to keep him from moving (forward by default).
104
+ warrior.bind!
105
+ Bind unit in given direction to keep him from moving (forward by default).
95
106
 
96
- warrior.rescue!
97
- Rescue a captive from his chains (earning 50 points) in given direction (forward by default).
107
+ warrior.rescue!
108
+ Rescue a captive from his chains (earning 20 points) in given direction (forward by default).
109
+ ```
98
110
 
99
111
 
100
112
  A sense is something which gathers information about the floor. You can perform senses as often as you want per turn to gather information about your surroundings and to aid you in choosing the proper action. Senses do NOT end in an exclamation mark.
101
113
 
102
- warrior.feel
103
- Returns a Space for the given direction (forward by default).
114
+ ```
115
+ warrior.feel
116
+ Returns a Space for the given direction (forward by default).
104
117
 
105
- warrior.health
106
- Returns an integer representing your health.
118
+ warrior.health
119
+ Returns an integer representing your health.
107
120
 
108
- warrior.distance
109
- Returns the number of spaces the stairs are away.
121
+ warrior.distance
122
+ Returns the number of spaces the stairs are away.
110
123
 
111
- warrior.listen
112
- Returns an array of all spaces which have units in them.
124
+ warrior.listen
125
+ Returns an array of all spaces which have units in them.
126
+ ```
113
127
 
114
128
 
115
129
  Since what you sense will change each turn, you should record what information you gather for use on the next turn. For example, you can determine if you are being attacked if your health has gone down since the last turn.
116
130
 
117
131
 
118
- == Spaces
132
+ ## Spaces
119
133
 
120
134
  Whenever you sense an area, often one or multiple spaces (in an array) will be returned. A space is an object representing a square in the level. You can call methods on a space to gather information about what is there. Here are the various methods you can call on a space.
121
135
 
122
- space.empty?
123
- If true, this means that nothing (except maybe stairs) is at this location and you can walk here.
124
-
125
- space.stairs?
126
- Determine if stairs are at that location
127
-
128
- space.enemy?
129
- Determine if an enemy unit is at this location.
130
-
131
- space.captive?
132
- Determine if a captive is at this location.
133
-
134
- space.wall?
135
- Returns true if this is the edge of the level. You can't walk here.
136
-
137
- space.ticking?
138
- Returns true if this space contains a bomb which will explode in time.
139
-
140
- space.golem?
141
- Returns true if a golem is occupying this space.
142
-
143
- You will often call these methods directly after a sense. For example, the "feel" sense returns one space. You can call "captive?" on this to determine if a captive is in front of you.
144
-
145
- warrior.feel.captive?
146
-
147
-
148
- == Golem
136
+ ```
137
+ space.empty?
138
+ If true, this means that nothing (except maybe stairs) is at this location and you can walk here.
139
+
140
+ space.stairs?
141
+ Determine if stairs are at that location
142
+
143
+ space.enemy?
144
+ Determine if an enemy unit is at this location.
145
+
146
+ space.captive?
147
+ Determine if a captive is at this location.
148
+
149
+ space.wall?
150
+ Returns true if this is the edge of the level. You can't walk here.
151
+
152
+ space.ticking?
153
+ Returns true if this space contains a bomb which will explode in time.
154
+
155
+ space.golem?
156
+ Returns true if a golem is occupying this space.
157
+ ```
158
+
159
+ You will often call these methods directly after a sense. For example, the `feel` sense returns one space. You can call `captive?` on this to determine if a captive is in front of you.
160
+
161
+ ```
162
+ warrior.feel.captive?
163
+ ```
164
+
165
+
166
+ ## Golem
149
167
 
150
168
  Along your journey you may discover the ability to create a golem. This is a separate unit which you also control. The turn handling is done through a block. Here is an example.
151
169
 
152
- warrior.form! do |golem|
153
- golem.attack! if golem.feel.enemy?
154
- end
170
+ ```rb
171
+ warrior.form! do |golem|
172
+ golem.attack! if golem.feel.enemy?
173
+ end
174
+ ```
155
175
 
156
176
  Complex logic can be placed in this block just like in the player turn method. You may want to move the logic into its own class or create multiple classes for different types of golems. You can create multiple golems in a level, but each one will take half of the warrior's health.
157
177
 
158
178
 
159
- == Epic Mode
160
-
179
+ ## Epic Mode
180
+
161
181
  Once you reach the top of the tower, you will enter epic mode. When running rubywarrior again it will run your current player.rb through all levels in the tower without stopping.
162
182
 
163
183
  Your warrior will most likely not succeed the first time around, so use the -l option on levels you are having difficulty or want to fine-tune the scoring.
164
184
 
165
- rubywarrior -l 3
185
+ ```sh
186
+ rubywarrior -l 3
187
+ ```
166
188
 
167
189
  Once your warrior reaches the top again you will receive an average grade, along with a grade for each level. The grades from best to worst are S, A, B, C, D and F. Try to get S on each level for the ultimate score.
168
190
 
169
- Note: I'm in the process of fine-tuning the grading system. If you find the "S" grade to be too easy or too difficult to achieve on a given level, please add an issue for this on GitHub.
191
+ Note: I'm in the process of fine-tuning the grading system. If you find the `S` grade to be too easy or too difficult to achieve on a given level, please add an issue for this on GitHub.
170
192
 
171
193
 
172
- == Tips
194
+ ## Tips
173
195
 
174
- If you ever get stuck on a level, review the README documentation and be sure you're trying each ability out. If you can't keep your health up, be sure to "rest" when no enemy is around (while keeping an eye on your health). Also, try to use far-ranged weapons whenever possible (such as the bow).
196
+ If you ever get stuck on a level, review the README documentation and be sure you're trying each ability out. If you can't keep your health up, be sure to `rest` when no enemy is around (while keeping an eye on your health). Also, try to use far-ranged weapons whenever possible (such as the bow).
175
197
 
176
- Remember, you're working in Ruby here. Don't simply fill up the "play_turn" method with a lot of code. Organize it with methods and classes. The player directory is set up as a load path so you can include other ruby files from your player.rb file.
198
+ Remember, you're working in Ruby here. Don't simply fill up the `play_turn` method with a lot of code. Organize it with methods and classes. The player directory is set up as a load path so you can include other ruby files from your player.rb file.
177
199
 
178
200
  Senses are cheap, so use them liberally. Store the sensed information to help you better determine what actions to take in the future.
179
201
 
180
- Running "rubywarrior" while you are in your profile directory will auto-select that profile so you don't have to each time.
202
+ Running `rubywarrior` while you are in your profile directory will auto-select that profile so you don't have to each time.
181
203
 
182
204
  If you're aiming for points, remember to sweep the area. Even if you're close to the stairs, don't go in until you've gotten everything (if you have the health). Use far-ranged senses (such as look and listen) to determine if there are any enemies left.
183
205
 
184
- Make sure to try the different options you can pass to the rubywarrior command. Run "rubywarrior --help" to see them all.
206
+ Make sure to try the different options you can pass to the rubywarrior command. Run `rubywarrior --help` to see them all.
data/bin/rubywarrior CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../lib/ruby_warrior'
2
+ require_relative '../lib/ruby_warrior'
3
3
 
4
4
  runner = RubyWarrior::Runner.new(ARGV, STDIN, STDOUT)
5
5
  runner.run
@@ -11,9 +11,9 @@ When /^I copy fixture "([^\"]*)" to "([^\"]*)"$/ do |from, to|
11
11
  end
12
12
 
13
13
  Then /^I should find file at "([^\"]*)"$/ do |path|
14
- File.exist?(path).should be_true
14
+ expect(File.exist?(path)).to eq(true)
15
15
  end
16
16
 
17
17
  Then /^I should find no file at "([^\"]*)"$/ do |path|
18
- File.exist?(path).should be_false
18
+ expect(File.exist?(path)).to eq(false)
19
19
  end
@@ -57,9 +57,9 @@ When /^I wait until it says "([^\"]*)"$/ do |phrase|
57
57
  end
58
58
 
59
59
  Then /^I should see "([^\"]*)"$/ do |phrase|
60
- @io.gets_until_include(phrase).should include(phrase)
60
+ expect(@io.gets_until_include(phrase)).to include(phrase)
61
61
  end
62
62
 
63
63
  Then /^I should not see "([^\"]*)" before "([^\"]*)"$/ do |first_phrase, second_phrase|
64
- @io.gets_until_include(second_phrase).should_not include(first_phrase)
64
+ expect(@io.gets_until_include(second_phrase)).to_not include(first_phrase)
65
65
  end
@@ -94,7 +94,9 @@ module RubyWarrior
94
94
  end
95
95
 
96
96
  def request_next_level
97
- if !Config.skip_input? && (next_level.exists? ? UI.ask("Would you like to continue on to the next level?") : UI.ask("Would you like to continue on to epic mode?"))
97
+ if Config.skip_input?
98
+ UI.puts "Staying on current level. Remove --skip option to continue on to the next level."
99
+ elsif (next_level.exists? ? UI.ask("Would you like to continue on to the next level?") : UI.ask("Would you like to continue on to epic mode?"))
98
100
  if next_level.exists?
99
101
  prepare_next_level
100
102
  UI.puts "See the updated README in the rubywarrior/#{profile.directory_name} directory."
@@ -103,7 +105,7 @@ module RubyWarrior
103
105
  UI.puts "Run rubywarrior again to play epic mode."
104
106
  end
105
107
  else
106
- UI.puts "Staying on current level. Try to earn more points next time."
108
+ UI.puts "Staying on current level."
107
109
  end
108
110
  end
109
111
 
@@ -19,7 +19,7 @@ module RubyWarrior
19
19
  # TODO refactor and test this method
20
20
  def generate
21
21
  if level.number == 1
22
- FileUtils.mkdir_p(level.player_path) unless File.exists? level.player_path
22
+ FileUtils.mkdir_p(level.player_path) unless File.exist? level.player_path
23
23
  FileUtils.cp(templates_path + '/player.rb', level.player_path)
24
24
  end
25
25
 
@@ -35,7 +35,7 @@ module RubyWarrior
35
35
  private
36
36
 
37
37
  def read_template(path)
38
- ERB.new(File.read(path), nil, '-').result(binding)
38
+ ERB.new(File.read(path), trim_mode: '-').result(binding)
39
39
  end
40
40
  end
41
41
  end
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "rubywarrior"
3
+ s.version = "0.2.0"
4
+ s.author = "Ryan Bates"
5
+ s.email = "ryan@railscasts.com"
6
+ s.homepage = "https://github.com/ryanb/ruby-warrior"
7
+ s.summary = "Game written in Ruby for learning Ruby."
8
+ s.description = "You play as a warrior climbing a tall tower. On each floor you need to write a Ruby script to instruct the warrior to battle enemies, rescue captives, and reach the stairs."
9
+ s.license = "MIT"
10
+
11
+ s.files = Dir["{lib,spec,features,towers,templates,bin}/**/*", "[A-Z]*", "init.rb"]
12
+ s.require_path = "lib"
13
+ s.executables = ["rubywarrior"]
14
+
15
+ s.required_rubygems_version = ">= 1.3.4"
16
+ end
@@ -5,33 +5,33 @@ describe RubyWarrior::Abilities::Attack do
5
5
  @attacker = stub(:position => stub, :attack_power => 3, :say => nil)
6
6
  @attack = RubyWarrior::Abilities::Attack.new(@attacker)
7
7
  end
8
-
8
+
9
9
  it "should subtract attack power amount from health" do
10
10
  receiver = RubyWarrior::Units::Base.new
11
11
  receiver.stubs(:alive?).returns(true)
12
12
  receiver.health = 5
13
13
  @attack.stubs(:unit).returns(receiver)
14
14
  @attack.perform
15
- receiver.health.should == 2
15
+ expect(receiver.health).to eq(2)
16
16
  end
17
-
17
+
18
18
  it "should do nothing if recipient is nil" do
19
19
  @attack.stubs(:unit).returns(nil)
20
- lambda { @attack.perform }.should_not raise_error
20
+ expect { @attack.perform }.to_not raise_error
21
21
  end
22
-
22
+
23
23
  it "should get object at position from offset" do
24
24
  @attacker.position.expects(:relative_space).with(1, 0)
25
25
  @attack.space(:forward)
26
26
  end
27
-
27
+
28
28
  it "should award points when killing unit" do
29
29
  receiver = stub(:take_damage => nil, :max_health => 8, :alive? => false)
30
30
  @attack.stubs(:unit).returns(receiver)
31
31
  @attacker.expects(:earn_points).with(8)
32
32
  @attack.perform
33
33
  end
34
-
34
+
35
35
  it "should not award points when not killing unit" do
36
36
  receiver = stub(:max_health => 8, :alive? => true)
37
37
  receiver.expects(:take_damage)
@@ -39,13 +39,13 @@ describe RubyWarrior::Abilities::Attack do
39
39
  @attacker.expects(:earn_points).never
40
40
  @attack.perform
41
41
  end
42
-
42
+
43
43
  it "should reduce attack power when attacking backward" do
44
44
  receiver = RubyWarrior::Units::Base.new
45
45
  receiver.stubs(:alive?).returns(true)
46
46
  receiver.health = 5
47
47
  @attack.stubs(:unit).returns(receiver)
48
48
  @attack.perform(:backward)
49
- receiver.health.should == 3
49
+ expect(receiver.health).to eq(3)
50
50
  end
51
51
  end