What is wrong with my code, I’ve spent way too much time on something that seems like a bug, and not actually code related. The coins get collected, the collector shows 300+, and the guy won’t leave the cave.
def onSpawn(event): # Send the pet to walk around the dungeon: pet.moveXY(69, 57) pet.moveXY(71, 57) pet.moveXY(71, 11) pet.moveXY(20, 11) pet.moveXY(21, 36) pet.moveXY(15, 36) pet.moveXY(hero.pos.x, hero.pos.y) # Don't forget to return it to the hero: pass pet.on("spawn", onSpawn) while True: # Guard peasants: enemy = hero.findNearestEnemy() # When you have 300+ gold move to the red mark: if enemy: hero.attack(enemy) else: hero.moveXY(21, 34) if hero.gold>=300: hero.moveXY(50, 34)
I keep having these problems with CodeCombat, I’ve experience multiple levels where it doesn’t work as intended. At this point it feels like I’m spending more time troubleshooting the platform, not evaluating my code. If this doesn’t stop happening, I’m going to cancel my subscription and find a different way to learn. This just isn’t a good use of time if I keep having to dig through old articles trying to figure out bugs.