def creatNewCharacter(self, nickname, profession): '''创建新角色 @profession (int) 角色职业 (0 新手 1战士 2 法师 3 游侠 4 牧师) ''' if profession not in range(1, 5): return {'result': False, 'message': Lg().g(589)} if len(nickname) < 2 or len(nickname) > 20: return {'result': False, 'message': Lg().g(590)} for word in dbaccess.All_ShieldWord: if nickname.find(word[0]) != -1: return {'result': False, 'message': Lg().g(21)} fieldname = self.getVacancy() if not fieldname: return {'result': False, 'message': Lg().g(591)} result = dbaccess.getCharacterIdByNickName(nickname) if result: return {'result': False, 'message': Lg().g(592)} result = dbaccess.creatNewCharacter(nickname, profession, self.baseInfo.id, fieldname) if result: setattr(self.baseInfo, fieldname, result) data = {} data['UserCharacterListInfo'] = self.getUserCharacterListInfo() data['newCharacterId'] = result content = Lg().g(593) title = Lg().g(594) m = Mail( title=title,type =0, senderId =-1, receiverId=result,\ sender = Lg().g(128),content=content) m.mailIntoDB() return {'result': True, 'message': Lg().g(595), 'data': data} else: return {'result': False, 'message': Lg().g(596)}
def creatNewCharacter(self, nickname, profession): """创建新角色 @profession (int) 角色职业 (0 新手 1战士 2 法师 3 游侠 4 牧师) """ if profession not in range(1, 5): return {"result": False, "message": Lg().g(589)} if len(nickname) < 2 or len(nickname) > 20: return {"result": False, "message": Lg().g(590)} for word in dbaccess.All_ShieldWord: if nickname.find(word[0]) != -1: return {"result": False, "message": Lg().g(21)} fieldname = self.getVacancy() if not fieldname: return {"result": False, "message": Lg().g(591)} result = dbaccess.getCharacterIdByNickName(nickname) if result: return {"result": False, "message": Lg().g(592)} result = dbaccess.creatNewCharacter(nickname, profession, self.baseInfo.id, fieldname) if result: setattr(self.baseInfo, fieldname, result) data = {} data["UserCharacterListInfo"] = self.getUserCharacterListInfo() data["newCharacterId"] = result content = Lg().g(593) title = Lg().g(594) m = Mail(title=title, type=0, senderId=-1, receiverId=result, sender=Lg().g(128), content=content) m.mailIntoDB() return {"result": True, "message": Lg().g(595), "data": data} else: return {"result": False, "message": Lg().g(596)}
def deleteMail(self,mailID): '''删除邮件''' result = self.checkMyMail(mailID) if not result: return {'result':False,'message':Lg().g(360)} m = Mail(id = mailID) result = m.destroyMail() return {'result':result,'message':Lg().g(361)}
def deleteMail(self, mailID): '''删除邮件''' result = self.checkMyMail(mailID) if not result: return {'result': False, 'message': Lg().g(360)} m = Mail(id=mailID) result = m.destroyMail() return {'result': result, 'message': Lg().g(361)}
def saveMail(self, mailID): '''保存邮件''' result = self.checkMyMail(mailID) if not result: return {'result': False, 'message': Lg().g(360)} m = Mail(id=mailID) result = m.updateMainInfo({'isSaved': 1}) if not result: return {'result': False, 'message': Lg().g(362)} return {'result': True, 'message': Lg().g(363)}
def BatchDelete(self, mailIDList): '''批量删除''' for mailId in mailIDList: result = self.checkMyMail(mailId) if not result: return {'result': False, 'message': Lg().g(364) % mailId} for mailId in mailIDList: m = Mail(id=mailId) result = m.destroyMail() return {'result': True, 'message': Lg().g(361)}
def sendMail(self,receiverId,title,content): '''发送邮件 @param receiverId: int 发送者的ID @param title: str 邮件的标题 @param content: str 邮件的内容 ''' m = Mail( title=title, senderId =self._owner.baseInfo.id, receiverId=receiverId,\ sender = self._owner.baseInfo.getNickName(),content=content) result = m.mailIntoDB() return result
def BatchDelete(self,mailIDList): '''批量删除''' for mailId in mailIDList: result = self.checkMyMail(mailId) if not result: return {'result':False,'message':Lg().g(364)%mailId} for mailId in mailIDList: m = Mail(id = mailId) result = m.destroyMail() return {'result':True,'message':Lg().g(361)}
def saveMail(self,mailID): '''保存邮件''' result = self.checkMyMail(mailID) if not result: return {'result':False,'message':Lg().g(360)} m = Mail(id = mailID) result = m.updateMainInfo({'isSaved':1}) if not result: return {'result':False,'message':Lg().g(362)} return {'result':True,'message':Lg().g(363)}
def sendMail(self, receiverId, title, content): '''发送邮件 @param receiverId: int 发送者的ID @param title: str 邮件的标题 @param content: str 邮件的内容 ''' m = Mail( title=title, senderId =self._owner.baseInfo.id, receiverId=receiverId,\ sender = self._owner.baseInfo.getNickName(),content=content) result = m.mailIntoDB() return result
def readMail(self,mailID): '''阅读邮件(将邮件未读状态改为以读状态) @param mailID: int 邮件的ID ''' result = self.checkMyMail(mailID) if not result: return {'result':False,'message':Lg().g(360)} m = Mail(id = mailID) m.updateMainInfo({'isReaded':1}) data = m.formatMailInfo() return {'result':True,'data':data}
def readMail(self, mailID): '''阅读邮件(将邮件未读状态改为以读状态) @param mailID: int 邮件的ID ''' result = self.checkMyMail(mailID) if not result: return {'result': False, 'message': Lg().g(360)} m = Mail(id=mailID) m.updateMainInfo({'isReaded': 1}) data = m.formatMailInfo() return {'result': True, 'data': data}
def acceptGuildApply(self, operator, characterId): '''同意角色的入会申请 @param operator: 操作者的id @param characterId: int 申请人的id ''' president = self.get('president') veteranList = eval('[' + self.guildinfo['veterans'] + ']') staffList = eval('[' + self.guildinfo['staffOfficers'] + ']') senatorsList = eval('[' + self.guildinfo['senators'] + ']') #获取操作者的权限 if operator == president: operatorpost = Lg().g(520) elif operator in veteranList: operatorpost = Lg().g(519) elif operator in staffList: operatorpost = Lg().g(518) elif operator in senatorsList: operatorpost = Lg().g(517) managementGroup = veteranList + staffList + senatorsList if not dbGuild.checkHasApply(self.id, characterId): return -4 if operator != self.president and operator not in managementGroup: return -1 #权限不够 if dbGuild.checkCharacterHasGuild(characterId): return -2 #已经加入了行会 curMenberNum = dbGuild.countGuildMenberNum(self.id) info = self.guildinfo maxMemberCount = 20 + ((info['emblemLevel'] - 1) * 30) if curMenberNum >= maxMemberCount: return -3 #成员数量达到上限 result = dbGuild.insertCharacterGuildInfo(characterId, self.id) dbGuild.delCharacterAllApply(characterId) if result: player = PlayersManager().getPlayerByID(operator) content = Lg().g(532)\ %(self.guildinfo.get('name',''),operatorpost,\ player.baseInfo.getNickName(),self.guildinfo.get('name','')) title = Lg().g(526) m = Mail( title=title,type =0, senderId =-1, receiverId=characterId,\ sender = Lg().g(128),content=content) m.mailIntoDB() player = PlayersManager().getPlayerByID(characterId) if player: player.guild.updateID(self.id) chatnoderemote.callRemote('updateGuild', characterId, self.id, 1) #同步聊天角色中的行会 player.updatePlayerInfo() return 1 #同意申请成功 return 0 #同意申请失败
def acceptGuildApply(self,operator,characterId): '''同意角色的入会申请 @param operator: 操作者的id @param characterId: int 申请人的id ''' president = self.get('president') veteranList = eval('['+self.guildinfo['veterans']+']') staffList = eval('['+self.guildinfo['staffOfficers']+']') senatorsList = eval('['+self.guildinfo['senators']+']') #获取操作者的权限 if operator==president: operatorpost =Lg().g(520) elif operator in veteranList: operatorpost = Lg().g(519) elif operator in staffList: operatorpost = Lg().g(518) elif operator in senatorsList: operatorpost = Lg().g(517) managementGroup = veteranList + staffList + senatorsList if not dbGuild.checkHasApply(self.id, characterId): return -4 if operator!=self.president and operator not in managementGroup: return -1#权限不够 if dbGuild.checkCharacterHasGuild(characterId): return -2#已经加入了行会 curMenberNum = dbGuild.countGuildMenberNum(self.id) info = self.guildinfo maxMemberCount = 20 + ((info['emblemLevel']-1)*30) if curMenberNum>=maxMemberCount: return -3#成员数量达到上限 result = dbGuild.insertCharacterGuildInfo(characterId, self.id) dbGuild.delCharacterAllApply(characterId) if result: player = PlayersManager().getPlayerByID(operator) content = Lg().g(532)\ %(self.guildinfo.get('name',''),operatorpost,\ player.baseInfo.getNickName(),self.guildinfo.get('name','')) title = Lg().g(526) m = Mail( title=title,type =0, senderId =-1, receiverId=characterId,\ sender = Lg().g(128),content=content) m.mailIntoDB() player = PlayersManager().getPlayerByID(characterId) if player: player.guild.updateID(self.id) chatnoderemote.callRemote('updateGuild',characterId,self.id,1)#同步聊天角色中的行会 player.updatePlayerInfo() return 1#同意申请成功 return 0#同意申请失败
def TransferCorps(self,operator,memberId): '''移交国长 @param operator: int 操作者的id @param memberId: int 被任命的角色的id ''' managementGroup = eval("["+self.guildinfo['veterans']+"]")\ +eval("["+self.guildinfo['staffOfficers']+"]")\ +eval("["+self.guildinfo['senators']+"]") if memberId not in managementGroup: return {'result':False,'message':Lg().g(534)} if operator!=self.president: return {'result':False,'message':Lg().g(515)} if not dbGuild.checkCharacterInGuild(memberId, self.id): return {'result':False,'message':Lg().g(524)} result = dbGuild.TransferCorps(self.id, operator, memberId) if result: self.president = memberId player = PlayersManager().getPlayerByID(operator) player.updatePlayerInfo() member = PlayersManager().getPlayerByID(memberId) if member: member.updatePlayerInfo() dbGuild.updateCharacterGuildInfo(memberId, {'post':4}) membername = dbGuild.getCharacterNameByID(memberId) content = Lg().g(535)%\ (self.guildinfo.get('nickname',''),membername,self.guildinfo.get('name',''),) title = Lg().g(526) for characterId in dbGuild.getAllGuildCharacterId(self.id): m = Mail( title=title,type =0, senderId =-1, receiverId=characterId[0],\ sender = Lg().g(128),content=content) m.mailIntoDB() postdict = dbGuild.updateGuildPost(self.id) self.veterans=postdict.veterans self.staffOfficers=postdict.staffOfficers self.senators=postdict.senators # self.SynchGuildInfo() return {'result':True,'message':Lg().g(85)} return {'result':False,'message':Lg().g(536)}
def TransferCorps(self, operator, memberId): '''移交国长 @param operator: int 操作者的id @param memberId: int 被任命的角色的id ''' managementGroup = eval("["+self.guildinfo['veterans']+"]")\ +eval("["+self.guildinfo['staffOfficers']+"]")\ +eval("["+self.guildinfo['senators']+"]") if memberId not in managementGroup: return {'result': False, 'message': Lg().g(534)} if operator != self.president: return {'result': False, 'message': Lg().g(515)} if not dbGuild.checkCharacterInGuild(memberId, self.id): return {'result': False, 'message': Lg().g(524)} result = dbGuild.TransferCorps(self.id, operator, memberId) if result: self.president = memberId player = PlayersManager().getPlayerByID(operator) player.updatePlayerInfo() member = PlayersManager().getPlayerByID(memberId) if member: member.updatePlayerInfo() dbGuild.updateCharacterGuildInfo(memberId, {'post': 4}) membername = dbGuild.getCharacterNameByID(memberId) content = Lg().g(535)%\ (self.guildinfo.get('nickname',''),membername,self.guildinfo.get('name',''),) title = Lg().g(526) for characterId in dbGuild.getAllGuildCharacterId(self.id): m = Mail( title=title,type =0, senderId =-1, receiverId=characterId[0],\ sender = Lg().g(128),content=content) m.mailIntoDB() postdict = dbGuild.updateGuildPost(self.id) self.veterans = postdict.veterans self.staffOfficers = postdict.staffOfficers self.senators = postdict.senators # self.SynchGuildInfo() return {'result': True, 'message': Lg().g(85)} return {'result': False, 'message': Lg().g(536)}
def refuseGuildApply(self, operator, characterId): '''拒绝角色的入会申请 @param operator: 操作者的id @param characterId: int 申请人的id ''' president = self.get('president') veteranList = eval('[' + self.guildinfo['veterans'] + ']') staffList = eval('[' + self.guildinfo['staffOfficers'] + ']') senatorsList = eval('[' + self.guildinfo['senators'] + ']') #获取操作者的权限 if operator == president: operatorpost = Lg().g(520) elif operator in veteranList: operatorpost = Lg().g(519) elif operator in staffList: operatorpost = Lg().g(518) elif operator in senatorsList: operatorpost = Lg().g(517) managementGroup = veteranList + staffList + senatorsList if not dbGuild.checkHasApply(self.id, characterId): return -4 if operator != self.president and operator not in managementGroup: return -1 #权限不够 result = dbGuild.delGuildApplyJoinRecord(self.id, characterId) if result: player = PlayersManager().getPlayerByID(operator) content = Lg().g(533) % (player.baseInfo.getName(), operatorpost, self.guildinfo.get('nickname', '')) title = Lg().g(526) m = Mail( title=title,type =0, senderId =-1, receiverId=characterId,\ sender = Lg().g(128),content=content) m.mailIntoDB() tplayer = PlayersManager().getPlayerByID(characterId) if tplayer: tplayer.quest.specialTaskHandle(ADDGUILDTASKTYPE) return 1
def refuseGuildApply(self,operator,characterId): '''拒绝角色的入会申请 @param operator: 操作者的id @param characterId: int 申请人的id ''' president = self.get('president') veteranList = eval('['+self.guildinfo['veterans']+']') staffList = eval('['+self.guildinfo['staffOfficers']+']') senatorsList = eval('['+self.guildinfo['senators']+']') #获取操作者的权限 if operator==president: operatorpost =Lg().g(520) elif operator in veteranList: operatorpost = Lg().g(519) elif operator in staffList: operatorpost = Lg().g(518) elif operator in senatorsList: operatorpost = Lg().g(517) managementGroup = veteranList + staffList + senatorsList if not dbGuild.checkHasApply(self.id, characterId): return -4 if operator!=self.president and operator not in managementGroup: return -1#权限不够 result = dbGuild.delGuildApplyJoinRecord(self.id, characterId) if result: player = PlayersManager().getPlayerByID(operator) content = Lg().g(533)%(player.baseInfo.getName(),operatorpost,self.guildinfo.get('nickname','')) title = Lg().g(526) m = Mail( title=title,type =0, senderId =-1, receiverId=characterId,\ sender = Lg().g(128),content=content) m.mailIntoDB() tplayer = PlayersManager().getPlayerByID(characterId) if tplayer: tplayer.quest.specialTaskHandle(ADDGUILDTASKTYPE) return 1
def fireMember(self,operator,memberId): '''开除行会成员 @param operator: 操作者的id @param memberID: int 成员的id 角色id ''' from app.scense.core.instance.ColonizeManage import ColonizeManage president = self.getPresident() veteranList = eval('['+self.guildinfo['veterans']+']') staffList = eval('['+self.guildinfo['staffOfficers']+']') senatorsList = eval('['+self.guildinfo['senators']+']') #获取操作者的权限 if operator==president: operatorpost =4 elif operator in veteranList: operatorpost = 3 elif operator in staffList: operatorpost = 2 elif operator in senatorsList: operatorpost = 1 else: operatorpost = 0 #获取被操作者的权限 if memberId==president: memberpost =4 elif memberId in veteranList: memberpost = 3 elif memberId in staffList: memberpost = 2 elif memberId in senatorsList: memberpost = 1 else: memberpost = 0 if operator ==memberId: return {'result':False,'message':Lg().g(523)}#权限不够 if operatorpost<= memberpost: return {'result':False,'message':Lg().g(515)}#权限不够 if not dbGuild.checkCharacterInGuild(memberId, self.id): return {'result':False,'message':Lg().g(524)} result = dbGuild.deleteCharacterGuildRelation(memberId) if result: postdict = dbGuild.updateGuildPost(self.id) self.veterans=postdict.veterans self.staffOfficers=postdict.staffOfficers self.senators=postdict.senators content = Lg().g(525)%(self.guildinfo.get('nickname',''),\ self.guildinfo.get('name','')) title = Lg().g(526) m = Mail( title=title,type =0, senderId =-1, receiverId=memberId,\ sender = Lg().g(128),content=content) m.mailIntoDB() player = PlayersManager().getPlayerByID(memberId) if player: player.guild.updateID(0) chatnoderemote.callRemote('updateGuild',memberId,self.id,0)#同步聊天角色中的行会 playerList = dbGuild.getGuildCharacterIdList(self.id) msg = Lg().g(527)%(player.baseInfo.getName(),self.getGuildName()) sendList = [PlayersManager().getPlayerByID(p[0]).getDynamicId()\ for p in playerList \ if PlayersManager().getPlayerByID(p[0]) and \ PlayersManager().getPlayerByID(p[0]).getDynamicId()] pushPromptedMessage(msg, sendList) player.updatePlayerInfo() ColonizeManage().updateGuild(memberId, 0, u'') return {'result':True,'message':Lg().g(528)}#开除成功 return {'result':False,'message':Lg().g(529)}#开除失败
def fireMember(self, operator, memberId): '''开除行会成员 @param operator: 操作者的id @param memberID: int 成员的id 角色id ''' from app.scense.core.instance.ColonizeManage import ColonizeManage president = self.getPresident() veteranList = eval('[' + self.guildinfo['veterans'] + ']') staffList = eval('[' + self.guildinfo['staffOfficers'] + ']') senatorsList = eval('[' + self.guildinfo['senators'] + ']') #获取操作者的权限 if operator == president: operatorpost = 4 elif operator in veteranList: operatorpost = 3 elif operator in staffList: operatorpost = 2 elif operator in senatorsList: operatorpost = 1 else: operatorpost = 0 #获取被操作者的权限 if memberId == president: memberpost = 4 elif memberId in veteranList: memberpost = 3 elif memberId in staffList: memberpost = 2 elif memberId in senatorsList: memberpost = 1 else: memberpost = 0 if operator == memberId: return {'result': False, 'message': Lg().g(523)} #权限不够 if operatorpost <= memberpost: return {'result': False, 'message': Lg().g(515)} #权限不够 if not dbGuild.checkCharacterInGuild(memberId, self.id): return {'result': False, 'message': Lg().g(524)} result = dbGuild.deleteCharacterGuildRelation(memberId) if result: postdict = dbGuild.updateGuildPost(self.id) self.veterans = postdict.veterans self.staffOfficers = postdict.staffOfficers self.senators = postdict.senators content = Lg().g(525)%(self.guildinfo.get('nickname',''),\ self.guildinfo.get('name','')) title = Lg().g(526) m = Mail( title=title,type =0, senderId =-1, receiverId=memberId,\ sender = Lg().g(128),content=content) m.mailIntoDB() player = PlayersManager().getPlayerByID(memberId) if player: player.guild.updateID(0) chatnoderemote.callRemote('updateGuild', memberId, self.id, 0) #同步聊天角色中的行会 playerList = dbGuild.getGuildCharacterIdList(self.id) msg = Lg().g(527) % (player.baseInfo.getName(), self.getGuildName()) sendList = [PlayersManager().getPlayerByID(p[0]).getDynamicId()\ for p in playerList \ if PlayersManager().getPlayerByID(p[0]) and \ PlayersManager().getPlayerByID(p[0]).getDynamicId()] pushPromptedMessage(msg, sendList) player.updatePlayerInfo() ColonizeManage().updateGuild(memberId, 0, u'') return {'result': True, 'message': Lg().g(528)} #开除成功 return {'result': False, 'message': Lg().g(529)} #开除失败