Esempio n. 1
0
    def send_socket_changed_notify(self, socket_id, socket):
        msg = protomsg.UpdateSocketNotify()
        s = msg.sockets.add()
        self._msg_socket(s, socket_id, socket)
        publish_to_char(self.char_id, pack_msg(msg))

        socket_changed_signal.send(sender=None, socket_obj=socket)
Esempio n. 2
0
def _equip_changed(char_id, equip_obj, **kwargs):
    equip_id = equip_obj.equip_id

    f = Formation(char_id)
    socket = f.find_socket_by_equip(equip_id)

    if socket:
        socket_changed_signal.send(sender=None, socket_obj=socket)
Esempio n. 3
0
def _equip_changed(char_id, equip_obj, **kwargs):
    equip_id = equip_obj.equip_id

    f = Formation(char_id)
    socket = f.find_socket_by_equip(equip_id)

    if socket:
        socket_changed_signal.send(sender=None, socket_obj=socket)
Esempio n. 4
0
    def special_buy(self, socket_id, tp):
        # FIXME
        try:
            this_socket = self.formation.sockets[str(socket_id)]
        except KeyError:
            raise SanguoException(errormsg.FORMATION_NONE_EXIST_SOCKET,
                                  self.char_id, "Formation Special Buy",
                                  "socket {0} not exist".format(socket_id))

        if not this_socket.hero:
            raise SanguoException(errormsg.FORMATION_NO_HERO, self.char_id,
                                  "Formation Special Buy",
                                  "socket {0} no hero".format(socket_id))

        oid = MongoHero.objects.get(id=this_socket.hero).oid

        this_hero = HEROS[oid]
        special_cls = [int(i) for i in this_hero.special_equip_cls.split(',')]

        def _find_speicial_id(equipments):
            for e in equipments:
                if e.step == 0 and e.cls in special_cls:
                    return e.id

            # FIXME
            raise Exception("Special buy, not find. tp = {0}".format(tp))

        from core.item import Item
        item = Item(self.char_id)

        if tp == SpecialEquipmentBuyRequest.SOCKET_WEAPON:
            on_id = _find_speicial_id(ALL_WEAPONS.values())
            new_id = item.equip_add(on_id)
            self.formation.sockets[str(socket_id)].weapon = new_id
        elif tp == SpecialEquipmentBuyRequest.SOCKET_ARMOR:
            on_id = _find_speicial_id(ALL_ARMORS.values())
            new_id = item.equip_add(on_id)
            self.formation.sockets[str(socket_id)].armor = new_id
        else:
            on_id = _find_speicial_id(ALL_JEWELRY.values())
            new_id = item.equip_add(on_id)
            self.formation.sockets[str(socket_id)].jewelry = new_id

        self.formation.save()
        socket_changed_signal.send(
            sender=None, socket_obj=self.formation.sockets[str(socket_id)])

        standard_drop = make_standard_drop_from_template()
        standard_drop['equipments'] = [(new_id, 1, 1)]
        standard_drop['income'] = 1
        standard_drop['func_name'] = "Special Buy"
        standard_drop['des'] = ''
        resource_logger(self.char_id, standard_drop)

        self.send_socket_changed_notify(socket_id,
                                        self.formation.sockets[str(socket_id)])
Esempio n. 5
0
    def send_socket_changed_notify(self, socket_id, socket):
        msg = protomsg.UpdateSocketNotify()
        s = msg.sockets.add()
        self._msg_socket(s, socket_id, socket)
        publish_to_char(self.char_id, pack_msg(msg))

        socket_changed_signal.send(
            sender=None,
            socket_obj=socket
        )
Esempio n. 6
0
    def send_update_notify(self, _id, h):
        hobj = OneHorse(int(_id), h.oid, h.attack, h.defense, h.hp)
        msg = HorsesUpdateNotify()
        msg.horse.MergeFrom(hobj.make_msg())
        publish_to_char(self.char_id, pack_msg(msg))

        f = Formation(self.char_id)
        socket = f.find_socket_by_horse(int(_id))
        if socket:
            socket_changed_signal.send(sender=None, socket_obj=socket)
Esempio n. 7
0
    def send_update_notify(self, _id, h):
        hobj = OneHorse(int(_id), h.oid, h.attack, h.defense, h.hp)
        msg = HorsesUpdateNotify()
        msg.horse.MergeFrom(hobj.make_msg())
        publish_to_char(self.char_id, pack_msg(msg))

        f = Formation(self.char_id)
        socket = f.find_socket_by_horse(int(_id))
        if socket:
            socket_changed_signal.send(
                sender=None,
                socket_obj=socket
            )
Esempio n. 8
0
    def _replace_hero(self, socket_id, hero_id):
        off_hero = self.formation.sockets[str(socket_id)].hero
        hero_changed_signal.send(
            sender=None,
            hero_id=off_hero,
        )

        self.formation.sockets[str(socket_id)].hero = hero_id
        self.formation.save()

        socket_changed_signal.send(
            sender=None, socket_obj=self.formation.sockets[str(socket_id)])

        self.send_socket_changed_notify(socket_id,
                                        self.formation.sockets[str(socket_id)])
Esempio n. 9
0
    def _replace_hero(self, socket_id, hero_id):
        off_hero = self.formation.sockets[str(socket_id)].hero
        hero_changed_signal.send(
            sender=None,
            hero_id=off_hero,
        )

        self.formation.sockets[str(socket_id)].hero = hero_id
        self.formation.save()

        socket_changed_signal.send(
            sender=None,
            socket_obj=self.formation.sockets[str(socket_id)]
        )

        self.send_socket_changed_notify(socket_id, self.formation.sockets[str(socket_id)])