Exemple #1
0
def GetChatInfoRequest_1011(dynamicId, request_proto):
    '''获取私聊信息'''
    argument = GetOneObjectChatInfo1011_pb2.GetOneObjectChatInfoRequest()
    argument.ParseFromString(request_proto)
    response = GetOneObjectChatInfo1011_pb2.GetOneObjectChatInfoResponse()

    id = argument.id
    tid = argument.chatObjectId
    val = ChaterLogManager().getLog(id, tid)
    if val.get('result', None):
        response.result = True
        response.message = u''
        response.chatMessage = val.get('result', u'')
        response.level = val.get('level', 0)
        response.perfession = val.get('perfession', Lg().g(143))
        response.chatObjectPos = val.get('chatObjectPos', u'')
        response.name = val.get('name', u'')

    else:
        response.result = True
        response.message = u''
        response.chatMessage = val.get('result', u'')
        response.level = val.get('level', 0)
        response.perfession = val.get('perfession', Lg().g(143))
        response.chatObjectPos = val.get('chatObjectPos', u'')
        response.name = val.get('name', u'')
    return response.SerializeToString()
Exemple #2
0
def sendMessage(dynamicId,
                characterId,
                topic,
                content,
                linkData,
                tonickname=None):
    '''发送聊天信息
    @param dynamicId: int 客户端的id
    @param characterId: int 角色的id
    @param topic: int 频道的编号    
    @param content: string 发送的消息内容
    @param linkData: dict list 连接信息内容
    '''

    chater = ChaterManager().getChaterByCharacterId(characterId)
    if not chater:
        return {'result': False, 'message': Lg().g(639)}
    if topic == 7:
        toplayer = ChaterManager().getChaterByCharacterId(characterId)
        if not toplayer:
            return {'result': False, "message": Lg().g(640)}
        else:
            topic = toplayer.baseInfo.id

    targetList = []
    chaterName = chater.getCharacterName()
    profession = chater.getProfession()

    if topic == 1:  #世界频道聊天
        idlist = ChaterManager().getAlldynamicId()
        targetList = idlist
    elif topic == 2:  #当前 相当于同场景
        roomId = chater.getRoomId()
        targetList = ChatRoomManager().getRoomMember(roomId)

    elif topic == 3:  #国
        gid = chater.guildid
        if gid < 1:
            return {'result': False, "message": Lg().g(641)}
        else:
            #            return {'result':False,"message":u"国聊天功能暂未开放,敬请期待"}
            #            idlist = ChaterManager().getAlldynamicId()
            #            targetList=idlist
            #            content=u"国聊天暂未开放"
            plist = GuildManager().getdtidListBygid(gid)
            if plist:
                targetList = list(plist)


#        gid=player.guild.getID()#返回行会id
#        resut=setGuildPlayerDynamicId(gid,targetList) #设置添加targetList,国聊天角色动态id列表,返回是否成功
#        if not resut:
#            return {'result':False,"message":Lg().g(641)}
    result = doGmCommand(characterId, content)
    #    if not result:
    pushChatMessage(topic, characterId, chaterName, profession,
                    dbshieldword.replaceIllegalChar(content), linkData,
                    targetList)
    return {'result': True}
Exemple #3
0
 def getProfessionName(self):
     '''获取聊天职业名称'''
     return {
         0: u'新手',
         1: Lg().g(390),
         2: Lg().g(391),
         3: Lg().g(392),
         4: Lg().g(393)
     }.get(self.profession)
Exemple #4
0
 def checkCanMosaic(self, gemId, position):
     '''检测是否能镶嵌
     '''
     if getattr(self, 'slot_%d' % position):
         return {'result': False, 'message': Lg().g(354)}  #镶嵌位已经镶嵌了宝石
     gemtype = dbItems.ALL_GEMINFO[gemId]['type']
     for pp in range(1, 5):  #检测是否有相同类型的宝石
         gemtemplate = getattr(self, 'slot_%d' % pp)
         if not gemtemplate:
             continue
         thistype = dbItems.ALL_GEMINFO[gemtemplate]['type']
         if thistype == gemtype:
             return {'result': False, 'message': Lg().g(355)}
     return {'result': True}
