「网易官方」极客战记(codecombat)攻略-沙漠-钥匙陷阱-key-traps

(点击图片进入关卡)

这些钥匙是如此近,但不要急于亲自拿。

简介

你必须释放圣骑士。要做到这一点,你需要三个钥匙。

使用你的宠物来获得这些钥匙。 不要试图用你的英雄收集他们。

默认代码

# 获得三把钥匙并释放圣骑士。
def onSpawn(event):
    # 宠物需要找到并拿回3个钥匙。
    # 您需要下一个类型的物品:
    # "bronze-key", "silver-key"和 "gold-key"

 

pet.on("spawn", onSpawn)
while True:
    enemy = hero.findNearestEnemy()
    if enemy and enemy.team == "ogres":
        hero.attack(enemy)
    if hero.health < 300:
        # 你也可以在主线程中使用宠物
        potion = pet.findNearestByType("potion")
        if potion:
            hero.moveXY(potion.pos.x, potion.pos.y)

概览

你已经掌握了最近这个关卡所需的技能。 如果您在这个关卡遇到问题,请尝试返回并重新掌握您的技能。

注意物品类型和拼写错误。 物品类型是字符串。

提醒你一下:

potion = pet.findNearestByType("potion")
pet.fetch(potion)

钥匙陷阱 解法

# 获得三把钥匙并释放圣骑士。
def onSpawn(event):
    # 宠物需要找到并拿回3个钥匙。
    # 您需要下一个类型的物品:
    # "bronze-key", "silver-key"和 "gold-key"
    pet.fetch(pet.findNearestByType("bronze-key"))
    pet.fetch(pet.findNearestByType("silver-key"))
    pet.fetch(pet.findNearestByType("gold-key"))
pet.on("spawn", onSpawn)
while True:
    enemy = hero.findNearestEnemy()
    if enemy and enemy.team == "ogres":
        hero.attack(enemy)
    if hero.health < 300:
        # 你也可以在主线程中使用宠物
        potion = pet.findNearestByType("potion")
        if potion:
            hero.moveXY(potion.pos.x, potion.pos.y)
 
本攻略发于极客战记官方教学栏目,原文地址为:
 
原文地址:https://www.cnblogs.com/codecombat/p/13222989.html