def get_start_activity(self, pid): """ 活动是否开启 """ ally = self._game.rpc_ally_mgr.get_ally_by_pid(pid) now_sec = common.current_time() - common.zero_day_time() if self.warstart_config and self.warstart_config.stime < now_sec and \ ally.data.level >= self.warstart_config.unlock: return True, self.warstart_config.type return False, None
def gem_next_time(self): """珠宝商店下次刷新时间""" ct = common.current_time() t = common.zero_day_time() for i in xrange(4): t = t + 3600*6 if t >= ct: break return t
def time_start(self): """ 根据当前时间和配置表数据对应开启活动 """ now_sec = common.current_time() - common.zero_day_time() for res_config in self.res_warstart_configs.itervalues(): notice_time = res_config.stime - res_config.ntime if notice_time <= now_sec < res_config.etime: self.warstart_config = res_config l_sec = now_sec - res_config.stime spawn(self._notice, l_sec) log.debug('start----- %s, %s', res_config.stime, res_config.type) return True return False
def _loop_war(self): """ 活动开启提前通知 """ while 1: now_sec = common.current_time() - common.zero_day_time() #开启的活动结束 if self.warstart_config and now_sec > self.warstart_config.etime: if self.time_start(): #本次开启活动时清楚上一次的数据 self.stop_activity() #未开启活动时 elif self.warstart_config is None: self.time_start() sleep(1)
def player_logon(self, pid): """ 玩家登陆监听 """ if not self.warstart_config: return if pid in self.win_pids: return ally = Game.rpc_ally_mgr.get_ally_by_pid(pid) if not ally: return if ally.data.level < self.warstart_config.unlock: return l_sec = self.warstart_config.stime - (common.current_time()-common.zero_day_time()) if l_sec > self.warstart_config.ntime: return sleep(10) self._notice(l_sec, [pid])
def player_logon(self, pid): """ 玩家登陆监听 """ if not self.warstart_config: return if pid in self.win_pids: return ally = Game.rpc_ally_mgr.get_ally_by_pid(pid) if not ally: return if ally.data.level < self.warstart_config.unlock: return l_sec = self.warstart_config.stime - (common.current_time() - common.zero_day_time()) if l_sec > self.warstart_config.ntime: return sleep(10) self._notice(l_sec, [pid])
def gm_start_activity(self, war_type, time=300): """ gm开启活动 """ if time > 300: time = 300 self.stop_activity() now_sec = common.current_time() - common.zero_day_time() for res_warstart in self.res_warstart_configs.itervalues(): if war_type == res_warstart.type: self.warstart_config = copy.copy(res_warstart) self.warstart_config.etime = now_sec + 60 * 60 start_time = now_sec + time self.warstart_config.stime = start_time log.debug('gm-start----- %s, %s', start_time, res_warstart.type) break l_sec = self.warstart_config.stime - now_sec if l_sec <= self.warstart_config.ntime: spawn(self._notice, l_sec)
def next_reward_time(self): """ 到下一次奖励的具体时间 :rtype : int """ reward_time = self.reward_time zero_time = zero_day_time() for index, weekday in enumerate(arena_rw_weekdays): t = week_time(weekday, zero=1) delay_time = t - zero_time if delay_time < 0: #前几天 continue if delay_time == 0: if reward_time == t: #今天刚奖励完 continue return t #返回下周奖励时间 return week_time(arena_rw_weekdays[0], zero=1, delta=1)
def get_activity_infos(self, ally_only): """ 获取活动信息 """ pid = self.data.id _game = self._game arena, fish, cat, grave, allyFight, allyBoss, allyBossTime, wBoss, wBossSecs = 0,0,0,0,0,0,0,0,0 allyWarSky, allyWarWorld = 2, 2 awar_sky_data, awar_world_data = '', '' vip = self.data.vip if not ally_only: #竞技场 if self.can_arena(): rs, data = _game.rpc_arena_mgr.enter(pid, vip) if rs: arena = data[ARENA_INFO_COUNT] #fish rs, data = _game.fish_mgr.fish_enter(self) if rs: fish = data['n'] #world boss rs, data = _game.rpc_boss_mgr.is_start_world_boss(pid) if rs: wBoss = 1 wBossSecs = int(time.time() - common.zero_day_time()) if self.ally: #cat rs, data = _game.rpc_ally_mgr.cat_enter(pid, self.data.vip) if rs: cat = data[ALLY_CAT_COUNT] #grave rs, data = _game.rpc_ally_mgr.grave_enter(pid, self.data.vip) if rs: grave = data[ALLY_GRAVE_COUNT1] #allyBoss, 检查是否可进入是否结束 rs, data1 = _game.rpc_boss_mgr.ally_boss_get_time(self.ally['aid'], is_enter=True) rs, data2 = _game.rpc_boss_mgr.ally_boss_get_time(self.ally['aid'], is_fight=True) if rs: allyBossTime = data1[0] #0=不可进入已结束,1=可进入未结束,2=不可进入未结束 if data1[1]: allyBoss = 1 elif not data1[1] and not data2[1]: allyBoss = 2 # rs, data = _game.rpc_awar_mgr.get_start_activity(pid) awar_sky_data, awar_world_data = _game.rpc_awar_mgr.get_activity_time(self.ally['aid']) if rs and data == ALLY_SKY_WAR: allyWarSky = 1 elif rs and data == ALLY_WORLD_WAR: allyWarWorld = 1 #allyFight #rs, data = _game.rpc_ally_mgr. #allyBoss = 1 if ally_only: return dict(allyFight=allyFight, allyBoss=allyBoss, allyBossTime=allyBossTime, cat=cat, grave=grave, allyWarSky=allyWarSky, allyWarWorld=allyWarWorld, awar_sky_data=awar_sky_data, awar_world_data=awar_world_data) return dict(arena=arena, fish=fish, ctreenum=_game.ctree_mgr.api_ctree_get_rest_quota(self), cat=cat, grave=grave, allyFight=allyFight, allyBoss=allyBoss, allyBossTime=allyBossTime, wBoss=wBoss, wBossSecs=wBossSecs, allyWarSky=allyWarSky, allyWarWorld=allyWarWorld, awar_sky_data=awar_sky_data, awar_world_data=awar_world_data)
def get_activity_infos(self, ally_only): """ 获取活动信息 """ pid = self.data.id _game = self._game arena, fish, cat, grave, allyFight, allyBoss, allyBossTime, wBoss, wBossSecs = 0, 0, 0, 0, 0, 0, 0, 0, 0 allyWarSky, allyWarWorld = 2, 2 awar_sky_data, awar_world_data = '', '' vip = self.data.vip if not ally_only: #竞技场 if self.can_arena(): rs, data = _game.rpc_arena_mgr.enter(pid, vip) if rs: arena = data[ARENA_INFO_COUNT] #fish rs, data = _game.fish_mgr.fish_enter(self) if rs: fish = data['n'] #world boss rs, data = _game.rpc_boss_mgr.is_start_world_boss(pid) if rs: wBoss = 1 wBossSecs = int(time.time() - common.zero_day_time()) if self.ally: #cat rs, data = _game.rpc_ally_mgr.cat_enter(pid, self.data.vip) if rs: cat = data[ALLY_CAT_COUNT] #grave rs, data = _game.rpc_ally_mgr.grave_enter(pid, self.data.vip) if rs: grave = data[ALLY_GRAVE_COUNT1] #allyBoss, 检查是否可进入是否结束 rs, data1 = _game.rpc_boss_mgr.ally_boss_get_time(self.ally['aid'], is_enter=True) rs, data2 = _game.rpc_boss_mgr.ally_boss_get_time(self.ally['aid'], is_fight=True) if rs: allyBossTime = data1[0] #0=不可进入已结束,1=可进入未结束,2=不可进入未结束 if data1[1]: allyBoss = 1 elif not data1[1] and not data2[1]: allyBoss = 2 # rs, data = _game.rpc_awar_mgr.get_start_activity(pid) awar_sky_data, awar_world_data = _game.rpc_awar_mgr.get_activity_time( self.ally['aid']) if rs and data == ALLY_SKY_WAR: allyWarSky = 1 elif rs and data == ALLY_WORLD_WAR: allyWarWorld = 1 #allyFight #rs, data = _game.rpc_ally_mgr. #allyBoss = 1 if ally_only: return dict(allyFight=allyFight, allyBoss=allyBoss, allyBossTime=allyBossTime, cat=cat, grave=grave, allyWarSky=allyWarSky, allyWarWorld=allyWarWorld, awar_sky_data=awar_sky_data, awar_world_data=awar_world_data) return dict(arena=arena, fish=fish, ctreenum=_game.ctree_mgr.api_ctree_get_rest_quota(self), cat=cat, grave=grave, allyFight=allyFight, allyBoss=allyBoss, allyBossTime=allyBossTime, wBoss=wBoss, wBossSecs=wBossSecs, allyWarSky=allyWarSky, allyWarWorld=allyWarWorld, awar_sky_data=awar_sky_data, awar_world_data=awar_world_data)