rubywarrior 0.1.0 → 0.1.1

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.
@@ -1,3 +1,14 @@
1
+ 0.1.1 (Jan 3, 2010)
2
+
3
+ * Speeding up play speed a little
4
+
5
+ * Ticking captive explosion now kills everything on the floor, adjusting level 6 to compensate
6
+
7
+ * Adding intermediate level 7
8
+
9
+ * Keep track of last level played in profile and go back to normal mode when level is added
10
+
11
+
1
12
  0.1.0 (Jan 2, 2010)
2
13
 
3
14
  * initial release
@@ -28,7 +28,6 @@ Feature: Play levels
28
28
  When I run rubywarrior
29
29
  Then I should see "Joe - beginner - level 1"
30
30
 
31
- @focus
32
31
  Scenario: Replay levels as epic when finishing last level with grades
33
32
  When I copy fixture "short-tower" to "towers/short"
34
33
  Given a profile named "Bill" on "short"
@@ -49,3 +48,24 @@ Feature: Play levels
49
48
  Then I should see "grade for this tower"
50
49
  When I run rubywarrior
51
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"
@@ -2,13 +2,15 @@ module RubyWarrior
2
2
  module Abilities
3
3
  class Explode < Base
4
4
  def description
5
- "Kills you. You probably don't want to do this intentionally."
5
+ "Kills you and all surrounding units. You probably don't want to do this intentionally."
6
6
  end
7
7
 
8
8
  def perform
9
9
  if @unit.position
10
- @unit.say "explodes"
11
- @unit.take_damage(@unit.health)
10
+ @unit.say "explodes, collapsing the cealing and damanging every unit."
11
+ @unit.position.floor.units.map do |unit|
12
+ unit.take_damage(100)
13
+ end
12
14
  end
13
15
  end
14
16
  end
@@ -13,7 +13,15 @@ module RubyWarrior
13
13
  make_game_directory unless File.exist?(Config.path_prefix + '/rubywarrior')
14
14
  end
15
15
 
16
- profile.epic? ? play_epic_mode : play_normal_mode
16
+ if profile.epic?
17
+ if profile.level_after_epic?
18
+ go_back_to_normal_mode
19
+ else
20
+ play_epic_mode
21
+ end
22
+ else
23
+ play_normal_mode
24
+ end
17
25
  end
18
26
 
19
27
  def make_game_directory
@@ -111,6 +119,13 @@ module RubyWarrior
111
119
  profile.save # this saves score too
112
120
  end
113
121
 
122
+ def go_back_to_normal_mode
123
+ profile.enable_normal_mode
124
+ prepare_next_level
125
+ UI.puts "Another level has been added since you started epic, going back to normal mode."
126
+ UI.puts "See the updated README in the rubywarrior/#{profile.directory_name} directory."
127
+ end
128
+
114
129
 
115
130
  # profiles
116
131
 
@@ -2,7 +2,7 @@ require 'base64'
2
2
 
3
3
  module RubyWarrior
4
4
  class Profile
5
- attr_accessor :score, :epic_score, :current_epic_score, :average_grade, :current_epic_grades, :abilities, :level_number, :tower_path, :warrior_name, :player_path
5
+ attr_accessor :score, :epic_score, :current_epic_score, :average_grade, :current_epic_grades, :abilities, :level_number, :last_level_number, :tower_path, :warrior_name, :player_path
6
6
 
7
7
  def initialize
8
8
  @tower_path = nil
@@ -14,6 +14,7 @@ module RubyWarrior
14
14
  @average_grade = nil
15
15
  @abilities = []
16
16
  @level_number = 0
17
+ @last_level_number = nil
17
18
  end
18
19
 
19
20
  def encode
@@ -81,12 +82,27 @@ module RubyWarrior
81
82
  @epic = true
82
83
  @epic_score ||= 0
83
84
  @current_epic_score ||= 0
85
+ @last_level_number ||= @level_number
86
+ end
87
+
88
+ def enable_normal_mode
89
+ @epic = false
90
+ @epic_score = 0
91
+ @current_epic_score = 0
92
+ @current_epic_grades = {}
93
+ @average_grade = nil
94
+ @level_number = @last_level_number
95
+ @last_level_number = nil
84
96
  end
85
97
 
86
98
  def epic?
87
99
  @epic
88
100
  end
89
101
 
102
+ def level_after_epic?
103
+ Level.new(self, last_level_number+1).exists? if last_level_number
104
+ end
105
+
90
106
  def update_epic_score
91
107
  if @current_epic_score > @epic_score
92
108
  @epic_score = @current_epic_score
@@ -12,7 +12,7 @@ module RubyWarrior
12
12
  def run
13
13
  Config.in_stream = @stdin
14
14
  Config.out_stream = @stdout
15
- Config.delay = 0.8
15
+ Config.delay = 0.6
16
16
  parse_options
17
17
  @game.start
18
18
  end
@@ -2,20 +2,21 @@ require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  describe RubyWarrior::Abilities::Explode do
4
4
  before(:each) do
