首页 > 代码库 > codecombat 严峻的决心
codecombat 严峻的决心
# 你的目标是保护 Reynaldo # 找到生命值最低的武士 def lowestHealthPaladin(): lowestHealth = 99999 lowestFriend = None friends = hero.findFriends() for friend in friends: if friend.type != "paladin": continue if friend.health < lowestHealth and friend.health < friend.maxHealth: lowestHealth = friend.health lowestFriend = friend return lowestFriend def commandPeasant(peasant): item = peasant.findNearestItem() if item: hero.command(peasant, "move", item.pos) def commandGriffin(griffin): target = hero.findNearest(hero.findByType(‘warlock‘)) if target: hero.command(griffin, "attack", target) else: target = griffin.findNearestEnemy() def commandPaladin(paladin): # 使用函数 lowestHealthPaladin() 找到生命值最低的武士,并治疗 # 你能使用 paladin.canCast("heal") 和 command(paladin, "cast", "heal", target) # 武士也能防御:command(paladin, "shield") # 不要忘了他们还能攻击 target = hero.findNearest(hero.findByType(‘warlock‘)) if paladin.health < 250: hero.command(paladin, "shield") else: if paladin.canCast("heal"): healtarget = lowestHealthPaladin() # and healtarget and healtarget.health < 400: if healtarget: hero.command(paladin, "cast", "heal", healtarget) else: target = paladin.findNearestEnemy() hero.command(paladin, "attack", target) def commandFriends(): # 指挥你的队友 friends = hero.findFriends() for friend in friends: if friend.type == "peasant": commandPeasant(friend) if friend.type == "griffin-rider": commandGriffin(friend) if friend.type == "paladin": commandPaladin(friend) while True: commandFriends() # 召唤 格里芬骑士 if hero.gold >= hero.costOf("griffin-rider"): hero.summon("griffin-rider")
本文出自 “运维新手” 博客,请务必保留此出处http://67263992.blog.51cto.com/3718090/1886941
codecombat 严峻的决心
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。