コード例 #1
0
ファイル: views.py プロジェクト: yaosj/sanguo-server
def vip_get_reward(request):
    req = request._proto
    char_id = request._char_id

    vip = VIP(char_id)
    reward_msg = vip.get_reward(req.vip)

    response = VIPGetRewardResponse()
    response.ret = 0
    response.reward.MergeFrom(reward_msg)
    return pack_msg(response)
コード例 #2
0
def vip_get_reward(request):
    req = request._proto
    char_id = request._char_id

    vip = VIP(char_id)
    reward_msg = vip.get_reward(req.vip)

    response = VIPGetRewardResponse()
    response.ret = 0
    response.reward.MergeFrom(reward_msg)
    return pack_msg(response)
コード例 #3
0
def buy_reward(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    vip_level = request._proto.vip

    v = VIP(server_id, char_id)
    rc = v.buy_reward(vip_level)

    response = VIPBuyRewardResponse()
    response.ret = 0
    response.drop.MergeFrom(rc.make_protomsg())

    return ProtobufResponse(response)
コード例 #4
0
    def sign_in(self, _id):
        """

        :rtype: ResourceClassification
        """
        if self.get_signed_id():
            raise GameException(
                ConfigErrorMessage.get_error_id("UNION_ALREADY_SIGNED"))

        config = ConfigUnionSignin.get(_id)
        if not config:
            raise GameException(ConfigErrorMessage.get_error_id("BAD_MESSAGE"))

        if config.vip:
            VIP(self.server_id, self.char_id).check(config.vip)

        rc = ResourceClassification.classify(config.cost)
        rc.check_exist(self.server_id, self.char_id)
        rc.remove(self.server_id, self.char_id, message="Union.sign_in")

        self.add_contribution(config.contribution, send_notify=False)

        rc = ResourceClassification.classify(config.rewards)
        rc.add(self.server_id, self.char_id, message="Union.sign_in")

        ValueLogUnionSignInTimes(self.server_id,
                                 self.char_id).record(sub_id=_id)

        self.send_notify()
        return rc
コード例 #5
0
ファイル: welfare.py プロジェクト: zhifuliu/dianjing
    def signin(self):
        today_times = ValueLogWelfareSignInTimes(self.server_id, self.char_id).count_of_today()
        if today_times > 0:
            raise GameException(ConfigErrorMessage.get_error_id("WELFARE_ALREADY_SIGNED"))

        day = self.doc['signin'] + 1
        if day == ConfigWelfareSignIn.LAST_DAY:
            self.doc['signin'] = ConfigWelfareSignIn.FIRST_DAY - 1
        else:
            self.doc['signin'] = day

        config = ConfigWelfareSignIn.get(day)

        reward = []
        reward.extend(config.reward)

        if VIP(self.server_id, self.char_id).level >= config.vip:
            reward.extend(config.vip_reward)

        rc = ResourceClassification.classify(reward)
        rc.add(self.server_id, self.char_id, message="Welfare.signin")

        MongoWelfare.db(self.server_id).update_one(
            {'_id': self.char_id},
            {'$set': {
                'signin': self.doc['signin']
            }}
        )

        ValueLogWelfareSignInTimes(self.server_id, self.char_id).record()
        self.send_signin_notify()
        return rc
コード例 #6
0
ファイル: territory.py プロジェクト: zhifuliu/dianjing
    def try_unlock_slot(self, send_notify=True):
        vip_level = VIP(self.server_id, self.char_id).level
        updater = {}

        bid_sids = []

        for building_id, config_building in ConfigTerritoryBuilding.INSTANCES.iteritems(
        ):
            for slot_id, config_slot in config_building.slots.iteritems():
                if str(slot_id) in self.doc['buildings'][str(
                        building_id)]['slots']:
                    # 已经开启了
                    continue

                # 条件满足一个就可以
                if (vip_level >= config_slot.need_vip_level) or (
                        self.doc['buildings'][str(building_id)]['level'] >=
                        config_slot.need_building_level):
                    slot_doc = MongoTerritory.document_slot()
                    self.doc['buildings'][str(building_id)]['slots'][str(
                        slot_id)] = slot_doc
                    updater['buildings.{0}.slots.{1}'.format(
                        building_id, slot_id)] = slot_doc

                    bid_sids.append((building_id, slot_id))

        if updater:
            MongoTerritory.db(self.server_id).update_one({'_id': self.char_id},
                                                         {'$set': updater})

        if send_notify:
            for bid, sid in bid_sids:
                self.send_notify(building_id=bid, slot_id=sid)
コード例 #7
0
ファイル: tower.py プロジェクト: zhifuliu/dianjing
    def __init__(self, server_id, char_id):
        self.reset_times = ValueLogTowerResetTimes(server_id, char_id).count_of_today()
        self.remained_times = VIP(server_id, char_id).tower_reset_times - self.reset_times
        if self.remained_times < 0:
            self.remained_times = 0

        self.reset_cost = ConfigTowerResetCost.get_cost(self.reset_times + 1)
コード例 #8
0
def _new_purchase(char_id, new_got, total_got, **kwargs):
    VIP(char_id).send_notify()

    plog = MongoPurchaseLog()
    plog.char_id = char_id
    plog.sycee = new_got
    plog.purchase_at = arrow.utcnow().timestamp
    plog.save()

    # 需要发送活动通知的, 就必须用 ActivityStatic trig
    acs = ActivityStatic(char_id)
    acs.trig(5001)
    acs.trig(14001)
    ActivityEntry(char_id, 16001).trig(new_got/2)
    ActivityEntry(char_id, 17001).trig()
    ActivityEntry(char_id, 17002).trig()

    acs.trig(18006)

    ActivityEntry(char_id, 999).trig()
    ActivityEntry(char_id, 1000).trig()

    acs.trig(19001)
    acs.trig(20001)

    if ActivityEntry(char_id, 30006).trig(new_got):
        acs.send_update_notify(activity_ids=[30006])

    ActivityEntry(char_id, 40000).trig()
コード例 #9
0
ファイル: arena.py プロジェクト: zhifuliu/dianjing
    def __init__(self, server_id, char_id):
        self.match_times = ValueLogArenaMatchTimes(server_id,
                                                   char_id).count_of_today()
        self.buy_times = ValueLogArenaBuyTimes(server_id,
                                               char_id).count_of_today()
        self.reset_times = ValueLogArenaSearchResetTimes(
            server_id, char_id).count_of_today()

        vip = VIP(server_id, char_id)

        self.remained_match_times = ARENA_FREE_TIMES + self.buy_times - self.match_times
        if self.remained_match_times < 0:
            self.remained_match_times = 0

        self.remained_buy_times = vip.arena_buy_times - self.buy_times
        if self.remained_buy_times < 0:
            self.remained_buy_times = 0

        self.remained_reset_times = vip.arena_search_reset_times - self.reset_times
        if self.remained_reset_times < 0:
            self.remained_reset_times = 0

        self.buy_cost = ConfigArenaBuyTimesCost.get_cost(self.buy_times + 1)
        self.reset_cost = ConfigArenaSearchResetCost.get_cost(
            self.reset_times + 1)
コード例 #10
0
ファイル: resource.py プロジェクト: zhifuliu/dianjing
    def add(self, server_id, char_id, message=""):
        from core.club import Club
        from core.bag import Bag
        from core.staff import StaffManger, StaffRecruit
        from core.talent import TalentManager
        from core.territory import Territory
        from core.vip import VIP
        from core.arena import Arena
        from core.energy import Energy
        from core.plunder import Plunder

        club_property = self.money_as_text_dict()
        if self.club_exp:
            club_property['exp'] = self.club_exp
        if club_property:
            club_property['message'] = message
            Club(server_id, char_id).update(**club_property)

        if self.vip_exp:
            VIP(server_id, char_id).add_exp(self.vip_exp)

        if self.bag:
            bag = Bag(server_id, char_id)
            bag.batch_add(self.bag)

        sm = StaffManger(server_id, char_id)
        if self.staff:
            sm.batch_add(self.staff)

        if self.staff_exp_pool:
            sm.add_exp_pool(self.staff_exp_pool)

        if self.talent_point:
            TalentManager(server_id,
                          char_id).add_talent_points(self.talent_point)

        if self.arena_point:
            Arena(server_id, char_id).add_point(self.arena_point)

        if self.territory_product:
            Territory(server_id, char_id).add_product(self.territory_product)

        if self.work_card:
            Territory(server_id, char_id).add_work_card(self.work_card)

        if self.energy:
            Energy(server_id, char_id).add(self.energy)

        if self.staff_recruit_score:
            StaffRecruit(server_id,
                         char_id).add_score(self.staff_recruit_score)

        if self.station_exp:
            Plunder(server_id, char_id).add_station_exp(self.station_exp)

        if self.resource_data:
            _r = _Resource()
            _r.resource = dict(self.resource_data)
            _r.add(server_id, char_id)
コード例 #11
0
    def __init__(self, server_id, char_id):
        self.buy_times = ValueLogEnergyBuyTimes(server_id,
                                                char_id).count_of_today()
        self.remained_buy_times = VIP(
            server_id, char_id).energy_buy_times - self.buy_times
        if self.remained_buy_times < 0:
            self.remained_buy_times = 0

        self.buy_cost = ConfigEnergyBuyCost.get_cost(self.buy_times + 1)
コード例 #12
0
ファイル: territory.py プロジェクト: zhifuliu/dianjing
    def get_remained_help_times(self):
        # 剩余的帮助别人的次数
        total_times = VIP(self.server_id, self.char_id).territory_help_times
        current_times = ValueLogTerritoryHelpFriendTimes(
            self.server_id, self.char_id).count_of_today()
        remained = total_times - current_times
        if remained < 0:
            remained = 0

        return remained
コード例 #13
0
    def __init__(self, server_id, char_id):
        vip = VIP(server_id, char_id)

        self.buy_times = ValueLogPlunderBuyTimes(server_id,
                                                 char_id).count_of_today()
        self.remained_buy_times = vip.plunder_buy_times - self.buy_times
        if self.remained_buy_times < 0:
            self.remained_buy_times = 0

        self.buy_cost = ConfigPlunderBuyTimesCost.get_cost(self.buy_times + 1)
コード例 #14
0
    def __init__(self, server_id, char_id, tp):
        self.current_refresh_times = ValueLogStoreRefreshTimes(
            server_id, char_id).count_of_today(sub_id=tp)
        self.remained_refresh_times = VIP(
            server_id,
            char_id).store_refresh_times - self.current_refresh_times
        if self.remained_refresh_times < 0:
            self.remained_refresh_times = 0

        self.refresh_cost = ConfigStoreRefreshCost.get_cost(
            tp, self.current_refresh_times + 1)
コード例 #15
0
    def is_applied(self):
        # vip 自动apply
        if self.doc['applied']:
            return True

        if self.club_level < APPLY_CLUB_LEVEL_LIMIT:
            return False

        if VIP(self.server_id, self.char_id).level < AUTO_APPLY_VIP_LEVEL:
            return False

        return True
コード例 #16
0
    def __init__(self, server_id, char_id):
        self.server_id = server_id
        self.char_id = char_id

        self.max_times = GlobalConfig.value("UNION_HARASS_TIMES")
        self.current_times = ValueLogUnionHarassTimes(
            server_id, char_id).count_of_today()
        self.current_buy_times = ValueLogUnionHarassBuyTimes(
            server_id, char_id).count_of_today()

        self.vip_max_buy_times = VIP(server_id, char_id).union_harass_buy_times
        self._calculate()
コード例 #17
0
ファイル: tower.py プロジェクト: zhifuliu/dianjing
    def buy_goods(self, goods_index):
        goods = self.doc.get('goods', [])
        try:
            goods_id, bought = goods[goods_index]
        except IndexError:
            raise GameException(ConfigErrorMessage.get_error_id("INVALID_OPERATE"))

        if bought:
            raise GameException(ConfigErrorMessage.get_error_id("TOWER_GOODS_HAS_BOUGHT"))

        config = ConfigTowerSaleGoods.get(goods_id)

        if config.vip_need:
            VIP(self.server_id, self.char_id).check(config.vip_need)

        cost = [(money_text_to_item_id('diamond'), config.price_now)]
        rc = ResourceClassification.classify(cost)
        rc.check_exist(self.server_id, self.char_id)
        rc.remove(self.server_id, self.char_id, message="Tower.buy_goods")

        got = [(config.item_id, config.amount)]
        rc = ResourceClassification.classify(got)
        rc.add(self.server_id, self.char_id, message="Tower.buy_goods")

        self.doc['goods'][goods_index][1] = 1

        # NOTE 这里要把买完的那一组删掉
        if goods_index % 2 == 0:
            # 0, 2, 4 的情况,这组下一个的index是 goods_index+1
            other_index = goods_index + 1
        else:
            other_index = goods_index - 1

        if self.doc['goods'][other_index][1] == 1:
            _index = min(other_index, goods_index)
            self.doc['goods'].pop(_index)
            self.doc['goods'].pop(_index)

        MongoTower.db(self.server_id).update_one(
            {'_id': self.char_id},
            {'$set': {
                'goods': self.doc['goods']
            }}
        )

        self.send_goods_notify()
        return rc
コード例 #18
0
ファイル: dungeon.py プロジェクト: zhifuliu/dianjing
    def send_notify(self, category_id=None):
        if category_id:
            act = ACT_UPDATE
            ids = [category_id]
        else:
            act = ACT_INIT
            ids = get_opened_category_ids()

        match_times = ValueLogDungeonMatchTimes(
            self.server_id, self.char_id).batch_count_of_today()
        buy_times = ValueLogDungeonBuyTimes(
            self.server_id, self.char_id).batch_count_of_today()
        total_reset_times = VIP(self.server_id,
                                self.char_id).dungeon_reset_times

        def _get_remained_match_times(_id):
            _id = str(_id)
            remained = DUNGEON_FREE_TIMES + buy_times.get(
                _id, 0) - match_times.get(_id, 0)
            if remained < 0:
                remained = 0

            return remained

        def _get_remained_buy_times(_id):
            remained = total_reset_times - buy_times.get(str(_id), 0)
            if remained < 0:
                return remained

            return remained

        def _get_buy_cost(_id):
            return ConfigDungeonBuyCost.get_cost(
                _id,
                buy_times.get(str(_id), 0) + 1)

        notify = DungeonNotify()
        notify.act = act

        for i in ids:
            notify_info = notify.info.add()
            notify_info.id = i
            notify_info.free_times = _get_remained_match_times(i)
            notify_info.buy_times = _get_remained_buy_times(i)
            notify_info.buy_cost = _get_buy_cost(i)

        MessagePipe(self.char_id).put(msg=notify)
コード例 #19
0
ファイル: dungeon.py プロジェクト: zhifuliu/dianjing
    def __init__(self, server_id, char_id, category_id):
        self.match_times = ValueLogDungeonMatchTimes(
            server_id, char_id).count_of_today(sub_id=category_id)
        self.buy_times = ValueLogDungeonBuyTimes(
            server_id, char_id).count_of_today(sub_id=category_id)

        self.remained_match_times = DUNGEON_FREE_TIMES + self.buy_times - self.match_times
        if self.remained_match_times < 0:
            self.remained_match_times = 0

        self.remained_buy_times = VIP(
            server_id, char_id).dungeon_reset_times - self.buy_times
        if self.remained_buy_times < 0:
            self.remained_buy_times = 0

        self.buy_cost = ConfigDungeonBuyCost.get_cost(category_id,
                                                      self.buy_times + 1)
コード例 #20
0
ファイル: task.py プロジェクト: zhifuliu/dianjing
    def refresh(self):
        club_level = get_club_property(self.server_id, self.char_id, 'level')
        vip_level = VIP(self.server_id, self.char_id).level
        passed_challenge_ids = Challenge(
            self.server_id, self.char_id).get_passed_challenge_ids()

        task_ids = []
        for k, v in ConfigTaskDaily.INSTANCES.iteritems():
            if club_level < v.club_level:
                continue

            if vip_level < v.vip_level:
                continue

            if v.challenge_id and v.challenge_id not in passed_challenge_ids:
                continue

            task_ids.append(k)

        return task_ids
コード例 #21
0
    def find_applied_clubs(cls, server_id):
        docs = MongoChampionship.db(server_id).find({'applied': True},
                                                    {'_id': 1})

        club_ids = [doc['_id'] for doc in docs]
        club_ids = set(club_ids)

        vip_ids = VIP.query_char_ids(server_id, min_level=AUTO_APPLY_VIP_LEVEL)

        if vip_ids:
            club_docs = MongoCharacter.db(server_id).find(
                {'_id': {
                    '$in': vip_ids
                }}, {'level': 1})

            for doc in club_docs:
                if doc['level'] >= APPLY_CLUB_LEVEL_LIMIT:
                    club_ids.add(doc['_id'])

        return list(club_ids)
コード例 #22
0
    def join(self):
        if self.doc['joined']:
            return

        diamond = GlobalConfig.value(
            "LEVEL_GROWING_ACTIVITY_JOIN_COST_DIAMOND")
        vip_need = GlobalConfig.value("LEVEL_GROWING_ACTIVITY_JOIN_VIP_LIMIT")

        VIP(self.server_id, self.char_id).check(vip_need)

        cost = [
            (money_text_to_item_id('diamond'), diamond),
        ]
        rc = ResourceClassification.classify(cost)
        rc.check_exist(self.server_id, self.char_id)
        rc.remove(self.server_id, self.char_id)

        current_level = get_club_property(self.server_id, self.char_id,
                                          'level')
        self._update(current_level, joined=True)
        self.send_notify()
コード例 #23
0
ファイル: mail.py プロジェクト: zhifuliu/dianjing
    def _send_to_one_server(sid, m, attachment):
        if m.has_condition():
            club_level = m.condition_club_level
            vip_level = m.condition_vip_level

            if m.condition_login_at_1:
                login_range = [
                    arrow.get(m.condition_login_at_1).timestamp,
                    arrow.get(m.condition_login_at_2).timestamp,
                ]
            else:
                login_range = None

            exclude_char_ids = m.get_parsed_condition_exclude_chars()

            result_list = []
            if club_level or login_range:
                result_list.append(Club.query_char_ids(sid, min_level=club_level, login_range=login_range))

            if vip_level:
                result_list.append(VIP.query_char_ids(sid, vip_level))

            if not result_list:
                return

            result = set(result_list[0])
            for i in range(1, len(result_list)):
                result &= set(result_list[i])

            result -= set(exclude_char_ids)

            to_char_ids = list(result)
            if not to_char_ids:
                return
        else:
            to_char_ids = ModelCharacter.objects.filter(server_id=sid).values_list('id', flat=True)
            to_char_ids = list(to_char_ids)

        SharedMail(sid).add(to_char_ids, m.title, m.content, attachment=attachment)
コード例 #24
0
ファイル: chat.py プロジェクト: zhifuliu/dianjing
    def normal_chat(self, channel, text):
        from tasks import world

        char_doc = MongoCharacter.db(self.server_id).find_one(
            {'_id': self.char_id},
            {'name': 1, 'vip': 1, 'level': 1}
        )

        union_id = 0
        if channel == CHAT_CHANNEL_PUBLIC:
            if char_doc['level'] < GlobalConfig.value("CHAT_LEVEL_LIMIT"):
                raise GameException(ConfigErrorMessage.get_error_id("CHAT_LEVEL_NOT_ENOUGH"))

            if ChatCD(self.server_id, self.char_id).get_cd_seconds():
                raise GameException(ConfigErrorMessage.get_error_id("CHAT_TOO_FAST"))

            if len(text) > CHAT_MAX_SIZE:
                raise GameException(ConfigErrorMessage.get_error_id("CHAT_TOO_LARGE"))

            ChatCD(self.server_id, self.char_id).set(GlobalConfig.value("CHAT_CD"))

        elif channel == CHAT_CHANNEL_UNION:
            union_id = Union(self.server_id, self.char_id).get_joined_union_id()
            if not union_id:
                raise GameException(ConfigErrorMessage.get_error_id("UNION_CHAT_NO_UNION"))
        else:
            raise GameException(ConfigErrorMessage.get_error_id("BAD_MESSAGE"))

        # 创建一个消息
        msg = ChatMessage()
        msg.channel = channel
        msg.club.id = str(self.char_id)
        msg.club.name = char_doc['name']
        msg.club.vip = VIP(self.server_id, self.char_id).level
        msg.msg = text
        data = base64.b64encode(msg.SerializeToString())

        # 立即通知自己
        notify = ChatNotify()
        notify.act = ACT_UPDATE
        notify_msg = notify.msgs.add()
        notify_msg.MergeFrom(msg)

        notify_bin = MessageFactory.pack(notify)
        MessagePipe(self.char_id).put(data=notify_bin)

        # 放入公共空间,让后面登陆的人都能看到
        # 等于离线消息
        if channel == CHAT_CHANNEL_PUBLIC:
            CommonPublicChat(self.server_id).push(data, slice_amount=20)
            # 给其他人广播通知
            arg = {
                'server_id': self.server_id,
                'exclude_chars': [self.char_id],
                'data': MessageFactory.pack(notify)
            }

            payload = cPickle.dumps(arg)
            world.broadcast(payload=payload)
        else:
            CommonUnionChat(self.server_id, union_id).push(data, slice_amount=20)
            arg = {
                'server_id': self.server_id,
                'exclude_chars': [self.char_id],
                'data': MessageFactory.pack(notify),
                'char_id': self.char_id
            }

            payload = cPickle.dumps(arg)
            world.broadcast_union_chat(payload=payload)

        chat_signal.send(
            sender=None,
            server_id=self.server_id,
            char_id=self.char_id
        )
コード例 #25
0
ファイル: game.py プロジェクト: zhifuliu/dianjing
def game_start_handler(server_id, char_id, **kwargs):
    MessagePipe(char_id).clean()

    msg = UTCNotify()
    msg.timestamp = arrow.utcnow().timestamp
    MessagePipe(char_id).put(msg=msg)

    msg = SocketServerNotify()
    ss = random.choice(settings.SOCKET_SERVERS)
    msg.ip = ss['host']
    msg.port = ss['tcp']
    MessagePipe(char_id).put(msg=msg)

    _Resource.send_notify(server_id, char_id)

    UnitManager(server_id, char_id).send_notify()

    Bag(server_id, char_id).send_notify()

    StaffManger(server_id, char_id).send_notify()
    StaffRecruit(server_id, char_id).send_notify()

    f = Formation(server_id, char_id)
    f.send_formation_notify()
    f.send_slot_notify()

    club = Club(server_id, char_id)
    club.set_login()
    club.send_notify()

    msg = CreateDaysNotify()
    msg.days = days_passed(club.create_at)
    msg.create_at = club.create_at
    MessagePipe(char_id).put(msg=msg)

    chall = Challenge(server_id, char_id)
    chall.send_chapter_notify()
    chall.send_challenge_notify()

    FriendManager(server_id, char_id).send_notify()
    MailManager(server_id, char_id).send_notify()

    TaskMain(server_id, char_id).send_notify()
    TaskDaily(server_id, char_id).send_notify()

    Chat(server_id, char_id).send_notify()

    Notification(server_id, char_id).send_notify()

    FinanceStatistics(server_id, char_id).send_notify()

    TalentManager(server_id, char_id).send_notify()

    Dungeon(server_id, char_id).send_notify()

    a = Arena(server_id, char_id)
    a.send_notify()
    a.send_honor_notify()

    t = Tower(server_id, char_id)
    t.send_notify()
    t.send_goods_notify()

    Territory(server_id, char_id).send_notify()
    TerritoryStore(server_id, char_id).send_notify()
    TerritoryFriend(server_id, char_id).send_remained_times_notify()

    Store(server_id, char_id).send_notify()
    VIP(server_id, char_id).send_notify()
    Collection(server_id, char_id).send_notify()

    Energy(server_id, char_id).send_notify()

    w = Welfare(server_id, char_id)
    w.send_signin_notify()
    w.send_new_player_notify()
    w.send_level_reward_notify()
    w.send_energy_reward_notify()

    Union(server_id, char_id).send_all_notify()

    Purchase(server_id, char_id).send_notify()

    ac = ActivityNewPlayer(server_id, char_id)
    ac.send_notify()
    ac.send_daily_buy_notify()

    ActivityOnlineTime(server_id, char_id).send_notify()
    ActivityChallenge(server_id, char_id).send_notify()
    ActivityPurchaseDaily(server_id, char_id).send_notify()
    ActivityPurchaseContinues(server_id, char_id).send_notify()
    ActivityLevelGrowing(server_id, char_id).send_notify()

    p = Plunder(server_id, char_id)

    p.send_search_notify()
    p.send_result_notify()
    p.send_revenge_notify()
    p.send_station_notify()
    p.send_formation_notify()
    p.send_plunder_times_notify()
    p.send_plunder_daily_reward_notify()

    SpecialEquipmentGenerator(server_id, char_id).send_notify()

    Party(server_id, char_id).send_notify()

    ins = Inspire(server_id, char_id)
    ins.try_open_slots(send_notify=False)
    ins.send_notify()

    cs = Championship(server_id, char_id)
    cs.try_initialize(send_notify=False)
    cs.send_notify()

    WinningPlunder(server_id, char_id).send_notify()
    WinningArena(server_id, char_id).send_notify()
    WinningChampionship(server_id, char_id).send_notify()
    Worship(server_id, char_id).send_notify()
    CommonArenaWinningChat(server_id, char_id).send_notify()
    CommonPlunderWinningChat(server_id, char_id).send_notify()
    CommonChampionshipChat(server_id, char_id).send_notify()

    send_system_notify(server_id, char_id)
    BroadCast(server_id, char_id).try_cast_login_notify()
コード例 #26
0
    def buy(self, tp, goods_id):
        if tp not in ALL_TYPES:
            raise GameException(
                ConfigErrorMessage.get_error_id("INVALID_OPERATE"))

        config = ConfigStore.get(goods_id)
        if not config:
            raise GameException(
                ConfigErrorMessage.get_error_id("STORE_GOODS_NOT_EXIST"))

        try:
            data = self.doc['tp'][str(tp)]['goods'][str(goods_id)]
        except KeyError:
            raise GameException(
                ConfigErrorMessage.get_error_id("INVALID_OPERATE"))

        if data['times'] >= config.times_limit:
            raise GameException(
                ConfigErrorMessage.get_error_id("STORE_GOODS_NO_TIMES"))

        if config.condition_id == 1:
            # VIP 等级
            VIP(self.server_id, self.char_id).check(config.condition_value)
        elif config.condition_id == 2:
            # 爬塔历史最高星
            Tower(self.server_id,
                  self.char_id).check_history_max_star(config.condition_value)
        elif config.condition_id == 3:
            # 竞技场当前排名
            Arena(self.server_id,
                  self.char_id).check_current_rank(config.condition_value)
        elif config.condition_id == 4:
            # 当前公会等级
            Union(self.server_id,
                  self.char_id).check_level(config.condition_value)

        item_id, item_amount, need_id, need_amount = config.content[
            data['index']]
        resource_classify = ResourceClassification.classify([(need_id,
                                                              need_amount)])
        resource_classify.check_exist(self.server_id, self.char_id)
        resource_classify.remove(self.server_id,
                                 self.char_id,
                                 message="Store.buy:{0}".format(goods_id))

        resource_classify = ResourceClassification.classify([(item_id,
                                                              item_amount)])
        resource_classify.add(self.server_id,
                              self.char_id,
                              message="Store.buy:{0}".format(goods_id))

        data['times'] += 1

        MongoStore.db(self.server_id).update_one({'_id': self.char_id}, {
            '$set': {
                'tp.{0}.goods.{1}.times'.format(tp, goods_id): data['times']
            }
        })

        self.send_notify(tp=tp)
        return resource_classify
コード例 #27
0
ファイル: counter.py プロジェクト: zhifuliu/sanguo-server
    def max_value(self):
        value = COUNTER[self.func_name]
        if value:
            return value

        return VIP(self.char_id).get_max_times(self.func_name)
コード例 #28
0
def login_notify(char_id):
    message_clean(char_id)
    function_open = FunctionOpen(char_id)
    function_open.send_notify()

    hero_objs = char_heros_obj(char_id)

    Char(char_id).send_notify()
    VIP(char_id).send_notify()

    hero_notify(char_id, hero_objs)
    Item(char_id).send_notify()

    f = Formation(char_id)
    f.send_socket_notify()
    f.send_formation_notify()

    Plunder(char_id).send_notify()

    p = Prison(char_id)
    p.send_prisoners_notify()

    a = Arena(char_id)
    a.send_notify()
    a.login_process()

    f = Friend(char_id)
    f.send_friends_notify()
    f.send_friends_amount_notify()

    CheckIn(char_id).send_notify()

    stage = Stage(char_id)
    stage.send_already_stage_notify()
    stage.send_new_stage_notify()

    stage_elite = EliteStage(char_id)
    stage_elite.send_notify()
    stage_elite.send_times_notify()

    stage_activity = ActivityStage(char_id)
    stage_activity.check(send_notify=False)
    stage_activity.send_notify()
    stage_activity.send_remained_times_notify()

    HeroPanel(char_id).send_notify()
    Task(char_id).send_notify()
    Achievement(char_id).send_notify()
    HeroSoul(char_id).send_notify()
    Levy(char_id).send_notify()
    Attachment(char_id).send_notify()

    BasePurchaseAction(char_id).send_notify()

    SystemBroadcast(char_id).send_global_broadcast()
    ChatMessagePublish(char_id).send_notify()

    affairs = Affairs(char_id)
    affairs.send_city_notify()
    affairs.send_hang_notify()

    HorseFreeTimesManager(char_id).send_notify()
    Horse(char_id).send_notify()

    union.send_notify(char_id)

    ae = ActivityEntry(char_id, 50006)
    if ae and ae.is_valid():
        ae.enable(ae.get_current_value(char_id))

    ActivityStatic(char_id).send_notify()

    # mail notify 要放在最后,因为 其他功能初始化时可能会产生登录邮件
    Mail(char_id).send_notify()
コード例 #29
0
 def checkin_total_amount(self):
     return VIP(self.char_id).get_max_times('union_checkin')
コード例 #30
0
ファイル: statistics.py プロジェクト: zhifuliu/dianjing
    def _single_response(_char):
        context['show'] = True
        context['char_id'] = _char.id
        context['char_name'] = _char.name
        context['server_id'] = _char.server_id

        _club = Club(_char.server_id, _char.id)
        _bag = Bag(_char.server_id, _char.id)
        _vip = VIP(_char.server_id, _char.id)
        _sm = StaffManger(_char.server_id, _char.id)
        _fm = Formation(_char.server_id, _char.id)
        _te = Territory(_char.server_id, _char.id)
        _union = Union(_char.server_id, _char.id)

        context['last_login'] = arrow.get(_club.last_login).to(settings.TIME_ZONE).format("YYYY-MM-DD HH:mm:ss")
        context['club_level'] = _club.level
        context['vip_level'] = _vip.doc['vip']
        context['vip_exp'] = _vip.doc['exp']
        context['power'] = _club.power

        context['diamond'] = _club.diamond
        context['gold'] = _club.gold
        context['crystal'] = _club.crystal
        context['gas'] = _club.gas
        context['item_30007'] = _bag.get_amount_by_item_id(30007)
        context['item_30008'] = _bag.get_amount_by_item_id(30008)
        context['item_30009'] = _bag.get_amount_by_item_id(30009)
        context['item_30015'] = _te.get_work_card_amount()

        _res = MongoResource.db(_char.server_id).find_one({'_id': _char.id})
        if not _res:
            _res = {'resource': {}}
        context['item_30022'] = _res['resource'].get('30022', 0)
        context['item_30023'] = _res['resource'].get('30023', 0)
        context['item_30019'] = _res['resource'].get('30019', 0)

        _union_id = _union.get_joined_union_id()
        if not _union_id:
            context['union'] = {}
        else:
            context['union'] = {
                'id': _union_id,
                'name': _union.union_doc['name'],
                'joined_at': arrow.get(_union.member_doc['joined_at']).to(settings.TIME_ZONE).format(
                    "YYYY-MM-DD HH:mm:ss"),
                'contribution': _union.member_doc['contribution']
            }

        in_formation_staffs = _fm.in_formation_staffs()
        staffs_data = []
        equip_data = []

        for k, v in in_formation_staffs.iteritems():
            staff_obj = _sm.get_staff_object(k)
            staff_name = ConfigItemNew.get(staff_obj.oid).name

            staffs_data.append({
                'id': staff_obj.id,
                'oid': staff_obj.oid,
                'name': staff_name,
                'level': staff_obj.level,
                'step': staff_obj.step,
                'star': staff_obj.star,
                'power': staff_obj.power,
                'unit_id': v['unit_id'],
                'position': v['position'],
            })

            for bag_slot_id in [staff_obj.equip_special, staff_obj.equip_decoration, staff_obj.equip_keyboard,
                                staff_obj.equip_monitor, staff_obj.equip_mouse]:

                if not bag_slot_id:
                    continue

                equip = _bag.get_slot(bag_slot_id)
                equip_data.append({
                    'oid': equip['item_id'],
                    'level': equip['level'],
                    'name': ConfigItemNew.get(equip['item_id']).name,
                    'staff_name': staff_name
                })

        context['staffs'] = staffs_data
        context['equips'] = equip_data

        return render_to_response(
            'dianjing_statistics_char.html',
            context=context
        )