forked from Cryz/battle_royale_sim
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
import random as _random
|
|
|
|
class BrSimPlayer():
|
|
|
|
def __init__(self, name, inventory= None):
|
|
self.name= name
|
|
self.health= 1
|
|
self.inventory= inventory or []
|
|
self.damage= 1 # this is the punch damage amount
|
|
self.max_weight= 5 # this is the max inventory weight
|
|
self.is_alive= True
|
|
self.agility= 10 # chance to avoid an hit
|
|
|
|
def is_alive(self):
|
|
return self.is_alive
|
|
|
|
def try_to_avoid_hit(self):
|
|
rnd= _random.randint(0, 100)
|
|
if rnd > self.agility: return True
|
|
return False
|
|
|
|
def steal(self):
|
|
#XXX can steal from death players or from sleeping players
|
|
pass
|
|
|
|
def escape(self):
|
|
#XXX It can run away from the fighting
|
|
pass
|
|
|
|
def heal(self):
|
|
#XXX if you have a wound and you have a medikit item, you can heal your wound or sickness
|
|
pass
|
|
|
|
def get_inventory(self):
|
|
return self.inventory
|
|
|
|
def get_name(self):
|
|
return self.name
|
|
|
|
def get_health(self):
|
|
return self.health
|
|
|
|
def get_damage(self):
|
|
return self.damage
|
|
|
|
def get_agility(self):
|
|
return self.agility
|
|
|
|
def get_data(self):
|
|
return {
|
|
'name': self.get_name(),
|
|
'inventory': self.get_inventory(),
|
|
'health': self.get_health(),
|
|
'damage': self.get_damage(),
|
|
'agility': self.get_agility(),
|
|
}
|