codecombat之Sarven沙漠13关代码分享
codecombat吧
全部回复
仅看楼主
level 4
ghjswj 楼主
// 我们在测试一个新的战斗单位:诱饵。
// 创建4个诱饵,然后汇报给 Naria
var decoysBuilt = 0;
loop {
var item = this.findNearestItem();
// 掠夺金币!
var x = item.pos.x ;
var y = item.pos.y ;
this.moveXY(x, y);
// 每个诱饵消费25个金币,使用石英灵石。
// 让它知道当你有超过25个金币的时候 this.gold.
if (this.gold > 25) {
this.buildXY("decoy", x, y);
decoysBuilt ++ ;
}
// 当你一直走的时候,保持统计你创建的诱饵的数量。
if (decoysBuilt == 4) {
break;
}
// 当你创建了4个诱饵时跳出循环
}
this.moveXY(14, 36);
this.say("完成创建诱饵!");
// 去找 Naria 并告诉她你创建了多少个诱饵。
this.say("4");
2015年12月21日 08点12分 1
1