예제 #1
0
    def __init__(self, x, y, name, oid, hp=None, max_hp=None,
                 mp=None, max_mp=None, fov_radius=cfg.TORCH_RADIUS,
                 inventory=None):
        ClientObject.__init__(self, x, y, name, oid)

        self.blocks_sight = False
        self.blocks_movement = True
        self.fov_radius = fov_radius

        # Field of view map.
        self.fov_map = None

        # FIXME: this should be loaded from a database
        if name == 'wizard':
            if hp is None:
                self.hp = 30
            self.atk_power = 5
            self.defense = 2
        elif name == 'orc':
            if hp is None:
                self.hp = 1
            self.atk_power = 1
            self.defense = 0
        elif name == 'troll':
            if hp is None:
                self.hp = 10
            self.atk_power = 2
            self.defense = 0

        if hp is not None:
            self.hp = hp

        if max_hp is None:
            self.max_hp = self.hp
        else:
            self.max_hp = max_hp

        if inventory is None:
            self.inventory = []
        else:
            self.inventory = inventory

        # FIXME dummy values
        self.mp = 13
        self.max_mp = 25
        self.xp = 1220
        self.xp_next_level = 2000
        self.weight = 580
        self.burdened = 1000
        self.hunger = 450
        self.max_hunger = 1000
예제 #2
0
    def _get_client_table_rows(self, object_type: ClientObject,
                               ids: List[str]):
        cur = self.client_conn.cursor()
        table_name = object_type.table_name()
        columns, constructors = zip(*object_type.db_columns_from_client())
        column_select_str = ', '.join(columns)

        for id in ids:
            cur.execute(
                f'SELECT {column_select_str} FROM {table_name} WHERE id = ?',
                [id])
            row = cur.fetchone()
            if row:
                values = [c(r) for c, r in zip(constructors, row)]
                yield object_type(**dict(zip(columns, values)))
예제 #3
0
 def __init__(self, x, y, name, oid):
     ClientObject.__init__(self, x, y, name, oid)
     self.blocks_sight = False
     self.blocks_movement = False
예제 #4
0
 def __init__(self, x, y, name, oid):
     ClientObject.__init__(self, x, y, name, oid)
     self.blocks_sight = False
     self.blocks_movement = False