forked from Cryz/battle_royale_sim
Compare commits
4 Commits
eb592579a0
...
d140e726b4
| Author | SHA256 | Date | |
|---|---|---|---|
| d140e726b4 | |||
| 9365abd05e | |||
| 072938fb24 | |||
| df4bd5290e |
@@ -14,9 +14,28 @@ class BrSimPlayer():
|
||||
def is_alive(self):
|
||||
return self.is_alive
|
||||
|
||||
def attack(self, target):
|
||||
if not self.is_alive(): return
|
||||
if not target.is_alive(): return
|
||||
if target.try_to_avoid_hit(): return # print something like 'enemy doges the attacl'
|
||||
|
||||
target.accuses_damage(self.damage)
|
||||
|
||||
def accuses_damage(self, damage):
|
||||
self.health -= damage
|
||||
if self.health <= 0:
|
||||
self.health = 0
|
||||
self.is_alive = False
|
||||
# show something like 'player is dead'
|
||||
else:
|
||||
# show something like 'get hit'
|
||||
pass
|
||||
|
||||
def try_to_avoid_hit(self):
|
||||
# maybe depend on the attack, if it is a gun shot it's quite impossible to dodge
|
||||
rnd= _random.randint(0, 100)
|
||||
if rnd > self.agility: return True
|
||||
# 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
|
||||
return False
|
||||
|
||||
def steal(self):
|
||||
|
||||
Reference in New Issue
Block a user