Created
December 2, 2017 01:15
-
-
Save sandersch/32c1eff774b7521faf725fedd3394421 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load 'bounty_parser.lic' | |
class Bounty | |
describe Parser, "#parse" do | |
it "can tell when we don't have a task" do | |
bounty = described_class.parse "You are not currently assigned a task." | |
bounty[:task].should == :taskmaster | |
bounty[:requirements].should be_nil | |
bounty[:status].should be_nil | |
end | |
context "when assigned a task" do | |
it "can tell we were assigned a cull task" do | |
bounty = described_class.parse "It appears they have a creature problem they'd like you to solve" | |
bounty[:task].should == :cull | |
bounty[:status].should == :assigned | |
end | |
it "can tell we were assigned an heirloom task" do | |
bounty = described_class.parse "It appears they need your help in tracking down some kind of lost heirloom" | |
bounty[:task].should == :heirloom | |
bounty[:status].should == :assigned | |
end | |
it "can tell we were assigned a skins task" do | |
bounty = described_class.parse "The local furrier Furrier has an order to fill and wants our help" | |
bounty[:task].should == :skins | |
bounty[:status].should == :assigned | |
end | |
it "can tell we were assigned a gem task" do | |
bounty = described_class.parse "The local gem dealer, GemTrader, has an order to fill and wants our help" | |
bounty[:task].should == :gem | |
bounty[:status].should == :assigned | |
end | |
it "can tell we were assigned a herb task" do | |
bounty = described_class.parse "Hmm, I've got a task here from the town of Ta'Illistim. The local herbalist's assistant, Jhiseth, has asked for our aid. Head over there and see what you can do. Be sure to ASK about BOUNTIES." | |
bounty[:task].should == :herb | |
bounty[:status].should == :assigned | |
bounty[:requirements].should == { | |
:town => "Ta'Illistim", | |
} | |
end | |
it "can tell we were assigned a rescue task" do | |
bounty = described_class.parse "It appears that a local resident urgently needs our help in some matter" | |
bounty[:task].should == :rescue | |
bounty[:status].should == :assigned | |
end | |
it "can tell we were assigned a bandit task" do | |
bounty = described_class.parse "The taskmaster told you: \"Hmm, I've got a task here from the town of Ta'Illistim. It appears they have a bandit problem they'd like you to solve. Go report to one of the guardsmen just inside the Ta'Illistim City Gate to find out more. Be sure to ASK about BOUNTIES.\"" | |
bounty[:task].should == :bandit | |
bounty[:status].should == :assigned | |
end | |
end | |
context "completed a task" do | |
it "can tell we have completed a taskmaster task" do | |
bounty = described_class.parse "You have succeeded in your task and can return to the Adventurer's Guild" | |
bounty[:task].should == :taskmaster | |
bounty[:status].should == :done | |
end | |
it "knows the heirloom item name for a completed heirloom task" do | |
bounty = described_class.parse "You have located an elegantly carved jade tiara and should bring it back to one of the guardsmen just inside the Ta'Illistim City Gate." | |
bounty[:task].should == :heirloom | |
bounty[:status].should == :done | |
bounty[:requirements][:item].should == "elegantly carved jade tiara" | |
bounty[:requirements][:town].should == "Ta'Illistim" | |
end | |
it "knows the heirloom item name for a completed heirloom task" do | |
bounty = described_class.parse "You have located some moonstone inset mithril earrings and should bring it back to one of the guardsmen just inside the Ta'Illistim City Gate." | |
bounty[:task].should == :heirloom | |
bounty[:status].should == :done | |
bounty[:requirements][:item].should == "moonstone inset mithril earrings" | |
bounty[:requirements][:town].should == "Ta'Illistim" | |
end | |
it "a completed heirloom task in the Landing" do | |
bounty = described_class.parse "You have located a bloodstone studded hair pin and should bring it back to Quin Telaren of Wehnimer's Landing." | |
bounty[:task].should == :heirloom | |
bounty[:status].should == :done | |
bounty[:requirements][:item].should == "bloodstone studded hair pin" | |
bounty[:requirements][:town].should == "Wehnimer's Landing" | |
end | |
{ | |
"Ta'Illistim" => "You succeeded in your task and should report back to one of the guardsmen just inside the Ta'Illistim City Gate.", | |
"Icemule Trace" => "You succeeded in your task and should report back to one of the Icemule Trace gate guards.", | |
"Ta'Vaalor" => "You succeeded in your task and should report back to one of the Ta'Vaalor gate guards.", | |
"Vornavis" => "You succeeded in your task and should report back to one of the Vornavis gate guards.", | |
"Wehnimer's Landing" => "You succeeded in your task and should report back to Quin Telaren of Wehnimer's Landing.", | |
"Kharam-Dzu" => "You succeeded in your task and should report back to the dwarven militia sergeant near the Kharam-Dzu town gates.", | |
}.each do |(town, task_desc)| | |
it "in #{town}" do | |
bounty = described_class.parse task_desc | |
bounty[:task].should == :dangerous | |
bounty[:status].should == :done | |
bounty[:requirements][:town].should == town | |
end | |
end | |
end | |
context "triggered a task" do | |
it "can tell we have triggered a rescue task for a male child" do | |
bounty = described_class.parse "You have made contact with the child you are to rescue and you must get him back alive to one of the guardsmen just inside the Sapphire Gate." | |
bounty[:task].should == :rescue | |
bounty[:status].should == :triggered | |
end | |
it "can tell we have triggered a rescue task for a female child" do | |
bounty = described_class.parse "You have made contact with the child you are to rescue and you must get her back alive to one of the guardsmen just inside the gate." | |
bounty[:task].should == :rescue | |
bounty[:status].should == :triggered | |
end | |
it "can tell we have triggered a dangerous task (male critter)" do | |
bounty = described_class.parse "You have been tasked to hunt down and kill a particularly dangerous CRITTER that has established a territory in near A PLACE. You have provoked his attention and now you must kill him!" | |
bounty[:task].should == :dangerous | |
bounty[:status].should == :triggered | |
end | |
it "can tell we have triggered a dangerous task (female critter)" do | |
bounty = described_class.parse "You have been tasked to hunt down and kill a particularly dangerous CRITTER that has established a territory in near A PLACE. You have provoked her attention and now you must kill her!" | |
bounty[:task].should == :dangerous | |
bounty[:status].should == :triggered | |
end | |
it "can tell we have triggered a dangerous task (unsexed critter)" do | |
bounty = described_class.parse "You have been tasked to hunt down and kill a particularly dangerous CRITTER that has established a territory in near A PLACE. You have provoked its attention and now you must kill it!" | |
bounty[:task].should == :dangerous | |
bounty[:status].should == :triggered | |
end | |
it "can tell we have triggered a dangerous task (return to area)" do | |
bounty = described_class.parse "You have been tasked to hunt down and kill a particularly dangerous CRITTER that has established a territory in near A PLACE. You have provoked her attention and now you must return to where you left her and kill her!" | |
bounty[:task].should == :dangerous | |
bounty[:status].should == :triggered | |
end | |
end | |
context "have an unfinished task" do | |
it "can tell we have an unfinished bandit task" do | |
bounty = described_class.parse "You have been tasked to suppress bandit activity on Sylvarraend Road near Ta'Illistim. You need to kill 20 of them to complete your task." | |
bounty[:task].should == :bandit | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :area => "Sylvarraend Road", :number => 20, :creature => 'bandit' } | |
end | |
it "can tell we have an unfinished cull task" do | |
bounty = described_class.parse "You have been tasked to suppress glacial morph activity in Gossamer Valley near Ta'Illistim. You need to kill 24 of them to complete your task." | |
bounty[:task].should == :cull | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :creature => "glacial morph", :area => "Gossamer Valley", :number => 24 } | |
end | |
it "can tell we have an unfinished cull task (ASSIST)" do | |
bounty = described_class.parse "You have been tasked to help Brikus suppress war griffin activity in Old Ta'Faendryl. You need to kill 14 of them to complete your task." | |
bounty[:task].should == :cull | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :creature => "war griffin", :area => "Old Ta'Faendryl", :number => 14 } | |
end | |
context "can tell we have an unfinished heirloom task" do | |
it "can parse a loot task" do | |
bounty = described_class.parse "You have been tasked to recover a dainty pearl string bracelet that an unfortunate citizen lost after being attacked by a festering taint in Old Ta'Faendryl. The heirloom can be identified by the initials VF engraved upon it. Hunt down the creature and LOOT the item from its corpse." | |
bounty[:task].should == :heirloom | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { | |
:action => "loot", :area => "Old Ta'Faendryl", :creature => "festering taint", | |
:item => "dainty pearl string bracelet" | |
} | |
end | |
it "can parse a loot task" do | |
bounty = described_class.parse "You have been tasked to recover an onyx-inset copper torc that an unfortunate citizen lost after being attacked by a centaur near Darkstone Castle near Wehnimer's Landing. The heirloom can be identified by the initials ZK engraved upon it. Hunt down the creature and LOOT the item from its corpse." | |
bounty[:task].should == :heirloom | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { | |
:action => "loot", :area => "Darkstone Castle", :creature => "centaur", | |
:item => "onyx-inset copper torc" | |
} | |
end | |
it "can parse a search task" do | |
bounty = described_class.parse "You have been tasked to recover an interlaced gold and ora ring that an unfortunate citizen lost after being attacked by a black forest viper in the Blighted Forest near Ta'Illistim. The heirloom can be identified by the initials MS engraved upon it. SEARCH the area until you find it." | |
bounty[:task].should == :heirloom | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { | |
:action => "search", :area => "Blighted Forest", :creature => "black forest viper", | |
:item => "interlaced gold and ora ring" | |
} | |
end | |
end | |
context "can tell we have an unfinished skins task" do | |
it "with a one word town name" do | |
bounty = described_class.parse "You have been tasked to retrieve 8 madrinol skins of at least fair quality for Gaedrein in Ta'Illistim. You can SKIN them off the corpse of a snow madrinol or purchase them from another adventurer. You can SELL the skins to the furrier as you collect them.\"" | |
bounty[:task].should == :skins | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { | |
:creature => "snow madrinol", | |
:quality => "fair", | |
:number => 8, | |
:skin => "madrinol skin", | |
:town => "Ta'Illistim", | |
} | |
end | |
it "with a multipart town name" do | |
bounty = described_class.parse "You have been tasked to retrieve 5 thrak tails of at least exceptional quality for the furrier in the Company Store in Kharam-Dzu. You can SKIN them off the corpse of a red-scaled thrak or purchase them from another adventurer. You can SELL the skins to the furrier as you collect them.\"" | |
bounty[:task].should == :skins | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { | |
:creature => "red-scaled thrak", | |
:quality => "exceptional", | |
:number => 5, | |
:skin => "thrak tail", | |
:town => "Kharam-Dzu", | |
} | |
end | |
end | |
it "can tell we have an unfinished gem task" do | |
bounty = described_class.parse "The gem dealer in Ta'Illistim, Tanzania, has received orders from multiple customers requesting an azure blazestar. You have been tasked to retrieve 10 of them. You can SELL them to the gem dealer as you find them." | |
bounty[:task].should == :gem | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :gem => "azure blazestar", :number => 10, :town => "Ta'Illistim" } | |
end | |
it "can tell we have an unfinished escort task" do | |
bounty = described_class.parse "The taskmaster told you: \"I've got a special mission for you. A certain client has hired us to provide a protective escort on his upcoming journey. Go to the area just inside the Sapphire Gate and WAIT for him to meet you there. You must guarantee his safety to Zul Logoth as soon as you can, being ready for any dangers that the two of you may face. Good luck!\"" | |
bounty[:task].should == :escort | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :destination => "Zul Logoth", :start => "the area just inside the Sapphire Gate" } | |
end | |
it "can tell we have an unfinished escort task" do | |
bounty = described_class.parse "I've got a special mission for you. A certain client has hired us to provide a protective escort on her upcoming journey. Go to the south end of North Market and WAIT for her to meet you there. You must guarantee her safety to Zul Logoth as soon as you can, being ready for any dangers that the two of you may face. Good luck!" | |
bounty[:task].should == :escort | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :destination => "Zul Logoth", :start => "the south end of North Market" } | |
end | |
context 'for herbs' do | |
it "can tell we have an unfinished herb task" do | |
bounty = described_class.parse "The herbalist's assistant in Ta'Illistim, Jhiseth, is working on a concoction that requires a sprig of holly found in Griffin's Keen near Ta'Illistim. These samples must be in pristine condition. You have been tasked to retrieve 6 samples." | |
bounty[:task].should == :herb | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { | |
:herb => "sprig of holly", | |
:area => "Griffin's Keen", | |
:number => 6, | |
:town => "Ta'Illistim", | |
} | |
end | |
it 'can parse an Icemule herb task' do | |
bounty = described_class.parse "The healer in Icemule Trace, Mirtag, is working on a concoction that requires a withered deathblossom found in the Rift. These samples must be in pristine condition. You have been tasked to retrieve 7 samples." | |
bounty[:task].should == :herb | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { | |
:herb => "withered deathblossom", | |
:area => "Rift", | |
:number => 7, | |
:town => "Icemule Trace", | |
} | |
end | |
end | |
it "can tell we have an unfinished dangerous task" do | |
bounty = described_class.parse "You have been tasked to hunt down and kill a particularly dangerous gnarled being that has established a territory in Old Ta'Faendryl. You can get its attention by killing other creatures of the same type in its territory." | |
bounty[:task].should == :dangerous | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :creature => "being", :area => "Old Ta'Faendryl" } | |
end | |
it "can tell we have an unfinished rescue task" do | |
bounty = described_class.parse "You have been tasked to rescue the young runaway son of a local citizen. A local divinist has had visions of the child fleeing from a black forest ogre in the Blighted Forest near Ta'Illistim. Find the area where the child was last seen and clear out the creatures that have been tormenting him in order to bring him out of hiding." | |
bounty[:task].should == :rescue | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :area => "Blighted Forest", :creature => "black forest ogre" } | |
end | |
it "can tell we have an unfinished rescue task" do | |
bounty = described_class.parse "You have been tasked to rescue the young kidnapped daughter of a local citizen. A local divinist has had visions of the child fleeing from a stone sentinel in Darkstone Castle near Wehnimer's Landing. Find the area where the child was last seen and clear out the creatures that have been tormenting her in order to bring her out of hiding." | |
bounty[:task].should == :rescue | |
bounty[:status].should == :unfinished | |
bounty[:requirements].should == { :area => "Darkstone Castle", :creature => "stone sentinel" } | |
end | |
end | |
it "can recognize a failed bounty" do | |
bounty = described_class.parse "You have failed in your task. Return to the Adventurer's Guild for further instructions." | |
bounty[:status].should == :failed | |
bounty[:task].should == :taskmaster | |
end | |
it 'can recognize a failed rescue task' do | |
bounty = described_class.parse "The child you were tasked to rescue is gone and your task is failed. Report this failure to the Adventurer's Guild." | |
bounty[:status].should == :failed | |
bounty[:task].should == :taskmaster | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment