Example #1
0
def startclose(groupid, itemid, pid, tagid):
    '''状态消失'''
    instanceinfo = ColonizeManage().getInstanceInfoByid(groupid)
    info = instanceinfo['property'][itemid]
    info[0] = False
    info[3] = False
    istruelgyc(pid, tagid)
Example #2
0
def updatecity():
    '''更新殖民城镇奖励'''
    citylist = dbPublicscene.Allinfo  #获取所有城镇的信息
    for info in ColonizeManage().getC().values():  #cityinfo #城市殖民信息
        if info['pid'] > 0:
            dl = citylist.get(info['cityid'], 0)
            cityname = dl['name']
            reward = dl['levelRequired'] * 20
            dbDefenceBonus.addCityLog(cityname, 1, reward, info['cityid'], 1)
Example #3
0
def changeimg(tagid, groupid, itemid, pid):
    '''状态还有30分钟的时候
    @param tagid: int 角色动态id
    '''
    instanceinfo = ColonizeManage().getInstanceInfoByid(groupid)
    info = instanceinfo['property'][itemid]
    info[3] = True  #表示小于30分钟
    icon_app.add(pid, 3)  #发送流光溢彩殖民管理图标
    reactor.callLater(configure.instanceStatusPrompt, startclose, groupid,
                      itemid, pid, tagid)  #半小时之后设置状态关闭
Example #4
0
def ClearanceOperate(did, pid, flg):
    '''给殖民地领主添加其副本的通关次数
    @param did: int  副本id
    @param pid: int 当前角色id
    @param flg: bool 副本是否胜利(通关)
    '''
    if not flg:
        return
    instanceid = InstanceGroupManage().getFristInstanceBy(did)  #副本组id
    if dbInstanceColonize.updateClearanceCount(instanceid):  #在保卫表中增加通关次数
        ColonizeManage().defupdateInstanceClearancecount(instanceid)
Example #5
0
def getypjc(groupid):
    '''根据副本组id获取状态信息 1力量、2敏捷 、3智力、4精神、5耐力、6所有'''
    instanceinfo = ColonizeManage().getInstanceInfoByid(groupid)
    val = {}
    for k in instanceinfo['property'].keys():
        val[k] = {}
        if instanceinfo['property'][k][0]:  #如果状态开启
            val[k]['status'] = 1  #激活
            val[k]['remainTime'] = outtime(instanceinfo['property'][k][1])
        else:
            val[k]['status'] = 0  #没激活
            val[k]['remainTime'] = 0
    return val
Example #6
0
def addInstanceColonizelog(cid, instanceid, iname):
    '''添加副本殖民成功记录'''
    player = PlayersManager().getPlayerByID(cid)  #获得当前角色
    gid = 0
    gname = Lg().g(143)
    if not player:
        log.err(Lg().g(106))
    if player.guild.getID() > 0:
        gid = player.guild.getID()
        gname = player.guild.getGuildName()
    ColonizeManage().updateInstancePid(instanceid, cid,
                                       player.baseInfo.getName(), gid, gname,
                                       iname)
    return True
Example #7
0
def updateBonus():
    '''更新殖民副本奖励'''
    for info in ColonizeManage().getI().values():  #info 殖民信息
        if info['pid'] > 0:
            count = 0  #入侵次数
            reward = 0  #副本组中规定的这个副本单次通关奖励数量
            info['wm'] = 0
            instanceid = InstanceGroupManage().getInstanceidByGroupid(
                info['id'])  #副本id
            instanceinfo = instance_app.allInfo.get(instanceid, 0)
            dl = instanceinfo['downlevle']
            rewardAll = dl * 20  #获得的威望值
            ismax = 0  #0没有达到最高值  1达到最高值
            if rewardAll > 0:  #如果奖励的技能石>0 则添加奖励
                dbDefenceBonus.addLog(info['name'], 0, reward, count, 0,
                                      info['pid'], ismax, rewardAll,
                                      info['id'])
