Hi! I’m having trouble with “Magic exam” in “Backwoods Forest”.
My problem is that I am only reaching 17 gold, and I would like to at least reach 18, hopefully 24.
If anyone out there has gotten this level with 18 or 24 gold, can you explain how you did it?
I’d like to know if you think there’s anything wrong with code, too.
Here it is:
# Try to get the best grade (gold) at the magic exam.
# Move to each X mark, then use a spell.
# There are 3 friends, 3 enemies, and 2 items.
def castIfReady(spellName , target):
ready = hero.canCast(spellName, target)
if ready:
hero.cast(spellName, target)
def enemyFriendItem():
friend = hero.findNearestFriend()
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
if enemy:
if enemy.type == "ogre":
castIfReady("force-bolt", enemy)
hero.say("Force Bolt.")
if enemy.type == "munchkin":
castIfReady("shrink", enemy)
hero.say("Shrink!")
if enemy.type == "scout":
castIfReady("poison-cloud", enemy)
hero.say("Poison!")
if enemy.type == "brawler":
castIfReady("poison-cloud", enemy)
hero.say("Poison yee-haw!")
if friend:
castIfReady("heal", friend)
hero.say("Heal ye!")
if item:
if item.type == "potion":
x = item.pos.x
y = item.pos.y
hero.moveXY(x, y)
hero.say("Take the item!")
else:
hero.say("Don't take it!")
while True:
friend = hero.findNearestFriend()
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
hero.moveXY(18, 40)
enemyFriendItem()
hero.moveXY(18, 24)
enemyFriendItem()
hero.moveXY(34, 40)
enemyFriendItem()
hero.moveXY(34, 24)
enemyFriendItem()
hero.moveXY(50, 40)
enemyFriendItem()
hero.moveXY(50, 24)
enemyFriendItem()
hero.moveXY(66, 40)
enemyFriendItem()
hero.moveXY(66, 24)
enemyFriendItem()