Exemplo n.º 1
0
    def send_notify(self):
        msg = CheckInNotify()
        for k in self.checkin_data.keys():
            item = msg.items.add()
            self._fill_up_one_item(item, k)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 2
0
def hero_notify(char_id, objs, message_name="HeroNotify"):
    data = getattr(protomsg, message_name)()

    for obj in objs:
        g = data.heros.add()
        g.id = obj.id
        g.original_id = obj.oid

        g.attack = int(obj.attack)
        g.defense = int(obj.defense)
        g.hp = int(obj.hp)
        g.cirt = int(obj.crit * 10)

        g.step = obj.step
        g.power = obj.power
        g.max_socket_amount = obj.max_socket_amount
        g.current_socket_amount = obj.current_socket_amount

        for k, v in obj.hero.wuxings.iteritems():
            wuxing = HeroWuXing(int(k), v.level, v.exp)
            msg_wuxing = g.wuxing.add()
            msg_wuxing.MergeFrom(wuxing.to_proto())


    publish_to_char(char_id, pack_msg(data))
Exemplo n.º 3
0
    def equip_add(self, oid, level=1, notify=True):
        try:
            this_equip = EQUIPMENTS[oid]
        except KeyError:
            raise SanguoException(errormsg.EQUIPMENT_NOT_EXIST, self.char_id,
                                  "Equipment Add",
                                  "Equipment {0} NOT exist".format(oid))

        new_id = id_generator('equipment')[0]
        me = MongoEmbeddedEquipment()
        me.oid = oid
        me.level = level
        me.gems = [0] * this_equip.slots

        self.item.equipments[str(new_id)] = me
        self.item.save()

        if notify:
            msg = protomsg.AddEquipNotify()
            msg_equip = msg.equips.add()
            self._msg_equip(msg_equip, new_id, me,
                            Equipment(self.char_id, new_id, self.item))
            publish_to_char(self.char_id, pack_msg(msg))

        return new_id
Exemplo n.º 4
0
    def send_notify(self):
        msg = AchievementNotify()
        for v in ACHIEVEMENTS.values():
            a = msg.achievements.add()
            self._fill_up_achievement_msg(a, v)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 5
0
    def send_stuff_notify(self):
        msg = protomsg.StuffNotify()
        for k, v in self.item.stuffs.iteritems():
            s = msg.stuffs.add()
            s.id, s.amount = int(k), v

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 6
0
    def send_notify(self):
        msg = protomsg.HangNotify()
        msg.remained_time = self.get_hang_remained()

        if self.hang_doing:
            msg.hang.stage_id = self.hang_doing.stage_id
            msg.hang.start_time = self.hang_doing.start
            if self.hang_doing.finished:
                msg.hang.used_time = self.hang_doing.actual_seconds
            else:
                msg.hang.used_time = arrow.utcnow().timestamp - self.hang_doing.start

            msg.hang.finished = self.hang_doing.finished

            times = msg.hang.used_time / 15
            stage = STAGES[self.hang_doing.stage_id]
            msg.hang.rewared_gold = self._actual_gold(stage.normal_gold * times)
            msg.hang.rewared_exp = stage.normal_exp * times

            for l in self.hang_doing.logs:
                msg_log = msg.logs.add()
                msg_log.attacker = l.name
                msg_log.win = l.gold > 0
                msg_log.gold = abs(l.gold)


        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 7
0
 def send_notify(self):
     self.load_mongo_record()
     msg = PlunderNotify()
     msg.current_times = self.mongo_plunder.current_times
     msg.max_times = self.max_plunder_times()
     msg.success_times_weekly = PlunderLeaderboardWeekly.get_char_times(self.char_id)
     publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 8
0
    def send_socket_notify(self):
        msg = protomsg.SocketNotify()
        for k, v in self.formation.sockets.iteritems():
            s = msg.sockets.add()
            self._msg_socket(s, int(k), v)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 9
0
    def remove(self, _id):
        self.mongo_horse.horses.pop(str(_id))
        self.mongo_horse.save()

        msg = HorsesRemoveNotify()
        msg.ids.extend([_id])
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 10
0
    def send_equip_notify(self):
        msg = protomsg.EquipNotify()
        for _id, data in self.item.equipments.iteritems():
            equip = msg.equips.add()
            self._msg_equip(equip, int(_id), data, Equipment(self.char_id, int(_id), self.item))

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 11
0
    def send_notify(self, char=None, opended_funcs=None):
        if not char:
            char = self.mc

        msg = protomsg.CharacterNotify()
        msg.char.id = char.id
        msg.char.name = char.name
        msg.char.gold = char.gold
        msg.char.sycee = char.sycee
        msg.char.level = char.level
        msg.char.current_exp = char.exp
        msg.char.next_level_exp = level_update_exp(char.level)
        msg.char.official = char.official
        msg.char.official_exp = char.official_exp
        msg.char.next_official_exp = official_update_exp(char.level)

        msg.char.power = self.power
        msg.char.vip = char.vip
        msg.char.purchase_got = char.purchase_got

        msg.char.leader = self.leader

        if opended_funcs:
            msg.funcs.extend(opended_funcs)

        publish_to_char(self.id, pack_msg(msg))
Exemplo n.º 12
0
    def send_already_stage_notify(self):
        msg = protomsg.AlreadyStageNotify()
        for _id, star in self.stage.stages.iteritems():
            s = msg.stages.add()
            self._msg_stage(s, int(_id), star)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 13
0
    def add(self, oid):
        assert oid in HORSE

        embedded_horse = MongoEmbeddedHorse()
        embedded_horse.oid = oid
        embedded_horse.attack = 0
        embedded_horse.defense = 0
        embedded_horse.hp = 0

        new_id = id_generator('equipment')[0]

        self.mongo_horse.horses[str(new_id)] = embedded_horse
        self.mongo_horse.save()

        hobj = OneHorse(
            new_id,
            embedded_horse.oid,
            embedded_horse.attack,
            embedded_horse.defense,
            embedded_horse.hp
        )

        msg = HorsesAddNotify()
        msg_h = msg.horses.add()
        msg_h.MergeFrom(hobj.make_msg())
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 14
0
    def someone_refuse_me(self, from_id):
        self.mf.friends.pop(str(from_id))
        self.mf.save()

        msg = protomsg.RemoveFriendNotify()
        msg.id = from_id
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 15
0
    def remove(self, _id):
        self.mongo_horse.horses.pop(str(_id))
        self.mongo_horse.save()

        msg = HorsesRemoveNotify()
        msg.ids.extend([_id])
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 16
0
    def enable(self, enabled):
        self.stage.activities.extend(enabled)
        self.stage.save()

        msg = protomsg.NewActivityStageNotify()
        msg.ids.extend(enabled)
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 17
0
    def send_notify(self):
        msg = protomsg.EliteStageNotify()
        for _id in self.stage.elites.keys():
            s = msg.stages.add()
            self._msg_one_stage(s, int(_id))

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 18
0
    def send_friends_notify(self):
        msg = protomsg.FriendsNotify()
        for k, v in self.friends_list():
            f = msg.friends.add()
            self._msg_friend(f, k, v)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 19
0
    def send_notify(self):
        msg = protomsg.HangNotify()
        msg.remained_time = self.get_hang_remained()

        if self.hang_doing:
            msg.hang.stage_id = self.hang_doing.stage_id
            msg.hang.start_time = self.hang_doing.start
            if self.hang_doing.finished:
                msg.hang.used_time = self.hang_doing.actual_seconds
            else:
                msg.hang.used_time = arrow.utcnow(
                ).timestamp - self.hang_doing.start

            msg.hang.finished = self.hang_doing.finished

            times = msg.hang.used_time / 15
            stage = STAGES[self.hang_doing.stage_id]
            msg.hang.rewared_gold = self._actual_gold(stage.normal_gold *
                                                      times)
            msg.hang.rewared_exp = stage.normal_exp * times

            for l in self.hang_doing.logs:
                msg_log = msg.logs.add()
                msg_log.attacker = l.name
                msg_log.win = l.gold > 0
                msg_log.gold = abs(l.gold)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 20
0
    def send_prisoners_notify(self):
        msg = protomsg.PrisonerListNotify()
        for k, v in self.p.prisoners.iteritems():
            p = msg.prisoner.add()
            self._fill_up_prisoner_msg(p, int(k), v.oid, v.prob, v.active)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 21
0
    def send_friends_notify(self):
        msg = protomsg.FriendsNotify()
        for k, v in self.friends_list():
            f = msg.friends.add()
            self._msg_friend(f, k, v)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 22
0
    def send_notify(self):
        msg = CheckInNotify()
        for k in CHECKIN_DATA.keys():
            item = msg.items.add()
            self._fill_up_one_item(item, k)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 23
0
    def equip_add(self, oid, level=1, notify=True):
        try:
            this_equip = EQUIPMENTS[oid]
        except KeyError:
            raise SanguoException(
                errormsg.EQUIPMENT_NOT_EXIST,
                self.char_id,
                "Equipment Add",
                "Equipment {0} NOT exist".format(oid)
            )

        new_id = id_generator('equipment')[0]
        me = MongoEmbeddedEquipment()
        me.oid = oid
        me.level = level
        me.gems = [0] * this_equip.slots

        self.item.equipments[str(new_id)] = me
        self.item.save()

        if notify:
            msg = protomsg.AddEquipNotify()
            msg_equip = msg.equips.add()
            self._msg_equip(msg_equip, new_id, me, Equipment(self.char_id, new_id, self.item))
            publish_to_char(self.char_id, pack_msg(msg))

        return new_id
Exemplo n.º 24
0
    def purge_soul(self, _id):
        self.mongo_hs.souls.pop(str(_id))
        self.mongo_hs.save()

        msg = protomsg.RemoveHeroSoulNotify()
        msg.ids.append(_id)
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 25
0
    def send_notify(self):
        msg = TaskNotify()
        for t in self.task.doing:
            this_task = TASKS[t]
            if this_task.func and not func_opened(self.char_id,
                                                  this_task.func):
                # 对于没有开放功能的任务不显示
                continue

            msg_t = msg.tasks.add()
            msg_t.id = t

            current_times = self.task.tasks[str(this_task.tp)]
            if current_times > this_task.times:
                current_times = this_task.times

            msg_t.current_times = current_times

            if t in self.task.complete:
                status = MsgTask.COMPLETE
            elif t in self.task.finished:
                status = MsgTask.REWARD
            else:
                status = MsgTask.DOING

            msg_t.status = status

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 26
0
    def stuff_add(self, add_stuffs, send_notify=True):
        """

        @param add_stuffs: [(id, amount), (id, amount)]
        @type add_stuffs: list | tuple
        """
        for _id, _ in add_stuffs:
            if _id not in STUFFS:
                raise SanguoException(
                    errormsg.STUFF_NOT_EXIST,
                    self.char_id,
                    "Stuff Add",
                    "Stuff Oid {0} not exist".format(_id)
                )

        stuffs = self.item.stuffs
        add_stuffs_dict = {}
        for _id, _amount in add_stuffs:
            add_stuffs_dict[_id] = add_stuffs_dict.get(_id, 0) + _amount

        new_stuffs = []
        update_stuffs = []
        for _id, _amount in add_stuffs_dict.iteritems():
            sid = str(_id)
            if sid in stuffs:
                stuffs[sid] += _amount
                update_stuffs.append((_id, stuffs[sid]))
            else:
                stuffs[sid] = _amount
                new_stuffs.append((_id, _amount))

        self.item.stuffs = stuffs
        self.item.save()

        for _id, _amount in add_stuffs_dict.iteritems():
            stuff_add_signal.send(
                sender=None,
                char_id=self.char_id,
                stuff_id=_id,
                add_amount=_amount,
                new_amount=stuffs[str(_id)]
            )

        if not send_notify:
            return
        if new_stuffs:
            msg = protomsg.AddStuffNotify()
            for k, v in new_stuffs:
                s = msg.stuffs.add()
                s.id, s.amount = k, v

            publish_to_char(self.char_id, pack_msg(msg))

        if update_stuffs:
            msg = protomsg.UpdateStuffNotify()
            for k, v in update_stuffs:
                s = msg.stuffs.add()
                s.id, s.amount = k, v

            publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 27
0
    def gem_remove(self, _id, amount):
        """

        @param _id: gem id
        @type _id: int
        @param amount: this gem amount
        @type amount: int
        """
        try:
            this_gem_amount = self.item.gems[str(_id)]
        except KeyError:
            raise SanguoException(
                errormsg.GEM_NOT_EXIST,
                self.char_id,
                "Gem Remove",
                "Gem {0} not exist".format(_id)
            )

        new_amount = this_gem_amount - amount
        if new_amount <= 0:
            self.item.gems.pop(str(_id))
            self.item.save()

            msg = protomsg.RemoveGemNotify()
            msg.ids.append(_id)
            publish_to_char(self.char_id, pack_msg(msg))
        else:
            self.item.gems[str(_id)] = new_amount
            self.item.save()
            msg = protomsg.UpdateGemNotify()
            g = msg.gems.add()
            g.id, g.amount = _id, new_amount

            publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 28
0
    def send_notify(self):
        msg = AchievementNotify()
        for v in ACHIEVEMENTS.values():
            a = msg.achievements.add()
            self._fill_up_achievement_msg(a, v)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 29
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)
Exemplo n.º 30
0
    def send_gem_notify(self):
        msg = protomsg.GemNotify()
        for k, v in self.item.gems.iteritems():
            g = msg.gems.add()
            g.id, g.amount = int(k), v

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 31
0
    def enable(self, enabled):
        self.stage.activities.extend(enabled)
        self.stage.save()

        msg = protomsg.NewActivityStageNotify()
        msg.ids.extend(enabled)
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 32
0
    def add_soul(self, souls):
        new_souls = []
        update_souls = []
        for _id, amount in souls:
            str_id = str(_id)
            if str_id in self.mongo_hs.souls:
                self.mongo_hs.souls[str_id] += amount
                update_souls.append((_id, self.mongo_hs.souls[str_id]))
            else:
                self.mongo_hs.souls[str_id] = amount
                new_souls.append((_id, amount))

        self.mongo_hs.save()
        if new_souls:
            msg = protomsg.AddHeroSoulNotify()
            for _id, amount in new_souls:
                s = msg.herosouls.add()
                s.id = _id
                s.amount = amount

            publish_to_char(self.char_id, pack_msg(msg))

        if update_souls:
            msg = protomsg.UpdateHeroSoulNotify()
            for _id, amount in update_souls:
                s = msg.herosouls.add()
                s.id = _id
                s.amount = amount

            publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 33
0
    def purge_soul(self, _id):
        self.mongo_hs.souls.pop(str(_id))
        self.mongo_hs.save()

        msg = protomsg.RemoveHeroSoulNotify()
        msg.ids.append(_id)
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 34
0
    def send_equip_notify(self):
        msg = protomsg.EquipNotify()
        for _id, data in self.item.equipments.iteritems():
            equip = msg.equips.add()
            self._msg_equip(equip, int(_id), data, Equipment(self.char_id, int(_id), self.item))

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 35
0
    def send_notify(self):
        msg = TaskNotify()
        for t in self.task.doing:
            this_task = TASKS[t]
            if this_task.func and not func_opened(self.char_id, this_task.func):
                # 对于没有开放功能的任务不显示
                continue

            msg_t = msg.tasks.add()
            msg_t.id = t

            current_times = self.task.tasks[str(this_task.tp)]
            if current_times > this_task.times:
                current_times = this_task.times

            msg_t.current_times = current_times

            if t in self.task.complete:
                status = MsgTask.COMPLETE
            elif t in self.task.finished:
                status = MsgTask.REWARD
            else:
                status = MsgTask.DOING

            msg_t.status = status

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 36
0
    def add_soul(self, souls):
        new_souls = []
        update_souls = []

        for _id, _ in souls:
            if _id not in HEROS:
                raise RuntimeError("soul {0} not exist".format(_id))

        for _id, amount in souls:
            str_id = str(_id)
            if str_id in self.mongo_hs.souls:
                self.mongo_hs.souls[str_id] += amount
                update_souls.append((_id, self.mongo_hs.souls[str_id]))
            else:
                self.mongo_hs.souls[str_id] = amount
                new_souls.append((_id, amount))

        self.mongo_hs.save()
        if new_souls:
            msg = protomsg.AddHeroSoulNotify()
            for _id, amount in new_souls:
                s = msg.herosouls.add()
                s.id = _id
                s.amount = amount

            publish_to_char(self.char_id, pack_msg(msg))

        if update_souls:
            msg = protomsg.UpdateHeroSoulNotify()
            for _id, amount in update_souls:
                s = msg.herosouls.add()
                s.id = _id
                s.amount = amount

            publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 37
