sprite = codesters.Sprite("knight1", -175, -150)
sprite.set_speed(2)
def park_scene():
stage.set_background("park")
sprite.say("I should hurry to the castle!")
sprite.move_forward(550)
park_scene()
def bridge_scene():
stage.set_background("drawbridge")
sprite.go_to(-175, -150)
sprite.say("I made it!")
stage.wait(2)
bridge_scene()
def battle_scene():
dragon = codesters.Sprite("dragon", 150, -150)
sprite.say("Oh no a dragon!")
t = codesters.Teacher()
try:
tval1 = len(t.find_text('sprite.'))
except:
tval1 = "DNE"
try:
tval2 = len(t.find_text('dragon.'))
except:
tval2 = "DNE"
try:
params = t.find_function('say')
tval3 = params[3][1].lower()
except:
params = "DNE"
tval3 = "DNE"
try:
param = t.find_text('sprite.')
indents = []
for item in param:
indent = t.get_indent_at_line(item[0])
indents.append(indent)
tval4 = indents.count(0)
except:
tval4 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 >= 8, "Great job!")
t1.add_failure(tval1 <= 6, "Did you add actions for your sprite to the battle scene? Have it defeat the dragon!")
t1.add_failure(tval1 == 7, "Try adding another action to make your battle scene more complex!")
t1.add_failure(tval1 == "DNE", "Did you delete your sprite?")
t2 = TestObjective()
t2.add_success(tval2 >= 2, "Great job!")
t2.add_failure(tval2 < 2, "Try adding another action for your dragon in the battle scene.")
t2.add_failure(tval2 == 0, "Did you add actions to your dragon in the battle scene?")
t2.add_failure(tval2 == "DNE", "Did you delete your dragon?")
t3 = TestObjective()
t3.add_success('clear' in tval3, "Great job!")
t3.add_failure('oh no a dragon' in tval3, "Did you add another Say command at the end of the battle?")
t3.add_failure('i am a sprite' in tval3, "Did you change the string in the say command?")
t3.add_failure('clear' not in tval3, "Did you have your sprite announce that the path is clear?")
t4 = TestObjective()
t4.add_success(tval4 == 1, "Great job!")
t4.add_failure(tval4 > 1, "Make sure all your commands are indented inside your function!")
tester = TestManager()
tester.add_test_list([t1, t2, t3, t4])
tester.run_tests()
tester.display_first_feedback()