Gather herbs to make spells.
A game allows players to cast spells against each other. A spell must be brewed in a cauldron before it can be cast. Each spell requires two ingredients (herbs) before it can be brewed. Herbs can be foraged in the game world.
Write a program that allows the user to add a herb to a list of herbs foraged. Once foraged, the user can choose two herbs to be combined to brew a spell. The user can also cast a brewed spell. When spells are brewed the herbs used are removed from the list. The outcome of each action is shown to the user. The list of valid herbs and spells is shown below.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
Spells and herbs are:
Spell | Herb 1 | Herb 2 |
---|---|---|
teleport | dandelion | burdock |
protect | pipewort | ragwort |
sprites | snapdragon | toadflex |
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :dandelion
dandelion found.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :burdock
burdock found.
Forage herb, brew or cast a spell? f/b/c :b
What spell do you want to brew? :teleport
teleport has been brewed.
Forage herb, brew or cast a spell? f/b/c :c
What spell do you want to cast? :teleport
teleport has been cast.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :mint
Cannot find herb.
Forage herb, brew or cast a spell? f/b/c :b
What spell do you want to brew? :teleport
Cannot brew the spell, you don't have the correct herbs.
Forage herb, brew or cast a spell? f/b/c :b
What spell do you want to brew? :appear
That spell is not in the spell book.
Forage herb, brew or cast a spell? f/b/c :c
What spell do you want to cast? :shield
You have not brewed that spell.
Use these resources as a reference to help you meet the success criteria.
Run the unit tests below to check that your program has met the success criteria.
Forage herb, brew or cast a spell? f/b/c :b
What spell do you want to brew? :steal
That spell is not in the spell book.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :burdock
burdock found.
Forage herb, brew or cast a spell? f/b/c :b
What spell do you want to brew? :teleport
Cannot brew the spell, you don't have the correct herbs.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :dandylion
dandylion found.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :burdock
burdock found.
Forage herb, brew or cast a spell? f/b/c :b
What spell do you want to brew? :teleport
teleport has been brewed.
Forage herb, brew or cast a spell? f/b/c :c
What spell do you want to cast? :sprites
You have not brewed that spell.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :dandylion
dandylion found.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :burdock
burdock found.
Forage herb, brew or cast a spell? f/b/c :b
What spell do you want to brew? :teleport
teleport has been brewed.
Forage herb, brew or cast a spell? f/b/c :c
What spell do you want to cast? :teleport
teleport has been cast.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :basil
Cannot find herb.
Forage herb, brew or cast a spell? f/b/c :f
What herb do you want to look for? :burdock
burdock found.
Check that you have:
A full list of spells and herbs would allow you to extend the program further if you wanted to:
Spell | Herb 1 | Herb 2 |
---|---|---|
teleport | dandelion | burdock |
protect | pipewort | ragwort |
sprites | snapdragon | toadflex |
zombie | devilsbit | bones |
swift | speedwell | sage |
freeze | bind weed | bog weed |
doppleganger | fox glove | catsear |
invisible | chondrilla | hemlock |
reverse | thistle | skullcap |
heal | balm | feverfew |
fireball | dragonsteeth | mousetail |
lightening | cud weed | knap weed |
spells = ["teleport", "protect", "sprites", "zombie", "swift", "freeze", "doppleganger", "invisible", "reverse", "heal", "fireball", "lightening"]
herb = ["dandelion", "pipewort", "snapdragon", "devilsbit", "speedwell", "bind weed", "fox glove", "chondrilla", "thistle", "balm", "dragonsteeth", "cud weed", "burdock", "ragwort", "toadflex", "bones", "sage", "bog weed", "catsear", "hemlock", "skullcap", "feverfew", "mousetail", "knap weed"]