Browse Source

init

master
Philipp Horstenkamp 4 months ago
commit
c6827b56a8
Signed by: philipp
GPG Key ID: DD53EAC36AFB61B4
  1. 17
      main.mjs

17
main.mjs

@ -0,0 +1,17 @@
import { prototypes, utils, constants } from '/game';
export function loop() {
const tower = utils.getObjectsByPrototype(prototypes.StructureTower)[0];
if(tower.store[constants.RESOURCE_ENERGY] < 10) {
var myCreep = utils.getObjectsByPrototype(prototypes.Creep).find(creep => creep.my);
if(myCreep.store[constants.RESOURCE_ENERGY] == 0) {
var container = utils.getObjectsByPrototype(prototypes.StructureContainer)[0];
myCreep.withdraw(container, constants.RESOURCE_ENERGY);
} else {
myCreep.transfer(tower, constants.RESOURCE_ENERGY);
}
} else {
var target = utils.getObjectsByPrototype(prototypes.Creep).find(creep => !creep.my);
tower.attack(target);
}
}
Loading…
Cancel
Save