codecombat极客战记 --木材的叛徒

while True:
    # 收集金子
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x,item.pos.y)
    # 如果你有足够的金币,召唤一个士兵。
    if hero.gold>hero.costOf("soldier"):
        hero.summon("soldier")
    # 使用 for 循环来命令每个士兵。
    for friend in hero.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            soldier = hero.findFriends()
            
            # 如果这有一个敌人,命令她攻击。
            # 小心!如果你的战士被打败了,术士就会出现!
            # 否则的话,移动她到地图的右边。
            if enemy:
                hero.command(friend, "attack", enemy)
            else:
                hero.command(friend, "move", {"x":91,"y":57})

重点是要移动到shaman (巫师)的位置,巫师出现要立即攻击他,翻译有点差,提示要注意士兵的生命值根本没有用,术士(shaman ,巫师)一定会出现,关键士兵移动目标位置一定是术士的位置

猜你喜欢

转载自blog.csdn.net/weixin_42861040/article/details/83927230