Exemple #1
0
 def send_reward(self):
     res_tbox = Game.res_mgr.tboxs.get(self.bid)
     if res_tbox is None:
         log.error('ally_team(%s) res_tbox is None, pids(%s)', self.tid, self.pids)
         return
     rw = Game.reward_mgr.get(res_tbox.trid)
     items = rw.reward(None)
     if items is None:
         log.error('ally_team(%s) reward_items is None, pids(%s)', self.tid, self.pids)
         return
     rw_mail = Game.res_mgr.reward_mails.get(RW_MAIL_ATBOX)
     boss = Game.res_mgr.monsters.get(res_tbox.tmid)
     content = rw_mail.content % dict(name = boss.name)
     pids = []
     for pid in self.pids:
         player = Game.rpc_player_mgr.get_rpc_player(pid)
         if player is None:
             player = Player.load_player(pid)
         if player is None:
             continue
         data = player.get_ally_tbox_data()
         if not is_today(data['t']):
             data['bids'] = []
             data['cr'] = 0
         if len(data['bids']) == 0:
             data['bids'].append(self.bid)
             data['t'] = current_time()
             pids.append(pid)
         if pid == self.lid:
             data['cr'] += 1
         player.set_ally_tbox_data(data)
     Game.mail_mgr.send_mails(pids, MAIL_REWARD, rw_mail.title, content, items)
Exemple #2
0
 def send_reward(self):
     res_tbox = Game.res_mgr.tboxs.get(self.bid)
     if res_tbox is None:
         log.error('ally_team(%s) res_tbox is None, pids(%s)', self.tid,
                   self.pids)
         return
     rw = Game.reward_mgr.get(res_tbox.trid)
     items = rw.reward(None)
     if items is None:
         log.error('ally_team(%s) reward_items is None, pids(%s)', self.tid,
                   self.pids)
         return
     rw_mail = Game.res_mgr.reward_mails.get(RW_MAIL_ATBOX)
     boss = Game.res_mgr.monsters.get(res_tbox.tmid)
     content = rw_mail.content % dict(name=boss.name)
     pids = []
     for pid in self.pids:
         player = Game.rpc_player_mgr.get_rpc_player(pid)
         if player is None:
             player = Player.load_player(pid)
         if player is None:
             continue
         data = player.get_ally_tbox_data()
         if not is_today(data['t']):
             data['bids'] = []
             data['cr'] = 0
         if len(data['bids']) == 0:
             data['bids'].append(self.bid)
             data['t'] = current_time()
             pids.append(pid)
         if pid == self.lid:
             data['cr'] += 1
         player.set_ally_tbox_data(data)
     Game.mail_mgr.send_mails(pids, MAIL_REWARD, rw_mail.title, content,
                              items)
Exemple #3
0
 def gem_reset(self):
     """珠宝商店重置"""
     d_cost = self.player._game.setting_mgr.setdefault(GEM_SHOP_RESET_COST, GEM_SHOP_RESET_COST_V)
     if d_cost is None:
         return False, errcode.EC_VALUE
     if not common.is_today(self.gemShopData.rt):
         self.gemShopData.rc = 0
         self.gemShopData.rt = common.current_time()
     d_cost = common.str2dict2(d_cost)
     cost = 0
     for k, v in d_cost.iteritems():
         start, end = int(v[0]), int(v[1])
         cs = 0
         if start <= self.gemShopData.rc + 1 <= end:
             index = range(start, end + 1).index(self.gemShopData.rc + 1) + 1
             cost = int(k) * index + cs
             break
         cs += int(k) * end
     if not self.player.enough_coin_ex(0, aCoin3=cost):
         return False, errcode.EC_COST_ERR
     self.player.cost_coin_ex(aCoin3=cost)
     self.gemShopData.rc += 1
     self.gemShopData.sids = self.player._game.res_mgr.get_gem_shop_by_rate(self.gemShopData.n)
     nt = self.gem_next_time()
     return True, dict(n = self.gemShopData.n, sids = self.gemShopData.sids, t=nt - common.current_time(),
         data = self.player.pack_msg_data(coin=True), rc = self.gemShopData.rc)
Exemple #4
0
    def _get_consume_quota(self, player):
        p_data = player.play_attr.get(CTREE_PLAYER_ATTR_COINSTREE)
        if not p_data:
            p_data = self._ctree_data_to_dict(0, 0)
        last_up_time = p_data.get(CTreeMgr._KEY_UPDATE_TIME, 0)
        if not is_today(last_up_time):
            p_data = self._ctree_data_to_dict(0, 0)

        return (p_data.get(CTreeMgr._KEY_NUM,
                           0), p_data.get(CTreeMgr._KEY_UPDATE_TIME, 0))
Exemple #5
0
    def _get_consume_quota(self, player):
        p_data = player.play_attr.get(CTREE_PLAYER_ATTR_COINSTREE)
        if not p_data:
            p_data = self._ctree_data_to_dict(0, 0)
        last_up_time = p_data.get(CTreeMgr._KEY_UPDATE_TIME, 0)
        if not is_today(last_up_time):
            p_data = self._ctree_data_to_dict(0, 0)

        return (p_data.get(CTreeMgr._KEY_NUM, 0),
                p_data.get(CTreeMgr._KEY_UPDATE_TIME, 0))
Exemple #6
0
 def _func(self, *args, **kw):
     _data = kw.pop('_data')
     #每日零点更新数据
     player = _data[0]
     if not is_today(player.achievement.data[KEY_DAY_TIME]):
         new = copy.deepcopy(player._game.achi_mgr.get_new())
         player.achievement.data[KEY_DAY] = new[KEY_DAY]
         player.achievement.data[KEY_DAY_TIME] = int(time.time())
     kw['_data'] = self.get_data(_data)
     if kw['_data'] is None:
         return
     return func(self, *args, **kw)
