changes Snape -> Snoope and add ability to extend exercise.
This commit is contained in:
parent
e082761458
commit
d33816eedc
|
@ -7,7 +7,7 @@ def make_example_potion(student_name="ASPP student"):
|
||||||
"""Make and return an example potion."""
|
"""Make and return an example potion."""
|
||||||
my_potion = potion_class.Potion(student_name=student_name)
|
my_potion = potion_class.Potion(student_name=student_name)
|
||||||
# Set up your old kettle and light an eternal flame underneath it.
|
# Set up your old kettle and light an eternal flame underneath it.
|
||||||
my_potion.setup(container=containers.OLD_KETTLE)
|
my_potion.setup(container=containers.OLD_KETTLE, heat_source="eternal_flame")
|
||||||
# Simmer for 5 hours.
|
# Simmer for 5 hours.
|
||||||
cooking.simmer(my_potion, duration=5)
|
cooking.simmer(my_potion, duration=5)
|
||||||
print(f"You successfully ran make_example_potion, {student_name}, well done :).")
|
print(f"You successfully ran make_example_potion, {student_name}, well done :).")
|
||||||
|
|
|
@ -18,10 +18,10 @@ def stir(potion, direction):
|
||||||
direction : {'clockwise', 'anti-clockwise'} str
|
direction : {'clockwise', 'anti-clockwise'} str
|
||||||
The direction in which the potions is to be stirred
|
The direction in which the potions is to be stirred
|
||||||
"""
|
"""
|
||||||
if direction == "clockwise":
|
if direction.isin(["clockwise", "clock_wise", "clock-wise"]):
|
||||||
potion.colour = "vomit-yellow"
|
potion.colour = "vomit-yellow"
|
||||||
print('NO!! Your potion turns vomit-yellow. Did you stir in the right direction?')
|
print('Your potion turns a revolting vomit-yellow.')
|
||||||
elif direction == "anti-clockwise":
|
elif direction.isin(["anti-clockwise", "anticlockwise", "anti_clock_wise", "anti-clock-wise"]):
|
||||||
potion.colour = "newt-green"
|
potion.colour = "newt-green"
|
||||||
print('Your potion turns a lovely newt-green.')
|
print('Your potion turns a lovely newt-green.')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
def inspection_by_Snape(potion, target_potion='python_expert'): # pylint: disable=invalid-name
|
def inspection_by_snoope(potion, target_potion='python_expert'): # pylint: disable=invalid-name
|
||||||
"""Checks if potion was brewed correctly.
|
"""Checks if potion was brewed correctly.
|
||||||
|
|
||||||
Prints narration of inspection process - read to see if potion passed inspection.
|
Prints narration of inspection process - read to see if potion passed inspection.
|
||||||
Snape checks container, heat_source, ingredients, and whether potion was cooked.
|
Snoope checks container, heat_source, ingredients, and whether potion was cooked.
|
||||||
If something is wrong, function returns at that point.
|
If something is wrong, function returns at that point.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -16,16 +16,16 @@ def inspection_by_Snape(potion, target_potion='python_expert'): # pylint: disab
|
||||||
potion : obj
|
potion : obj
|
||||||
Instance of Potion (class from potion_class).
|
Instance of Potion (class from potion_class).
|
||||||
target_potion: str, optional
|
target_potion: str, optional
|
||||||
Name of potion to be checked by Snape. Currently possible potions are 'python expert', 'example_potion'
|
Name of potion to be checked by Snoope. Currently possible potions are 'python expert', 'example_potion'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print('-------------------------------')
|
print('-------------------------------')
|
||||||
if not potion:
|
if not potion:
|
||||||
print('"There is no potion I can inspect!"')
|
print('"There is no potion I can inspect!" says Snoope and ignores you completely.')
|
||||||
print(' (Tip: are you actually returning a proper potion and passing it to Snape?)')
|
print(' (Tip: are you actually returning a proper potion and passing it to Snoope?)')
|
||||||
return
|
return
|
||||||
|
|
||||||
print(f'A sour looking Snape walks towards you to inspect your {target_potion} potion.')
|
print(f'A sour looking Snoope walks towards you to inspect your {target_potion} potion.')
|
||||||
print(f'"What do we have here, {potion.student_name}...?"')
|
print(f'"What do we have here, {potion.student_name}...?"')
|
||||||
print_delay_dots()
|
print_delay_dots()
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ def inspection_by_Snape(potion, target_potion='python_expert'): # pylint: disab
|
||||||
|
|
||||||
# check that correct setup was used
|
# check that correct setup was used
|
||||||
if potion.container == expected_container and potion.heat_source == expected_heat_source:
|
if potion.container == expected_container and potion.heat_source == expected_heat_source:
|
||||||
print('You have used the correct setup, Snape cannot complain - he looks even more sour.')
|
print('You have used the correct setup, Snoope cannot complain - he looks even more sour.')
|
||||||
else:
|
else:
|
||||||
print(f'Snape smirks and remarks "You have used the wrong cauldron or heat, {potion.student_name}!" \n'
|
print(f'Snoope smirks and remarks "You have used the wrong cauldron or heat, {potion.student_name}!" \n'
|
||||||
f'With a flick of his wand he vanishes the potion. \n'
|
f'With a flick of his wand he vanishes the potion. \n'
|
||||||
f'"I am taking 10 points from Ravenclaw, {potion.student_name}. Start again!"')
|
f'"I am taking 10 points from Ravenclaw, {potion.student_name}. Start again!"')
|
||||||
return
|
return
|
||||||
|
@ -57,20 +57,22 @@ def inspection_by_Snape(potion, target_potion='python_expert'): # pylint: disab
|
||||||
expected_ingredients = ['fish_eyes', 'tea_leaves', 'unicorn_hair']
|
expected_ingredients = ['fish_eyes', 'tea_leaves', 'unicorn_hair']
|
||||||
expected_cooked = True
|
expected_cooked = True
|
||||||
expected_simmer_duration = 2
|
expected_simmer_duration = 2
|
||||||
|
expected_anticlock_colour = "newt-green"
|
||||||
|
expected_clock_colour = "vomit-yellow"
|
||||||
elif target_potion == 'example_potion':
|
elif target_potion == 'example_potion':
|
||||||
expected_ingredients = []
|
expected_ingredients = []
|
||||||
expected_cooked = True
|
expected_cooked = True
|
||||||
expected_simmer_duration = 5
|
expected_simmer_duration = 5
|
||||||
else:
|
else:
|
||||||
print(f'"What is this, {potion.student_name}? This is not the name of an existing potion, check your spelling!"')
|
print(f'"What is this, {potion.student_name}? This is not the name of an existing potion, check your spelling!"')
|
||||||
print(' (Target potion was not recognised, please check your spelling.)')
|
print(' (Target potion name was not recognised, please check your spelling.)')
|
||||||
return
|
return
|
||||||
|
|
||||||
# check if all ingredients are there
|
# check if all ingredients are there
|
||||||
if sorted(potion.ingredients) == expected_ingredients:
|
if sorted(potion.ingredients) == expected_ingredients:
|
||||||
print('You have used the correct ingredients, Snape cannot complain - his face darkens.')
|
print('You have used the correct ingredients, Snoope cannot complain - his face darkens.')
|
||||||
else:
|
else:
|
||||||
print(f'Snape smirks and remarks "You have used the wrong ingredients, {potion.student_name}!" \n'
|
print(f'Snoope smirks and remarks "You have used the wrong ingredients, {potion.student_name}!" \n'
|
||||||
f'With a flick of his wand he vanishes the potion. \n'
|
f'With a flick of his wand he vanishes the potion. \n'
|
||||||
f'"I am taking 10 points from Gryffindor, {potion.student_name}. Start again!"')
|
f'"I am taking 10 points from Gryffindor, {potion.student_name}. Start again!"')
|
||||||
return
|
return
|
||||||
|
@ -79,22 +81,31 @@ def inspection_by_Snape(potion, target_potion='python_expert'): # pylint: disab
|
||||||
|
|
||||||
# check that potion is cooked
|
# check that potion is cooked
|
||||||
if potion.cooked == expected_cooked and potion.simmer_duration == expected_simmer_duration:
|
if potion.cooked == expected_cooked and potion.simmer_duration == expected_simmer_duration:
|
||||||
print('The potion is cooked properly, Snape cannot complain - he is looking annyoyed now.')
|
print('The potion is cooked properly, snoope cannot complain - he is looking annyoyed now.')
|
||||||
else:
|
else:
|
||||||
if potion.simmer_duration < expected_simmer_duration:
|
if potion.simmer_duration < expected_simmer_duration:
|
||||||
print('Snape smirks and remarks "Your potion is undercooked!" \n')
|
print('Snoope smirks and remarks "Your potion is undercooked!" \n')
|
||||||
elif potion.simmer_duration > expected_simmer_duration:
|
elif potion.simmer_duration > expected_simmer_duration:
|
||||||
print('Snape smirks and remarks "Your potion is overcooked!" \n')
|
print('Snoope smirks and remarks "Your potion is overcooked!" \n')
|
||||||
print(f'With a flick of his wand he vanishes the potion. \n'
|
print(f'With a flick of his wand he vanishes the potion. \n'
|
||||||
f'"I am taking 10 points from Hufflepuff, {potion.student_name}. Start again!"')
|
f'"I am taking 10 points from Hufflepuff, {potion.student_name}. Start again!"')
|
||||||
return
|
return
|
||||||
|
|
||||||
print_delay_dots()
|
print_delay_dots()
|
||||||
|
|
||||||
print(f'Snape mutters "You got away this time, {potion.student_name}!", since there is nothing wrong with '
|
if potion.colour == expected_anticlock_colour:
|
||||||
|
print("Professor Dimbledore unexpectedly walks through the door, sees your potion and exclaims:")
|
||||||
|
print(f'"Oh my, {potion.student_name}, your potion is absolutely perfect! ')
|
||||||
|
print(' You earn 1000 points and the House Cup for this year\'s ASPP Summer School!"')
|
||||||
|
print('You and your class mates leave to have a butterbeer at the beach in Heraklion!')
|
||||||
|
elif potion.colour == expected_clock_colour:
|
||||||
|
print("Your potion does not only look disgusting, it also smells like rotten eggs. ")
|
||||||
|
print("You vomit into your cauldron and while this does not change the colour, you know you will not pass the class, so you start again. ")
|
||||||
|
else:
|
||||||
|
print(f'Snoope mutters "You got away this time, {potion.student_name}!", since there is nothing wrong with '
|
||||||
f'your {target_potion} potion.')
|
f'your {target_potion} potion.')
|
||||||
print_delay_dots()
|
print_delay_dots()
|
||||||
print('You pack your bags and leave as fast as you can to have a butterbeer at the lake!')
|
print('You pack your bags and leave as fast as you can to have a butterbeer at the beach in Heraklion!')
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Potion:
|
||||||
The name of the heat source used to cook the potions
|
The name of the heat source used to cook the potions
|
||||||
"""
|
"""
|
||||||
if container is None:
|
if container is None:
|
||||||
print('You have not specified a container - where do you think you will brew your potion?')
|
print('You have not specified a container - where will you brew your potion?')
|
||||||
if heat_source is None:
|
if heat_source is None:
|
||||||
print('You have not specified a heat source - how will you cook the potion?')
|
print('You have not specified a heat source - how will you cook the potion?')
|
||||||
self.container = container
|
self.container = container
|
||||||
|
|
Loading…
Reference in a new issue