def doMatch(dynamicId, characterId, npcid): '''''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} data = gamer.trainmatch.doMacth(npcid) return {'result': True, 'data': data}
def sendMail(dynamicId, characterId, gamerName, title, content): '''添加邮件 @param dynamicId:int 客户端的动态id @param characterId:int 角色的ID @param gamerName:str 接收人的名称 @param content:str 邮件内容 @param title:str 标题 ''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.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(gamerName) if not toId: return {'result': False, 'message': u""} if toId[0] == characterId: return {'result': False, 'message': u""} result = gamer.mail.sendMail(toId[0], title, content) if result: return {'result': True, 'message': u""} return {'result': False, 'message': u""}
def UseItem(dynamicId, characterId, itemId, targetId): '''获取包裹的信息''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'messgae': "角色不存在"} data = gamer.pack.useItem(itemId, targetId) return data
def buyItem(dynamicId,characterId,shopCategory,itemId,buyNum): '''购买道具''' gamer=GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result':False,'message':u"角色不存在"} data=gamer.shop.buyItem(shopCategory,itemId,buyNum) return data
def RotatePlayer(dynamicId, characterId, mainPlayerid, benchPlayerid): '''球员轮换''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} mainplayer = gamer.player.getPlayer(mainPlayerid) benchplayer = gamer.player.getPlayer(benchPlayerid) if mainplayer and benchplayer: maintempID = mainplayer.templateInfo.get('id') bebchtempID = benchplayer.templateInfo.get('id') if not gamer.player.IsOnCourt( bebchtempID, benchPlayerid) or maintempID == bebchtempID: playertemps = gamer.player.getPlayers() mainpos = mainplayer.getPlayerpos() benchpos = benchplayer.getPlayerpos() maincategory = mainplayer.getPlayerCategory() benchcategory = benchplayer.getPlayerCategory() mainplayer.savePlayerpos(benchpos, benchcategory) benchplayer.savePlayerpos(mainpos, maincategory) players = [] for player in gamer.player.getPlayers().values(): if player.getPlayerpos() >= 'a' and player.getPlayerpos( ) < 'z': #场上球员 info = player.formatPlayerInfo() players.append(info) if len(players) != 11: #球员不是11人 gamer.player._players = playertemps return {'result': False, 'message': u"换人失败"} gamer.CalPower() return {'result': True, 'message': u""} else: return {'result': False, 'message': u"该球员已经在场上"} else: return {'result': False, 'message': u"球员不存在"}
def addPlayer(dynamicId, characterId, templateId): #添加新球员到替补席 '''添加新球员到替补席''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} result = gamer.player.addPlayer(templateId) return result
def playerListInfo(dynamicId, characterId): '''获取角色的球员列表''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} playerList = gamer.player.FormatPlayerList() return {'result': True, 'data': playerList}
def GetPackageInfo(dynamicId, characterId): '''获取包裹的信息''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'messgae': "角色不存在"} data = gamer.pack.getPackageItemList() return data
def getChallengeMatchInfoByLeague(dynamicId,characterId,leagueindex): '''根据级别获取挑战赛赛npc信息''' gamer=GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result':False,'message':u"角色不存在"} data=gamer.challengematch.getNpcByLeague(leagueindex) return {'result':True,'data':data}
def addPlayerExp(dynamicId, characterId, playerid, exp): '''球员加经验''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} result = gamer.player.addPlayerExp(playerid, exp) return result
def GetCompoundPackage_2109(dynamicId, characterId): '''获取合成包裹的信息 ''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} response = gamer.pack.HouQuSuiPianBaoguo() return response
def getTrainBase(dynamicId, characterId): '''获取训练基地信息''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} trainbase = TrainBase() data = trainbase.getTrainBase() #获取训练基地信息 return {'result': True, 'data': data}
def GetOneItemInfo(dynamicId, characterId, itemid): '''获取单个物品的详细信息 ''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} response = gamer.pack.getOneItemInfo(itemid) return response
def commitTask(dynamicId,characterId,taskId): '''提交任务''' gamer=GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result':False,'message':u"角色不存在"} gamer.task._tasks.get(taskId).setStatus(1) data=gamer.task.commitTask(taskId) return data
def CompoundItem(dynamicId, characterId, tempid): '''合成物品 ''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} response = gamer.pack.CompoundItem(tempid) return response
def getMailList(dynamicId, characterId): '''获取邮件列表 @param characterId: int 角色的ID ''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} mailListInfo = gamer.mail.getMailList() return {'result': True, 'data': mailListInfo}
def upgradePlayer(dynamicId, characterId, playerid, gamecoin, itemid): '''球员升级''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} if gamer.finance.addGameCoin(-gamecoin): result = gamer.player.upgradePlayer(playerid) return result else: return {'result': False, 'message': u"银币不足"}
def TaskAcceptTaskList(dynamicId,characterId): '''获取可接任务列表 @param dynamicId: int 客户端动态id @param characterId: int 角色id ''' gamer=GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result':False,'message':u"角色不存在"} data=gamer.task.getReceivedTaskList() return {'result':True,'data':data}
def getMailInfo(dynamicId, characterId, mailId): '''获取邮件的详细信息 @param characterId: int 角色的ID @param mailId: int 邮件的ID ''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} mailInfo = gamer.mail.readMail(mailID) return mailInfo
def playertraining(dynamicId, characterId, Shoot, Dribbling, Speed, Pass, Tackle, Tackling, _Save, Response, playerid, Trainpoint): '''球员训练''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} result = gamer.player.PlayerTraining(playerid, Shoot, Dribbling, Speed, Pass, Tackle, Tackling, _Save, Response, Trainpoint, gamer) return result
def SignPlayer(dynamicId, characterId, playerId, gamecoin): #签约球员 '''签约球员''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} player = gamer.player.getPlayer(playerId) if gamer.finance.addGameCoin(-gamecoin): player.setPlayerCategory(2) player.setPlayerpos('z') return {'result': True, 'message': u""} else: return {'result': False, 'message': u"银币不足"}
def dropPlayer(dynamicId, characterId, playerid): #尚未添加返还训练点 '''解雇球员''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} result = gamer.player.DropPlayer(playerid) if result: # returnpoint=PlayerInner.DISSMISSPOINT.get(playerquality) 查询训练点 # gamer.playerInner.updatePoint(returnpoint) 返还训练点 return {'result': True, 'message': ""} else: return {'result': False, 'message': u"解雇失败"}
def DissmissPlayer(dynamicId, characterId, playerid): '''遣散球员''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} player = gamer.player.getPlayer(playerid) playerquality = player.level.getPlayerQuality() result = gamer.player.DropPlayer(playerid) if result: returnpoint = PlayerInner.DISSMISSPOINT.get(playerquality) gamer.playerInner.updatePoint(returnpoint) return {'result': True, 'message': ""} else: return {'result': False, 'message': u"遣散失败"}
def getShopInfo(dynamicId,characterId,shopCategory): '''获取商城信息 @param dynamicId:int 客户端id @param characterId:int 角色id @param shopCategory:int 商店类型 1金币2银币 ''' gamer=GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result':False,'message':u"角色不存在"} shop=ShopManager().getShopByCategory(shopCategory) if not shop: shop=Shop(shopCategory) ShopManager().addShop(shop) data=shop.getShopInfo() return {'result':True,'data':data}
def getPlayerInner(dynamicId, characterId): '''获取球员寻找信息''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} data = {} pi = gamer.playerInner data['xy'] = pi.xy data['ctime1'] = pi.getTime(1) data['ctime2'] = pi.getTime(2) data['cs1'] = pi.cs1 data['cs2'] = pi.cs2 data['player1'] = pi.inner[0] data['player2'] = pi.inner[1] data['player3'] = pi.inner[2] data['point'] = pi.point return {'result': True, 'data': data}
def PickPlayer(dynamicId, characterId, picktype, leagueindex, costpoint=0): '''挑选球员''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} info = gamer.playerInner.pickPlayer(picktype, costpoint, leagueindex) if info.get('result'): playerid = info.get('data').get('playerid') player = gamer.player.addPlayer(playerid, 1, 3) if player == -1: return {'result': False, 'message': u"替补席已满"} elif player == -2: return {'result': False, 'message': u"球员大厅已满"} else: info['data']['player'] = player.formatPlayerInfo() else: return info return {'result': True, 'data': info.get('data')}
def GetCompoundItem(dynamicId, characterId, tempid): '''获取当前碎片能合成的物品的信息 ''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.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 newtempid: 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']
def beginTraining(dynamicId, characterId, num): '''开始训练''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} trainpoint = gamer.attribute.getTrainPoint() trainbaseinfo = dbTrainbase.getTrainbaseInfo(characterId) #获取训练纪录 if not trainbaseinfo: dbTrainbase.initTrainbaseInfo(characterId) #初始化训练纪录 trainbaseinfo = dbTrainbase.getTrainbaseInfo(characterId) timeleft = trainbaseinfo.get('timeleft') #剩余训练时间 if not timeleft > 0: return {'result': False, 'message': u"shijianyongjin"} startTime = datetime.datetime.now() finishTime = startTime + datetime.timedelta(seconds=timeleft) trainbase = TrainBase() status = trainbase.getTrainBase().get(num).get('status') if status == 1: #训练场已被占用 return {'result': False, 'message': u"yizhanyong"} getTrainPoint = trainbase.getTrainBase().get(num).get( 'trainpoint') * timeleft / 3600 trainpoint += getTrainPoint dbTrainbase.updateTrainbaseInfo(characterId, { 'starttime': str(startTime), 'finishtime': str(finishTime), 'num': num }) #更新训练纪录 trainbase.setTainBaseStatus(num, 1, characterId) #更新训练场为占用 reactor.callLater(timeleft, doWhenTrainingFinished, {'trainpoint': trainpoint}, gamer, num) #训练结束 return { 'result': True, 'data': { 'startTime': str(startTime), 'finishTime': str(finishTime), 'gettrainpoint': getTrainPoint } }
def endTraining(dynamicId, characterId): #中断训练 '''中断训练''' gamer = GamersManager().getGamerByID(characterId) if not gamer or not gamer.CheckClient(dynamicId): return {'result': False, 'message': u"角色不存在"} trainpoint = gamer.attribute.getTrainPoint() trainbaseinfo = dbTrainbase.getTrainbaseInfo(characterId) if not trainbaseinfo: return {'result': False, 'message': u""} trainbase = TrainBase() now = datetime.datetime.now() startTime = trainbaseinfo.get('starttime') finishTime = trainbaseinfo.get('finishtime') num = trainbaseinfo.get('num') if num > 0: now = int(time.mktime(now.timetuple())) startTime = int(time.mktime(startTime.timetuple())) finishTime = int(time.mktime(finishTime.timetuple())) traintime = now - startTime timeleft = finishTime - now if timeleft > 0: getTrainPoint = trainbase.getTrainBase().get(num).get( 'trainpoint') * traintime / 3600 trainpoint += getTrainPoint dbTrainbase.updateTrainbaseInfo( characterId, { 'finishtime': datetime.datetime.now(), 'num': 0, 'timeleft': timeleft }) #更新训练纪录 gamer.attribute.setTrainPoint(trainpoint) #更新球队训练点 trainbase.setTainBaseStatus(num, 0) #更新训练场为可用 return {'result': True, 'data': {'gettrainpoint': getTrainPoint}} else: return {'result': False, 'message': u"xunlianyijieshu"} else: return {'result': False, 'message': u"weixunlian"}