Feud

Feud

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.

Make


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:

Success Criteria

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

Complete the subprogram called `take_action` that:

  1. Prompts the user to enter "f", "b" or "c" to forage, brew or cast a spell.
  2. The user cannot continue unless they enter a valid input.
  3. The relevant subprogram is called: `forage_herb`, `brew_spell` or `cast_spell`.

Complete the subprogram called `forage_herb` that:

  1. Prompts the user to enter the herb they want to look for.
  2. If the herb is a valid herb in the list of herbs it is added to the herbs collected.
  3. It outputs "[herb] found" or "Cannot find herb.".

Complete the subprogram called `brew_spell` that:

  1. Prompts the user to enter the spell they want to brew.
  2. For a valid spell it calls the `cauldron` subprogram with the paramters spell and herb. Spell is the spell to be brewed and herb is a list of the herbs required for that spell.
  3. If the spell is not valid it outputs, "That spell is not in the spell book."

Complete the subprogram called `cauldron` that:

  1. Takes two parameters: spell and herb.
  2. If the herbs have been collected...
  3. ...the spell is added to the spells brewed list...
  4. ...and all herbs used are removed from the herbs collected.
  5. It outputs, "[spell] has been brewed" or "Cannot brew the spell, you don't have the correct herbs."

Complete the subprogram called `cast_spell` that:

  1. Prompts the user to enter the spell they want to cast.
  2. If the spell has been brewed it is removed from the spells brewed.
  3. It outputs, "[spell] has been cast." or "You have not brewed that spell."

Complete the `main program` so that:

  1. Creates an empty list for the herbs collected.
  2. Creates and empty list for the spells brewed.
  3. Starts an infinite loop to...
  4. ...repeatedly call the `take_action` subprogram.

Typical inputs and outputs from the program would be:

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.

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


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:

  • Used comments within the code to describe the purpose of subprograms, conditions and iterations.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.

Extend


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"]

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500

Email: admin@craigndave.co.uk

Craig'n'Dave logo

Craig 'n' Dave

Bett Awards 2024 Finalist