模拟CS (警察和匪徒)

警察和匪徒不能攻击队友

class Foo():
    def da(self,b):
        if self.juese == b.juese:
            print("不能攻击队友")
        else :
            b.hp -= 10
            print(f"{self.juese}{self.name}使用武器{self.wq}攻击了{b.juese}{b.name},{b.name}掉血10,还有{b.hp}血量")

class Pol(Foo):
    def __init__(self,name,wq,hp):
        self.name = name
        self.wq = wq
        self.hp = hp
        self.juese= "警察"

class Ter(Foo):
    def __init__(self,name,wq,hp):
        self.name = name
        self.wq = wq
        self.hp = hp
        self.juese= "匪徒"

p1 = Pol("宝宝","m4a1",100)
p2 = Pol("壮壮","m4a1",100)
t = Ter("强强","ak47",100)
p1.da(t)
p2.da(p1)
t.da(p2)

  

posted on 2019-01-03 20:04  哎呀!土豆  阅读(176)  评论(0编辑  收藏  举报

导航