Example #8
0
def InstanceMapInfos(dynamicId, characterId):
    '''获取副本组信息
    @param dynamicId: int 客户端的id
    @param characterId: int 角色的id
    '''
    player = PlayersManager().getPlayerByID(characterId)
    if not player:
        return {'result': False, 'message': Lg().g(18)}
    guildId = player.guild.getID()
    if not guildId:
        self_color = int(DEFAULTCOLOR, 16)
    else:
        guild = GuildManager().getGuildById(guildId)
        self_color = guild.guildinfo.get('color', int(DEFAULTCOLOR, 16))
    cityid = player.baseInfo.getTown()
    infos = ColonizeManage().getInstanceListByCityid(cityid)
    return {'result': True, 'self_color': self_color, 'infos': infos}
Example #9
0
def updateColonize(instanceid, instancename, pid, cid, pname):
    '''更改副本保卫者
    @param instanceid: int 副本组id
    @param pid: int 挑战者id
    @param cid: int 领主id
    '''

    player = PlayersManager().getPlayerByID(pid)  #获得挑战者角色
    gid = 0
    gname = Lg().g(143)
    if not player:
        log.err(Lg().g(106))
    if player.guild.getID() > 0:
        gid = player.guild.getID()
        gname = player.guild.getGuildName()
    ColonizeManage().updateInstancePid(instanceid, pid,
                                       player.baseInfo.getName(), gid, gname,
                                       instancename)  #内存中更改信息
Example #10
0
def istruelgyc(pid, tagid):
    '''根据角色id,判断是否推送流光溢彩
    @param pid: int 角色动态id
    return 0:表示殖民管理没有流光溢彩 1表示有流光溢彩
    '''
    data = dbInstanceColonize.getAllinstanceListBypid(pid)
    flg = False
    for item in data:
        groupid = item['instanceid']
        instanceinfo = ColonizeManage().getInstanceInfoByid(groupid)
        for k in instanceinfo['property'].keys():
            if instanceinfo['property'][k][0]:  #如果状态开启
                if instanceinfo['property'][k][3]:  #如果剩余时间小于半小时
                    flg = True
    if flg:
        icon_app.add(pid, 3)
    else:
        icon_app.add(pid, 2)
Example #11
0
def Preperty(groupid, itemid, tagid, pid):
    instanceinfo = ColonizeManage().getInstanceInfoByid(groupid)
    if instanceinfo['property'][itemid][0]:  #如果时间还有没到
        instanceinfo['property'][itemid][1] = gettime()
        instanceinfo['property'][itemid][2].cancel()  #取消定时器
        instanceinfo['property'][itemid][3] = False  #设置状态>30分钟
        dsq = reactor.callLater(configure.instanceStatus -
                                configure.instanceStatusPrompt, changeimg,
                                tagid, groupid, itemid, pid)  #开始一个新的定时器
        instanceinfo['property'][itemid][2] = dsq
    else:  #如果时间到了
        instanceinfo['property'][itemid] = [True, gettime(), None, False]
        dsq = reactor.callLater(configure.instanceStatus -
                                configure.instanceStatusPrompt, changeimg,
                                tagid, groupid, itemid, pid)  #30分钟的时候推送流光溢彩
        instanceinfo['property'][itemid][2] = dsq


#    publicnoderemote.callRemote('updateColonizeManage',ColonizeManage().citys,ColonizeManage().instancetocity,ColonizeManage().Portals,ColonizeManage().instancetoprotal)
    istruelgyc(pid, tagid)
Example #12
0
    def formatSceneInfo(self):
        '''格式化场景信息'''
        sceneInfo = {}
        sceneInfo['id'] = self._id  #场景的ID
        sceneInfo['resourceId'] = self._resourceid  #场景的资源类型
        sceneInfo['sceneType'] = self._type  #场景的类型
        sceneInfo['scenename'] = self._name  #场景的名称
        sceneInfo['npclist'] = [dbNpc.ALL_NPCS.get(npcID) for\
                                 npcID in self._npclist] #场景的npc信息
        sceneInfo['portals'] = [dbPortals.ALL_PORTALS.get(portalId) for\
                                 portalId in self._portals] #场景中传送门的信息
        if self._type == 1:  #公共场景时
            colonizeInfo = ColonizeManage().getCityByCityid(self._id)
            if colonizeInfo:
                sceneInfo['corpsName'] = colonizeInfo.get('gname')
                sceneInfo['rewardCorpsName'] = colonizeInfo.get('pname')
        elif self._type == 2:  #副本场景时
            colonizeInfo = ColonizeManage().getInstanceInfoByid(self._group)
            if colonizeInfo:
                sceneInfo['corpsName'] = colonizeInfo.get('gname')
                sceneInfo['rewardCorpsName'] = colonizeInfo.get('pname')

        return sceneInfo
