打卡——极客战记之KELVINTAPH十字军

KELVINTAPH十字军

只是为了Mark下,只是为了Mark下,只是为了Mark下!!
我知道:
绝对不是最好的代码,甚至不是好的代码!
绝对需要拼上最好的装备,虽然没用人民币,但是前面积攒的宝石几乎用花了!
照搬也不一定能通过,因为敌人是随机出现的!

我的装备
# 你可以通过墙壁找到朋友,但不是敌人。
# 注意光滑,无摩擦的冰块!


def commandPaladin(pala):
    friends =  hero.findFriends()
    for friend in friends:
        if friend.type != "paladin" and friend.health < friend.Maxhealth / 2:
            hero.command(pala, "cast", "heal", friend)
        else:
            continue
    

def findWitch(friend):
    enemies = friend.findEnemies()
    for enemy in enemies:
        if enemy.type == "witch" and enemy.health > 0:
            return enemy

def commandArcher(arch):
    witch = findWitch(arch)
    if witch:
        #hero.say(witch.id)
        hero.command(arch, "attack", witch)
    else:
        enemy = arch.findNearestEnemy()
        if enemy:
            hero.command(arch, "attack", enemy)
    

#hero.moveXY(5, 24)
while True:
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            commandPaladin(friend)
            pass
        elif friend.type == "archer":
            commandArcher(friend)
        elif friend.type == "soldier":
            commandArcher(friend)
        else:
            pass
        w = findWitch(friend)
    if not w:
        hero.say("Witch is dead!")
        break

hero.moveXY(9, 14)
friends = hero.findFriends()
for friend in friends:
    hero.command(friend, "move", {"x":54, "y":38})

count = 0
while count < 1:
    hero.moveXY(32, 14)
    hero.moveXY(2, 14)
    count += 1

hero.moveXY(65, 14)

friends = hero.findFriends()
for friend in friends:
    hero.command(friend, "move", {"x":78, "y":40})

catas = hero.findByType("catapult", hero.findEnemies())
for cata in catas:
    hero.attack(cata)
hero.moveXY(78 , 14)  



准备休息一段时间,暂时不过关了。
关于Python的基础应该差不多学完了,不熟的、不太懂的,主要是CodeCommbat的库。比如hero.command()这个方法,我怀疑它的内部实现有一个内嵌的循环,所以一不小心就会死循环。
另一个比较困扰我的是向量,大学知识差不多还给老师了,需要温习温习再战!
放假了,承诺了要带儿子打极客,所以,最近都会跟他一起去征战副线关卡。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 只是为了Mark下,只是为了Mark下,只是为了Mark下!!我知道:绝对不是最好的代码,甚至不是好的代码!绝对需...
    晏如V5阅读 1,589评论 0 1
  • 梗来源于基友想要寻找动漫的描述,其实就是一篇傻白甜,以及必然的OCC,请轻拍以及善用只看该作者 以下正文 001 ...
    晏怀瑾阅读 2,810评论 5 18
  • 梨花开,春带雨 。梨花落,春入泥, 此生只为一人去。 杨玉环和李隆基的爱情故事流传至今,一曲荡气...
    陌城锦书来阅读 2,047评论 0 0
  • 340天。回家了。刚回到家,好几个月不见得小家伙就跑过来要拥抱,看她手臂用力张开,忍不住把她抱在怀里。才发觉,在不...
    黑兔子Gary阅读 431评论 2 0
  • 他问她睡了没有 被她呵呵了一脸 脏死了。
    留子尧阅读 3,700评论 0 1