「网易官方」极客战记(codecombat)攻略-沙漠-诅咒谷-cursed-valley

(点击图片进入关卡)

这太热了,太热了。 专注在你的任务上,不要被炎热分心。

简介

炎热的太阳正在耗尽英雄的生命值! 保存你的力量!

只有在 enemy.team 是 "ogres" 和 enemy.type 是 "skeleton" 时才会被攻击。

除非 item.type 是 "potion" 并且 hero.health 小于 hero.maxHealth / 4 ,否则不要收集任何项目。

默认代码

# 炎热的太阳正在耗尽英雄的生命值!

 

while True:
    enemy = hero.findNearestEnemy()
    # 攻击!如果敌人存在且enemy.team 为 "ogres"
    # 并且 enemy.type是 "skeleton"
    if enemy and enemy.team == "ogres" and enemy.type == "skeleton":
        hero.attack(enemy)

 

    item = hero.findNearestItem()
    # 收集物品,如果物品存在且 item.type是"potion"
    # 并且 hero.health小于hero.maxHealth / 4

概览

被诅咒的墓地是一个危险的地方!

确保检查骨架的类型,以便英雄不会攻击任何牦牛。 还要确保只攻击 "ogres" 团队中的骷髅。

对物品做同样的事情。 如果英雄的生命值低于 hero.maxHealth / 4 ,那么只能拿到药水。

诅咒谷 解法

# 炎热的太阳正在耗尽英雄的生命值!

 

while True:
    enemy = hero.findNearestEnemy()
    # 攻击!如果敌人存在且enemy.team 为 "ogres"
    # 并且 enemy.type是 "skeleton"
    if enemy and enemy.team == "ogres" and enemy.type == "skeleton":
        hero.attack(enemy)

 

    item = hero.findNearestItem()
    # 收集物品,如果物品存在且 item.type是"potion"
    # 并且 hero.health小于hero.maxHealth / 4
    if item and item.type == "potion" and hero.health < hero.maxHealth / 4:
        hero.move(enemy)
 
本攻略发于极客战记官方教学栏目,原文地址为:
原文地址:https://www.cnblogs.com/codecombat/p/13183917.html