加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
role.terminalKeeper.js 2.30 KB
一键复制 编辑 原始数据 按行查看 历史
Lev 提交于 2020-02-17 12:50 . first commit
module.exports = {
run: function(creep){
if(false){
if(creep.store.getFreeCapacity() == 0){
for(var resource in creep.store){
if(creep.pos.isNearTo(creep.room.storage)) creep.transfer(creep.room.storage,resource);
else creep.moveTo(creep.room.storage);
}
}else{
for(var resource in creep.room.terminal.store){
var amount = creep.room.terminal.store[resource];
if(amount > creep.store.getFreeCapacity()) amount = creep.store.getFreeCapacity();
if(creep.pos.isNearTo(creep.room.terminal)) creep.say(creep.withdraw(creep.room.terminal ,resource ,amount));
else creep.moveTo(creep.room.terminal);
}
}
return;
}
if(!creep.pos.isEqualTo(22,27)){
creep.moveTo(22,27);
return;
}
if(creep.room.terminal.store.getFreeCapacity() >= 0 && creep.room.storage.store[RESOURCE_ENERGY] > 200000){
if(creep.store.getUsedCapacity() == 0){
var amount = creep.room.terminal.store.getFreeCapacity();
if(amount > creep.store.getFreeCapacity()) amount = creep.store.getFreeCapacity();
if(creep.pos.isNearTo(creep.room.storage)) creep.withdraw(creep.room.storage,RESOURCE_ENERGY,amount);
else creep.moveTo(creep.room.storage);
}else{
if(creep.pos.isNearTo(creep.room.terminal)) creep.transfer(creep.room.terminal,RESOURCE_ENERGY);
else creep.moveTo(creep.room.terminal);
}
}else{
return;
if(creep.store.getFreeCapacity() == 0){
if(creep.pos.isNearTo(creep.room.storage)) creep.transfer(creep.room.storage,RESOURCE_ENERGY);
else creep.moveTo(creep.room.storage);
}else{
var amount = creep.room.terminal.store[RESOURCE_ENERGY]-100000;
if(amount > creep.store.getFreeCapacity()) amount = creep.store.getFreeCapacity();
if(creep.pos.isNearTo(creep.room.terminal)) creep.say(creep.withdraw(creep.room.terminal,RESOURCE_ENERGY,amount));
else creep.moveTo(creep.room.terminal);
}
}
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化