Skip to content

Instantly share code, notes, and snippets.

@nwwells
Last active October 12, 2015 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwwells/f0d3491e86de6edb012f to your computer and use it in GitHub Desktop.
Save nwwells/f0d3491e86de6edb012f to your computer and use it in GitHub Desktop.
A thing for Eko
// Defeat the enemy hero in under three minutes.
this.buildArmy = function() {
// Your hero can summon and command allied troops.
var buildOrder = [
"soldier",
"soldier",
"archer",
]; // "archer", "artillery", "arrow-tower"
var type = buildOrder[this.built.length % buildOrder.length];
if (this.gold >= this.costOf(type)) {
this.summon(type);
}
};
var DESIRABLE_CONTROL_POINTS = [
"North",
"Center",
"East",
"Northeast"
];
this.commandArmy = function() {
var friends = this.built;
var enemies = this.findEnemies();
// is something wrong with the JS interpreter, that I can't chain calls?
var points = this.getControlPoints();
// can't figure out how to make filter work!?
//points = points.filter(function (cp) {
// return DESIRABLE_CONTROL_POINTS.indexOf(cp.id) !== -1;
//}, this);
for (var i = 0; i < friends.length; ++i) {
var friend = friends[i];
if (friend.health <= 0 || friend.type == "arrow-tower") {
continue;
}
// Command your army to capture control points.
// Make sure to choose your control points wisely!
var point = points[i % points.length];
//short-circuit the points on the other side
if ((i % points.length) > 3) {
this.command(friend, "attack", friend.findNearest(enemies));
} else if (this.now() < 30) {
this.command(friend, "defend", point.pos);
} else {
this.command(friend, "attack", enemies[1]);
}
}
};
this.controlHero = function() {
var enemies = this.findEnemies();
var nearestEnemy = this.findNearest(enemies);
var shouldMove = this.now() > 30 && this.now() < 45;
var shouldAttack = this.now() > 45;
// Use your hero's abilities to turn the tide.
if (shouldMove) {
this.moveXY(116, 94);
}
if (shouldAttack) {
this.attack(nearestEnemy);
}
};
loop {
this.buildArmy();
this.commandArmy();
this.controlHero();
}
  1. js, L9: $scope.$apply references the $apply function without calling it.
  2. js, L15: $scope.user.lastname is undefined. You probably meant to use $scope.user.lastName?
  3. js, L15: Should there be a space between the firstName and the lastName?
  4. html, L3: Missing field for user.lastName? I suppose, though, that is we're allowing a login without any form of authentication, we may as well assume that we know the last name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment