Exemplo n.º 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):
     ClientMonster.__init__(self,
                            x,
                            y,
                            name,
                            oid,
                            hp=hp,
                            max_hp=max_hp,
                            mp=mp,
                            max_mp=max_mp,
                            fov_radius=fov_radius,
                            inventory=inventory)
Exemplo n.º 2
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):
     ClientMonster.__init__(self, x, y, name, oid, hp=hp,
                      max_hp=max_hp, mp=mp, max_mp=max_mp,
                      fov_radius=fov_radius, inventory=inventory)
Exemplo n.º 3
0
def handle_responses():
    """Read in server responses from the network and process."""

    res = Network.get_response()
    while res:
        # Load level map
        if 'map' in res:
            CS.map = ClientMap.unserialize(res['map'])
            new_dlevel = True
        else:
            new_dlevel = False

        # Update log messages
        if 'log' in res:
            for msg in res['log']:
                CS.msgs.append(msg)

            CS.log_updated = True

        # Update monsters
        if 'm' in res:
            for oid, m_str in res['m'].iteritems():
                if oid in ClientObject.obj_dict:
                    ClientObject.obj_dict[oid].update_from_string(m_str)
                else:
                    mon = ClientMonster.unserialize(m_str)
                    mon.place_on_map()

        # Delete monsters
        if 'm_del' in res:
            for oid, flags in res['m_del']:
                ClientObject.obj_dict[oid].delete(flags)

        # Update items
        if 'i' in res:
            for oid, i_str in res['i'].iteritems():
                if oid in ClientObject.obj_dict:
                    ClientObject.obj_dict[oid].update_from_string(i_str)
                else:
                    item = ClientItem.unserialize(i_str)
                    item.place_on_map()

        # Delete items
        if 'i_del' in res:
            for oid, flags in res['i_del']:
                ClientObject.obj_dict[oid].delete(flags)

        # Update the player object
        if 'u' in res:
            if CS.u is not None:
                CS.u.update_from_string(res['u'])
            else:
                CS.u = ClientPlayer.unserialize(res['u'])

            # If we're changing dungeon levels, the player needs a new FOV map
            if new_dlevel:
                CS.u.set_fov_map(CS.map.grid)

            CS.u.fov_map.do_fov(CS.u.x, CS.u.y, CS.u.fov_radius)
            gui.center_map()

        res = Network.get_response()
Exemplo n.º 4
0
def handle_responses():
    """Read in server responses from the network and process."""

    res = Network.get_response()
    while res:
        # Load level map
        if 'map' in res:
            CS.map = ClientMap.unserialize(res['map'])
            new_dlevel = True
        else:
            new_dlevel = False

        # Update log messages
        if 'log' in res:
            for msg in res['log']:
                CS.msgs.append(msg)

            CS.log_updated = True

        # Update monsters
        if 'm' in res:
            for oid, m_str in res['m'].iteritems():
                if oid in ClientObject.obj_dict:
                    ClientObject.obj_dict[oid].update_from_string(m_str)
                else:
                    mon = ClientMonster.unserialize(m_str)
                    mon.place_on_map()

        # Delete monsters
        if 'm_del' in res:
            for oid, flags in res['m_del']:
                ClientObject.obj_dict[oid].delete(flags)

        # Update items
        if 'i' in res:
            for oid, i_str in res['i'].iteritems():
                if oid in ClientObject.obj_dict:
                    ClientObject.obj_dict[oid].update_from_string(i_str)
                else:
                    item = ClientItem.unserialize(i_str)
                    item.place_on_map()

        # Delete items
        if 'i_del' in res:
            for oid, flags in res['i_del']:
                ClientObject.obj_dict[oid].delete(flags)

        # Update the player object
        if 'u' in res:
            if CS.u is not None:
                CS.u.update_from_string(res['u'])
            else:
                CS.u = ClientPlayer.unserialize(res['u'])

            # If we're changing dungeon levels, the player needs a new FOV map
            if new_dlevel:
                CS.u.set_fov_map(CS.map.grid)

            CS.u.fov_map.do_fov(CS.u.x, CS.u.y, CS.u.fov_radius)
            gui.center_map()

        res = Network.get_response()