ok so here is the full code nick hopefully you can figure out the problem
this.findTypeInRange = function(units, type) {
for (var i = 0; i < units.length; ++i) {
var unit = units[i];
if (unit.type === type && this.distance(unit) < this.attackRange)
return unit;
}
return null;
};
var shaman = this.findTypeInRange(enemies, "shaman");
var brawler = this.findTypeInRange(enemies, "brawler");
var thrower = this.findTypeInRange(enemies, "thrower", "spear");
var munchkin = this.findTypeInRange('munchkin'
var buildOrder = ['tharin', 'soldier', 'soldier', 'soldier', 'archer'];
var type = builOrder[this.built.length % buildOrder.length];
… is missing its closing parenthesis ). So the error message is showing up on the next line, because it’s still looking for the ) there.
Another problem is that it should include the enemies array in that line like it does in the one before it:
var munchkin = this.findTypeInRange(enemies, "munchkin");
The line right before it is passing an extra argument "spear" to this.findTypeInRange, but that’s just not doing anything because JavaScript doesn’t care if you pass extra arguments.
You also have builOrder instead of buildOrder on the last line.
OK so i fixed it and i doesnt have any errors so thank you now any way so i run the code to see what happens and it says erroer line 10 enemies is not defined and how do i make it build the build order
When you get a relatively easy error message like that, you should try fixing it yourself before asking here. Did you try this?
var enemies = this.getEnemies();
That should have been in the sample code that you started with on Tharin himself. In general, Dungeon Arena isn’t really a learning level, so if it’s too hard to figure out how to get it working, you might want to do more practice on the earlier levels.
well i’m sorry that i’m not a big coder i thought this was supposed to be a learning game which i am but i still need help so don’t act like i’m a complete idiot. anyway i did that but now i don’t know how to put my build order into effect
I’m sorry, I should have worded that differently. CodeCombat is mostly a learning game, but the multiplayer arenas (like Dungeon Arena) aren’t intended for learning. They are aimed at experienced developers, so they are much, much harder than the beginner campaign tutorial content has gotten to.
Is it building the guys in the right order and combination? If it stops after the archer, it’s because you can only build one hero in Dungeon Arena, so it’s trying to build Tharin again but can never re-build him. I would try taking Tharin out of the builder order and building him separately like it does in the default code, so put this above the code you have now:
// CHOOSE YOUR HERO! You can only build one hero.
var hero;
hero = 'tharin'; // A fierce knight with battlecry abilities.
//hero = 'hushbaum'; // A fiery spellcaster hero.
if(hero && !this.builtHero) {
this.builtHero = this.build(hero);
return;
}
This builds the hero first, but only if you haven’t already built one.