Exemple #5
0
def sendMessage(dynamicId,
                characterId,
                topic,
                content,
                linkData,
                tonickname=None):
    '''发送聊天信息
	@param dynamicId:int 客户端的id
	@param characterId:int 角色的id
	@param topic :int 频道的编号
	@param content:string 发送的消息内容
	@param linkData: dict list 连接信息内容
	'''

    chater = ChaterManager().getChaterByCharacterId(characterId)
    if not chater:
        return {'result': False, 'message': Lg().g(639)}
    if topic == 7:
        toplayer = ChaterManager().getChaterByCharacterId(characterId)
        if not toplayer:
            return {'result': False, "message": Lg().g(640)}
        else:
            topic = toplayer.baseInfo.id

    targetList = []
    chaterName = chater.getCharacterName()

    if topic == 1:  #世界聊天
        idlist = ChaterManager().getAlldynamicId()
        targetList = idlist
    elif topic == 2:  #当前场景
        roomId = chater.getRoomId()
        targetList = ChatRoomManager().getRoomMember(roomId)
    elif topic == 3:  #公会
        gid = chater.guildid
        if gid < 1:
            return {'result': False, "message": Lg().g(641)}
        else:
            plist = GuildManager().getdtidListBygid(gid)
            if plist:
                targetList = list(plist)

    result = doGmCommand(characterId, content)

    pushChatMessage(topic, characterId, chaterName,
                    dbShieldWord.replaceIllegalChar(content), linkData,
                    targetList)
    return {'result': True}
def pushChatToObjectList(id,tid):
    '''推送私聊角色列表'''
    from app.chatServer.core.ChaterManager import ChaterManager
    from app.chatServer.core.ChaterLogManager import ChaterLogManager
    response=ChatToObjectListInfo1010_pb2.ChatToObjectListResponse()
    clog=ChaterLogManager().addChatLog(id) #获取聊天类
    listid=clog.getFriends()#获取角色私聊对象id列表
    if len(listid)<0:
        return
    player=ChaterManager().getChaterByCharacterId(id)
#    player=PlayersManager().getPlayerByID(id)
    if not player:
        #print "推送私聊角色列表时没有角色"+str(id)
        return 
    #print "角色私聊角色列表发送给"+player.baseInfo.getNickName()
    playerid=player.getDynamicId()
    for cid in listid:
        player1=ChaterManager().getChaterByCharacterId(cid)
        info=response.chatObjectInfo.add()
        info.chatObjectId=cid
        info.name=player1.getCharacterName()
        #print "私聊信息角色列表:"+player1.baseInfo.getNickName()
        info.level=str(player1.level)
        info.perfession=player1.getProfessionName()
        if player1.island:
                info.chatObjectPos=player1.scenename
        else:
            info.chatObjectPos=Lg().g(106)
        info.readFlag=ChaterLogManager().getFriendReaderState(id, cid)
    #print "------------------------------------------------------------------"
    msg = response.SerializeToString()
    pushApplyMessage(1010,msg,[playerid])
Exemple #7
0
    def __init__(self,
                 characterId,
                 dynamicId=-1,
                 charactername=u'',
                 level=0,
                 donttalk=0):
        '''聊天成员类初始化
		@param characterId: int 角色的id
		@param charactername: str 角色的名称
		@param dynamicId:int 聊天客户端的ID
		@param roomId:int 房间号ID
		'''
        self.charactername = charactername  #角色名称
        self.level = level  #角色等级
        self.guildid = 0  #公会id
        self.dynamicId = dynamicId  #角色动态id
        self.island = True  #是否在线 False表示离线 True表示在线
        self.characterId = characterId  #角色id

        self.scenename = Lg().g(106)  #所在场景名称
        self.roomId = 0  #房间号码
        self.donttalk = donttalk  #0不禁言 1禁言
        gid = 0  #dbGuild.getGuildidBypid(characterId)#通过角色id获取所属公会
        if gid:
            self.guildid = gid
        if len(charactername) < 1:
            info.dbCharacter.getInfoByid(characterId)  #通过角色id获取角色信息
            if not info:
                print characterId
            self.charactername = info.get('nickname', charactername)  #角色名称
            self.level = info.get('level', level)  #角色等级
            self.donttalk = info.get('donttalk', 0)  #0不禁言 1禁言
Exemple #8
0
def senGuildCement(msg, targetList=[]):
    '''发送错误提示'''

    for k in ChaterManager()._chaters:
        targetId = ChaterManager()._chaters[k].dynamicId
        targetList.append(targetId)
    pushChatMessage(7, -1, Lg().g(128), 0, msg, [], targetList)
Exemple #9
0
def SendChatMessageRequest_1013(dynamicId,request_proto):
	'''当前角色发送私聊信息'''
	import time
	from app.chatServer.core.ChaterManager import ChaterManager
	argument=SendChatMessage1013_pb2.SendChatMessageRequest()
	argument.ParseFromString(request_proto)
	response=SendChatMessage1013_pb2.SendChatMessageResponse()
	id=argument.id
	tid=argument.chatId
	context=argument.chatMessage

	chater=ChaterManager().getChaterByCharacterId(id)
	if chater.donttalk==0:#不禁言
		timet=ste(time.strftime('%Y-%m-%d %X'))
		title="<font color='#ffffff'>"
		title+=chater.getrCharacterName()
		title+=":</font><br/>"
		title+=u"<font color='#ffffff'>&nbsp;&nbsp;%s</font><br/>"%context
		ChaterLogManager().addLog(id,tid,title,timet)
		response.result=True
		response.message=u''
	else:#禁言
		response.result=True
		response.message=Lg().g(644)
	return response.SerializeToString()
Exemple #10
0
def sendAnnouncement(msg):
    '''发送系统公告'''
    targetList = []
    for k in ChaterManager()._chaters:
        targetId = ChaterManager()._chaters[k].dynamicId
        targetList.append(targetId)
    pushChatMessage(7, -1, Lg().g(128), 0, msg, [], targetList)
Exemple #11
0
def pushSystemchat(strInfo):
    '''推送聊天框系统消息
	@param strInfo: str 系统消息内容
	'''
    sendList = [
        chater.getDynamicId() for chater in ChaterManager()._chaters.values()
    ]
    pushChatMessage(5, -1, Lg().g(128), 0, strInfo, [], sendList)
Exemple #12
0
def loginToChatServer(dynamicId, characterId, roomId):
    '''登录聊天服务器
	@param dynamicId:int 客户端的id
	@param characterId:int int角色的id
	'''
    chater = ChaterManager().addChaterByid(characterId)
    if chater:
        ChaterManager().updateOnland(characterId, dynamicId)
        chater.setRoomId(roomId)
        ChatRoomManager().joinRoom(dynamicId, roomId)
    gid = chater.guildid  #公会id 没有公会默认0
    dtid = chater.dynamicId
    GuildManager().add(dtid, gid)
    targetList = []
    targetList.append(dynamicId)
    content = Lg().g(638)
    pushChatMessage(5, -1, Lg().g(128), content, [], targetList)
    return {'result': True, 'message': Lg().g(25)}
Exemple #13
0
def setLinkData(linkData=[]):
    '''设置一个空的角色链接数据
	@param linkData:[] 连接数据 默认值为[]
	'''
    it = {}
    it['id'] = 0
    it['name'] = Lg().g(128)
    it['chatEquipType'] = 1  #0代表物品 1代表角色
    it['itemQuality'] = 0
    linkData.append(it)
Exemple #14
0
def sendSysInfomation(msg, dynamicId, linkData=[]):
    '''发送系统提示消息
	@param msg: 发送的聊天信息
	@param linkData: 物品的有提示信息
	@param dynamicId:角色动态id
	'''
    targetList = []
    dynamicId = ChaterManager().getChaterDynamicId
    if dynamicId:
        targetList.append(dynamicId)
    pushChatMessage(5, -1, Lg().g(128), -1, msg, linkData, targetList)