Example #13
0
    def leaveGuild(self, operator):
        '''离开行会'''
        from app.scense.core.instance.ColonizeManage import ColonizeManage
        if self.getPresident() == operator:
            newPresident = self.findNewPresident()
            if not newPresident:
                return {'result': False, 'message': Lg().g(550)}
            else:
                dbGuild.updateCharacterGuildInfo(newPresident, {'post': 4})
                self.president = newPresident
#        if operator in eval("["+self.guildinfo['veterans']+"]"):
#            newstaffOfficers = str(eval("["+self.guildinfo['veterans']+"]").remove(operator))[1:-1]
#            self.update('veterans', newstaffOfficers)
#        if operator in eval("["+self.guildinfo['staffOfficers']+"]"):
#            newveterans = str(eval("["+self.guildinfo['staffOfficers']+"]").remove(operator))[1:-1]
#            self.update('staffOfficers', newveterans)
#        if operator in eval("["+self.guildinfo['senators']+"]"):
#            newsenators = str(eval("["+self.guildinfo['senators']+"]").remove(operator))[1:-1]
#            self.update('senators', newsenators)
        result = dbGuild.deleteCharacterGuildRelation(operator)
        if result:
            postdict = dbGuild.updateGuildPost(self.id)
            self.veterans = postdict.veterans
            self.staffOfficers = postdict.staffOfficers
            self.senators = postdict.senators
            player = PlayersManager().getPlayerByID(operator)
            player.updatePlayerInfo()
            playerList = dbGuild.getGuildCharacterIdList(self.id)
            msg = Lg().g(551) % player.baseInfo.getName()
            sendList = [PlayersManager().getPlayerByID(p[0]).getDynamicId()\
                         for p in playerList \
                        if PlayersManager().getPlayerByID(p[0]) and \
                        PlayersManager().getPlayerByID(p[0]).getDynamicId()]
            pushPromptedMessage(msg, sendList)
            ColonizeManage().updateGuild(operator, 0, Lg().g(143))
            return {'result': True, 'message': Lg().g(552)}  #开除成功
        return {'result': False, 'message': Lg().g(553)}  #开除失败
Example #14
0
 def formatSceneInfo(self):
     '''格式化场景信息'''
     sceneInfo = {}
     sceneInfo['id'] = self._id  #场景的ID
     sceneInfo['resourceId'] = self._resourceid #场景的资源类型
     sceneInfo['sceneType'] = self._type #场景的类型
     sceneInfo['scenename'] = self._name  #场景的名称
     sceneInfo['npclist'] = [dbNpc.ALL_NPCS.get(npcID) for\
                              npcID in self._npclist] #场景的npc信息
     sceneInfo['portals'] = [dbPortals.ALL_PORTALS.get(portalId) for\
                              portalId in self._portals] #场景中传送门的信息
     if self._type ==1:#公共场景时
         colonizeInfo = ColonizeManage().getCityByCityid(self._id)
         if colonizeInfo:
             sceneInfo['corpsName'] = colonizeInfo.get('gname')
             sceneInfo['rewardCorpsName'] = colonizeInfo.get('pname')
     elif self._type ==2:#副本场景时
         colonizeInfo = ColonizeManage().getInstanceInfoByid(self._group)
         if colonizeInfo:
             sceneInfo['corpsName'] = colonizeInfo.get('gname')
             sceneInfo['rewardCorpsName'] = colonizeInfo.get('pname')
         
     return sceneInfo
