mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 16:49:11 +00:00
Fix QuestStage bug where it would not propery get the attribute.
This commit is contained in:
@@ -7,7 +7,8 @@ module TutorialInstructions
|
||||
# Sends the appropriate instruction to the player.
|
||||
def self.show_instruction(player)
|
||||
instructions = CONVERSATIONS[:tutorial_island_instructions]
|
||||
name = case player.tutorial_island_progress
|
||||
progress = player.tutorial_island_progress.name
|
||||
name = case progress
|
||||
# The Runescape Guide instructions.
|
||||
when :not_started then :getting_started
|
||||
when :runescape_guide_finished then :scenery
|
||||
@@ -17,6 +18,7 @@ module TutorialInstructions
|
||||
when :given_axe then :viewing_items
|
||||
when :cut_tree then :cut_tree
|
||||
when :cutting_tree then :please_wait
|
||||
else raise "No dialogue for current stage #{progress} exists."
|
||||
end
|
||||
|
||||
dialogue = instructions.part(name)
|
||||
|
||||
@@ -5,9 +5,11 @@ private
|
||||
STAGES = []
|
||||
|
||||
# The stages that are used when interacting with the Runescape Guide.
|
||||
STAGES << RUNESCAPE_GUIDE = [ :not_started, :talk_to_people, :go_through_door, :runescape_guide_finished, :moving_around ]
|
||||
RUNESCAPE_GUIDE = [ :not_started, :talk_to_people, :go_through_door, :runescape_guide_finished, :moving_around ]
|
||||
STAGES.concat(RUNESCAPE_GUIDE)
|
||||
|
||||
# The stages that are used when interacting with the Survival Expert.
|
||||
STAGES << SURVIVAL_EXPERT = [ :given_axe, :cut_tree, :cutting_tree, ]
|
||||
SURVIVAL_EXPERT = [ :given_axe, :cut_tree, :cutting_tree, ]
|
||||
STAGES.concat(SURVIVAL_EXPERT)
|
||||
|
||||
quest :tutorial_island, STAGES
|
||||
@@ -10,5 +10,7 @@
|
||||
<scripts>
|
||||
<script>repository.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
<dependencies>
|
||||
<dependency>attributes</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
# Defines a quest with the specified name.
|
||||
def quest(name, *stage_names)
|
||||
stages = Array.new(stage_names.size)
|
||||
stage_names.each_with_index { |stage, index| stages << stage.kind_of?(QuestStage) ? stage : QuestStage.new(stage, index, name) }
|
||||
def quest(name, stage_names)
|
||||
stages = { }
|
||||
stage_names.each_with_index { |stage, index| stages[stage] = QuestStage.new(stage, index, name) }
|
||||
|
||||
QUESTS[name] = Quest.new(name, stages)
|
||||
end
|
||||
@@ -18,6 +18,7 @@ class Quest
|
||||
|
||||
# Creates the Quest.
|
||||
def initialize(name, stages)
|
||||
raise "Quest name must be a symbol, received '#{name}'." unless name.kind_of?(Symbol)
|
||||
@name = name
|
||||
@stages = stages
|
||||
end
|
||||
@@ -34,7 +35,9 @@ class Quest
|
||||
|
||||
# Gets the QuestStage with the specified name.
|
||||
def stage(name)
|
||||
@stages[name]
|
||||
stage = @stages[name]
|
||||
raise "No stage named #{name} exists in #{@name}." if stage.nil?
|
||||
stage
|
||||
end
|
||||
|
||||
end
|
||||
@@ -113,14 +116,15 @@ class Player
|
||||
args[0] = arg.name if arg.kind_of?(QuestStage)
|
||||
end
|
||||
|
||||
result = super.method_missing(symbol, args)
|
||||
result = super(symbol, args)
|
||||
string = symbol.to_s
|
||||
|
||||
if (string.ends_with('_progress'))
|
||||
if (string.end_with?('_progress'))
|
||||
name = string[0..-10] # Cut the '_progress' from the end
|
||||
quest = QUESTS[name.to_sym]
|
||||
result = quest.stage(result) unless quest.nil?
|
||||
raise "No QuestStage with the name #{result} exists - define it as part of the Quest declaration." if result.nil?
|
||||
raise "No Quest with the name '#{name}' exists." if quest.nil?
|
||||
|
||||
result = quest.stage(result)
|
||||
end
|
||||
|
||||
result
|
||||
|
||||
Reference in New Issue
Block a user