Ejemplo n.º 1
0
 def checkPlayerCamp(self,playerId):
     '''检测角色的阵营是否属于本场景,不是发出警告
     '''
     player = PlayersManager().getPlayerByID(playerId)
     camp = player.guild.getID()
     mapCamp = self.getCamp()
     if camp!=0 and camp!=mapCamp and mapCamp!=0:#发出警告
         guildname = player.guild.getGuildName()
         nickname = player.baseInfo.getName()
         pushSystemInfo(u'%s国的【%s】进入%s境内'%(guildname,nickname,self._name))
Ejemplo n.º 2
0
 def checkPlayerCamp(self, playerId):
     '''检测角色的阵营是否属于本场景,不是发出警告
     '''
     player = PlayersManager().getPlayerByID(playerId)
     camp = player.guild.getID()
     mapCamp = self.getCamp()
     if camp != 0 and camp != mapCamp and mapCamp != 0:  #发出警告
         guildname = player.guild.getGuildName()
         nickname = player.baseInfo.getName()
         pushSystemInfo(u'%s国的【%s】进入%s境内' %
                        (guildname, nickname, self._name))
Ejemplo n.º 3
0
 def afterFight(self,monsterId,playerId,currentHp):
     '''场景中的战后处理
     @monsterId 怪物的ID
     @param playerId: int 攻击的角色的ID
     @currentHp: int 怪物的当前血量 
     '''
     if monsterId>10:
         return
     monster = self._monsters.get(monsterId)
     if not monster:
         if monsterId == 1:#主帅旗被砍掉
             from app.scense.core.guild.GuildManager import GuildManager
             from app.scense.core.campaign.FortressManager import FortressManager
             from app.scense.utils.dbopera import dbfortress
             player = PlayersManager().getPlayerByID(playerId)
             guildId = player.guild.getID()
             fortress = FortressManager().getFortressBySceneId(self._id)
             info = {}
             info['kimoriScore'] = 0
             info['siegeScore'] = 0
             info['siege'] = 0
             info['isOccupied'] = 1
             info['kimori'] = guildId
             info['siege'] = 0
             guild1 = GuildManager().getGuildById(guildId)
             if guild1:
                 guild1.addExp(3500)
                 msg = u"%s国成功征战%s,成为其国领地!"%(guild1.name,self._name)
                 pushSystemInfo(msg)
                 dbfortress.updateFortressInfo(fortress.id, {'kimori':info['kimori'],
                                             'isOccupied':1,'siege':0})
             return
         else:
             return
     monster.updateHp(currentHp)
     
     
     
Ejemplo n.º 4
0
 def afterFight(self, monsterId, playerId, currentHp):
     '''场景中的战后处理
     @monsterId 怪物的ID
     @param playerId: int 攻击的角色的ID
     @currentHp: int 怪物的当前血量 
     '''
     if monsterId > 10:
         return
     monster = self._monsters.get(monsterId)
     if not monster:
         if monsterId == 1:  #主帅旗被砍掉
             from app.scense.core.guild.GuildManager import GuildManager
             from app.scense.core.campaign.FortressManager import FortressManager
             from app.scense.utils.dbopera import dbfortress
             player = PlayersManager().getPlayerByID(playerId)
             guildId = player.guild.getID()
             fortress = FortressManager().getFortressBySceneId(self._id)
             info = {}
             info['kimoriScore'] = 0
             info['siegeScore'] = 0
             info['siege'] = 0
             info['isOccupied'] = 1
             info['kimori'] = guildId
             info['siege'] = 0
             guild1 = GuildManager().getGuildById(guildId)
             if guild1:
                 guild1.addExp(3500)
                 msg = u"%s国成功征战%s,成为其国领地!" % (guild1.name, self._name)
                 pushSystemInfo(msg)
                 dbfortress.updateFortressInfo(fortress.id, {
                     'kimori': info['kimori'],
                     'isOccupied': 1,
                     'siege': 0
                 })
             return
         else:
             return
     monster.updateHp(currentHp)
Ejemplo n.º 5
0
    def FightInScene(self,monsterId,now_X,playerId):
        '''副本战斗
        @param monsterId: int 怪物的id
        @param now_X: int 碰撞点的x坐标
        '''
        from app.scense.core.fight.fight_new import Fight
        if not self._monsters:
            return {'result':False,'message':u'不存在怪物实例'}
#        if not self.checkCanFight(monsterId, playerId):
#            return {'result':False,'message':u'无法进行攻击'}
        fightInfo = {}
        fightType = 1
        sendList = self.getSendList()
        players = [PlayersManager().getPlayerByID(playerId)]
        monster = self._monsters.get(monsterId,None)
        deffen = []
        guildname = players[0].guild.getGuildName()
        if not monster:
            return {'result':False,'message':u'不存在怪物实例'}
        if monsterId <10:
            pushSystemInfo(u'%s正在遭受%s国攻击'%(self._name,guildname))
        msgsendList = []
        for pp in players:#如果有抓宠技能则消耗相应的道具
            pp.skill.autoUnloadCatch()
            if pp.skill.checkHasEquipCatchSkill():
                level = pp.skill.getCatchPetLevel()
                itemTemplateID = pp.skill.CATCHCONSUME.get(level,0)
                msgsendList.append(pp.getDynamicId())
                if itemTemplateID:
                    pp.pack.delItemByTemplateId(itemTemplateID,1)
        
        if monster.formatInfo['difficulty']==5 and msgsendList:
            msg = Lg().g(574)
            pushPromptedMessage(msg, msgsendList)
        challengers = BattleSide(players)
        ruleInfo = monster.getRule()
        if not ruleInfo:
            deffen.append(monster)
            defenders = BattleSide(deffen)
        else:
            temlist,rule = ruleInfo[0],ruleInfo[1]
            i = 100
            for tem in temlist:
                i+=1
                _monser = Monster(id = i,templateId = tem)
                deffen.append(_monser)
            defenders = BattleSide(deffen,state = 0)
            defenders.setMatrixPositionBatch(rule)
        #获取战场中心位置
        realcenter = self._width/2
        data = Fight( challengers, defenders, realcenter)
        data.DoFight()
        
        #战后处理
        if data.battleResult == 1:
            mconfigId = monster.getMconfig()
            self.KilledMonster(mconfigId, monsterId)
        elif data.battleResult == 3:
            fightType = 3
            monster = self._monsters[monsterId]
            for player in self._playerlist:
                pl = PlayersManager().getPlayerByID(player)
                pl.baseInfo.initPosition((300,300))
            monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
        elif data.battleResult == 2:
            fightType = 2
            monster = self._monsters[monsterId]
            for player in self._playerlist:
                pl = PlayersManager().getPlayerByID(player)
#                pl.baseInfo.initPosition((300,300))
            monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
            
        settlementData = []
        dropoutid = monster.formatInfo['dropoutid']
        for player in data.fighters.values():
            if player['characterType']==2:#怪物
                currentHp = player['chaCurrentHp']
            if player['characterType']==3:#宠物
                pet = PlayersManager().getPlayerByID(playerId).pet._pets.get(player['chaId'])
                pet.attribute.updateHp(int(player['chaCurrentHp']))#更新宠物的血量
                if data.battleResult == 1:
                    exp = monster.formatInfo.get('expbound',100)*len(deffen)
                    pet.level.addExp(exp)
                continue
            if player['characterType']==1:
                pp = PlayersManager().getPlayerByID(player['chaId'])
                if data.battleResult == 1:
                    dropoutIitem = dropout.getDropByid(dropoutid)
                    info = {}
                    info['id'] = player['chaId']
                    info['name'] = player['chaName']
                    info['profession'] = player['figureType']
                    info['expBonus'] = monster.formatInfo.get('expbound',100)*len(deffen)
                    info['coinBonus'] = 0
                    info['goldBonus'] = 0
                    info['itemsBonus'] = dropoutIitem#None#getDropByid(1)
                    info['popularity'] = 0
                    info['attackGoal'] = 0
                    info['defenseGoal'] = 0
                    info['slayGoal'] = 0
                    settlementData.append(info)
                    expEff = pp.attribute.getExpEff()#经验加成
                    pp.level.updateExp(pp.level.getExp()+info['expBonus']*expEff,state = 0)
                    pp.finance.updateCoin(pp.finance.getCoin()+info['coinBonus'],state = 0)
                    pp.finance.updateGold(pp.finance.getGold()+info['goldBonus'],state = 0)
                    if info['itemsBonus']:
                        pp.pack.putNewItemInPackage(info['itemsBonus'],state=0)
                    for monster in deffen:
                        pp.quest.killMonster(monster.templateId)
                pp.attribute.updateHp(int(player['chaCurrentHp']),state = 0)
                pp.effect.doEffectHot()#执行效果战后处理
            
        fightInfo['fightType'] = fightType
        fightInfo['battle'] = data
        fightInfo['sendList'] = sendList
        fightInfo['centerX'] = realcenter
        fightInfo['setData'] = settlementData
        fightInfo['centerY'] = HEIGHT
        self.afterFight(monsterId, playerId, currentHp)
        return {'result':True,'data':fightInfo}
Ejemplo n.º 6
0
    def FightInScene(self, monsterId, now_X, playerId):
        '''副本战斗
        @param monsterId: int 怪物的id
        @param now_X: int 碰撞点的x坐标
        '''
        from app.scense.core.fight.fight_new import Fight
        if not self._monsters:
            return {'result': False, 'message': u'不存在怪物实例'}
