Exemplo n.º 1
0
    def save_drop(self, _id=None):
        if _id:
            this_stage = STAGE_ELITE[_id]
        else:
            this_stage = self.this_stage

        exp = this_stage.normal_exp
        gold = this_stage.normal_gold

        drop_ids = [int(i) for i in this_stage.normal_drop.split(',') if i.isdigit()]

        prepare_drop = get_drop(drop_ids)
        prepare_drop['gold'] += gold
        prepare_drop['exp'] += exp

        if self.is_circle_reward:
            drop_hero_ids = this_stage.drop_hero_ids
            if drop_hero_ids:
                _drop_id = random.choice([int(i) for i in drop_hero_ids.split(',')])
                prepare_drop['heros'].append((_drop_id, 1))

        additional_drop = ActivityEntry(self.char_id, 11001).get_additional_drop()
        drop = merge_drop([prepare_drop, additional_drop])

        resource = Resource(self.char_id, "EliteStage Drop", "stage {0}".format(this_stage.id))
        standard_drop = resource.add(**drop)

        return standard_drop
Exemplo n.º 2
0
def _open_hero(char_id, hero_oid, **kwargs):
    drop1 = ActivityEntry(char_id, 9001).get_additional_drop()
    drop2 = ActivityEntry(char_id, 13001).get_additional_drop()

    drop = merge_drop([drop1, drop2])
    if is_empty_drop(drop):
        return

    resource = Resource(char_id, "HeroPanel open")
    resource.add(**drop)
Exemplo n.º 3
0
def _open_hero(char_id, hero_oid, sycee, **kwargs):
    drop1 = ActivityEntry(char_id, 9001).get_additional_drop()
    drop2 = ActivityEntry(char_id, 13001).get_additional_drop()

    drop = merge_drop([drop1, drop2])
    if not is_empty_drop(drop):
        resource = Resource(char_id, "HeroPanel open")
        resource.add(**drop)

    if sycee:
        TimesLogGetHeroBySycee(char_id).inc()
Exemplo n.º 4
0
def _open_hero(char_id, hero_oid, sycee, **kwargs):
    drop1 = ActivityEntry(char_id, 9001).get_additional_drop()
    drop2 = ActivityEntry(char_id, 13001).get_additional_drop()

    drop = merge_drop([drop1, drop2])
    if not is_empty_drop(drop):
        resource = Resource(char_id, "HeroPanel open")
        resource.add(**drop)

    if sycee:
        TimesLogGetHeroBySycee(char_id).inc()
Exemplo n.º 5
0
    def stuff_use(self, _id, amount):
        from core.attachment import standard_drop_to_attachment_protomsg, is_empty_drop, merge_drop
        from core.resource import Resource
        try:
            s = STUFFS[_id]
        except KeyError:
            raise SanguoException(
                errormsg.STUFF_NOT_EXIST,
                self.char_id,
                "Stuff Use",
                "stuff {0} not exist".format(_id)
            )

        # XXX
        if s.tp != 3:
            raise SanguoException(
                errormsg.STUFF_CAN_NOT_USE,
                self.char_id,
                "Stuff Use",
                "stuff {0} tp is {1}. Can not use".format(_id, s.tp)
            )

        # XXX 忽略amount,只能一个一个用
        self.stuff_remove(_id, amount)

        # 活动 10001
        additional_drop_1 = ActivityEntry(self.char_id, 10001).get_additional_drop(_id)
        additional_drop_2 = ActivityEntry(self.char_id, 12001).get_additional_drop(_id)
        additional_drop_3 = ActivityEntry(self.char_id, 15001).get_additional_drop(_id)

        prepare_drop = self.get_sutff_drop(_id)
        drop = merge_drop([prepare_drop, additional_drop_1, additional_drop_2, additional_drop_3])
        if is_empty_drop(drop):
            return None

        resource = Resource(self.char_id, "Stuff Use", "use {0}".format(_id))
        standard_drop = resource.add(**drop)
        return standard_drop_to_attachment_protomsg(standard_drop)
Exemplo n.º 6
0
    def stuff_use(self, _id, amount):
        from core.attachment import standard_drop_to_attachment_protomsg, is_empty_drop, merge_drop
        from core.resource import Resource
        try:
            s = STUFFS[_id]
        except KeyError:
            raise SanguoException(errormsg.STUFF_NOT_EXIST, self.char_id,
                                  "Stuff Use",
                                  "stuff {0} not exist".format(_id))

        # XXX
        if s.tp != 3:
            raise SanguoException(
                errormsg.STUFF_CAN_NOT_USE, self.char_id, "Stuff Use",
                "stuff {0} tp is {1}. Can not use".format(_id, s.tp))

        # XXX 忽略amount,只能一个一个用
        self.stuff_remove(_id, amount)

        # 活动 10001
        additional_drop_1 = ActivityEntry(self.char_id,
                                          10001).get_additional_drop(_id)
        additional_drop_2 = ActivityEntry(self.char_id,
                                          12001).get_additional_drop(_id)
        additional_drop_3 = ActivityEntry(self.char_id,
                                          15001).get_additional_drop(_id)

        prepare_drop = self.get_sutff_drop(_id)
        drop = merge_drop([
            prepare_drop, additional_drop_1, additional_drop_2,
            additional_drop_3
        ])
        if is_empty_drop(drop):
            return None

        resource = Resource(self.char_id, "Stuff Use", "use {0}".format(_id))
        standard_drop = resource.add(**drop)
        return standard_drop_to_attachment_protomsg(standard_drop)