def modifyfbId(playerId): ''' 修改用户副本进度 ''' from scene.constants import FbType from scene.manager import set_fb_score, sync_scene_infos from config.configs import get_config, FbInfoByTypeConfig, FbInfoConfig from entity.manager import g_entityManager player = g_entityManager.get_player(int(playerId)) if not player: return FAILURE fbID = int(request.GET.getone("fbId") or 0) if not fbID: configs = get_config(FbInfoByTypeConfig).get(FbType.Normal, [])\ + get_config(FbInfoByTypeConfig).get(FbType.Guide, [])\ + get_config(FbInfoByTypeConfig).get(FbType.Advanced, []) for c in configs: if c.ID not in player.fbscores: set_fb_score(player, c.ID, 3) else: configs = get_config(FbInfoConfig) if fbID in configs: set_fb_and_prev_score(player, fbID, 3) else: return json.dumps('failure') player.save() sync_scene_infos(player, FbType.Normal) sync_scene_infos(player, FbType.Advanced) return SUCCESS
def clear_fb_count(target): from entity.manager import g_entityManager from scene.manager import sync_scene_infos, FbType if target.isdigit(): players = [g_entityManager.get_player(int(target))] elif target == 'all': players = g_entityManager.players.values() else: return json.dumps('invalid target') for player in players: for fbid, data in player.fbscores.items(): data['count'] = 0 data['refreshCount'] = 0 player.fbscores[fbid] = data player.save() sync_scene_infos(player, FbType.Normal) sync_scene_infos(player, FbType.Advanced) sync_scene_infos(player, FbType.Campaign) return json.dumps('cleared %s' % target)
def enter(self, msgtype, body): req = poem_pb.EnterRequest() req.ParseFromString(body) entityID = req.entityID # 不允许重新登录 if g_playerManager.has_player(entityID): if g_playerManager.peers[entityID].key == self.peer.key: return # 给已登录的发送重复登录消息 g_playerManager.sendto(entityID, fail_msg(msgtype, msgTips.FAIL_MSG_KICKED)) g_playerManager.kick_player(entityID) clientVersion = req.clientVersion featureCode = req.featureCode clientIP, _ = self.peer._sock.getpeername() or ('', '') self.player = player = g_entityManager.load_player( self.userID, entityID, clientVersion, featureCode, clientIP) if not player: self.peer.sender(fail_msg(msgtype, msgTips.FAIL_MSG_LOAD_PLAYER)) self.peer.close() return PlayerOnlineIndexing.update(settings.WORLD["ID"], player.entityID) player.clientVersion = clientVersion player.featureCode = featureCode player.clientIP = clientIP player.appid = req.deviceInfo.appid player.UDID = req.deviceInfo.UDID player.idfa = req.deviceInfo.idfa player.IMEI = req.deviceInfo.IMEI player.MAC = req.deviceInfo.MAC player.save() g_playerManager.register(player.entityID, self.peer) player.sync(all=True) # 发送公告 notice_rsp = get_notice_rsp() g_playerManager.sendto(player.entityID, success_msg(msgid.NOTICE, notice_rsp)) sync_scene_infos(player) rsp = poem_pb.EnterResponse() rsp.ENABLE_GIFTKEY = settings.ENABLE_GIFTKEY # cdkey rsp.REV = settings.REV rsp.time = int(time.time()) self.peer.sender(success_msg(msgtype, rsp)) gm_logger.info({ 'access': { 'entityID': player.entityID, 'type': 'login', 'userID': player.userID, 'username': player.username, 'onlines': g_playerManager.count(), 'username_alias': player.username_alias, 'channel': player.channel } }) from common.log import role_login role_login(player=player)
def give_goods(player, goods, amount=None): rest = 0 famount = float(goods.amount) if amount is not None and famount != amount: if amount > famount: rest = amount - famount else: # 当充值金额不足,选择同类型的满足金额的商品,多出金额返还 sdktype = username2type(player.username) label = username2label(player.username) sdkconfigs = get_config(RechargeBySdktypeConfig).get(sdktype, []) labconfigs = get_config(RechargeByLabelConfig).get(label, []) typconfigs = get_config(RechargeByTypeConfig).get(goods.type, []) ids = {e.id for e in sdkconfigs} & {e.id for e in labconfigs} ids = ids & {e.id for e in typconfigs} configs = get_config(RechargeConfig) configs = [configs[e] for e in ids] configs = sorted(configs, key=lambda s: float(s.amount), reverse=True) for config in configs: if float(config.amount) < amount: goods = config rest = amount - famount break else: goods = None rest = amount if goods: is_first = goods.id not in player.bought_recharges if goods.type == RechargeType.LimitedPacks: reward_type = RewardType.LimitedPacks elif goods.type == RechargeType.TimeLimitedPacks: reward_type = RewardType.TimeLimitedPacks elif goods.type == RechargeType.TriggerPacks1: reward_type = RewardType.TriggerPacks1 elif goods.type == RechargeType.TriggerPacks2: reward_type = RewardType.TriggerPacks2 else: reward_type = RewardType.Recharge credits = (famount + rest) * 10 else: is_first = False reward_type = RewardType.Recharge credits = rest * 10 reward = open_reward(reward_type, goods, is_first, rest * 10) result = reward.apply(player) logger.debug("recharge result {}".format(result)) # 不使用golden是因为有些商品是礼包,不包含钻石 __vip = player.vip player.credits += credits if player.vip != __vip: # VIP改变导致活动副本次数改变 from scene.manager import sync_scene_infos sync_scene_infos(player, FbType.Campaign) from explore.ambition import reload_vip_ambition reload_vip_ambition(player) if not player.bought_recharges: player.first_recharge_numb = result.get("gold", 0) if goods: if goods.type == RechargeType.MonthlyCard30: if not player.monthly_card_30: player.monthly_card_30 = 30 from task.manager import on_monthly_card on_monthly_card(player) elif goods.type == RechargeType.Monthcard1: player.monthcard1 += MonthCardDays elif goods.type == RechargeType.Monthcard2: player.monthcard2 += MonthCardDays elif goods.type == RechargeType.Weekscard1: player.weekscard1 += WeeksCardDays elif goods.type == RechargeType.Weekscard2: player.weekscard2 += WeeksCardDays elif goods.type == RechargeType.LimitedPacks: now = int(time.time()) player.limited_packs_used_count += 1 player.limited_packs_last_time = now elif goods.type == RechargeType.TimeLimitedPacks: now = int(time.time()) player.timelimited_packs_last_time = now elif goods.type in (RechargeType.TriggerPacks1, RechargeType.TriggerPacks2): # 支付回调问题 # NOTE # player.trigger_packs_buy_count += 1 pass # 记录首次充值获得的金额数 player.bought_recharges.add(goods.id) from campaign.manager import on_recharge on_recharge(player, goods.golden) from task.manager import on_vip_level on_vip_level(player) player.save() player.sync() return result
def reloadConfig(name): import settings from common import ConfigFiles from config.configs import get_registereds from yy.config.fields import ValidationError from entity.manager import g_entityManager source = request.POST.getone("source") or '' config_files = ConfigFiles(settings.REGION['ID']) try: if name == "all": config_files.load_configs(get_registereds(), settings.CONFIG_FILE_PATH) else: configs = [] for each in get_registereds(): if each.__Meta__.table == name: configs.append(each) if not configs: raise ValidationError("找不到文件%s对应的Config" % name) if source: data = {configs[0].__Meta__.table: source} config_files.load_configs(configs, '', **data) else: config_files.load_configs(configs, settings.CONFIG_FILE_PATH) except ValidationError as e: return json.dumps(e.message) if name == "daytime" or name == "all": from pvp.rank import g_rankManager g_rankManager.start() if name == "campaign" or name == "all": from campaign.manager import g_campaignManager g_campaignManager.start() if name == "Dlc_campaign" or name == "all": from explore.dlc import g_dlcCampaignManager g_dlcCampaignManager.start() if name == "gve_campaign" or name == "all": from campaign.manager import g_campaignManager g_campaignManager.gve_campaign.start() if name == "boss_campaign" or name == "all": from explore.boss import g_bossCampaignManager g_bossCampaignManager.start() if name == "ranking_campaign" or name == 'all': from ranking.manager import g_rankingCampaignManager g_rankingCampaignManager.reload() if name == "city_campaign" or name == 'all': from campaign.manager import g_campaignManager g_campaignManager.city_dungeon_campaign.start() g_campaignManager.city_dungeon_campaign.sync() g_campaignManager.city_contend_campaign.start() g_campaignManager.city_contend_campaign.sync() if name == "limit" or name == "all": from world.service import get_limited_packs_time t = get_limited_packs_time() if t: for p in g_entityManager.players.values(): p.clear_limited_packs_flag() p.sync('limited_packs_flag') if name == "ExSceneInfo" or name == "all": from scene.constants import FbType from scene.manager import sync_scene_infos for p in g_entityManager.players.values(): sync_scene_infos(p, FbType.Campaign) return SUCCESS