Exemple #15
0
    def updateFJ(self):
        '''更新物品附加信息(适用于强化物品)'''
        qh = self.attribute.getStrengthen()

        pz = self.baseInfo.getItemTemplateInfo().get("baseQuality", 0)  #获取品质
        #        qh=StrengthenManager().getGainInfo(self.attribute.strengthen,pz) #获取强化信息
        itemProfession = self.baseInfo.getItemProfession(
        )  #职业类型限制 1战士 2 法师 3 游侠 4 牧师
        #        if not qh:
        #            return False
        #        if self.attribute.strengthen>=0:
        #            pass
        #            #print " "
        iteminfo = self.baseInfo.getItemTemplateInfo()  #物品模板id信息
        typeid = iteminfo.get('bodyType', 0)
        array = configure.getAttributeByZyAndWqTypeid(itemProfession, typeid,
                                                      qh)
        if array[0] == Lg().g(36):
            self.attribute.extMagicAttack = array[1]  #附加魔法攻击
        elif array[0] == Lg().g(34):
            self.attribute.extPhysicalAttack = array[1]  #附加物理攻击
        elif array[0] == Lg().g(35):
            self.attribute.extPhysicalDefense = array[1]  #附加物理防御
        elif array[0] == Lg().g(37):
            self.attribute.extMagicDefense = array[1]  #附加魔法防御
        elif array[0] == Lg().g(55):
            self.attribute.extSpeedAdditional = array[1]  #附加攻速
        elif array[0] == Lg().g(32):
            self.attribute.extHpAdditional = array[1]  #附加最大血量
    def addLog(self, id, tid, context, time):
        '''添加聊天记录
        @param id: int  当前角色id
        @param tid: int 接受聊天信息对象id
        @param contxt: int 聊天内容
        '''
        from app.chatServer.core.ChaterManager import ChaterManager
        chater = ChaterManager().getChaterByCharacterId(tid)  #聊天接收者
        dyid = ChaterManager().getChaterByCharacterId(id).dynamicId

        ftypeid = chater.isf(id)  #1好友  2黑名单  0没有关系
        if ftypeid == 2:
            pushObjectNetInterface.pushOtherMessage(905, Lg().g(643), [dyid])
            return

        clog = self.addChatLog(id)  #获取或添加私聊类
        clog.addFriends(tid)  #当前角色添加私聊好友
        clog.addChat(tid, context, time)  #添加聊天记录

        clog1 = self.addChatLog(tid)  #获取或添加私聊类(聊天接受者聊天类)
        clog1.addReaderList(id)  #设置聊天接受者有未读信息
        clog1.addFriends(id)  #聊天接受者角色添加私聊好友
        cter = ChaterManager().getChaterByCharacterId(tid)  #聊天接收者

        sid = clog.getReading()  #获取正在聊天角色id
        if sid == tid:  #当前角色正在跟聊天接受者私聊中(并且私聊面板开启中)
            ct = self.getLogonly(id, tid)
            pushObjectNetInterface.pushChatToObjectList(id,
                                                        tid)  #推送给聊天发送者,聊天成员列表
            if cter.island:  #如果聊天接收者在线
                pushObjectNetInterface.pushChatToObjectList(
                    tid, id)  #推送给聊天发接收者,聊天成员列表
            pushObjectNetInterface.pushServerSendChatInfo(id, ct, tid)  #推送聊天信息
            if clog1.getReading() == id:  #如果对方也正在跟我聊天
                pushObjectNetInterface.pushServerSendChatInfo(tid, ct,
                                                              id)  #推送聊天信息
                clog1.delReaderList(id)
#            else:
#                pushObjectNetInterface.pushChatToObjectList(tid, id) #推送给聊天接受者,聊天成员列表
        else:  # 当前角色正在跟其他角色饲料中(或者私聊面板关闭)
            pushObjectNetInterface.pushChatToObjectList(id,
                                                        tid)  #推送给聊天发送者,聊天成员列表
            if not cter.island:  #如果对方已经下线
                return
            pushObjectNetInterface.pushChatToObjectList(tid,
                                                        id)  #推送给聊天接受者,聊天成员列表
#            pushObjectNetInterface.pushServerSendChatInfo(id, context)

        clog.setReading(tid)  #设置当前角色正在和tid聊天
Exemple #17
0
def sendSysInfomations_Item(msg, dynamicId, itemlist):
    """(根据物品实例列表)发送系统提示消息
    @param mag: 发送的聊天信息
    @param itemlist: 物品实例列表
    @param dynamicId: 角色动态id
    """
    targetList = []
    dynamicId = ChaterManager().getChaterDynamicId
    if dynamicId:
        targetList.append(dynamicId)
    if not itemlist:
        return
    linkData = []
    for item in itemlist:
        it = {}
        it['id'] = item.baseInfo.id
        it['name'] = item.baseInfo.getItemTemplateInfo().get('name', '')
        it['chatEquipType'] = 0
        it['itemInfo'] = item
        msg += u"[%" + it['name'] + u"%]  "
        linkData.append(it)
    pushChatMessage(5, -1,
                    Lg().g(128), -1,
                    Lg().g(642) + msg, linkData, targetList)