#        if not self.checkCanFight(monsterId, playerId):
#            return {'result':False,'message':u'无法进行攻击'}
        fightInfo = {}
        fightType = 1
        sendList = self.getSendList()
        players = [PlayersManager().getPlayerByID(playerId)]
        monster = self._monsters.get(monsterId, None)
        deffen = []
        guildname = players[0].guild.getGuildName()
        if not monster:
            return {'result': False, 'message': u'不存在怪物实例'}
        if monsterId < 10:
            pushSystemInfo(u'%s正在遭受%s国攻击' % (self._name, guildname))
        msgsendList = []
        for pp in players:  #如果有抓宠技能则消耗相应的道具
            pp.skill.autoUnloadCatch()
            if pp.skill.checkHasEquipCatchSkill():
                level = pp.skill.getCatchPetLevel()
                itemTemplateID = pp.skill.CATCHCONSUME.get(level, 0)
                msgsendList.append(pp.getDynamicId())
                if itemTemplateID:
                    pp.pack.delItemByTemplateId(itemTemplateID, 1)

        if monster.formatInfo['difficulty'] == 5 and msgsendList:
            msg = Lg().g(574)
            pushPromptedMessage(msg, msgsendList)
        challengers = BattleSide(players)
        ruleInfo = monster.getRule()
        if not ruleInfo:
            deffen.append(monster)
            defenders = BattleSide(deffen)
        else:
            temlist, rule = ruleInfo[0], ruleInfo[1]
            i = 100
            for tem in temlist:
                i += 1
                _monser = Monster(id=i, templateId=tem)
                deffen.append(_monser)
            defenders = BattleSide(deffen, state=0)
            defenders.setMatrixPositionBatch(rule)
        #获取战场中心位置
        realcenter = self._width / 2
        data = Fight(challengers, defenders, realcenter)
        data.DoFight()

        #战后处理
        if data.battleResult == 1:
            mconfigId = monster.getMconfig()
            self.KilledMonster(mconfigId, monsterId)
        elif data.battleResult == 3:
            fightType = 3
            monster = self._monsters[monsterId]
            for player in self._playerlist:
                pl = PlayersManager().getPlayerByID(player)
                pl.baseInfo.initPosition((300, 300))
            monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
        elif data.battleResult == 2:
            fightType = 2
            monster = self._monsters[monsterId]
            for player in self._playerlist:
                pl = PlayersManager().getPlayerByID(player)
#                pl.baseInfo.initPosition((300,300))
            monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())

        settlementData = []
        dropoutid = monster.formatInfo['dropoutid']
        for player in data.fighters.values():
            if player['characterType'] == 2:  #怪物
                currentHp = player['chaCurrentHp']
            if player['characterType'] == 3:  #宠物
                pet = PlayersManager().getPlayerByID(playerId).pet._pets.get(
                    player['chaId'])
                pet.attribute.updateHp(int(player['chaCurrentHp']))  #更新宠物的血量
                if data.battleResult == 1:
                    exp = monster.formatInfo.get('expbound', 100) * len(deffen)
                    pet.level.addExp(exp)
                continue
            if player['characterType'] == 1:
                pp = PlayersManager().getPlayerByID(player['chaId'])
                if data.battleResult == 1:
                    dropoutIitem = dropout.getDropByid(dropoutid)
                    info = {}
                    info['id'] = player['chaId']
                    info['name'] = player['chaName']
                    info['profession'] = player['figureType']
                    info['expBonus'] = monster.formatInfo.get(
                        'expbound', 100) * len(deffen)
                    info['coinBonus'] = 0
                    info['goldBonus'] = 0
                    info['itemsBonus'] = dropoutIitem  #None#getDropByid(1)
                    info['popularity'] = 0
                    info['attackGoal'] = 0
                    info['defenseGoal'] = 0
                    info['slayGoal'] = 0
                    settlementData.append(info)
                    expEff = pp.attribute.getExpEff()  #经验加成
                    pp.level.updateExp(pp.level.getExp() +
                                       info['expBonus'] * expEff,
                                       state=0)
                    pp.finance.updateCoin(pp.finance.getCoin() +
                                          info['coinBonus'],
                                          state=0)
                    pp.finance.updateGold(pp.finance.getGold() +
                                          info['goldBonus'],
                                          state=0)
                    if info['itemsBonus']:
                        pp.pack.putNewItemInPackage(info['itemsBonus'],
                                                    state=0)
                    for monster in deffen:
                        pp.quest.killMonster(monster.templateId)
                pp.attribute.updateHp(int(player['chaCurrentHp']), state=0)
                pp.effect.doEffectHot()  #执行效果战后处理

        fightInfo['fightType'] = fightType
        fightInfo['battle'] = data
        fightInfo['sendList'] = sendList
        fightInfo['centerX'] = realcenter
        fightInfo['setData'] = settlementData
        fightInfo['centerY'] = HEIGHT
        self.afterFight(monsterId, playerId, currentHp)
        return {'result': True, 'data': fightInfo}