From 0694ae0cae85d1a18c82ef0b4a2b4522055d816dfcfc40f599adc757e193cbd3 Mon Sep 17 00:00:00 2001 From: andrea Date: Wed, 23 Jul 2025 19:54:39 +0200 Subject: [PATCH] define the skeleton of the battle royale game --- entities/player.py | 20 ++++++++++++++++++++ entities/weapon_syms.py | 33 ++++++++++++++++++++++++++++++++ entities/weapons.py | 31 ++++++++++++++++++++++++++++++ main.py | 42 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 entities/player.py create mode 100644 entities/weapon_syms.py create mode 100644 entities/weapons.py create mode 100644 main.py diff --git a/entities/player.py b/entities/player.py new file mode 100644 index 0000000..fb46faa --- /dev/null +++ b/entities/player.py @@ -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 diff --git a/entities/weapon_syms.py b/entities/weapon_syms.py new file mode 100644 index 0000000..e46bc7e --- /dev/null +++ b/entities/weapon_syms.py @@ -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, + }, + } diff --git a/entities/weapons.py b/entities/weapons.py new file mode 100644 index 0000000..97496a0 --- /dev/null +++ b/entities/weapons.py @@ -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 diff --git a/main.py b/main.py new file mode 100644 index 0000000..75e10e0 --- /dev/null +++ b/main.py @@ -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() +