Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

inventory usage cuke test

  • Loading branch information...
commit 425f88c2b48494ce892d7b978622a908c363036d 1 parent 5b2936b
@bgoodspeed authored
View
25 features/inventory.feature
@@ -0,0 +1,25 @@
+Feature: menu
+ In order to use items, see stats, etc
+ As a player on the worldmap
+ I want to use items
+
+
+Scenario: using items from inventory
+ Given I press 'Menu'
+ And 2 ticks have passed
+ And I should be on 'Status'
+ And I press 'Down'
+ And 2 ticks have passed
+ And I should be on 'Inventory'
+ And I press 'Right'
+ And 2 ticks have passed
+ And I should be on 'All Items'
+ And I press 'Right'
+ And 2 ticks have passed
+ And I press 'Right'
+ And 2 ticks have passed
+ And I should be on 'hero'
+ And I press 'Right'
+ When 2 ticks have passed
+ Then I should see the Menu Layer
+ And I should be on 'hero'
View
22 features/menu.feature
@@ -3,15 +3,29 @@ Feature: menu
As a player on the worldmap
I want to load a menu
+Scenario: navigating submenu
+ Given I press 'Menu'
+ And 2 ticks have passed
+ And I should be on 'Status'
+ And I press 'Right'
+ When 2 ticks have passed
+ And I press 'Down'
+ When 2 ticks have passed
+ Then I should see the Menu Layer
+ And I should be on 'cohort'
+ And the current menu shows 'hero'
+ And the current menu shows 'cohort'
+
+
+
Scenario Outline: navigating menu
- Given I am at 320, 240
- And I press 'Menu'
+ Given I press 'Menu'
And 2 ticks have passed
- And I should be on Status
+ And I should be on 'Status'
And I press '<button>'
When 2 ticks have passed
Then I should see the Menu Layer
- And I should be on <active_menu_entry>
+ And I should be on '<active_menu_entry>'
And the current menu shows 'Status'
And the current menu shows 'Inventory'
And the current menu shows 'Levelup'
View
9 features/step_definitions/walkthrough_steps.rb
@@ -10,8 +10,6 @@
called = 0
Given /^I am at (\d+), (\d+)$/ do |x, y|
- @g = Game.new
-
@g.set_player_position(x.to_i,y.to_i)
@original_item_count = @g.inventory_count
end
@@ -86,14 +84,17 @@ def press(what)
@g.inventory_count.should == arg1.to_i + @original_item_count
end
+Given /^I should be on 'All Items'$/ do
+ @g.current_selected_menu_entry_name.should == "All Items"
+end
-Then /^I should be on (\w+)$/ do |arg1|
+Then /^I should be on '(\w+\.*\w*)'$/ do |arg1|
@g.current_selected_menu_entry_name.should == arg1
end
include UtilityMatchers
-Then /^the current menu shows '(\w+)'$/ do |what|
+Then /^the current menu shows '(\.+)'$/ do |what|
@g.current_menu_entries.should contain? what
end
View
7 features/support/env.rb
@@ -0,0 +1,7 @@
+# "before all"
+
+
+Before do
+ @g = Game.new
+end
+
View
10 lib/menu/inventory_display_action.rb
@@ -1,5 +1,7 @@
class InventoryDisplayAction
+ include Rubygame
+
attr_reader :text
def initialize(text, game, menu_helper)
@text = text
@@ -28,8 +30,12 @@ def surface_for(posn)
end
- def option_at(idx)
- party_members
+ def option_at(idx=nil)
+ if idx.nil?
+ party_members
+ else
+ party_members[idx]
+ end
end
def party_members
View
15 lib/menu/menu_helper.rb
@@ -19,7 +19,20 @@ def current_menu_entries
end
def current_selected_menu_entry_name
- @text_lines[@cursor_position]
+ if @show_section
+ if subsection_active?(@section_position)
+ if @needs_option
+ active_subsection.option_at(@option_position).name
+ else
+ active_subsection.info[@subsection_position].name
+ end
+
+ else
+ active_section.content[@section_position].text
+ end
+ else
+ @text_lines[@cursor_position]
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.