大领主打狗

'''
对象人:
特征:
   name='paladin'
   aggr=8000-10000
   health_point=343846
   mastered='37%'
技能:
   def judge():divine
   def templars_verdict():divine
   def crusader_strike():physic
   def divine_storm():divine

对象狗
特征
   name='prince'
   aggr=5000-6000
   health_point=365154
   mastered='57%'
技能
   def kill_command():
   def bite():
   def craw():

'''
import random
import time

judged=[]
class human:
    def __init__(self, name, aggr, health, mast):
        self.name = name
        self.aggr = aggr
        self.hp = health
        self.mastered = mast



    def judge(self,dog):
        if dog.hp <= 0:
            return True
        if self.hp>0:
            atk=self.aggr*(2+self.mastered)

            dog.hp-=atk

        print(f'''
[{self.name}]开始攻击[{dog.name}]
[{self.name}]使用了‘审判’对 [{dog.name}] 造成了{self.aggr*(2+self.mastered)}点伤害
[{dog.name}]还有{dog.hp}血     
        ''')
        print(".", end="")
        for i in range(5):
            print(".", end='')
            time.sleep(0.2)
        print(".")
        if dog.hp <= 0:
            print(f'[{self.name}]杀死了[{dog.name}]')

    def templars_verdict(self,dog):
        if dog.hp <= 0:
            return True
        if self.hp>0:
            atk = self.aggr * (4 + self.mastered)
            dog.hp-=atk
            print(f'''
[{self.name}]开始攻击[{dog.name}]
[{self.name}]使用了'圣殿骑士的裁决'对 [{dog.name}] 造成了{self.aggr * (4 + self.mastered)}点伤害
[{dog.name}]还有{dog.hp}血     
        ''')
            print(".", end="")
            for i in range(5):
                print(".", end='')
                time.sleep(0.2)
            print(".")
        if dog.hp <= 0:
            print(f'[{self.name}]杀死了[{dog.name}]')

    def crusader_strike(self,dog):
        if dog.hp <= 0:
            return True
        if self.hp>0:
            atk = self.aggr * 2
            dog.hp-=atk
            print(f'''
[{self.name}]开始攻击[{dog.name}]
[{self.name}]使用了'十字军打击'对 [{dog.name}] 造成了{self.aggr * 2}点伤害
[{dog.name}]还有{dog.hp}血     
        ''')
            print(".", end="")
            for i in range(5):
                print(".", end='')
                time.sleep(0.2)
            print(".")
        if dog.hp <= 0:
            print(f'[{self.name}]杀死了[{dog.name}]')

    def divine_storm(self,dog):
        if dog.hp <= 0:
            return True
        if self.hp>0:
            atk = self.aggr * (3 + self.mastered)
            dog.hp-=atk
            print(f'''
[{self.name}]开始攻击[{dog.name}]
[{self.name}]使用了'神圣风暴'对 [{dog.name}] 造成了{self.aggr * (3 + self.mastered)}点伤害
[{dog.name}]还有{dog.hp}血     
                ''')
            print(".", end="")
            for i in range(5):
                print(".", end='')
                time.sleep(0.2)
            print(".")
        if dog.hp <= 0:
            print(f'[{self.name}]杀死了[{dog.name}]')




class Dog:
    def __init__(self, name, aggr, health, mast):
        self.name = name
        # self.dog_type = dog_type
        self.aggr = aggr
        self.hp = health
        self.mastered = mast

    def kill_command(self,human):
        if human.hp<=0:
            return True
        if self.hp>0:
            atk = self.aggr * (4 + self.mastered)
            human.hp -= atk
            print(f'''
[{self.name}]开始攻击[{human.name}]
[{self.name}]使用了'杀戮命令'对 [{human.name}] 造成了{self.aggr * (4 + self.mastered)}点伤害
[{human.name}]还有{human.hp}血     
                ''')
            print(".", end="")
            for i in range(5):
                print(".", end='')
                time.sleep(0.2)
            print(".")

        if human.hp <= 0:
            print(f'[{self.name}]杀死了[{human.name}]')

    def bite(self,human):
        if human.hp<=0:
            return True
        if self.hp>0:
            atk = self.aggr * 8
            human.hp -= atk
            print(f'''
[{self.name}]开始攻击[{human.name}]
[{self.name}]使用了'绝命撕咬'对 [{human.name}] 造成了{self.aggr * 7}点伤害
[{human.name}]还有{human.hp}血     
                ''')
            print(".", end="")
            for i in range(5):
                print(".", end='')
                time.sleep(0.2)
            print(".")
        if human.hp <= 0:
            print(f'[{self.name}]杀死了[{human.name}]')
    def craw(self, human):
        if human.hp <= 0:
            return True
        if self.hp>0:
            atk = self.aggr * (3 + self.mastered)
            human.hp -= atk
            print(f'''
[{self.name}]开始攻击[{human.name}]
[{self.name}]使用了'黑爪'对 [{human.name}] 造成了{self.aggr * (3 + self.mastered)}点伤害
[{human.name}]还有{human.hp}血     
             ''')
            print(".", end="")
            for i in range(5):
                print(".", end='')
                time.sleep(0.2)
            print(".")
        if human.hp <= 0:
            print(f'[{self.name}]杀死了[{human.name}]')



human_atk=random.randint(8000,10000)
dog_atk=random.randint(5000,6000)
p1=human('paladin',human_atk,343846,0.37)
d1=Dog('prince',dog_atk,365154,0.17)

retribution = {
    1: p1.judge,
    2: p1.templars_verdict,
    3: p1.crusader_strike,
    4: p1.divine_storm

}
beast = {
    1: d1.kill_command,
    2: d1.bite,
    3: d1.craw

}

while True:


    flag1 = retribution[random.randint(1, 4)](d1)

    # print(flag1)
    if flag1:
        break

    flag2 = beast[random.randint(1, 3)](p1)
    if flag2:
        break
上一篇:Python实战之制作瘟疫传播实验


下一篇:状态模式