This commit is contained in:
Philipp Horstenkamp 2022-04-09 17:37:20 +02:00
commit c6827b56a8
Signed by: Philipp
GPG Key ID: DD53EAC36AFB61B4
1 changed files with 17 additions and 0 deletions

17
main.mjs Normal file
View File

@ -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);
}
}