def sendMail(dynamicId, characterId, playerName, title, content): '''添加邮件 @param dynamicId: int 客户端的动态id @param characterId: int 角色的id @param playerName: str 发送人的名称 @param content: str 邮件内容 @param title: str 标题 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} if not dbShieldWord.checkIllegalChar(title): return {'result': False, 'message': u""} if not dbShieldWord.checkIllegalChar(content): return {'result': False, 'message': u""} if len(title) > 12: return {'result': False, 'message': u""} toId = dbCharacter.getCharacterIdByNickName(playerName) if not toId: return {'result': False, 'message': u""} if toId[0] == characterId: return {'result': False, 'message': u""} result = player.mail.sendMail(toId[0], title, content) if result: return {'result': True, 'message': u""} return {'result': False, 'message': u""}
def roleInfo(dynamicId, characterId): '''获取角色的状态栏信息 @param userId: int 用户id @param characterId: 角色的id ''' player = PlayersManager().getPlayerBydynamicId(dynamicId) if dynamicId != player.getDynamicId(): return {'result': False, 'message': ""} playerinfo = player.formatInfo() responsedata = { 'result': True, 'message': '', 'data': { 'characterId': playerinfo['id'], 'rolename': playerinfo['nickname'], 'level': playerinfo['level'], 'exp': playerinfo['exp'], 'maxexp': playerinfo['maxExp'], 'coin': playerinfo['coin'], 'gold': playerinfo['gold'], 'tili': playerinfo['maxHp'], 'tilimax': playerinfo['maxHp'], 'huoli': playerinfo['energy'], 'maxhuoli': playerinfo['energy'], 'profession': playerinfo['profession'] } } return responsedata
def getSkillTreeInfo(dynamicId, characterId): """获取所有技能信息 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} return player.skill.getSkillTreeInfo()
def getPetSkillSetting(dynamicId, characterId, pet_id): '''获取伙伴技能设置 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} return player.skill.getPetSkillSetting(pet_id)
def getItemsInEquipSlotNew(dynamicId,characterId): """获取角色的装备栏信息 @param dynamicId: int 客户端的id @param characterId: int 角色的id """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result':False,'message':""} equipmentList = player.pack.getEquipmentSlotItemList() keys_copy = dict(equipmentList) equipmentList_copy = [] for position in range(1,7): item = keys_copy.get(position,None) if item: _item = {} _item['itemid'] = item.baseInfo.id _item['icon'] = item.baseInfo.getItemTemplateInfo().get('icon',0) _item['tempid'] = item.baseInfo.getItemTemplateId() _item['exp'] = item.exp iteminfo = {'pos':position,'item':_item} equipmentList_copy.append(iteminfo) playerInfo = player.formatInfoForWeiXin() data = {} data['equip'] = equipmentList_copy data['attack'] = playerInfo['attack'] data['fangyu'] = playerInfo['fangyu'] data['minjie'] = playerInfo['minjie'] return {'result':True,'message':u'','data':data}
def learnSkill(dynamicId, characterId, skill_id): '''学习技能 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} return player.skill.learnSkill(skill_id)
def sendMail(dynamicId, characterId, playerName, title, content): '''添加邮件 @param dynamicId: int 客户端的动态id @param characterId: int 角色的id @param playerName: str 发送人的名称 @param content: str 邮件内容 @param title: str 标题 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} if not dbShieldWord.checkIllegalChar(title): # 查询 title 是否存在屏蔽词 return {'result': False, 'message': u""} if not dbShieldWord.checkIllegalChar(content): # 查询 content 是否存在屏蔽词 return {'result': False, 'message': u""} if len(title) > 12: # 标题长度限制 return {'result': False, 'message': u""} toId = dbCharacter.getCharacterIdByNickName( playerName) # 根据昵称获取 角色(发信人) 的id if not toId: return {'result': False, 'message': u""} if toId[0] == characterId: return {'result': False, 'message': u""} result = player.mail.sendMail( toId[0], title, content) # 发送邮件(这里是保存到数据库,只有当收信人打开邮箱,才会收到从服务器更新) if result: return {'result': True, 'message': u""} return {'result': False, 'message': u""}
def getItemsInEquipSlotNew(dynamicId, characterId): '''获取角色的装备栏信息 @param dynamicId: int 客户端的id @param characterId: int 角色的id ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} equipmentList = player.pack.getEquipmentSlotItemList() keys_copy = dict(equipmentList) equipmentList_copy = [] for position in range(0, 8): item = keys_copy.get(position, None) if item: _item = {} _item['id'] = item.baseInfo.id _item['strengthen'] = dbItems.getItem( characterId, item.baseInfo.id)[0]['strengthen'] _item['tempid'] = item.baseInfo.getItemTemplateId() #_item['pos'] = position #_item['item'] = _item #_item['stacks'] = item.pack.getStack iteminfo = {'pos': position, 'item': _item} equipmentList_copy.append(iteminfo) #playerInfo = player.formatInfoForWeiXin() #data = {} #data['equip'] = equipmentList_copy #data['attack'] = playerInfo['attack'] #data['fangyu'] = playerInfo['fangyu'] #data['blood'] = playerInfo['blood'] return {'result': True, 'message': u'', 'data': equipmentList_copy}
def updateSkillSetting(dynamicId, characterId, pet_id, skill_id, space): '''更新技能设置 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} return player.skill.equipSkill(pet_id, skill_id, space)
def GetCompoundItem(dynamicId, characterId, tempid): '''获取当前碎片能合成的物品的信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} suipianinfo = dbItems.all_ItemTemplate.get(tempid) if not suipianinfo: return {'result': False, 'message': u"碎片信息不存在"} newtempid = suipianinfo.get('compound', 0) newiteminfo = dbItems.all_ItemTemplate.get(newtempid) if not newiteminfo: return {'result': False, 'message': u"该物品不能合成"} response = {} info = {} info['itemid'] = 0 info['icon'] = newiteminfo['icon'] info['itemname'] = newiteminfo['name'] info['itemdesc'] = newiteminfo['description'] info['tempid'] = newiteminfo['id'] info['qlevel'] = 0 info['attack'] = newiteminfo['basePhysicalAttack'] info['fangyu'] = newiteminfo['basePhysicalDefense'] info['minjie'] = newiteminfo['baseSpeedAdditional'] info['tili'] = newiteminfo['baseHpAdditional'] info['price'] = newiteminfo['buyingRateCoin'] info['stack'] = 1 info['qh'] = 1 if newiteminfo['bodyType'] > 0 else 0 response['hcprice'] = suipianinfo.get('comprice', 0) response['iteminfo'] = info return {'result': True, 'message': u"", 'data': response}
def getItemsInEquipSlotNew(dynamicId, characterId): '''获取角色的装备栏信息 @param dynamicId: int 客户端的id @param characterId: int 角色的id ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} equipmentList = player.pack.getEquipmentSlotItemList() keys_copy = dict(equipmentList) equipmentList_copy = [] for position in range(1, 7): item = keys_copy.get(position, None) if item: _item = {} _item['itemid'] = item.baseInfo.id _item['icon'] = item.baseInfo.getItemTemplateInfo().get('icon', 0) _item['tempid'] = item.baseInfo.getItemTemplateId() _item['exp'] = item.exp iteminfo = {'pos': position, 'item': _item} equipmentList_copy.append(iteminfo) playerInfo = player.formatInfoForWeiXin() data = {} data['equip'] = equipmentList_copy data['attack'] = playerInfo['attack'] data['fangyu'] = playerInfo['fangyu'] data['minjie'] = playerInfo['minjie'] return {'result': True, 'message': u'', 'data': data}
def GetJingJiInfo3700(dynamicId, characterId): '''获取竞技场信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} data = player.arena.getArenaAllInfo() return {'result': True, 'data': data}
def userskillreplace(dynamicId, characterId, tempid, pos): '''替换技能 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': "234"} data = player.pack.equipEquipmentByItemIdPos(tempid, pos) return data
def UserItemNew(dynamicId, characterId, tempid): '''使用物品 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': "234"} data = player.pack.equipEquipmentByItemId(tempid) return data
def unloadedEquipment_new(dynamicId, characterId, itemId): '''卸下装备 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} data = player.pack.unloaded(itemId) return data
def GetOneItemInfo(dynamicId, characterId, itemid): '''获取单个物品的详细信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} response = player.pack.getOneItemInfo(itemid) return response
def GetPackageInfo(dynamicId,characterId): """获取包裹的信息 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result':False,'message':""} data = player.pack.getPackageItemList() return data
def ArenaBattle_3704(dynamicId, characterId, tocharacterId): '''竞技场战斗 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} result = player.arena.doFight(tocharacterId) return result
def TiantiBattle_3701(dynamicId, characterId, tocharacterId, battleresult): '''天梯战斗结果处理 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} result = player.arena.doFight(tocharacterId) return result
def GetCharacterMatrixInfo(dynamicId,characterId): """获取角色的阵法信息 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result':False,'message':u""} matrixinfo = player.matrix.FormatMatrixInfoForWeixin() return {'result':True,'data':matrixinfo}
def GetStoneInfo(dynamicId, characterId): '''获取强化石的信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} data = player.pack.getStoneNum(characterId) return data
def GetCompoundPackage_2109(dynamicId, characterId): '''获取合成包裹的信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} response = player.pack.HuoQuSuiPianBaoguo() return response
def GetFashionInfo(dynamicId, characterId): '''获取包裹时装的信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} data = player.pack.getFashionList() return data
def GetAllPetListFormatForWeixin(dynamicId,characterId): """获取所有能上阵的武将的信息 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result':False,'message':u""} petList = player.pet.FormatPetList() return {'result':True,'data':petList}
def getLearnedSkills(dynamicId, characterId): """获取所有技能信息 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} learned_skills = player.skill.getSkills() return {"result": True, "data": learned_skills}
def getZhanYiInfo(dynamicId, characterId, index): """获取角色的战役信息 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} zhanyiinfo = player.zhanyi.getZhanYiInfo(index) return zhanyiinfo
def zhangjieFight(dynamicId, characterId, zhangjieid): """章节战斗 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': ""} fightresult = player.zhanyi.doZhangJie(zhangjieid) return fightresult
def getGuyongRecord(dynamicId,characterId): '''获取雇用记录 ''' player = PlayersManager().getPlayerByID(characterId) # 根据角色id获取玩家角色实例 if not player or not player.CheckClient(dynamicId): return {'result':False,'message':Lg().g(18)} response = player.friend.GetGuyongRecord() # 获取雇用记录 return response
def GuYongHaoYou(dynamicId,characterId,tid): '''雇佣好友 ''' player = PlayersManager().getPlayerByID(characterId) # 根据角色id获取玩家角色实例 if not player or not player.CheckClient(dynamicId): return {'result':False,'message':Lg().g(18)} response = player.friend.GuYongHaoYou(tid) # 雇用好友 return response
def GetFriendList(dynamicId,characterId,tag,index): '''获取好友排行信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result':False,'message':Lg().g(18)} response = player.friend.getFriendTop(tag,index) # 获取好友的排行信息 return response
def CompoundItem(dynamicId, characterId, tempid): """合成物品 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': u""} response = player.pack.CompoundItem(tempid) return response
def NetConnLost_2(dynamicId): '''loginout ''' player = PlayersManager().getPlayerBydynamicId(dynamicId) if not player: return True player.updatePlayerDBInfo() PlayersManager().dropPlayer(player) return True
def operaplayer_99(pid,oprea_str): """执行后台管理脚本 """ player = PlayersManager().getPlayerByID(pid) isOnline = 1 if not player: player = PlayerCharacter(pid) isOnline = 0 exec(oprea_str)#player.finance.addCoin(1000)脚本例子,通过角色类进行角色的各种操作,player.XXX.XXX if isOnline == 0: player.updatePlayerDBInfo()
def _getOtherCharacterInfo(tid): """获取其他玩家的信息 """ player = PlayersManager().getPlayerByID(tid) if not player: try: player = PlayerCharacter(tid) except: player = None if not player: return {'result':False,'message':u'该角色信息不存在'} info = player.formatInfoForWeiXin() return {'result':True,'message':u'','data':info}
def roleInfo(dynamicId,characterId): '''获取角色的状态栏信息 @param userId: int 用户id @param characterId: 角色的id ''' player = PlayersManager().getPlayerBydynamicId(dynamicId) if dynamicId != player.getDynamicId(): return {'result':False,'message':""} playerinfo = player.formatInfo() responsedata = {'result':True,'message':'', 'data':{'characterId':playerinfo['id'], 'rolename':playerinfo['nickname'], 'score':player.score}} return responsedata
def roleInfo(dynamicId,characterId): '''获取角色的状态栏信息 @param userId: int 用户id @param characterId: 角色的id ''' player = PlayersManager().getPlayerBydynamicId(dynamicId) if dynamicId != player.getDynamicId(): return {'result':False,'message':""} playerinfo = player.formatInfo() responsedata = {'result':True,'message':'', 'data':{'characterId':playerinfo['id'], 'rolename':playerinfo['nickname'], 'level':playerinfo['level'], 'exp':playerinfo['exp'], 'maxexp':playerinfo['maxExp'], 'coin':playerinfo['coin'], 'gold':playerinfo['gold'], 'tili':playerinfo['maxHp'], 'tilimax':playerinfo['maxHp'], 'huoli':playerinfo['energy'], 'maxhuoli':playerinfo['energy'], 'profession':playerinfo['profession']}} return responsedata
def enter_scene_remote(dynamic_id, character_id, pay_arg): """进入场景""" is_new_character = 0 player = PlayersManager().get_player_by_id(character_id) if not player: logger.debug('player login:%s', character_id) player = PlayerCharacter(character_id, dynamic_id=dynamic_id) is_new_character = init_player(player) PlayersManager().add_player(player) else: logger.debug('player exsit!========player.dynamic_id %s new dynamic_id %s' % (player.dynamic_id, dynamic_id)) if player.dynamic_id != dynamic_id: logger.error('dynamic id is not same:%s,%s:%s', character_id, dynamic_id, player.dynamic_id) player.dynamic_id = dynamic_id player.pay.set_pay_arg(pay_arg) # 设置支付参数 player.base_info.plat_id = pay_arg.get("plat_id") # ios 0 android 1 logger.debug("plat_id %s" % pay_arg.get("plat_id")) remote_gate.pull_message_remote(character_id) remote_gate['push'].online_offline_remote(player.base_info.id, 1) responsedata = GameLoginResponse() responsedata.res.result = True responsedata.id = player.base_info.id responsedata.nickname = player.base_info.base_name responsedata.level = player.base_info.level responsedata.exp = player.base_info.exp responsedata.gag = player.base_info.gag responsedata.closure = player.base_info.closure for k, i in enumerate(player.finance._finances): print(i) responsedata.finances.append(int(i)) responsedata.fine_hero = player.last_pick_time.fine_hero responsedata.excellent_hero = player.last_pick_time.excellent_hero responsedata.fine_equipment = player.last_pick_time.fine_equipment responsedata.excellent_equipment = player.last_pick_time.excellent_equipment responsedata.fine_hero_times = player.shop.single_coin_draw_times responsedata.excellent_hero_times = player.shop.single_gold_draw_times responsedata.pvp_times = player.pvp.pvp_times responsedata.pvp_refresh_count = player.pvp.pvp_refresh_count responsedata.pvp_overcome_index = player.pvp.pvp_overcome_current responsedata.pvp_overcome_refresh_count = player.pvp.pvp_overcome_refresh_count combat_power = player.line_up_component.combat_power responsedata.combat_power = combat_power hight_power = player.line_up_component.hight_power if hight_power and hight_power >= combat_power: responsedata.hight_power = hight_power else: responsedata.hight_power = combat_power player.line_up_component.hight_power = combat_power player.line_up_component.save_data() responsedata.hight_power = player.line_up_component.hight_power responsedata.newbee_guide_id = player.base_info.newbee_guide_id if player.guild.g_id != 0: responsedata.guild_id = player.guild.g_id responsedata.vip_level = player.base_info.vip_level # 体力 responsedata.get_stamina_times = player.stamina.get_stamina_times responsedata.buy_stamina_times = player.stamina.buy_stamina_times responsedata.last_gain_stamina_time = player.stamina.last_gain_stamina_time responsedata.server_time = int(time.time()) responsedata.register_time = player.base_info.register_time # responsedata.soul_shop_refresh_times = player.soul_shop.refresh_times buy_times_pb = responsedata.buy_times for item in player.stamina._stamina.stamina: item_pb = buy_times_pb.add() item_pb.resource_type = item.resource_type item_pb.buy_stamina_times = item.buy_stamina_times item_pb.last_gain_stamina_time = item.last_gain_stamina_time logger.debug("stamina %s buy_stamina_times %s last_gain_stamina_time %s" % (item.resource_type, item.buy_stamina_times, item.last_gain_stamina_time)) logger.debug("stamina %s" % buy_times_pb) if player.base_info.heads.head: for head in player.base_info.heads.head: responsedata.head.append(head) responsedata.now_head = player.base_info.heads.now_head for _id in player.base_info.first_recharge_ids: responsedata.first_recharge_ids.append(_id) responsedata.recharge = player.base_info.recharge # 累计充值 responsedata.tomorrow_gift = player.base_info.tomorrow_gift responsedata.battle_speed = player.base_info.battle_speed responsedata.story_id = player.base_info.story_id # 战力排行 if rank_helper.flag_doublu_day(): rank_name = 'PowerRank2' else: rank_name = 'PowerRank1' rank_no = rank_helper.get_rank_by_key(rank_name, player.base_info.id) responsedata.fight_power_rank = rank_no responsedata.is_open_next_day_activity = player.base_info.is_open_next_day_activity responsedata.first_recharge_activity = player.base_info.first_recharge_activity logger.debug("character info:----------------------id: %s" % player.base_info.id) logger.debug("stage_id: %s" % player.fight_cache_component.stage_id) logger.debug("vip_level:%d", player.base_info.vip_level) logger.debug("recharge:%d", player.base_info.recharge) logger.debug("register_time:%d", player.base_info.register_time) logger.debug("buy_stamina_times:%d", player.stamina.buy_stamina_times) logger.debug("first_recharge_activity:%d", player.base_info.first_recharge_activity) # logger.debug("coin:%d", player.finance.coin) # logger.debug("gold:%d", player.finance.gold) # logger.debug("hero_soul:%d", player.finance.hero_soul) # logger.debug("soul_shop_refresh_times:%d", player.soul_shop.refresh_times) if const.DEBUG: for slot_no, slot in player.line_up_component.line_up_slots.items(): hero = slot.hero_slot.hero_obj if not hero: continue combat_power_hero_lineup(player, hero, slot_no) awake_hero = player.fight_cache_component.change_hero(hero, hero.hero_info["awakeHeroID"]) combat_power_hero_lineup(player, awake_hero, slot_no, "awake") logger.debug('login:<%s>%s:%s %s:%s', player, character_id, responsedata.level, dynamic_id, player.dynamic_id) return {'player_data': responsedata.SerializeToString(), 'is_new_character': is_new_character}