0
    def send_stuff_notify(self):
        msg = protomsg.StuffNotify()
        for k, v in self.item.stuffs.iteritems():
            s = msg.stuffs.add()
            s.id, s.amount = int(k), v

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 38
0
    def send_socket_notify(self):
        msg = protomsg.SocketNotify()
        for k, v in self.formation.sockets.iteritems():
            s = msg.sockets.add()
            self._msg_socket(s, int(k), v)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 39
0
        def _get():
            got = False
            prob = self.p.prisoners[str_id].prob + treasures_prob
            if prob >= random.randint(1, 100):
                # got it
                save_hero(self.char_id, self.p.prisoners[str_id].oid)
                got = True

                self.p.prisoners.pop(str_id)

                msg = protomsg.RemovePrisonerNotify()
                msg.ids.append(_id)
                publish_to_char(self.char_id, pack_msg(msg))
            else:
                self.p.prisoners[str_id].active = False

                msg = protomsg.UpdatePrisonerNotify()
                p = msg.prisoner.add()
                p_obj = self.p.prisoners[str_id]
                self._fill_up_prisoner_msg(p, _id, p_obj.oid, p_obj.prob, p_obj.active)

                publish_to_char(self.char_id, pack_msg(msg))

            self.p.save()
            return got
Exemplo n.º 40
0
    def send_gem_notify(self):
        msg = protomsg.GemNotify()
        for k, v in self.item.gems.iteritems():
            g = msg.gems.add()
            g.id, g.amount = int(k), v

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 41
0
    def remove_soul(self, souls):
        remove_souls = []
        update_souls = []
        for _id, amount in souls:
            if not self.has_soul(_id, amount):
                raise SanguoException(
                    errormsg.SOUL_NOT_ENOUGH, self.char_id, "HeroSoul Remove",
                    "HeroSoul {0} not enough/exist, expected amount {1}".
                    format(_id, amount))

        for _id, amount in souls:
            str_id = str(_id)
            self.mongo_hs.souls[str_id] -= amount
            if self.mongo_hs.souls[str_id] <= 0:
                remove_souls.append(_id)
                self.mongo_hs.souls.pop(str_id)
            else:
                update_souls.append((_id, self.mongo_hs.souls[str_id]))

        self.mongo_hs.save()
        if remove_souls:
            msg = protomsg.RemoveHeroSoulNotify()
            msg.ids.extend(remove_souls)

            publish_to_char(self.char_id, pack_msg(msg))

        if update_souls:
            msg = protomsg.UpdateHeroSoulNotify()
            for _id, amount in update_souls:
                s = msg.herosouls.add()
                s.id = _id
                s.amount = amount

            publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 42
0
    def send_prisoners_notify(self):
        msg = protomsg.PrisonerListNotify()
        for k, v in self.p.prisoners.iteritems():
            p = msg.prisoner.add()
            self._fill_up_prisoner_msg(p, int(k), v.oid, v.prob, v.active)

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 43
0
    def send_notify(self, char=None, opended_funcs=None):
        if not char:
            char = self.mc

        msg = protomsg.CharacterNotify()
        msg.char.id = char.id
        msg.char.name = char.name
        msg.char.gold = char.gold
        msg.char.sycee = char.sycee
        msg.char.level = char.level
        msg.char.current_exp = char.exp
        msg.char.next_level_exp = level_update_exp(char.level)
        msg.char.official = char.official
        msg.char.official_exp = char.official_exp
        msg.char.next_official_exp = official_update_exp(char.level)

        msg.char.power = self.power
        msg.char.vip = char.vip
        msg.char.purchase_got = char.purchase_got

        msg.char.leader = self.leader

        if opended_funcs:
            msg.funcs.extend(opended_funcs)

        publish_to_char(self.id, pack_msg(msg))
