def addInstance(self,id,tag):
     '''根据副本 Id添加副本实例到副本管理器中
     @param id: int 副本的Id
     @param return: 返回副本管理器中的这个副本实例
     '''
     from app.scense.core.instance.Instance import Instance
     instance1=Instance(id)#创建一个副本对象
     if not instance1.templateInfo:            
         return None   #检索数据库中是否有此副本Id
     self._tag += 1
     instance1._tag= self._tag
     if self._instances.has_key(instance1._tag):
         raise Exception(u"系统记录冲突,此副本动态id已经存在")
     self._instances[instance1._tag]=instance1
     return self._instances[instance1._tag]
Esempio n. 2
0
 def addInstance(self, id, tag):
     '''根据副本 Id添加副本实例到副本管理器中
     @param id: int 副本的Id
     @param return: 返回副本管理器中的这个副本实例
     '''
     from app.scense.core.instance.Instance import Instance
     instance1 = Instance(id)  #创建一个副本对象
     if not instance1.templateInfo:
         return None  #检索数据库中是否有此副本Id
     self._tag += 1
     instance1._tag = self._tag
     if self._instances.has_key(instance1._tag):
         raise Exception(u"系统记录冲突,此副本动态id已经存在")
     self._instances[instance1._tag] = instance1
     return self._instances[instance1._tag]
Esempio n. 3
0
 def setAllId(self):
     '''将所有副本放入副本池中'''
     from app.scense.utils.dbopera import dbInstanceInfo
     from app.scense.core.instance.Instance import Instance
     list=dbInstanceInfo.getAllInstanceid()
     for item in list:
         self.list[item]=Instance(item)#实例化副本
Esempio n. 4
0
    def doRaids(self, rounds, raidsfamId):
        '''开始扫荡
        @param rounds: int 扫荡回合数
        @param raidsfamId: int 目标副本
        '''
        if raidsfamId not in self._owner.instance.clearances:
            return {'result': False, 'message': Lg().g(455)}
        from app.scense.core.instance.Instance import Instance
        if not rounds:
            rounds = self._owner.attribute.getEnergy() / 5
        energyrequired = rounds * 5
        if energyrequired > self._owner.attribute.getEnergy(
        ) or energyrequired == 0:
            msg = Lg().g(456)
            return {'result': False, 'message': msg}
#        if self._owner.baseInfo.getStatus()!=1:
#            msg = u"你正处于%s状态"%self._owner.baseInfo.getStatusName()
#            return {'result':False,'message':msg}
#        self._owner.baseInfo.setStatus(3)
        messagebox = []
        monsters = []
        instance = Instance(raidsfamId)
        for scene in instance._Scenes.values():
            for mon in scene._monsters.values():
                monsters.append(mon)
        challengers = BattleSide([self._owner])
        for index in range(rounds):
            self._owner.attribute.addEnergy(-5)  #消耗活力
            msg = Lg().g(457) % (index + 1)
            messagebox.append(msg)
            for monindex in range(len(monsters)):
                msg = self.doFightBound(challengers, monsters[monindex],
                                        monindex)
                #                self._owner.quest.killMonster(monsters[monindex].templateId)
                messagebox.append(msg)
            msg = self.doCardBound(instance)
            self._owner.quest.clearance(raidsfamId)
            self._owner.finance.updateAddMorale(2, state=True)
            messagebox.append(msg)
        self._owner.schedule.noticeSchedule(18)  #成功后的日程目标通知
        return {'result': True, 'message': u'', 'data': messagebox}
Esempio n. 5
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
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