Exemple #18
0
 def getMosaicInfo(self):
     '''获取镶嵌的信息'''
     slotinfo = {}
     if self._owner.baseInfo.getItemBodyType() == -1:
         return slotinfo
     for position in range(1, 5):
         gemtemplate = getattr(self, 'slot_%d' % position)
         slotinfo['xqItemId%d' % position] = gemtemplate
         if gemtemplate:
             slotinfo[
                 'xqDes%d' %
                 position] = dbItems.ALL_GEMINFO[gemtemplate]['effectdesc']
         else:
             slotinfo['xqDes%d' % position] = Lg().g(353)
     return slotinfo
Exemple #19
0
def getPlayerFriend(characterId, friendType, ziduan, guize):
    '''根据好友类型获取角色的所有好友
    @param characterId: int 角色的id
    @param friendType: 好友类型(1,2,3)1:好友  2:黑名单  3:全部   4:仇敌
    @param ziduan: int  1按角色名称,0角色等级,2行会名称  3最近登录时间
    @param guize: int 排序规则 1正序   0倒序
    '''
    filedList = [
        'id', 'nickname', 'profession', 'level', 'name', 'LastonlineTime',
        'clue', 'spirit'
    ]
    orders = ""  #排序
    dt = []  #存放data

    if ziduan == 1:
        orders = " order by c.nickname "
    elif ziduan == 0:
        orders = " order by c.level "
    elif ziduan == 2:
        orders = " order by g.name "
    elif ziduan == 3:
        orders = " order by c.LastonlineTime"
    if guize == 0:
        orders += " desc "

    sql = "SELECT c.id, c.nickname,c.profession,c.level,g.name,c.LastonlineTime,f.clue,c.spirit FROM tb_friend AS f ,tb_character AS c  LEFT JOIN tb_guild_character AS cg   ON c.id=cg.characterId LEFT JOIN tb_guild AS g ON cg.guildId=g.id WHERE f.playerId=c.id and f.characterId = " + str(
        characterId) + " and f.friendType = " + str(
            friendType) + " " + orders + ""

    cursor = dbaccess.dbpool.cursor()
    cursor.execute(sql)
    result1 = cursor.fetchall()  #当前页的信息
    for item in result1:
        data = {}  #存放一条数据
        for i in range(len(filedList)):
            if filedList[i] == 'name':
                if not item[i]:
                    data[filedList[i]] = Lg().g(143)
                    continue
            data[filedList[i]] = item[i]
        dt.append(data)

    if not dt:
        return None

    return dt
Exemple #20
0
def selectFriend(name, ziduan, guize):
    '''查找好友(模糊查找)
    @param name: string 好友的角色的昵称(名字)
    @param ziduan: int  1按角色名称,0角色等级,2行会名称  3最近登录时间
    @param guize: int 排序规则 1正序   0倒序
    '''

    filedList = [
        'id', 'nickname', 'profession', 'level', 'name', 'LastonlineTime'
    ]
    orders = ""  #排序
    dt = []  #存放data

    if ziduan == 1:
        orders = " order by c.nickname "
    elif ziduan == 0:
        orders = " order by c.level "
    elif ziduan == 2:
        orders = " order by g.name "
    elif ziduan == 3:
        orders = " order by c.LastonlineTime"
    if guize == 0:
        orders += " desc "

    sql = "SELECT c.id, c.nickname,c.profession,c.level,g.name,c.LastonlineTime FROM tb_character AS c LEFT JOIN tb_guild_character AS cg ON c.id=cg.characterId LEFT JOIN tb_guild AS g ON cg.guildId=g.id WHERE c.nickname LIKE'%" + name + "%' " + orders + ""

    cursor = dbaccess.dbpool.cursor()
    cursor.execute(sql)
    result1 = cursor.fetchall()  #当前页的信息
    for item in result1:
        data = {}  #存放一条数据
        for i in range(len(filedList)):
            if filedList[i] == 'name':
                if not item[i]:
                    data[filedList[i]] = Lg().g(143)
                    continue
            data[filedList[i]] = item[i]
        dt.append(data)
    cursor.close()

    if not dt:
        return None

    return dt
Exemple #21
0
def creatNewCharacter(nickname ,profession ,userId ,fieldname):
    '''创建新的角色
    @param nickname: str 角色的昵称
    @param profession: int 角色的职业编号
    @param userId: int 用户的id
    @param fieldname: str 用户角色关系表中的字段名,表示用户的第几个角色
    '''
    sql = "insert into `tb_character`(nickName,profession,userId) values('%s',%d,%d)"%(nickname ,profession,userId )
    cursor = dbaccess.dbpool.cursor()
    count = cursor.execute(sql)
    dbaccess.dbpool.commit()
    cursor.close()
    if count >= 1:
        characterId = getCharacterIdByName(nickname)
        updateUserCharacter(userId,fieldname,characterId)
        addMail(TITLE, -1, Lg().g(128), characterId, NEWCHARACTERMAIL, 0)
        return characterId
    else:
        return 0
