# 你的目標是保護 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")
codecombat 嚴峻的決心
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.