「网易官方」极客战记(codecombat)攻略-山峰-安息之云指挥官-cloudrip-commander

(点击图片进入关卡)

使用你的新老大 Star 开始召唤和指挥你的骑兵!

简介

在这个关卡,你可以进入 boss 星 I。你现在可以召唤 summon "soldier" 和 "archer" 盟军

你现在也可以 command 你的 soldier 和 archer 盟友。

默认代码

# 召唤一些士兵,然后引导他们去你的基地。
# 每个士兵消耗20金币。
while hero.gold > hero.costOf("soldier"):
    hero.summon("soldier")

 

soldiers = hero.findFriends()
soldierIndex = 0
# 添加一个while 循环来命令所有的士兵。
soldier = soldiers[soldierIndex]
hero.command(soldier, "move", {"x": 50, "y": 40})
# 去加入你的朋友!

概览

在本关你可以使用 Boss Star, 一个可以用来召唤和指挥盟友的装备

1 级 Boss Star 可以让你召唤士兵 “soldier”,指挥士兵 "soldier" 和弓箭手 "archer"

示例代码展示了如何使用 "costOf" 函数,以及如何使用 "summon" 函数召唤士兵 "soldier"———当然你得有足够的金币去召唤他们

然后,你可以使用 "findFriends" 函数获取一个你盟友的数组,并展示如何使用命令 "command" 让你的盟友进行移动 "move"

你还需要把命令代码 "command" 放进循环 "while" 内,因为你得命令所有士兵移动。

然后,使用另一个 "while" 循环,让你的英雄移动到 X 标记

安息之云指挥官解法

# 召唤一些士兵,然后引导他们去你的基地。
# 每个士兵消耗20金币。
while hero.gold > hero.costOf("soldier"):
    hero.summon("soldier")

 

soldiers = hero.findFriends()
soldierIndex = 0
# 添加一个while 循环来命令所有的士兵。
while soldierIndex < len(soldiers):
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})
    soldierIndex += 1
# 去加入你的朋友!
target = {"x": 48, "y": 40}
while hero.distanceTo(target):
    hero.move(target)
 
本攻略发于极客战记官方教学栏目,原文地址为:
原文地址:https://www.cnblogs.com/codecombat/p/13557962.html