From bee2e94f82d3667a08a26e92b1b6f4991fe4bd036d4f96ac8568bb807b678d9a Mon Sep 17 00:00:00 2001 From: andrea Date: Sat, 26 Jul 2025 23:10:51 +0200 Subject: [PATCH] item --- debug.py | 1 - entities/arena.py | 3 +-- entities/items/item.py | 21 +++++++++++++++++++++ entities/{ => items}/weapon_syms.py | 13 ++----------- entities/{ => items}/weapons.py | 9 +++++---- 5 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 entities/items/item.py rename entities/{ => items}/weapon_syms.py (67%) rename entities/{ => items}/weapons.py (76%) diff --git a/debug.py b/debug.py index 02712e9..08ae720 100644 --- a/debug.py +++ b/debug.py @@ -1,7 +1,6 @@ import time as _time import random as _rand import main as _main -from entities import weapon_syms as _wsyms def _debug_data(): players= [ diff --git a/entities/arena.py b/entities/arena.py index 9a74440..9756b40 100644 --- a/entities/arena.py +++ b/entities/arena.py @@ -1,7 +1,6 @@ from entities import player as _player -from entities import weapons as _weapons -from entities import weapon_syms as _wsyms from entities import event_picker as _events +from entities.items import weapons as _weapons class BrSimArena(): diff --git a/entities/items/item.py b/entities/items/item.py new file mode 100644 index 0000000..8aa6e23 --- /dev/null +++ b/entities/items/item.py @@ -0,0 +1,21 @@ +import random as _random + +class BrSimItem(): + + def __init__(self): + pass + + def get_name(self): + return self.name + + def get_item_type(self): + return self.item_type + + def get_weight(self): + return self.weight + + def is_weapon(self): + return False + + def is_cure(self): + return False diff --git a/entities/weapon_syms.py b/entities/items/weapon_syms.py similarity index 67% rename from entities/weapon_syms.py rename to entities/items/weapon_syms.py index e46bc7e..789be0d 100644 --- a/entities/weapon_syms.py +++ b/entities/items/weapon_syms.py @@ -1,6 +1,5 @@ KNIFE= 1 -GUN= 2 -BOMB= 3 +ARCH= 2 SHORT_RANGE= 1 FAR_RANGE= 2 @@ -14,7 +13,7 @@ WEAPONS= { 'ammons': -1, # -1, no limit 'range': SHORT_RANGE, }, - GUN: { + ARCH: { 'weight': 2, 'name': 'gun', 'damage': 3, @@ -22,12 +21,4 @@ WEAPONS= { '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/items/weapons.py similarity index 76% rename from entities/weapons.py rename to entities/items/weapons.py index fd54870..1e82a72 100644 --- a/entities/weapons.py +++ b/entities/items/weapons.py @@ -1,10 +1,11 @@ import random as _random -from entities import weapon_syms as _syms +from entities.items import item as _item +from entities.items import weapon_syms as _syms -class BrSimWeapon(): +class BrSimWeapon(_item.BrSimItem): - def __init__(self, wtype): - self.weapon= _syms.WEAPONS[wtype] + def __init__(self, wtype= None): + self.weapon= _syms.WEAPONS[wtype or _random.randint(1,2)] self.name= self.weapon['name'] self.damage= self.weapon['damage'] self.weight= self.weapon['weight']