Example #15
0
def getBattlePlayer(instanceid, cid):
    '''副本殖民战斗,返回对手实例'''
    from app.scense.core.instance.Instance import Instance
    from app.scense.core.map.MapManager import MapManager
    player = PlayersManager().getPlayerByID(cid)  #获取角色实例
    if player.baseInfo._state != 0:  #如果在普通场景
        return False, Lg().g(144), False


#    cityid=InstanceGroupManage().getcityidBygroupid(instanceid)
#    if player.baseInfo._town!=cityid:
#        pushObjectNetInterface.pushOtherMessage(905, u'只能殖民本场景的副本', [player.getDynamicId()])
#        return False,u'只能殖民本场景的副本',False

    if player.level._level <= 12:
        return False, Lg().g(145), False

    guildLevel = player.guild.getGuildLevel()  #当前角色行会等级
    if guildLevel < 1:  #没有国
        return False, Lg().g(146), False

    zmcount = int(math.ceil((guildLevel / 5.0)))  #可殖民副本数量
    yydata = 0  #该角色已殖民数量
    for info in ColonizeManage().getI().values():
        if info['pid'] == cid:
            yydata += 1
    if zmcount <= yydata:
        pushObjectNetInterface.pushOtherMessage(905,
                                                Lg().g(147),
                                                [player.getDynamicId()])
        return False, Lg().g(147), False

    player.schedule.noticeSchedule(17, goal=1)
    tlist = []
    sceneId = player.baseInfo.getTown()
    scene = MapManager().getMapId(sceneId)
    scene.dropPlayer(cid)
    allInfo = instance_app.allInfo
    info = allInfo.get(instanceid)
    downlevel = info.get('downlevle', 0)  #殖民等级
    if downlevel > player.level.getLevel():  #如果角色等级<副本等级要求
        return False, Lg().g(148), False

    instancegroupid = InstanceGroupManage().getFristInstanceBy(
        instanceid)  #根据副本id获取副本组id
    pid = ColonizeManage().getpidByinstanceid(
        instancegroupid)  #通过副本组id获得副本殖民者id
    mosterid = 15001
    if pid < 1:  #如果此副本没有被殖民
        try:
            mosterid = instanceColonizeChallenge.getColonizeChallengeByMosterid(
                instancegroupid)  #获取怪物id
            if mosterid < 0:
                log.err(u'殖民战斗当中副本组中没有配置对应的殖民挑战怪物,殖民副本组id为%d' %
                        instancegroupid)
        except Exception as e:
            log.err(u'殖民战斗当中副本组中没有配置对应的殖民挑战怪物,殖民副本组id为%d' % instancegroupid)
            log.err(e.message)

        tlist.append(Monster(templateId=mosterid))
    else:  #如果此副本被殖民了
        py = PlayersManager().getPlayerByID(pid)
        if not py:
            py = PlayerCharacter(pid)
        tlist.append(py)
    instance = Instance(instanceid)  #副本
    scene = instance.getScene(instance._inSceneid)  #第一个场景实例
    del instance
    zon = random.randint(500, scene._width - 500)
    return tlist, zon, scene.formatSceneInfo()  #场景资源id
Example #16
0
def iscoloBypid(pid):
    '''该角色是否有殖民地'''
    flg = ColonizeManage().ishavestrengthen(pid)
    return flg
Example #17
0
    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)}  #开除失败
Example #18
0
def outGuild(pid, pname, gname):
    from app.scense.core.instance.ColonizeManage import ColonizeManage
    for info in ColonizeManage().getI().values():
        if info['pid'] == pid:
            mmg = Lg().g(208) % (info['name'], pname, gname)
            addmessage(mmg, type=1, id=info['id'])
Example #19
0
def getPidByinstanceid(instanceid):
    '''根据副本id获取领主id'''
    instancegroupid = InstanceGroupManage().getFristInstanceBy(
        instanceid)  #根据副本id获取副本组id
    return ColonizeManage().getpidByinstanceid(instancegroupid)  #领主id
Example #20
0
 def isHaveStrengthen(self):
     '''判断角色是否有殖民地'''
     from app.scense.core.instance.ColonizeManage import ColonizeManage
     pid = self.baseInfo.id  #角色id
     flg = ColonizeManage().ishavestrengthen(pid)
     return flg