Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Found a protecial bug please help ...... Game dev 2 4. Guard duty


This is my code for level 4. Guard Duty.
// Add a soldier to the level to prevent ogres from crossing the path.
// Command the soldier using an event handler function.
function soldierLogic() {
game.spawnHeroXY(soldier, 42, 48);
// Fill in the code for the soldier’s actions here.
// Remember to use ‘soldier’ instead of ‘hero’!
while (true) {
var enemy = soldier.findNearestEnemy();
if (enemy) {
} else
hero.moveXY(42, 48);
// This assigns your spawned unit to the soldier variable.
var soldier = game.spawnXY(“soldier”, 42, 48);
// This says to run the soldierLogic function when the soldier is spawned.
soldier.on(“spawn”, soldierLogic);
My freinds and I have spent 2 lessons (2h 45 min) trying to figure this out… We think this is a bug


Please format your code according to the CodeCombat FAQ.


} else

Is that the error? Also, the number of brackets do not match up