rubywarrior-i18n 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/CHANGELOG.rdoc +38 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +44 -0
  4. data/LICENSE +20 -0
  5. data/README.md +199 -0
  6. data/Rakefile +17 -0
  7. data/bin/rubywarrior +5 -0
  8. data/features/command_options.feature +46 -0
  9. data/features/levels.feature +71 -0
  10. data/features/profiles.feature +56 -0
  11. data/features/step_definitions/common_steps.rb +19 -0
  12. data/features/step_definitions/interaction_steps.rb +65 -0
  13. data/features/support/env.rb +12 -0
  14. data/features/support/mockio.rb +57 -0
  15. data/features/towers.feature +14 -0
  16. data/i18n/en.yml +232 -0
  17. data/i18n/es.yml +233 -0
  18. data/lib/ruby_warrior.rb +53 -0
  19. data/lib/ruby_warrior/abilities/attack.rb +25 -0
  20. data/lib/ruby_warrior/abilities/base.rb +44 -0
  21. data/lib/ruby_warrior/abilities/bind.rb +20 -0
  22. data/lib/ruby_warrior/abilities/detonate.rb +34 -0
  23. data/lib/ruby_warrior/abilities/direction_of.rb +13 -0
  24. data/lib/ruby_warrior/abilities/direction_of_stairs.rb +13 -0
  25. data/lib/ruby_warrior/abilities/distance_of.rb +13 -0
  26. data/lib/ruby_warrior/abilities/explode.rb +28 -0
  27. data/lib/ruby_warrior/abilities/feel.rb +14 -0
  28. data/lib/ruby_warrior/abilities/form.rb +25 -0
  29. data/lib/ruby_warrior/abilities/health.rb +13 -0
  30. data/lib/ruby_warrior/abilities/listen.rb +15 -0
  31. data/lib/ruby_warrior/abilities/look.rb +16 -0
  32. data/lib/ruby_warrior/abilities/pivot.rb +17 -0
  33. data/lib/ruby_warrior/abilities/rescue.rb +24 -0
  34. data/lib/ruby_warrior/abilities/rest.rb +20 -0
  35. data/lib/ruby_warrior/abilities/shoot.rb +24 -0
  36. data/lib/ruby_warrior/abilities/walk.rb +21 -0
  37. data/lib/ruby_warrior/config.rb +22 -0
  38. data/lib/ruby_warrior/core_additions.rb +29 -0
  39. data/lib/ruby_warrior/floor.rb +71 -0
  40. data/lib/ruby_warrior/game.rb +209 -0
  41. data/lib/ruby_warrior/level.rb +123 -0
  42. data/lib/ruby_warrior/level_loader.rb +56 -0
  43. data/lib/ruby_warrior/player_generator.rb +41 -0
  44. data/lib/ruby_warrior/position.rb +82 -0
  45. data/lib/ruby_warrior/profile.rb +120 -0
  46. data/lib/ruby_warrior/runner.rb +34 -0
  47. data/lib/ruby_warrior/space.rb +71 -0
  48. data/lib/ruby_warrior/tower.rb +14 -0
  49. data/lib/ruby_warrior/turn.rb +38 -0
  50. data/lib/ruby_warrior/ui.rb +54 -0
  51. data/lib/ruby_warrior/units/archer.rb +34 -0
  52. data/lib/ruby_warrior/units/base.rb +100 -0
  53. data/lib/ruby_warrior/units/captive.rb +17 -0
  54. data/lib/ruby_warrior/units/golem.rb +20 -0
  55. data/lib/ruby_warrior/units/sludge.rb +30 -0
  56. data/lib/ruby_warrior/units/thick_sludge.rb +13 -0
  57. data/lib/ruby_warrior/units/warrior.rb +73 -0
  58. data/lib/ruby_warrior/units/wizard.rb +34 -0
  59. data/lib/ruby_warrior/version.rb +3 -0
  60. data/spec/fixtures/short-tower/level_001.rb +15 -0
  61. data/spec/fixtures/short-tower/level_002.rb +15 -0
  62. data/spec/fixtures/walking_player.rb +5 -0
  63. data/spec/ruby_warrior/abilities/attack_spec.rb +51 -0
  64. data/spec/ruby_warrior/abilities/base_spec.rb +38 -0
  65. data/spec/ruby_warrior/abilities/bind_spec.rb +19 -0
  66. data/spec/ruby_warrior/abilities/direction_of_spec.rb +13 -0
  67. data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +13 -0
  68. data/spec/ruby_warrior/abilities/distance_of_spec.rb +13 -0
  69. data/spec/ruby_warrior/abilities/explode_spec.rb +32 -0
  70. data/spec/ruby_warrior/abilities/feel_spec.rb +13 -0
  71. data/spec/ruby_warrior/abilities/form_spec.rb +48 -0
  72. data/spec/ruby_warrior/abilities/health_spec.rb +13 -0
  73. data/spec/ruby_warrior/abilities/listen_spec.rb +17 -0
  74. data/spec/ruby_warrior/abilities/look_spec.rb +15 -0
  75. data/spec/ruby_warrior/abilities/pivot_spec.rb +18 -0
  76. data/spec/ruby_warrior/abilities/rescue_spec.rb +40 -0
  77. data/spec/ruby_warrior/abilities/rest_spec.rb +29 -0
  78. data/spec/ruby_warrior/abilities/shoot_spec.rb +22 -0
  79. data/spec/ruby_warrior/abilities/throw_spec.rb +46 -0
  80. data/spec/ruby_warrior/abilities/walk_spec.rb +25 -0
  81. data/spec/ruby_warrior/core_additions_spec.rb +7 -0
  82. data/spec/ruby_warrior/floor_spec.rb +81 -0
  83. data/spec/ruby_warrior/game_spec.rb +119 -0
  84. data/spec/ruby_warrior/level_loader_spec.rb +54 -0
  85. data/spec/ruby_warrior/level_spec.rb +203 -0
  86. data/spec/ruby_warrior/player_generator_spec.rb +12 -0
  87. data/spec/ruby_warrior/position_spec.rb +108 -0
  88. data/spec/ruby_warrior/profile_spec.rb +171 -0
  89. data/spec/ruby_warrior/space_spec.rb +190 -0
  90. data/spec/ruby_warrior/tower_spec.rb +15 -0
  91. data/spec/ruby_warrior/turn_spec.rb +42 -0
  92. data/spec/ruby_warrior/ui_spec.rb +93 -0
  93. data/spec/ruby_warrior/units/archer_spec.rb +23 -0
  94. data/spec/ruby_warrior/units/base_spec.rb +133 -0
  95. data/spec/ruby_warrior/units/captive_spec.rb +23 -0
  96. data/spec/ruby_warrior/units/golem_spec.rb +28 -0
  97. data/spec/ruby_warrior/units/sludge_spec.rb +27 -0
  98. data/spec/ruby_warrior/units/thick_sludge_spec.rb +19 -0
  99. data/spec/ruby_warrior/units/warrior_spec.rb +65 -0
  100. data/spec/ruby_warrior/units/wizard_spec.rb +23 -0
  101. data/spec/spec_helper.rb +10 -0
  102. data/templates/README.erb +33 -0
  103. data/templates/player.rb +5 -0
  104. data/towers/beginner/level_001.rb +18 -0
  105. data/towers/beginner/level_002.rb +19 -0
  106. data/towers/beginner/level_003.rb +23 -0
  107. data/towers/beginner/level_004.rb +20 -0
  108. data/towers/beginner/level_005.rb +24 -0
  109. data/towers/beginner/level_006.rb +21 -0
  110. data/towers/beginner/level_007.rb +20 -0
  111. data/towers/beginner/level_008.rb +23 -0
  112. data/towers/beginner/level_009.rb +22 -0
  113. data/towers/intermediate/level_001.rb +20 -0
  114. data/towers/intermediate/level_002.rb +22 -0
  115. data/towers/intermediate/level_003.rb +25 -0
  116. data/towers/intermediate/level_004.rb +26 -0
  117. data/towers/intermediate/level_005.rb +21 -0
  118. data/towers/intermediate/level_006.rb +25 -0
  119. data/towers/intermediate/level_007.rb +27 -0
  120. data/towers/intermediate/level_008.rb +25 -0
  121. data/towers/intermediate/level_009.rb +33 -0
  122. metadata +226 -0