Exemplo n.º 44
0
    def send_city_notify(self):
        msg = CityNotify()
        for cid in CITY_IDS:
            city = msg.cities.add()
            city.id = cid
            city.status = CityMsg.OPEN if cid in self.mongo_affairs.opened else CityMsg.CLOSE

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 45
0
    def send_notify(self):
        msg = protomsg.HeroSoulNotify()
        for _id, amount in self.mongo_hs.souls.iteritems():
            s = msg.herosouls.add()
            s.id = int(_id)
            s.amount = amount

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 46
0
    def send_notify(self):
        msg = protomsg.HeroSoulNotify()
        for _id, amount in self.mongo_hs.souls.iteritems():
            s = msg.herosouls.add()
            s.id = int(_id)
            s.amount = amount

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 47
0
    def send_remained_times_notify(self):
        msg = protomsg.EliteStageRemainedTimesNotify()
        free_counter = Counter(self.char_id, 'stage_elite')
        msg.max_free_times = free_counter.max_value
        msg.cur_free_times = free_counter.cur_value

        msg.total_reset_cost = self.get_total_reset_cost()
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 48
0
    def send_remained_times_notify(self):
        msg = protomsg.EliteStageRemainedTimesNotify()
        free_counter = Counter(self.char_id, 'stage_elite')
        msg.max_free_times = free_counter.max_value
        msg.cur_free_times = free_counter.cur_value

        msg.total_reset_cost = self.get_total_reset_cost()
        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 49
0
    def send_city_notify(self):
        msg = CityNotify()
        for cid in CITY_IDS:
            city = msg.cities.add()
            city.id = cid
            city.status = CityMsg.OPEN if cid in self.mongo_affairs.opened else CityMsg.CLOSE

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 50
0
    def send_notify(self):
        msg = HorsesNotify()
        for k, v in self.mongo_horse.horses.iteritems():
            hobj = OneHorse(int(k), v.oid, v.attack, v.defense, v.hp)
            msg_h = msg.horses.add()
            msg_h.MergeFrom(hobj.make_msg())

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 51
0
    def send_notify(self):
        msg = protomsg.EliteStageNotify()
        for _id, times in self.stage.elites.iteritems():
            s = msg.stages.add()
            s.id = int(_id)
            s.current_times = times

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 52
0
 def send_notify(self):
     self.load_mongo_record()
     msg = PlunderNotify()
     msg.current_times = self.mongo_plunder.current_times
     msg.max_times = self.max_plunder_times()
     msg.success_times_weekly = PlunderLeaderboardWeekly.get_char_times(
         self.char_id)
     publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 53
0
    def send_notify(self):
        msg = HorsesNotify()
        for k, v in self.mongo_horse.horses.iteritems():
            hobj = OneHorse(int(k), v.oid, v.attack, v.defense, v.hp)
            msg_h = msg.horses.add()
            msg_h.MergeFrom(hobj.make_msg())

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 54
0
    def send_apply_list_notify(self):
        msg = protomsg.UnionApplyListNotify()

        for c in self.applied_list:
            msg_char = msg.chars.add()
            msg_char.MergeFrom(create_character_infomation_message(c))

        publish_to_char(self.char_id, pack_msg(msg))
Exemplo n.º 55
0
    def send_apply_list_notify(self):
        msg = protomsg.UnionApplyListNotify()

        for c in self.applied_list:
            msg_char = msg.chars.add()
            msg_char.MergeFrom(create_character_infomation_message(c))

        publish_to_char(self.char_id, pack_msg(msg))