|
| 1 | +require File.dirname(__FILE__) + '/../../spec_helper' |
| 2 | + |
| 3 | +describe RubyWarrior::Abilities::Form do |
| 4 | + before(:each) do |
| 5 | + @floor = RubyWarrior::Floor.new |
| 6 | + @floor.width = 2 |
| 7 | + @floor.height = 3 |
| 8 | + @warrior = RubyWarrior::Units::Warrior.new |
| 9 | + @floor.add(@warrior, 0, 0, :east) |
| 10 | + @form = RubyWarrior::Abilities::Form.new(@warrior) |
| 11 | + end |
| 12 | + |
| 13 | + it "should form a golem in front of warrior" do |
| 14 | + @form.perform |
| 15 | + @floor.get(1, 0).should be_kind_of(RubyWarrior::Units::Golem) |
| 16 | + end |
| 17 | + |
| 18 | + it "should form a golem in given direction" do |
| 19 | + @form.perform(:right) |
| 20 | + @floor.get(0, 1).should be_kind_of(RubyWarrior::Units::Golem) |
| 21 | + end |
| 22 | + |
| 23 | + it "should not form golem if space isn't empty" do |
| 24 | + @floor.add(RubyWarrior::Units::Base.new, 1, 0) |
| 25 | + @form.perform(:forward) |
| 26 | + @form.perform(:left) |
| 27 | + @floor.units.size.should == 2 |
| 28 | + end |
| 29 | + |
| 30 | + it "should reduce warrior's health by half (rounding down) and give it to the golem" do |
| 31 | + @warrior.health = 19 |
| 32 | + @form.perform |
| 33 | + @warrior.health.should == 10 |
| 34 | + @floor.get(1, 0).max_health.should == 9 |
| 35 | + end |
| 36 | + |
| 37 | + it "should add passed block as golem's turn block" do |
| 38 | + @passed = nil |
| 39 | + @form.perform(:forward) { |turn| @passed = turn } |
| 40 | + @floor.get(1, 0).play_turn(:turn) |
| 41 | + @passed.should == :turn |
| 42 | + end |
| 43 | + |
| 44 | + it "should start in same direction as warrior" do |
| 45 | + @form.perform(:right) |
| 46 | + @floor.get(0, 1).position.direction.should == :east |
| 47 | + end |
| 48 | +end |
0 commit comments