5
+ @floor = RubyWarrior::Floor.new
6
+ @floor.width = 2
7
+ @floor.height = 3
5
8
  @captive = RubyWarrior::Units::Captive.new
9
+ @floor.add(@captive, 0, 0)
6
10
  @explode = RubyWarrior::Abilities::Explode.new(@captive)
7
11
  end
8
12
 
9
- it "should set health to 0" do
10
- @captive.position = stub
13
+ it "should subtract 100 health from each unit on the floor" do
14
+ unit = RubyWarrior::Units::Base.new
15
+ unit.health = 20
16
+ @floor.add(unit, 0, 1)
11
17
  @captive.health = 10
12
18
  @explode.perform
13
- @captive.health.should == 0
14
- end
15
-
16
- it "should do nothing if no position" do
17
- @captive.health = 10
18
- @explode.perform
19
- @captive.health.should == 10
19
+ @captive.health.should == -90
20
+ unit.health.should == -80
20
21
  end
21
22
  end
@@ -94,6 +94,33 @@ describe RubyWarrior::Profile do
94
94
  @profile.current_epic_grades = {}
95
95
  @profile.calculate_average_grade.should be_nil
96
96
  end
97
+
98
+ it "should remember current level number as last_level_number" do
99
+ @profile.level_number = 7
100
+ @profile.enable_epic_mode
101
+ @profile.last_level_number.should == 7
102
+ end
103
+
104
+ it "should enable normal mode by clearing epic scores and resetting last level number" do
105
+ @profile.last_level_number = 7
106
+ @profile.epic_score = 123
107
+ @profile.current_epic_score = 100
108
+ @profile.current_epic_grades = { 1 => 100 }
109
+ @profile.average_grade = "C"
110
+ @profile.enable_normal_mode
111
+ @profile.should_not be_epic
112
+ @profile.epic_score.should be_zero
113
+ @profile.current_epic_score.should be_zero
114
+ @profile.last_level_number.should be_nil
115
+ @profile.average_grade.should be_nil
116
+ @profile.current_epic_grades.should == {}
117
+ @profile.level_number.should == 7
118
+ end
119
+
120
+ it "should be no level after epic if last level isn't specified" do
121
+ @profile.last_level_number = nil
122
+ @profile.should_not be_level_after_epic
123
+ end
97
124
 
98
125
  describe "with tower path" do
99
126
  before(:each) do
@@ -1,24 +1,22 @@
1
1
  # ------
2
- # | SC >|
3
- # |@ SC |
2
+ # |Cs >|
3
+ # |@ sC |
4
4
  # ------
5
5
 
6
6
  description "What's that ticking? Some captives have a timed bomb at their feet!"
7
- tip "It's best to rescue captives first that have space.ticking?, they'll soon go!"
7
+ tip "Hurry and rescue captives first that have space.ticking?, they'll soon go!"
8
8
  clue "Avoid fighting enemies at first. Go around them until you've rescued all of the ticking captives."
9
9
 
10
10
  time_bonus 50
11
- ace_score 130
11
+ ace_score 108
12
12
  size 6, 2
13
13
  stairs 5, 0
14
14
 
15
15
  warrior 0, 1, :east
16
16
 
17
- unit :thick_sludge, 1, 0, :west
18
- unit :thick_sludge, 3, 1, :west
19
- unit :captive, 2, 0, :west do |u|
20
- u.bomb_time = 6
21
- end
17
+ unit :sludge, 1, 0, :west
18
+ unit :sludge, 3, 1, :west
19
+ unit :captive, 0, 0, :west
22
20
  unit :captive, 4, 1, :west do |u|
23
- u.bomb_time = 10
21
+ u.bomb_time = 7
24
22
  end
@@ -0,0 +1,24 @@
1
+ # -----
2
+ # | sC >|
3
+ # |@ s C|
4
+ # | s |
5
+ # -----
6
+
7
+ description "Another ticking sound, but some sludge is blocking the way."
8
+ tip "Quickly kill the sludge and rescue the captive before the bomb goes off. You can't simply go around them."
9
+ clue "You'll need to bind the two other sludge first before killing the one blocking the way to the ticking captive."
10
+
11
+ time_bonus 70
12
+ ace_score 134
13
+ size 5, 3
14
+ stairs 4, 0
15
+
16
+ warrior 0, 1, :east
17
+
18
+ unit :sludge, 1, 0, :south
19
+ unit :sludge, 1, 2, :north
20
+ unit :sludge, 2, 1, :west
21
+ unit :captive, 4, 1, :west do |u|
22
+ u.bomb_time = 10
23
+ end
24
+ unit :captive, 2, 0, :west
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubywarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-02 00:00:00 -08:00
12
+ date: 2010-01-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -123,6 +123,7 @@ files:
123
123
  - towers/intermediate/level_004.rb
124
124
  - towers/intermediate/level_005.rb
125
125
  - towers/intermediate/level_006.rb
126
+ - towers/intermediate/level_007.rb
126
127
  - templates/player.rb
127
128
  - templates/README.erb
128
129
  - bin/rubywarrior