Oh, whoops, I looked at the example in the hint, where it says “build a soldier”…
Thanks Bryukh!
Oh, whoops, I looked at the example in the hint, where it says “build a soldier”…
Thanks Bryukh!
I play codecombat in python, so can you help me figure out how to get the last word?
Sorry, I am now spawning the soldiers, but the peasants that are not talking I am not spawning a soldier. Is this a glitch or is this supposed to happen?
Never mind I got it.
My guy summons the soldiers and they defeat their enemies, but when I get to the end my guy doesn’t attack.
for (var x = 8; x <= 72; x += 16) {
hero.moveXY(x, 22);
// Peasants know whom to summon.
var peasant = hero.findNearest(hero.findFriends());
var message = peasant.message;
if (message) {
// Words are seaparated by whitespaces.
var words = message.split(" ");
// "words" is an array of words from the "message".
// Get the last word. It's the required type.
var type = words[words.length - 1];
// Summon the required unit type.
hero.summon(type);
}
}
for (var i = 0; i < hero.built.length; i++) {
var unit = hero.built[i];
// Command the unit to defend the unit's position.
hero.command(unit, "defend", unit.pos);
}
var enemy = hero.findNearestEnemy();
if (enemy){
hero.attack(enemy);
}
what is the code in python
Hi @happy390, if you need help with your code, please post it. SwyGuy is not active anymore and so cannot help you. Also, it’s against the rules to give out complete solutions to levels. Instead we’ll point out any errors and help you fix them.