Exemple #22
0
def aaa(msg=u""):
    '''推送世界消息'''
    #    list=[]
    #    list.append(PlayerCharacter(1000050))
    linkData = []
    setlinkData(linkData)
    #    for item in list:
    #        it={}
    #        it['id']=item.baseInfo.id
    #        it['name']=item.baseInfo.getName()
    #        it['chatEquipType']=1 #0代表物品  1代表角色
    #        msg+=u"[%"+it['name']+"%]"
    #        linkData.append(it)

    targetList = []
    setAllChatPlayerDynamicId(targetList)  #设置targetList为所有在线聊天角色的动态id
    #print msg+"aaa()"
    #    pushChatMessage(1, -1, Lg().g(128), -1, msg,[], targetList)
    pushChatMessage(5, -1, Lg().g(128), -1, msg, [], targetList)
Exemple #23
0
def sendMessage_1003(_conn, request_proto):
    '''发送聊天消息'''
    from app.chatServer.core.ChaterManager import ChaterManager
#    from core.Item import Item
    argument = sendMessage1003_pb2.chatConectingRequest()
    argument.ParseFromString(request_proto)
    response = sendMessage1003_pb2.chatConectingResponse()
    
    dynamicId = _conn.transport.sessionno
    characterId = argument.id #当前角色id
    topic = argument.topic #频道号  
    tonickname=argument.chatOjbect #角色昵称
    content = argument.content #内容
    
    chater=ChaterManager().getChaterByCharacterId(characterId)
    if chater.donttalk==0:#不禁言
        linkData = [] #聊天连接信息
        for _item in argument.linkData:
            item = {}
            item['chatEquipType'] = _item.chatEquipType #0物品 1角色 2怪物
            item['id'] = _item.id
            item['name'] = _item.name
            
            if _item.chatEquipType==0:
                item1=Item(id=_item.id)
                item['itemInfo']=item1
#            elif _item.chatEquipType==1:
#                linkData.append(item)
#                continue
            
            linkData.append(item)
        Lt().add(characterId, tonickname, content)
        data = chat.sendMessage(dynamicId, characterId, topic, content,linkData,tonickname)
        response.result = data.get('result',False)
        response.message = data.get('message',u'')
    else:#禁言
        response.result = False
        response.message =Lg().g(644) 
    return response.SerializeToString()
Exemple #24
0
    def __init__(self,
                 characterId,
                 dynamicId=-1,
                 charactername=u'',
                 profession=1,
                 level=0,
                 donttalk=0):
        '''聊天成员类初始化
        @param characterId: int 角色的id
        @param charactername: str 角色的名称
        @param dynamicId: int 聊天客户端的ID
        @param roomId: int 房间号ID
        '''
        self.charactername = charactername  #角色名称
        self.level = level  #角色等级
        self.guildid = 0  #国id
        self.profession = profession  #职业编号
        self.dynamicId = dynamicId  #角色动态id
        self.island = True  #是否在线  False表示离线,True表示在线
        self.characterId = characterId  #角色id

        self.blacklist = set(dbFriend.getAllbyTypeid(characterId, 2))  #角色的黑名单
        self.whitelist = set(dbFriend.getAllbyTypeid(characterId,
                                                     1))  #角色的白名单(好友)
        self.scenename = Lg().g(106)  #所在场景名称
        self.roomId = 0  #房间号码
        self.donttalk = donttalk  # 0不禁言 1禁
        gid = dbGuild.getGuildidBypid(characterId)  #通过角色id获取所属国
        if gid:
            self.guildid = gid
        if len(charactername) < 1:
            info = dbCharacter.getInfoByid(characterId)  #通过角色id获取角色信息
            if not info:
                print characterId
            self.charactername = info.get('nickname', charactername)  #角色名称
            self.level = info.get('level', level)  #角色等级
            self.donttalk = info.get('donttalk', 0)  # 0不禁言 1禁
            self.profession = info.get('profession', profession)  #职业编号
