summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rubywarrior/ultimate-beginner/.profile10
-rw-r--r--rubywarrior/ultimate-beginner/README15
-rw-r--r--rubywarrior/ultimate-beginner/player.rb12
-rw-r--r--rubywarrior/ultimate-beginner/spec/player_spec.rb43
4 files changed, 59 insertions, 21 deletions
diff --git a/rubywarrior/ultimate-beginner/.profile b/rubywarrior/ultimate-beginner/.profile
index 1654c9c..eeef16e 100644
--- a/rubywarrior/ultimate-beginner/.profile
+++ b/rubywarrior/ultimate-beginner/.profile
@@ -3,9 +3,9 @@ c2Vycy9tby8ucnZtL2dlbXMvcnVieS0xLjkuMy1wMzkyQHJ1Ynktd2Fycmlv
ci9nZW1zL3J1Ynl3YXJyaW9yLTAuMS4zL3Rvd2Vycy9Vc2Vycy9tby8ucnZt
L2dlbXMvcnVieS0xLjkuMy1wMzkyQHJ1Ynktd2Fycmlvci9nZW1zL3J1Ynl3
YXJyaW9yLTAuMS4zL3Rvd2Vycy9iZWdpbm5lcgY6BkVUOhJAd2Fycmlvcl9u
-YW1lSSINdWx0aW1hdGUGOwdUOgtAc2NvcmVpKToYQGN1cnJlbnRfZXBpY19z
+YW1lSSINdWx0aW1hdGUGOwdUOgtAc2NvcmVpYzoYQGN1cnJlbnRfZXBpY19z
Y29yZWkAOhlAY3VycmVudF9lcGljX2dyYWRlc3sAOhBAZXBpY19zY29yZWkA
-OhNAYXZlcmFnZV9ncmFkZTA6D0BhYmlsaXRpZXNbCDoJZmVlbDoMYXR0YWNr
-IToKd2FsayE6EkBsZXZlbF9udW1iZXJpCDoXQGxhc3RfbGV2ZWxfbnVtYmVy
-MDoRQHBsYXllcl9wYXRoSSIkLi9ydWJ5d2Fycmlvci91bHRpbWF0ZS1iZWdp
-bm5lcgY7B1Q=
+OhNAYXZlcmFnZV9ncmFkZTA6D0BhYmlsaXRpZXNbCjoLaGVhbHRoOgpyZXN0
+IToJZmVlbDoMYXR0YWNrIToKd2FsayE6EkBsZXZlbF9udW1iZXJpCToXQGxh
+c3RfbGV2ZWxfbnVtYmVyMDoRQHBsYXllcl9wYXRoSSIkLi9ydWJ5d2Fycmlv
+ci91bHRpbWF0ZS1iZWdpbm5lcgY7B1Q=
diff --git a/rubywarrior/ultimate-beginner/README b/rubywarrior/ultimate-beginner/README
index 9e60688..a058fe4 100644
--- a/rubywarrior/ultimate-beginner/README
+++ b/rubywarrior/ultimate-beginner/README
@@ -1,16 +1,17 @@
-Level 3
+Level 4
-The air feels thicker than before. There must be a horde of sludge.
+You can hear bow strings being stretched.
-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.
+Tip: No new abilities this time, but you must be careful not to rest while taking damage. Save a @health instance variable and compare it on each turn to see if you're taking damage.
- ---------
-|@ s ss s>|
- ---------
+ -------
+|@ Sa S>|
+ -------
> = Stairs
@ = ultimate (20 HP)
- s = Sludge (12 HP)
+ S = Thick Sludge (24 HP)
+ a = Archer (7 HP)
Warrior Abilities:
diff --git a/rubywarrior/ultimate-beginner/player.rb b/rubywarrior/ultimate-beginner/player.rb
index b2cec68..616628f 100644
--- a/rubywarrior/ultimate-beginner/player.rb
+++ b/rubywarrior/ultimate-beginner/player.rb
@@ -1,9 +1,17 @@
class Player
def play_turn(warrior)
if warrior.feel.empty?
- warrior.walk!
+ if warrior.health == 20
+ warrior.walk!
+ else
+ warrior.rest!
+ end
else
- warrior.attack!
+ if warrior.health == 20
+ warrior.attack!
+ else
+ warrior.walk!(:backward)
+ end
end
end
end
diff --git a/rubywarrior/ultimate-beginner/spec/player_spec.rb b/rubywarrior/ultimate-beginner/spec/player_spec.rb
index 2fe4450..32ee857 100644
--- a/rubywarrior/ultimate-beginner/spec/player_spec.rb
+++ b/rubywarrior/ultimate-beginner/spec/player_spec.rb
@@ -6,7 +6,6 @@ describe Player do
let(:sut) { Player.new }
let(:warrior) { fake }
-
context "when there is no obstacle" do
let(:feeling) { fake }
@@ -15,10 +14,24 @@ describe Player do
feeling.stub(:empty?).and_return(true)
end
- before { sut.play_turn(warrior) }
+ context "when your health is full" do
+ before { warrior.stub(:health).and_return(20) }
+
+ before { sut.play_turn(warrior) }
- it "should walk" do
- warrior.should have_received(:walk!)
+ it "should walk" do
+ warrior.should have_received(:walk!)
+ end
+ end
+
+ context "when your health is low" do
+ before { warrior.stub(:health).and_return(19) }
+
+ before { sut.play_turn(warrior) }
+
+ it "should rest" do
+ warrior.should have_received(:rest!)
+ end
end
end
@@ -30,10 +43,26 @@ describe Player do
feeling.stub(:empty?).and_return(false)
end
- before { sut.play_turn(warrior) }
+ context "when your health is full" do
+ before :each do
+ warrior.stub(:health).and_return(20)
+ end
+
+ before { sut.play_turn(warrior) }
+
+ it "should attack the sludge" do
+ warrior.should have_received(:attack!)
+ end
+ end
- it "should attack the sludge" do
- warrior.should have_received(:attack!)
+ context "when your health is low" do
+ before :each do
+ warrior.stub(:health).and_return(19)
+ end
+ it "should walk backwards then rest" do
+ sut.play_turn(warrior)
+ warrior.should have_received(:walk!, :backward)
+ end
end
end
end