#coding=utf-8
class Guns(object):
def __init__(self):
self.type = "M16"
self.bulletnum = 30
self.harm = 50
def show_info(self):
print 'the gunInfo type is:%s,bulletnum is:%s,harm is:%s' % (self.type, self.bulletnum, self.harm)
def add_bullet(self, k=5):
for v in xrange(k):
self.bulletnum += 30
print 'the gun bulletnum is:%d,now!' % self.bulletnum
class Person(object):
def __init__(self):
self.name = 'player1'
self.blood = 100
self.position = (0, 0)
self.harm_people = []
self.gun = Guns()
def get_a_gun(self,gun):
# print 'get a gunInfo is:%s,%s,%s' %(gun.type,gun.bulletnum,gun.harm)
gun.show_info()
class Police(Person):
def __init__(self):
Person.__init__(self)
self.name = 'Police'
self.kill_index = 0
self.pers = Thief()
def shoot(self,gun,pers):
if gun.bulletnum < 150:
gun.add_bullet()
#
gun.bulletnum -= 1
pers.blood -= gun.harm
if pers.blood <= 0:
pers.isDead = True
pers.killed_index += 1
self.kill_index += 1
self.harm_people.append(pers.name)
print 'kill_index is:%d,harm_people is:%s' %(self.kill_index,self.harm_people)
return self.kill_index,self.harm_people
class Thief(Person):
def __init__(self):
Person.__init__(self)
self.name = 'thief'
self.killed_index = 0
self.isDead = False
def show_thief_info(self):
print 'thief blood is:%d,isDead is:%s,killed_index is:%d' %(self.blood,self.isDead,self.killed_index)
g = Guns()
p1 = Thief()
pers = Police()
def mainRun(g,p1):
for x in xrange(10):
p1.get_a_gun(g)
p1.show_thief_info()
if p1.isDead:
print "the Thief has dead, stop shoot"
break
else:
pers.shoot(g,p1)
mainRun(g,p1)
#