def friend_list(p, req): ''' 获取好友列表 ''' cid, [index] = req user = g_UserMgr.getUser( cid ) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) add_douzhan = yield user.goodwill_mgr.check_achieve() totals = len(user.friends) #成就 yield user.achievement_mgr.update_achievement_status( ACHIEVEMENT_QUEST_ID_20, totals ) friend_cids = user.friends[:index+20] if (not friend_cids): defer.returnValue( [index, totals, [], 0, GET_DOUZHAN_DAILY_LIMIT + add_douzhan] ) # 给好友赠送斗战点的信息 gift_cids = [] gift_data = yield redis.hget(HASH_FRIENDS_SEND_DOUZHAN, cid) if gift_data: gift_data = loads(gift_data) dt_now = datetime.now() dt_last = datetime.fromtimestamp( gift_data[0] ) if dt_last.date() == dt_now.date(): gift_cids = gift_data[1] friend_info = [] offline_cids = [] for _cid in friend_cids: online_user = g_UserMgr.getUser( _cid ) if online_user: _info = online_user.friend_info() _info.append(1) # 0-离线, 1-在线 _info.append( 1 if _cid in gift_cids else 0 ) # 0-未赠送, 1-已赠送 # 在线好友排序 ?? friend_info.append( _info ) else: offline_cids.append( _cid ) # 查询db 获取offline_cids的基本信息 try: if offline_cids: dataset = yield cs_call("cs_offline_friends", [cid, offline_cids]) if dataset: for _info in dataset: _info = list( _info ) _info.append(0) # 0-离线, 1-在线 _info.append( 1 if _info[0] in gift_cids else 0 ) # 0-未赠送, 1-已赠送 friend_info.append( _info ) except Exception as e: log.error('cs_offline_friends error. e: {0}'.format( e )) left_count, gift_data = yield get_friend_douzhan_status(cid, add_douzhan) defer.returnValue( [index, totals, friend_info, len(gift_data), left_count] )
def gs_gm_get_camp_info(p, req): ''' return camp 1-6 detail info. ''' cid, = req user = g_UserMgr.getUser(cid) if not user: log.error('Unknown user. cid: {0}.'.format( cid )) defer.returnValue( [] ) _camp_info = [] _camp_fellow = user.fellow_mgr.get_camp_fellow() for _idx, _ufid in enumerate( _camp_fellow ): _dict_data = {'camp_id':_idx+1, 'fellow':{}, 'helmet':{}, 'weapon':{}, 'necklace':{}, 'armor':{}, 'bookwar':{}, 'horse':{}} if _ufid <= 0: _camp_info.append( _dict_data ) continue # 获取camp_id上的fellow _fellow = user.fellow_mgr.gm_get_camp_fellow( _ufid ) if not _fellow: _camp_info.append( _dict_data ) log.error('Unknown _ufid. cid: {0}, _ufid: {1}.'.format( cid, _ufid )) continue _dict_data['fellow'] = _fellow # 获取camp_id上的装备 2-头盔 3-武器, 4-项链, 5-护甲 _dict_data['helmet'], _dict_data['weapon'], _dict_data['necklace'], _dict_data['armor'] = yield user.bag_equip_mgr.gm_get_camp_equip( _idx+1 ) _dict_data['bookwar'], _dict_data['horse'] = yield user.bag_treasure_mgr.gm_get_camp_treasure( _idx+1 ) _camp_info.append(_dict_data) defer.returnValue( _camp_info )
def gs_gm_login(p, req): ''' gm login gameserver as offline login @param: query_flag-查询标志位 ''' cid, query_flag = req user = g_UserMgr.getUser(cid, True) if user: defer.returnValue( NO_ERROR ) try: res_err = yield cs_call("cs_character_login", [cid]) except Exception as e: log.error('gm cs_character_login error. e: {0}'.format( e )) defer.returnValue( UNKNOWN_ERROR ) if res_err[0]: log.error('Get char data error. cid: {0}, res_err: {1}.'.format(cid, res_err)) defer.returnValue( res_err[0] ) user = g_UserMgr.loginUser( res_err[1], flag=True ) user.offline_flag = True yield user.fellow_mgr.value_list # 查询玩家离线登陆后 5min下线 if query_flag: reactor.callLater(SESSION_LOGOUT_REAL, gs_offline_logout, cid) defer.returnValue( NO_ERROR )
def gs_gm_get_bag_info(p, req): ''' return bag info by type. param: bag_type 1-装备, 2-装备碎片, 3-伙伴背包, 4-分魂背包, 5-道具背包, 6-宝物背包, 7-战魂背包 ''' cid, bag_type = req user = g_UserMgr.getUser(cid) if not user: log.error('Unknown user. cid: {0}.'.format( cid )) defer.returnValue( [] ) _bag_info = [] if bag_type == 1: _bag_info = yield user.bag_equip_mgr.gm_equip_info() elif bag_type == 2: _bag_info = yield user.bag_equipshard_mgr.gm_equipshard_info() elif bag_type == 3: _bag_info = yield user.fellow_mgr.gm_fellow_info() elif bag_type == 4: _bag_info = yield user.bag_fellowsoul_mgr.gm_fellowsoul_info() elif bag_type == 5: _bag_info = yield user.bag_item_mgr.gm_item_info() elif bag_type == 6: _bag_info = yield user.bag_treasure_mgr.gm_treasure_info() elif bag_type == 7: _bag_info = yield user.bag_treasureshard_mgr.gm_treasureshard_info() else: defer.returnValue( [] ) defer.returnValue( _bag_info )
def constellation_select(p, req): res = UNKNOWN_ERROR #同时兼容新旧协议, 当旧协议时,is_highlight置为-1:未知, 其他状态: 0:未亮, 1:高亮 try: cid, ( star_id, is_highlight ) = req except: cid, ( star_id, ) = req is_highlight = -1 user = g_UserMgr.getUser(cid) if user: con_mgr = yield user.constellation # 检查是否需要0点更新 if con_mgr.need_refresh: defer.returnValue( CONSTELLATION_NEED_REFRESH ) if con_mgr.select_count < CONSTELLATION_SELECT_MAX: res = con_mgr.select( int( star_id ), int( is_highlight ) ) # 每日任务计数 yield user.daily_quest_mgr.update_daily_quest( DAILY_QUEST_ID_7, 1 ) else: res = CONSTELLATION_SELECT_REACH_MAX defer.returnValue( res )
def gs_offline_login(cid): user = g_UserMgr.getUser(cid, True) if user: defer.returnValue( user ) alliance_info = 0, '', 0 try: res_err = yield cs_call("cs_character_login", [cid]) # get alliance info alliance_info = yield alli_call('get_alliance_info', [cid]) except Exception as e: log.error('cs_character_login error. e: {0}'.format( e )) defer.returnValue( None ) if res_err[0]: log.error('Get char data error. cid: {0}, res_err: {1}.'.format(cid, res_err)) defer.returnValue( None ) user = g_UserMgr.loginUser( res_err[1], True ) user.offline_flag = True if alliance_info[0] > 0: user.alliance_id = alliance_info[0] user.alliance_name = alliance_info[1] defer.returnValue( user )
def start_plunder(p, req): ''' @summary: 开始抢夺玩家, 避免同一宝物的碎片玩家被多人同时抢夺 ''' res_err = UNKNOWN_ERROR cid, (plunder_cid, shard_id) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format(cid)) return res_err if user.base_att.douzhan < PVP_NEED_DOUZHAN: log.error('douzhan of user {0} have been zero!!!'.format(cid)) return CHAR_DOUZHAN_NOT_ENOUGH # 抢夺对象不是玩家 if plunder_cid <= 0: return NO_ERROR item_conf = get_item_by_itemid(shard_id) if not item_conf: log.error('Can not find conf. shard_id: {0}.'.format(shard_id)) return NOT_FOUND_CONF # 碎片可合成的宝物信息 _, treasure_id, _ = item_conf['ChangeList'][0] res_err = AvoidWarMgr.start_plunder_shard(treasure_id, plunder_cid) return res_err
def get_plunder_info(p, req): ''' @summary: 获取夺宝基本信息 ''' res_err = UNKNOWN_ERROR cid, (plunder_type, ) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format(cid)) defer.returnValue(res_err) shard_type = 0 if plunder_type == 1: #战马 shard_type = ITEM_TYPE_HORSESHARD elif plunder_type == 2: #兵书 shard_type = ITEM_TYPE_BOOKWARSHARD else: log.error( '[ get_plunder_info ]cid:{0}, Unknown plunder type: {1}.'.format( cid, plunder_type)) defer.returnValue(res_err) value_list = yield user.bag_treasureshard_mgr.value_list_by_type( shard_type) avoid_time = yield AvoidWarMgr.remain_avoid_war_time(cid) defer.returnValue((avoid_time, value_list))
def gs_logout(p, req): cid = req user = g_UserMgr.getUser(cid) if not user: log.warn('User had logout. cid: {0}.'.format( cid )) defer.returnValue( UNKNOWN_ERROR ) # 有离线登陆的玩家 if user.offline_num > 0: log.warn('User had offline login, could not logout. cid: {0}.'.format( cid )) # 更新标志位为离线登陆标志 user.offline_flag = True defer.returnValue( UNKNOWN_ERROR ) if worldBoss.running: worldBoss.remove_attacker(cid) try: res = yield cs_call('cs_character_logout', cid) except: log.warn('Some exp raise in gs_logout. cid: {0}.'.format( cid )) defer.returnValue( UNKNOWN_ERROR ) else: g_UserMgr.logoutUser(cid) log.debug('user logout sucess. cid: {0}.'.format( cid )) defer.returnValue( res )
def set_camp_treasure(p, req): res_err = UNKNOWN_ERROR cid, [camp_id, pos_id, old_ueid, new_ueid] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format(cid)) defer.returnValue(res_err) # 玩家装备ID不能同时为空 if not (old_ueid or new_ueid): log.error( 'set treasure error. old_ueid and new_ueid could not be all null.') defer.returnValue(CLIENT_DATA_ERROR) elif old_ueid and new_ueid: # 更换 res_err = yield user.bag_treasure_mgr.treasure_replace( camp_id, pos_id, old_ueid, new_ueid) elif new_ueid: # 新增 res_err = yield user.bag_treasure_mgr.treasure_wear( camp_id, pos_id, new_ueid) else: # 卸下 res_err = yield user.bag_treasure_mgr.treasure_discard( camp_id, pos_id, old_ueid) defer.returnValue(res_err)
def fellowsoul_combine(p, req): res_err = UNKNOWN_ERROR cid, [user_fellow_id] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( res_err ) res_err, fellow_id = yield user.bag_fellowsoul_mgr.combine( user_fellow_id ) if not res_err: try: # args: fellow_id, is_major, camp_id, on_troop res_err, attrib = yield user.fellow_mgr.create_table_data( fellow_id, 0, 0, 0 ) except Exception as e: log.warn('Create fellow fail! e:', e) defer.returnValue(res_err) #errorno, value = yield user.fellow_mgr.addNewFellow( fellow_id ) if not res_err: _conf = get_fellow_by_fid(fellow_id) if _conf: q = _conf.get('Quality', 0) if q>= 2: user.achievement_mgr.update_achievement_status(29, 1) if q>= 3: user.achievement_mgr.update_achievement_status(30, 1) if q>= 4: user.achievement_mgr.update_achievement_status(31, 1) defer.returnValue( [attrib.attrib_id, attrib.fellow_id] ) defer.returnValue( res_err )
def randcard(p, req): ''' @summary: In client, card_type=1 ~ 3 ''' res_err = UNKNOWN_ERROR cid, (card_type, rand_times) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( res_err ) # 背包容量判断 (去掉容量判断) #cur_capacity = yield user.fellow_mgr.cur_capacity() #if cur_capacity >= user.base_att.fellow_capacity: # log.error('cid: {0}, max fellow capacity: {1}, cur_capacity: {2}.'.format( cid, user.base_att.fellow_capacity, cur_capacity )) # defer.returnValue( FELLOW_CAPACITY_NOT_ENOUGH ) if rand_times <= 0: defer.returnValue( REQUEST_LIMIT_ERROR ) randcard_mgr = GSRandCardMgr( user ) res_err = yield randcard_mgr.randcard( card_type, rand_times ) defer.returnValue( res_err )
def gift_douzhan(send_cid, rcv_cid): user = g_UserMgr.getUser( send_cid ) if not user: log.error('Can not find user. send_cid: {0}.'.format( send_cid )) defer.returnValue( CONNECTION_LOSE ) # 维护自己的已赠送好友斗战点的信息 send_data = yield redis.hget(HASH_FRIENDS_SEND_DOUZHAN, send_cid) if send_data: send_data = loads(send_data) else: send_data = [int(time()), []] dt_now = datetime.now() dt_last = datetime.fromtimestamp( send_data[0] ) if dt_last.date() == dt_now.date(): if rcv_cid in send_data[1]: #log.error('Rcv user had gift douzhan. send_cid: {0}, rcv_cid: {1}.'.format( send_cid, rcv_cid )) defer.returnValue( NO_ERROR ) else: send_data[1].append( rcv_cid ) yield redis.hset(HASH_FRIENDS_SEND_DOUZHAN, send_cid, dumps(send_data)) else: send_data = [int(time()), [rcv_cid]] yield redis.hset(HASH_FRIENDS_SEND_DOUZHAN, send_cid, dumps(send_data)) # 每日任务计数 yield user.daily_quest_mgr.update_daily_quest( DAILY_QUEST_ID_10, 1 ) # 维护好友的可领取斗战点的信息 gift_data = dumps( (send_cid, user.lead_id, user.nick_name, user.level, user.might) ) yield redis.hset( HASH_FRIENDS_GIFT_DOUZHAN % rcv_cid, send_cid, gift_data ) defer.returnValue( NO_ERROR )
def item_sell(p, req): res_err = UNKNOWN_ITEM_ERROR cid, (user_item_ids, bag_type) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format(cid)) defer.returnValue(CONNECTION_LOSE) if bag_type == BAG_MANAGER_TYPE_EQUIP: res_err, _prices = yield user.bag_equip_mgr.get_sell_back_cost( user_item_ids) if not res_err: user.get_golds(_prices, WAY_SELL_EQUIP) elif bag_type == BAG_MANAGER_TYPE_ITEM: res_err, _prices = yield user.bag_item_mgr.get_sell_back_cost( user_item_ids) if not res_err: user.get_golds(_prices, WAY_SELL_ITEM) elif bag_type == BAG_MANAGER_TYPE_TREASURE: res_err, _prices = yield user.bag_treasure_mgr.get_sell_back_cost( user_item_ids) if not res_err: user.get_golds(_prices, WAY_SELL_TREASURE) else: res_err = UNKNOWN_BAG_TYPE defer.returnValue(res_err) if res_err: defer.returnValue(res_err) defer.returnValue([user.golds])
def gs_alliance_sacrifice(p, req): ''' 公会成员拜祭女蜗宫 ''' cid, need_credits, award_list = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue((CONNECTION_LOSE, 0, [])) res = yield user.consume_credits(need_credits, WAY_ALLIANCE_SACRIFICE) if res: defer.returnValue((res, user.credits, [])) items_return = [] for _type, _id, _num in award_list: model = ITEM_MODELs.get(_type, None) if not model: log.error('Unknown item type. item type: {0}.'.format(_type)) continue errorno, res_value = yield model(user, ItemID=_id, ItemNum=_num, AddType=WAY_ALLIANCE_SACRIFICE) if not errorno: for _v in res_value: items_return = total_new_items(_v, items_return) defer.returnValue((NO_ERROR, user.credits, items_return))
def sync_arena_lottery(p, req): ''' 翻牌奖励进玩家背包 @param: msg_notice-0:无走马灯,1-走马灯广播''' res_err = UNKNOWN_ERROR cid, [item_type, item_id, item_num, msg_notice] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( res_err ) _model = ITEM_MODELs.get( item_type, None ) if not _model: log.error('Unknown item type. item_type: {0}.'.format( item_type )) defer.returnValue( UNKNOWN_ITEM_ERROR ) res_err, value = yield _model( user, ItemID=item_id, ItemNum=item_num, AddType=WAY_LOTTERY_AWARD, CapacityFlag=False ) if res_err: defer.returnValue( res_err ) # 翻牌得到稀有道具 if msg_notice: message = [RORATE_MESSAGE_ACHIEVE, [ACHIEVE_TYPE_LOTTERY, [user.base_att.nick_name, item_type, item_id, item_num]]] gw_broadcast('sync_broadcast', [message]) defer.returnValue( value )
def get_direct_package_reward(p, req): cid, [package_id, item_id, item_num] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format(cid)) defer.returnValue(CONNECTION_LOSE) if item_num <= 0: defer.returnValue(REQUEST_LIMIT_ERROR) if package_id not in [DIRECT_PACKAGE_ID, SEVEN_DAY]: defer.returnValue(CHAR_ITEM_NOT_ENOUGH) totalnum, attrs = yield user.bag_item_mgr.get_items(package_id) if totalnum == 0: defer.returnValue(CHAR_ITEM_NOT_ENOUGH) res = yield item_use_normal_item(user, ItemType=ITEM_TYPE_DIRECT_PACKAGE, ItemID=package_id, ItemNum=1) left_res = (res[1][0][0], res[1][0][1], res[1][0][2], res[1][0][3]) if package_id == DIRECT_PACKAGE_ID: reward = yield item_add_normal_item(user, ItemType=ITEM_TYPE_DIRECT_PACKAGE, ItemID=item_id, ItemNum=item_num, AddType=WAY_DIRECT_PACKAGE) elif package_id == SEVEN_DAY: reward = yield item_add_fellow(user, ItemType=ITEM_TYPE_FELLOW, ItemID=item_id, ItemNum=item_num, AddType=WAY_DIRECT_PACKAGE) defer.returnValue(([left_res], reward[1]))
def item_sell(p, req): res_err = UNKNOWN_ITEM_ERROR cid, (user_item_ids, bag_type) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) if bag_type == BAG_MANAGER_TYPE_EQUIP: res_err, _prices = yield user.bag_equip_mgr.get_sell_back_cost( user_item_ids ) if not res_err: user.get_golds(_prices, WAY_SELL_EQUIP) elif bag_type == BAG_MANAGER_TYPE_ITEM: res_err, _prices = yield user.bag_item_mgr.get_sell_back_cost( user_item_ids ) if not res_err: user.get_golds(_prices, WAY_SELL_ITEM) elif bag_type == BAG_MANAGER_TYPE_TREASURE: res_err, _prices = yield user.bag_treasure_mgr.get_sell_back_cost( user_item_ids ) if not res_err: user.get_golds(_prices, WAY_SELL_TREASURE) else: res_err = UNKNOWN_BAG_TYPE defer.returnValue( res_err ) if res_err: defer.returnValue( res_err ) defer.returnValue( [user.golds] )
def start_plunder(p, req): ''' @summary: 开始抢夺玩家, 避免同一宝物的碎片玩家被多人同时抢夺 ''' res_err = UNKNOWN_ERROR cid, ( plunder_cid, shard_id ) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) return res_err if user.base_att.douzhan < PVP_NEED_DOUZHAN: log.error('douzhan of user {0} have been zero!!!'.format( cid )) return CHAR_DOUZHAN_NOT_ENOUGH # 抢夺对象不是玩家 if plunder_cid <= 0: return NO_ERROR item_conf = get_item_by_itemid( shard_id ) if not item_conf: log.error('Can not find conf. shard_id: {0}.'.format( shard_id )) return NOT_FOUND_CONF # 碎片可合成的宝物信息 _, treasure_id, _ = item_conf['ChangeList'][0] res_err = AvoidWarMgr.start_plunder_shard( treasure_id, plunder_cid ) return res_err
def get_plunder_info(p, req): ''' @summary: 获取夺宝基本信息 ''' res_err = UNKNOWN_ERROR cid, (plunder_type, ) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( res_err ) shard_type = 0 if plunder_type == 1: #战马 shard_type = ITEM_TYPE_HORSESHARD elif plunder_type == 2: #兵书 shard_type = ITEM_TYPE_BOOKWARSHARD else: log.error('[ get_plunder_info ]cid:{0}, Unknown plunder type: {1}.'.format( cid, plunder_type )) defer.returnValue( res_err ) value_list = yield user.bag_treasureshard_mgr.value_list_by_type(shard_type) avoid_time = yield AvoidWarMgr.remain_avoid_war_time(cid) defer.returnValue( (avoid_time, value_list) )
def skill_ball_unlock(p, req): cid, ball_index, unlock_type = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid:', cid) return CONNECTION_LOSE, None res = user.skill_ball_unlock(int(ball_index), int(unlock_type)) return res
def gs_alliance_info(p, req): ''' 同步或更新玩家的公会ID ''' cid, alliance_info = req user = g_UserMgr.getUser(cid) if user: user.alliance_id = alliance_info[0] user.alliance_name = alliance_info[1]
def sync_user_to_cs(p, req): cid = req user = g_UserMgr.getUser(cid) if user: user.syncGameDataToCS() return NO_ERROR else: log.error('Can not find user, cid:', cid) return CONNECTION_LOSE
def gs_update_achievement(p, req): cid, t_type, count = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue(CONNECTION_LOSE) yield user.achievement_mgr.update_achievement_status(t_type, count) defer.returnValue(NO_ERROR)
def gs_update_achievement(p, req): cid, t_type, count = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) yield user.achievement_mgr.update_achievement_status(t_type, count) defer.returnValue(NO_ERROR)
def get_joust_ranklist(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) res_err = yield g_JoustMgr.ranklist() defer.returnValue( res_err )
def worldboss_attacked_rank(p, req): res = UNKNOWN_ERROR cid, = req user = g_UserMgr.getUser(cid) if user: res = yield worldBoss.current_rank() defer.returnValue( res )
def worldboss_leave(p, req): res = NO_ERROR cid, = req user = g_UserMgr.getUser(cid) if user and worldBoss.running: worldBoss.remove_attacker(cid) return res
def excite_activity_info(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) data = yield user.get_excite_activity_info() defer.returnValue( data )
def get_consume_activity_status(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.consume_activity_status() defer.returnValue( res_err )
def sync_joust_revenge(p, req): cid, [enemy_cid, battle_status] = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) res_err = yield g_JoustMgr.request_joust_battle( JOUST_BATTLE_REVERGE, user, enemy_cid, battle_status ) defer.returnValue( res_err )
def get_joust_enemy(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) res_err = yield g_JoustMgr.enemy_info( user ) defer.returnValue( res_err )
def refresh_joust_players(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) res_err = yield g_JoustMgr.refresh_players( user ) defer.returnValue( res_err )
def honor_exchange_status(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) res_err = yield g_JoustMgr.get_exchange_status( user ) defer.returnValue( res_err )
def get_achievement_status(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.achievement_mgr.status() defer.returnValue( res_err )
def set_jade_one_touch(p, req): ''' 一键穿戴玉魄 ''' cid, [camp_id, one_touch_data] = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) res_err = yield user.bag_jade_mgr.set_one_touch( camp_id, one_touch_data ) defer.returnValue( res_err )
def buy_open_server_reward(p, req): res = CONNECTION_LOSE cid, [acType, quest_id] = req user = g_UserMgr.getUser(cid) if user: res = yield user.open_server_mgr.buy_open_server_item(acType, quest_id) defer.returnValue( res )
def get_open_server_quest_info(p, req): res = CONNECTION_LOSE cid, = req user = g_UserMgr.getUser(cid) if user: res = yield user.open_server_mgr.get_open_server_activity_status() defer.returnValue(res)
def get_quest_reward(p, req): cid, [quest_id] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format(cid)) defer.returnValue(CONNECTION_LOSE) res_err = yield user.daily_quest_mgr.get_daily_quest_reward(quest_id) defer.returnValue(res_err)
def get_quest_reward(p, req): cid, [quest_id] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.daily_quest_mgr.get_daily_quest_reward(quest_id) defer.returnValue( res_err )
def set_camp_one_touch(p, req): cid, [camp_id, one_touch_data] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.set_camp_one_touch(camp_id, one_touch_data) defer.returnValue( res_err )
def set_camp_predestine(p, req): cid, [camp_pos_id, old_ufid, new_ufid] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.set_camp_predestine(camp_pos_id, old_ufid, new_ufid) defer.returnValue( res_err )
def red_point_status(p, req): cid, = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( (CONNECTION_LOSE, []) ) res_err = {'alliance': user.alliance_id} return res_err
def get_atlaslist_info(p, req): ''' 好友留言 ''' cid, [category_id, second_type] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.atlaslist_mgr.atlaslist_info(category_id, second_type) defer.returnValue( res_err )
def request_atlaslist_award(p, req): ''' 领取星级图鉴收齐后的奖励 ''' cid, [category_id, second_type, quality] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.atlaslist_mgr.atlaslist_award(category_id, second_type, quality) defer.returnValue( res_err )
def get_achievement_reward(p, req): cid, [acType, reward_id] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.achievement_mgr.get_reward( acType, reward_id ) defer.returnValue( res_err )
def get_dungeon_reward(p, req): cid, [scene_id, dungeon_id] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.scene_mgr.dungeon_reward(scene_id, dungeon_id) defer.returnValue( res_err )
def reset_monster_count(p, req): cid, [scene_id, dungeon_id, reset_way] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.scene_mgr.reset_dungeon_count(scene_id, dungeon_id, reset_way) defer.returnValue( res_err )
def multi_monster_group(p, req): res_err = UNKNOWN_ERROR cid, scene_ids = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( res_err ) all_dungeon = yield user.scene_mgr.multi_dungeon_group( scene_ids ) defer.returnValue( all_dungeon )
def jade_list(p, req): ''' 获取玉魄列表 ''' cid, [index] = req user = g_UserMgr.getUser(cid) if not user: defer.returnValue( CONNECTION_LOSE ) _len, value_list = yield user.bag_jade_mgr.value_list( index ) max_capacity = user.base_att.jade_capacity _level = user.bag_jade_mgr.random_jade_level defer.returnValue( (_len, max_capacity, _level, value_list) )
def exchange_goodwill_level(p, req): ''' 互换好感度等级 ''' cid, [left_fellow_id, right_fellow_id] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.goodwill_mgr.exchange_goodwill(left_fellow_id, right_fellow_id) defer.returnValue( res_err )
def activescene_data(p, req): res_err = UNKNOWN_ERROR cid, = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( res_err ) res_err = yield user.activescene_mgr.activescene_data() defer.returnValue( res_err )
def get_scene_ranklist(p, req): ''' 获取剧情排行榜前10名 ''' cid, = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) res_err = yield user.scene_mgr.ranklist() defer.returnValue( res_err )