1
0

define the skeleton of the battle royale game

This commit is contained in:
andrea
2025-07-23 19:54:39 +02:00
parent 86c7f7ae48
commit 0694ae0cae
4 changed files with 126 additions and 0 deletions

20
entities/player.py Normal file
View File

@@ -0,0 +1,20 @@
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

33
entities/weapon_syms.py Normal file
View File

@@ -0,0 +1,33 @@
KNIFE= 1
GUN= 2
BOMB= 3
SHORT_RANGE= 1
FAR_RANGE= 2
WEAPONS= {
KNIFE: {
'weight': 1,
'name': 'knife',
'damage': 3,
'miss_chance': 0, # from 0 to 100, this is the probably to miss the hit
'ammons': -1, # -1, no limit
'range': SHORT_RANGE,
},
GUN: {
'weight': 2,
'name': 'gun',
'damage': 3,
'miss_chance': 20, # from 0 to 100, this is the probably to miss the hit
'ammons': 10, # -1, no limit
'range': FAR_RANGE,
},
BOMB: {
'weight': 2,
'name': 'bomb',
'damage': 10,
'miss_chance': 5, # from 0 to 100, this is the probably to miss the hit
'ammons': 1,
'range': FAR_RANGE,
},
}

31
entities/weapons.py Normal file
View File

@@ -0,0 +1,31 @@
import random as _random
from entities import weapon_syms as _syms
class BrSimPlayer():
def __init__(self, wtype):
self.weapon= _syms.WEAPONS[wtype]
self.name= self.weapon['name']
self.damage= self.weapon['damage']
self.weight= self.weapon['weight']
self.range= self.weapon['range']
self.ammons= self.weapon['ammons']
self.miss_chance= self.weapon['miss_chance']
def _ammons_check(self):
if self.ammons == -1: return True # this weapons doesn't needs ammons
return self.ammons > 0
def _try_to_hit(self):
if not self.miss_chance: return True
rnd= _random.randint(0, 100)
if rnd > self.miss_chance: return True
return False
def hit(self, hits= 1):
if not _ammons_check: return 0
if not _try_to_hit(): return 0
return self.damage
def add_ammons(self, ammons):
self.ammons+= ammons

42
main.py Normal file
View File

@@ -0,0 +1,42 @@
from entities import player as _player
from entities import weapons as _weapons
from entities import weapon_syms as _wsyms
class BrSimArena():
# players = [{'name': name, 'inventory': default_inventory, other_stats}]
# weapons = [{WEAPON.KNIFE: quantity}, etc...] # this is the whole quantity of the items available on the world
def __init__(self, players, weapons):
self.day= 1
self.players= players
self.weapons= weapons
def next_day(self):
self.day+= 1
def do_random_event(self):
#XXX random player does random action according to his inventory health, wounds, available weapons on the world, etc...
pass
def supporter_donation(self):
#XXX supporter donate a random item or weapon to a random player
#TODO maybe in future a player can have charism stats that can influence the chance to get a donation
pass
def init_arena():
players= [{'name': 'Crystal'}, {'name': 'Cyan'}]
weapons= [{_wsyms.KNIFE: 1}]
return BrSimArena(players, weapons)
Arena= init_arena()
def run_event():
pass
def main():
print(Arena.players)
print(Arena.weapons)
run_event()