forked from Cryz/battle_royale_sim
is_alive() is now based on player's health instead of a dedicated state
This commit is contained in:
@@ -8,11 +8,10 @@ class BrSimPlayer():
|
|||||||
self.inventory= inventory or []
|
self.inventory= inventory or []
|
||||||
self.damage= 1 # this is the punch damage amount
|
self.damage= 1 # this is the punch damage amount
|
||||||
self.max_weight= 5 # this is the max inventory weight
|
self.max_weight= 5 # this is the max inventory weight
|
||||||
self.is_alive= True
|
|
||||||
self.agility= 10 # chance to avoid an hit
|
self.agility= 10 # chance to avoid an hit
|
||||||
|
|
||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
return self.is_alive
|
return self.health > 0
|
||||||
|
|
||||||
def attack(self, target):
|
def attack(self, target):
|
||||||
if not self.is_alive(): return
|
if not self.is_alive(): return
|
||||||
@@ -25,7 +24,6 @@ class BrSimPlayer():
|
|||||||
self.health -= damage
|
self.health -= damage
|
||||||
if self.health <= 0:
|
if self.health <= 0:
|
||||||
self.health = 0
|
self.health = 0
|
||||||
self.is_alive = False
|
|
||||||
# show something like 'player is dead'
|
# show something like 'player is dead'
|
||||||
else:
|
else:
|
||||||
# show something like 'get hit'
|
# show something like 'get hit'
|
||||||
@@ -34,7 +32,6 @@ class BrSimPlayer():
|
|||||||
def try_to_avoid_hit(self):
|
def try_to_avoid_hit(self):
|
||||||
# maybe depend on the attack, if it is a gun shot it's quite impossible to dodge
|
# maybe depend on the attack, if it is a gun shot it's quite impossible to dodge
|
||||||
rnd= _random.randint(0, 100)
|
rnd= _random.randint(0, 100)
|
||||||
# if rnd > self.agility: return True ## XXX this is strange, if the agility is high the chances to dodge are lower
|
|
||||||
if rnd < self.agility: return True
|
if rnd < self.agility: return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user