Exemplo n.º 1
0
    def boss_has_been_killed(self, boss_id):
        # 击杀boss后发送奖励
        logs = self.get_battle_members_in_ordered(boss_id)
        member_ids = [log.char_id for log in logs]

        killer = self.char_id

        m = Mail(killer)
        drop = make_standard_drop_from_template()
        drop['union_coin'] = UNION_BOSS_KILLER_REWARD.coin
        m.add(
            UNION_BOSS_KILLER_REWARD.mail_title,
            UNION_BOSS_KILLER_REWARD.mail_content,
            attachment=json.dumps(drop)
            )

        LOWEST_RANK = max(UNION_BOSS_REWARD.keys())
        UNION_BOSS_REWARD_TUPLE = UNION_BOSS_REWARD.items()
        UNION_BOSS_REWARD_TUPLE.sort(key=lambda item: item[0])

        for index, mid in enumerate(member_ids):
            rank = index + 1
            if rank > LOWEST_RANK:
                break

            m = Mail(mid)

            for _rank, _reward in UNION_BOSS_REWARD_TUPLE:
                if _rank >= rank:
                    drop = make_standard_drop_from_template()
                    drop['union_coin'] = _reward.coin
                    m.add(
                        _reward.mail_title.format(rank),
                        _reward.mail_content.format(rank),
                        attachment=json.dumps(drop)
                    )

                    break

        # 工会获得贡献度
        self.union.add_contribute_points(UNION_BOSS[boss_id].contribute_points)
Exemplo n.º 2
0
    def boss_has_been_killed(self, boss_id):
        # 击杀boss后发送奖励
        logs = self.get_battle_members_in_ordered(boss_id)
        member_ids = [log.char_id for log in logs]

        killer = self.mongo_boss.opened[str(boss_id)].killer

        m = Mail(killer)
        drop = make_standard_drop_from_template()
        drop['union_coin'] = UNION_BOSS_KILLER_REWARD.coin
        m.add(
            UNION_BOSS_KILLER_REWARD.mail_title,
            UNION_BOSS_KILLER_REWARD.mail_content,
            attachment=json.dumps(drop)
            )

        LOWEST_RANK = max(UNION_BOSS_REWARD.keys())
        UNION_BOSS_REWARD_TUPLE = UNION_BOSS_REWARD.items().sort(key=lambda item: item[0])

        for index, mid in enumerate(member_ids):
            rank = index + 1
            if rank > LOWEST_RANK:
                break

            m = Mail(mid)

            for _rank, _reward in UNION_BOSS_REWARD_TUPLE:
                if _rank >= rank:
                    drop = make_standard_drop_from_template()
                    drop['union_coin'] = _reward.coin
                    m.add(
                        _reward.mail_title.format(rank),
                        _reward.mail_content.format(rank),
                        attachment=json.dumps(drop)
                    )

                    break

        # 工会获得贡献度
        self.union.add_contribute_points(UNION_BOSS[boss_id].contribute_points)
Exemplo n.º 3
0
from core.attachment import make_standard_drop_from_template, standard_drop_to_attachment_protomsg
from core.mail import Mail
from core.character import Char

from core.battle.hero import InBattleHero
from core.battle.battle import Ground
from core.battle import PVE

from preset import errormsg
from preset.data import UNION_BOSS, UNION_BOSS_REWARD, UNION_LEVEL

import protomsg


UNION_BOSS_KILLER_REWARD = UNION_BOSS_REWARD.pop(0)
UNION_BOSS_REWARD_LOWEST_RANK = max(UNION_BOSS_REWARD.keys())


class UnionBoss(UnionLoadBase):
    def __init__(self, char_id):
        super(UnionBoss, self).__init__(char_id)
        if isinstance(self.union, UnionBase):
            self.load_data()
            self.member = Member(self.char_id)


    def load_data(self):
        try:
            self.mongo_boss = MongoUnionBoss.objects.get(id=self.union.union_id)
        except DoesNotExist:
            self.mongo_boss = MongoUnionBoss(id=self.union.union_id)
Exemplo n.º 4
0
from core.mail import Mail
from core.character import get_char_property

from core.battle.hero import InBattleHero
from core.battle.battle import Ground
from core.battle import PVE

from utils.lock import Lock, LockTimeOut

from preset import errormsg
from preset.data import UNION_BOSS, UNION_BOSS_REWARD, UNION_LEVEL

import protomsg

UNION_BOSS_KILLER_REWARD = UNION_BOSS_REWARD.pop(0)
UNION_BOSS_REWARD_LOWEST_RANK = max(UNION_BOSS_REWARD.keys())


class UnionBoss(UnionLoadBase):
    def __init__(self, char_id):
        super(UnionBoss, self).__init__(char_id)
        if isinstance(self.union, UnionBase):
            self.load_data()
            self.member = Member(self.char_id)

    def load_data(self):
        try:
            self.mongo_boss = MongoUnionBoss.objects.get(
                id=self.union.union_id)
        except DoesNotExist:
            self.mongo_boss = MongoUnionBoss(id=self.union.union_id)