Exemple #7
0
 def _func(self, *args, **kw):
     _data = kw.pop('_data')
     #每日零点更新数据
     player = _data[0]
     if not is_today(player.achievement.data[KEY_DAY_TIME]):
         new = copy.deepcopy(player._game.achi_mgr.get_new())
         player.achievement.data[KEY_DAY] = new[KEY_DAY]
         player.achievement.data[KEY_DAY_TIME] = int(time.time())
     kw['_data'] = self.get_data(_data)
     if kw['_data'] is None:
         return
     return func(self, *args, **kw)
Exemple #8
0
 def handle(self, _data=None):
     player, aid, d_ever, target = _data
     ct = d_ever[KEY_TIME]
     if is_today(ct):
         #今日已经登陆过
         return
     #时间是否是昨天
     if is_yesterday(ct):
         d_ever[KEY_COUNT] += 1
     else:
         d_ever[KEY_COUNT] = 0
     #新号第一次登陆
     if ct == 0:
         d_ever[KEY_COUNT] = 1
     d_ever[KEY_TIME] = int(time.time())
     #是否达成目标
     if target[KEY_NEED] <= d_ever[KEY_COUNT]:
         d_ever[KEY_STATE] = STATE_1
Exemple #9
0
    def new(self, pid, bid, aid):
        if pid in self.pid2team:
            return False, errcode.EC_TEAM_SAME_NEW
        #同一玩家1天只能创建1次队伍
        player = Game.rpc_player_mgr.get_rpc_player(pid)
        if player is None:
            return False, errcode.EC_PLAYER_EMPTY
        data = player.get_ally_tbox_data()
        if not is_today(data['t']):
            data['cr'] = 0
        if 'cr' in data and data['cr'] > 0:
            return False, errcode.EC_TEAM_CAN_NOT_NEW

        team = self.TEAM_CLS(self, self.mgr.get_id())
        team.init(pid, bid, aid)
        team.join(pid)
        self.teams[team.tid] = team
        self.pid2team[pid] = team
        aid2teams = self.aid2teams.setdefault(aid, [])
        aid2teams.append(team)
        return True, team.tid
Exemple #10
0
    def new(self, pid, bid, aid):
        if pid in self.pid2team:
            return False, errcode.EC_TEAM_SAME_NEW
        #同一玩家1天只能创建1次队伍
        player = Game.rpc_player_mgr.get_rpc_player(pid)
        if player is None:
            return False, errcode.EC_PLAYER_EMPTY
        data = player.get_ally_tbox_data()
        if not is_today(data['t']):
            data['cr'] = 0
        if 'cr'in data and data['cr'] > 0:
            return False, errcode.EC_TEAM_CAN_NOT_NEW

        team = self.TEAM_CLS(self, self.mgr.get_id())
        team.init(pid, bid, aid)
        team.join(pid)
        self.teams[team.tid] = team
        self.pid2team[pid] = team
        aid2teams = self.aid2teams.setdefault(aid, [])
        aid2teams.append(team)
        return True, team.tid
Exemple #11
0
    def init_data(self, old):
        #当新增成就时,需要更新 旧数据(将新成就加上)
        if self.player.no_game:
            return old

        data = dict(day={}, ever={}, finish={})
        data.update(old)
        new = copy.deepcopy(self.player._game.achi_mgr.get_new())
        #隔天刷新每日成就  还需要考虑在线玩家数据清理
        if is_today(old[KEY_DAY_TIME]):
            for aid in new[KEY_DAY]:
                if aid in old[KEY_DAY]:
                    continue
                data[KEY_DAY][aid] = new[KEY_DAY][aid]
        else:
            data[KEY_DAY] = new[KEY_DAY]
        data[KEY_DAY_TIME] = int(time.time())

        for aid in new[KEY_EVER]:
            if aid in old[KEY_EVER] or aid in old[KEY_FINISH]:
                continue
            data[KEY_EVER][aid] = new[KEY_EVER][aid]
        return data
Exemple #12
0
    def init_data(self, old):
        #当新增成就时,需要更新 旧数据(将新成就加上)
        if self.player.no_game:
            return old

        data = dict(day = {}, ever = {}, finish = {})
        data.update(old)
        new = copy.deepcopy(self.player._game.achi_mgr.get_new())
        #隔天刷新每日成就  还需要考虑在线玩家数据清理
        if is_today(old[KEY_DAY_TIME]):
            for aid in new[KEY_DAY]:
                if aid in old[KEY_DAY]:
                    continue
                data[KEY_DAY][aid] = new[KEY_DAY][aid]
        else:
            data[KEY_DAY] = new[KEY_DAY]
        data[KEY_DAY_TIME] = int(time.time())

        for aid in new[KEY_EVER]:
            if aid in old[KEY_EVER] or aid in old[KEY_FINISH]:
                continue
            data[KEY_EVER][aid] = new[KEY_EVER][aid]
        return data
Exemple #13
0
 def pass_day(self):
     if not is_today(self.t):
         self.mfree = 0 #今日免费挖矿
         self.mcoin3 = 0 #今日元宝挖矿
         self.t = current_time()
Exemple #14
0
 def _func(self, *args, **kw):
     if not is_today(self.data[KEY_DAY_TIME]):
         new = copy.deepcopy(self.player._game.achi_mgr.get_new())
         self.data[KEY_DAY] = new[KEY_DAY]
     return func(self, *args, **kw)
Exemple #15
0
 def _func(self, *args, **kw):
     if not is_today(self.data[KEY_DAY_TIME]):
         new = copy.deepcopy(self.player._game.achi_mgr.get_new())
         self.data[KEY_DAY] = new[KEY_DAY]
     return func(self, *args, **kw)