Exemple #25
0
	def getLog(self,id,tid):
		'''获取聊天记录
		@param id: int 当前角色id
		@param tid:int 私聊对象id
		'''
		from app.chatServer.core.ChaterManager import ChaterManager
		clog=self.addChatLog(id)#获取或添加私聊类
		result=clog.getChatLog(id)#获取私聊信息
		clog.delReaderList(tid)#在未读信息列表中删除此角色id相应数据
		clog.addFriends(tid)#添加私聊最近联系人
		clog.setReading(tid)#设置当前跟谁聊天

		data={}
		gamers=ChaterManager().getChaterByCharacterId(tid)
		data['name']=gamers.charactername
		data['level']=str(gamers.level)

		if not gamers.island:#如果角色不在线
			data['chatObjectPos']=Lg().g(106)
		else:
			data['chatObjectPos']=gamers.scenename
		data['result']=result
		return data
Exemple #26
0
#coding:utf8
'''
Created on 2012-3-16
配置文件 配置各种变量
@author: jt
'''
from twisted.python import log
from app.chatServer.core.language.Language import Lg

formatNobility = {
    'Str': Lg().g(27),
    'Dex': Lg().g(28),
    'Vit': Lg().g(29),
    'Wis': Lg().g(30),
    'Spi': Lg().g(31),
    'MaxHp': Lg().g(32),
    'MaxMp': Lg().g(33),
    'PhyAtt': Lg().g(34),
    'PhyDef': Lg().g(35),
    'MigAtt': Lg().g(36),
    'MigDef': Lg().g(37),
    'HitRate': Lg().g(38),
    'CriRate': Lg().g(39),
    'Squelch': Lg().g(40),
    'ExpEff': Lg().g(41),
    'power': Lg().g(42),
    'StrPercen': Lg().g(43),
    'DexPercen': Lg().g(44),
    'VitPercen': Lg().g(45),
    'WisPercen': Lg().g(46),
    'SpiPercen': Lg().g(47),
Exemple #27
0
 def getName(self):
     '''获取物品名称'''
     return self.getItemTemplateInfo().get("name", Lg().g(278))
Exemple #28
0
def getAttributeByZyAndWqTypeid(zyid, wqtype, qh):
    '''根据角色职业类型和装备类型获取增加的属性
    @param zyid: int 职业限制      #1战士 2 法师 3 游侠 4 牧师
    @param wqtype: int 武器类型       #0=衣服#1=裤子 #2=头盔#3=手套#4=靴子#5=护肩#6=项链#7=戒指#8=主武器#9=副武器#10=双手
    @param qh: int 物品当前强化等级

    '''
    wg = qh * 45  #物理攻击
    mg = qh * 48  #魔法攻击
    wf = qh * 12  #物理防御
    mf = qh * 15  #魔法防御
    sm = qh * 120  #魔法防御
    sd = qh * 6  #攻速
    if wqtype == 9:  #副手
        if zyid == 0:
            return [[Lg().g(36), mg], [Lg().g(34), wg]]
        elif zyid % 2 == 0:  #如果是魔法类装备
            return [[Lg().g(36), mg]]
        else:
            return [[Lg().g(34), wg]]
    elif wqtype == 8:  #主手
        if zyid == 0:
            return [[Lg().g(36), mg], [Lg().g(34), wg]]
        elif zyid % 2 == 0:
            return [[Lg().g(36), mg]]
        else:
            return [[Lg().g(34), wg]]
    elif wqtype == 7:  #戒指
        if zyid == 0:
            return [[Lg().g(36), mg], [Lg().g(34), wg]]
        elif zyid % 2 == 0:
            return [[Lg().g(36), mg]]
        else:
            return [[Lg().g(34), wg]]
    elif wqtype == 6:  #项链
        if zyid == 0:
            return [[Lg().g(37), mf], [Lg().g(35), wf]]
        if zyid % 2 == 0:
            return [[Lg().g(37), mf]]
        else:
            return [[Lg().g(35), wf]]
    elif wqtype == 4:  #鞋子
        return [[Lg().g(55), sd]]
    elif wqtype == 1:  #裤子
        return [[Lg().g(32), sm]]
    elif wqtype == 3:  #护手
        return [[Lg().g(55), sd]]
    elif wqtype == 0:  #衣服
        return [Lg().g(35), wf]
    elif wqtype == 5:  #护肩
        return [[Lg().g(32), sm]]
    elif wqtype == 2:  #头盔
        return [[Lg().g(37), mf]]
    return [['空', 0]]