@@ -0,0 +1,38 @@
1
+ 0.1.3 (April 28, 2012)
2
+
3
+ * Making specs pass with latest RSpec.
4
+
5
+ * Lowering ace score for Beginner Level 6.
6
+
7
+ * Store relative tower paths in Profile so files can be moved.
8
+
9
+ * Other minor bug fixes (see commit history for details)
10
+
11
+
12
+ 0.1.2 (September 23, 2010)
13
+
14
+ * Adding intermediate level 9 with distance_of ability
15
+
16
+ * Adding intermediate level 8 with look and detonate abilities
17
+
18
+ * Raising an exception when performing an ability with a bad direction.
19
+
20
+ * Hard wrapping clue text to 80 characters
21
+
22
+ * Mention direction when ability is performed
23
+
24
+
25
+ 0.1.1 (Jan 3, 2010)
26
+
27
+ * Speeding up play speed a little
28
+
29
+ * Ticking captive explosion now kills everything on the floor, adjusting level 6 to compensate
30
+
31
+ * Adding intermediate level 7
32
+
33
+ * Keep track of last level played in profile and go back to normal mode when level is added
34
+
35
+
36
+ 0.1.0 (Jan 2, 2010)
37
+
38
+ * initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubywarrior-i18n (0.0.1)
5
+ r18n-desktop (= 1.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ builder (3.0.0)
11
+ cucumber (1.2.1)
12
+ builder (>= 2.1.2)
13
+ diff-lcs (>= 1.1.3)
14
+ gherkin (~> 2.11.0)
15
+ json (>= 1.4.6)
16
+ diff-lcs (1.1.3)
17
+ gherkin (2.11.1)
18
+ json (>= 1.4.6)
19
+ json (1.7.3)
20
+ metaclass (0.0.1)
21
+ mocha (0.11.4)
22
+ metaclass (~> 0.0.1)
23
+ r18n-core (1.0.0)
24
+ r18n-desktop (1.0.0)
25
+ r18n-core (= 1.0.0)
26
+ rake (0.9.2.2)
27
+ rspec (2.8.0)
28
+ rspec-core (~> 2.8.0)
29
+ rspec-expectations (~> 2.8.0)
30
+ rspec-mocks (~> 2.8.0)
31
+ rspec-core (2.8.0)
32
+ rspec-expectations (2.8.0)
33
+ diff-lcs (~> 1.1.2)
34
+ rspec-mocks (2.8.0)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ cucumber (= 1.2.1)
41
+ mocha (= 0.11.4)
42
+ rake
43
+ rspec (= 2.8.0)
44
+ rubywarrior-i18n!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Ryan Bates
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,199 @@
1
+ # Ruby Warrior (i18n-ed version)
2
+
3
+ This is a game designed to teach the Ruby language and artificial intelligence in a fun, interactive way.
4
+
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
+
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
+
9
+ # i18n-ed version
10
+
11
+ This is an exact copy of the Ryan Bates' game but I implemented [i18n](http://en.wikipedia.org/wiki/Internationalization_and_localization) to be easily translated and to use it in [KidsRuby](http://en.wikipedia.org/wiki/Internationalization_and_localization).
12
+
13
+ This version includes english as one of the currently supported languages, so `rubywarriorwarrior-i18n` in english and the official game are exactly the same.
14
+
15
+ Currently supported languages:
16
+
17
+ * English
18
+ * Spanish
19
+
20
+ If you want to translate `ruby-warrior-i18n` to your native language feel free to do it, here are the instructions:
21
+
22
+ * Fork this repo
23
+ * Create a topic branch named after the name of your language in english (ie. japanese, german, french)
24
+ * Create a yml file in the `i18n/` folder named after your languages' [two-letter code](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table)
25
+ * Make a pull request
26
+
27
+ ## Getting Started
28
+
29
+ First install the gem.
30
+
31
+ gem install rubywarrior-i18n
32
+
33
+ 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:
34
+
35
+ class Player
36
+ def play_turn(warrior)
37
+ # your code goes here
38
+ end
39
+ end
40
+
41
+ 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.
42
+
43
+ Here is a simple example which will instruct the warrior to attack if he feels an enemy, otherwise he will walk forward.
44
+
45
+ class Player
46
+ def play_turn(warrior)
47
+ if warrior.feel.enemy?
48
+ warrior.attack!
49
+ else
50
+ warrior.walk!
51
+ end
52
+ end
53
+ end
54
+
55
+ 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.
56
+
57
+ 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.
58
+
59
+ 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.
60
+
61
+ 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.
62
+
63
+ ## Scoring
64
+
65
+ 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.
66
+
67
+ * defeat an enemy to add his max health to your score
68
+ * rescue a captive to earn 20 points
69
+ * pass the level within the bonus time to earn the amount of bonus time remaining
70
+ * defeat all enemies and rescue all captives to receive a 20% overall bonus
71
+
72
+ A total score is kept as you progress through the levels. When you pass a level, that score is added to your total.
73
+
74
+ 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.
75
+
76
+ ## Perspective
77
+
78
+ 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.
79
+
80
+ ----
81
+ |C s>|
82
+ | S s|
83
+ |C @ |
84
+ ----
85
+
86
+ > = Stairs
87
+ @ = Warrior (20 HP)
88
+ s = Sludge (12 HP)
89
+ S = Thick Sludge (24 HP)
90
+ C = Captive (1 HP)
91
+
92
+
93
+ ## Commanding the Warrior
94
+
95
+ 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.
96
+
97
+ 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.
98
+
99
+ warrior.walk!
100
+ Move in given direction (forward by default).
101
+
102
+ warrior.attack!
103
+ Attack the unit in given direction (forward by default).
104
+
105
+ warrior.rest!
106
+ Gain 10% of max health back, but do nothing more.
107
+
108
+ warrior.bind!
109
+ Bind unit in given direction to keep him from moving (forward by default).
110
+
111
+ warrior.rescue!
112
+ Rescue a captive from his chains (earning 50 points) in given direction (forward by default).
113
+
114
+
115
+ 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.
116
+
117
+ warrior.feel
118
+ Returns a Space for the given direction (forward by default).
119
+
120
+ warrior.health
121
+ Returns an integer representing your health.
122
+
123
+ warrior.distance
124
+ Returns the number of spaces the stairs are away.
125
+
126
+ warrior.listen
127
+ Returns an array of all spaces which have units in them.
128
+
129
+
130
+ 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.
131
+
132
+ ## Spaces
133
+
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.
135
+
136
+ space.empty?
137
+ If true, this means that nothing (except maybe stairs) is at this location and you can walk here.
138
+
139
+ space.stairs?
140
+ Determine if stairs are at that location
141
+
142
+ space.enemy?
143
+ Determine if an enemy unit is at this location.
144
+
145
+ space.captive?
146
+ Determine if a captive is at this location.
147
+
148
+ space.wall?
149
+ Returns true if this is the edge of the level. You can't walk here.
150
+
151
+ space.ticking?
152
+ Returns true if this space contains a bomb which will explode in time.
153
+
154
+ space.golem?
155
+ Returns true if a golem is occupying this space.
156
+
157
+ 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.
158
+
159
+ warrior.feel.captive?
160
+
161
+ ## Golem
162
+
163
+ 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.
164
+
165
+ warrior.form! do |golem|
166
+ golem.attack! if golem.feel.enemy?
167
+ end
168
+
169
+ 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.
170
+
171
+ ## Epic Mode
172
+
173
+ 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.
174
+
175
+ 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.
176
+
177
+ rubywarrior -l 3
178
+
179
+ 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.
180
+
181
+ 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.
182
+
183
+ ## Tips
184
+
185
+ 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).
186
+
187
+ 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.
188
+
189
+ Senses are cheap, so use them liberally. Store the sensed information to help you better determine what actions to take in the future.
190
+
191
+ Running `rubywarrior` while you are in your profile directory will auto-select that profile so you don't have to each time.
192
+
193
+ 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.
194
+
195
+ Make sure to try the different options you can pass to the `rubywarrior` command. Run `rubywarrior --help` to see them all.
196
+
197
+ ## TODO
198
+
199
+ Implement i18n in cucumber and rspec tests
@@ -0,0 +1,17 @@
1
+ require 'rake'
2
+ require 'rspec'
3
+ require 'rspec/core/rake_task'
4
+ require 'cucumber'
5
+ require 'cucumber/rake/task'
6
+ require 'bundler/gem_tasks'
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ t.pattern = "spec/**/*_spec.rb"
11
+ end
12
+
13
+ Cucumber::Rake::Task.new(:features) do |t|
14
+ t.cucumber_opts = "features --format progress"
15
+ end
16
+
17
+ task :default => [:spec, :features]
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../lib/ruby_warrior'
3
+
4
+ runner = RubyWarrior::Runner.new(ARGV, STDIN, STDOUT)
5
+ runner.run
@@ -0,0 +1,46 @@
1
+ Feature: Command Options
2
+ In order to play the game the way I want
3
+ As a player
4
+ I want to customize rubywarrior with options
5
+
6
+ Background:
7
+ Given no profile at "tmp"
8
+
9
+ Scenario: Run ruby warrior in specified directory with -d option
10
+ Given a profile named "Joe" on "beginner"
11
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
12
+ And I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0"
13
+ And I answer "y" to "next level"
14
+ Then I should see "the updated README in the rubywarrior/joe-beginner directory"
15
+
16
+ Scenario: Skip user input with -s option
17
+ Given a profile named "Joe" on "beginner"
18
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
19
+ And I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0 -s"
20
+ Then I should see "current level"
21
+ When I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0"
22
+ And I answer "y" to "next level"
23
+ Then I should see "the updated README in the rubywarrior/joe-beginner directory"
24
+ When I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -t 0 -s"
25
+ Then I should see "failed level 2"
26
+
27
+ Scenario: Unable to practice level if not epic
28
+ Given a profile named "Joe" on "beginner"
29
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
30
+ And I run rubywarrior with options "-d tmp/rubywarrior/joe-beginner -l 2"
31
+ Then I should see "Unable"
32
+
33
+ Scenario: Practice specific level when epic
34
+ When I copy fixture "short-tower" to "towers/short"
35
+ Given a profile named "Bill" on "short"
36
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/bill-short/player.rb"
37
+ And I run rubywarrior
38
+ And I choose "Bill - short - level 1" for "profile"
39
+ Then I answer "y" to "next level"
40
+ And I should see "the updated README in the rubywarrior/bill-short directory"
41
+ When I run rubywarrior
42
+ And I choose "Bill - short - level 2" for "profile"
43
+ Then I answer "y" to "epic"
44
+ And I should see "epic mode"
45
+ When I run rubywarrior with options "-d tmp/rubywarrior/bill-short -l 2"
46
+ Then I should not see "Level 1" before "Total Score: 17"
@@ -0,0 +1,71 @@
1
+ Feature: Play levels
2
+ In order to play ruby warrior
3
+ As a player
4
+ I want to advance through levels or retry them
5
+
6
+ Background:
7
+ Given no profile at "tmp"
8
+
9
+ Scenario: Pass first level, fail second level
10
+ Given a profile named "Joe" on "beginner"
11
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
12
+ And I run rubywarrior
13
+ And I choose "Joe - beginner - level 1" for "profile"
14
+ And I answer "y" to "next level"
15
+ Then I should see "the updated README in the rubywarrior/joe-beginner directory"
16
+ When I run rubywarrior
17
+ And I choose "Joe - beginner - level 2" for "profile"
18
+ And I answer "y" to "clues"
19
+ Then I should see "warrior.feel.empty?"
20
+
21
+ Scenario: Retry first level
22
+ Given a profile named "Joe" on "beginner"
23
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/joe-beginner/player.rb"
24
+ And I run rubywarrior
25
+ And I choose "Joe - beginner - level 1" for "profile"
26
+ And I answer "n" to "next level"
27
+ Then I should see "current level"
28
+ When I run rubywarrior
29
+ Then I should see "Joe - beginner - level 1"
30
+
31
+ Scenario: Replay levels as epic when finishing last level with grades
32
+ When I copy fixture "short-tower" to "towers/short"
33
+ Given a profile named "Bill" on "short"
34
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/bill-short/player.rb"
35
+ And I run rubywarrior
36
+ And I choose "Bill - short - level 1" for "profile"
37
+ Then I answer "y" to "next level"
38
+ And I should see "the updated README in the rubywarrior/bill-short directory"
39
+ When I run rubywarrior
40
+ And I choose "Bill - short - level 2" for "profile"
41
+ Then I answer "y" to "epic"
42
+ And I should see "epic mode"
43
+ When I run rubywarrior
44
+ And I choose "Bill - short - first score 34 - epic score 0" for "profile"
45
+ Then I should see "Level Grade: S"
46
+ When I run rubywarrior
47
+ And I choose "Bill - short - first score 34 - epic score 34" for "profile"
48
+ Then I should see "grade for this tower"
49
+ When I run rubywarrior
50
+ Then I should see "Bill - short - first score 34 - epic score 34"
51
+
52
+ Scenario: Continue normal mode after epic mode when level added
53
+ When I copy fixture "short-tower" to "towers/short"
54
+ Given a profile named "Bob" on "short"
55
+ When I copy fixture "walking_player.rb" to "tmp/rubywarrior/bob-short/player.rb"
56
+ And I run rubywarrior
57
+ And I choose "Bob - short - level 1" for "profile"
58
+ Then I answer "y" to "next level"
59
+ And I should see "the updated README in the rubywarrior/bob-short directory"
60
+ When I run rubywarrior
61
+ And I choose "Bob - short - level 2" for "profile"
62
+ Then I answer "y" to "epic"
63
+ And I should see "epic mode"
64
+ When I copy fixture "short-tower/level_002.rb" to "towers/short/level_003.rb"
65
+ And I run rubywarrior
66
+ And I choose "Bob - short - first score 34 - epic score 0" for "profile"
67
+ And I should see "Another level"
68
+ When I run rubywarrior
69
+ And I choose "Bob - short - level 3" for "profile"
70
+ Then I answer "y" to "epic"
71
+ And I should see "epic mode"