def doTowerBound(self,layer):
     '''执行爬塔成功后的奖励
     @param layer: int 塔的层数
     '''
     towerinfo = dbtower.ALL_TOWER_INFO.get(layer)
     if not towerinfo:
         return {'result':False,'message':Lg().g(496)}
     expbound = towerinfo.get('expbound',0)
     dropoutid = towerinfo.get('dropoutid',1)
     if not dropoutid:
         dropoutIitem = None
     else:
         dropoutIitem = dropout.getDropByid(dropoutid)
     boundinfo = {'exp':expbound,'item':dropoutIitem}
     if expbound:
         self._owner.level.addExp(expbound)
     if dropoutIitem:
         self._owner.pack.putNewItemInPackage(dropoutIitem)
     return boundinfo
 def doTowerBound(self, layer):
     '''执行爬塔成功后的奖励
     @param layer: int 塔的层数
     '''
     towerinfo = dbtower.ALL_TOWER_INFO.get(layer)
     if not towerinfo:
         return {'result': False, 'message': Lg().g(496)}
     expbound = towerinfo.get('expbound', 0)
     dropoutid = towerinfo.get('dropoutid', 1)
     if not dropoutid:
         dropoutIitem = None
     else:
         dropoutIitem = dropout.getDropByid(dropoutid)
     boundinfo = {'exp': expbound, 'item': dropoutIitem}
     if expbound:
         self._owner.level.addExp(expbound)
     if dropoutIitem:
         self._owner.pack.putNewItemInPackage(dropoutIitem)
     return boundinfo
Пример #3
0
    def doFightBound(self, challengers, monster, monindex):
        '''执行战斗奖励
        '''
        #        ruleInfo = monster.getRule()
        temlist, rule = monster.getRule()
        for temId in temlist:
            self._owner.quest.killMonster(temId)
        msgHead = Lg().g(458) % (monindex + 1)
        msgbox = []
        msgbox.append(msgHead)
        monstercnt = len(temlist)
        dropoutid = monster.formatInfo['dropoutid']
        expBonus = monster.formatInfo.get('expbound', 100) * monstercnt
        itemsBonus = dropout.getDropByid(dropoutid)
        members = challengers.getMembers()
        for mem in members:
            if mem['characterType'] == 3:  #宠物
                pet = self._owner.pet._pets.get(mem['chaId'])
                pet.level.addExp(expBonus)
                msg = Lg().g(459) % pet.baseInfo.getName()
            if mem['characterType'] == 1:
                expEff = self._owner.attribute.getExpEff()  #经验加成
                plexp = expBonus * expEff
                self._owner.level.addExp(plexp, update=0)
                msg = Lg().g(459) % self._owner.baseInfo.getNickName()
            msgbox.append(msg)
        msgbox[-1] = msgbox[-1][:-1]

        if itemsBonus:
            self._owner.pack.putNewItemInPackage(itemsBonus)
            itemtemplateid = itemsBonus.baseInfo.itemTemplateId
            itemname = itemsBonus.baseInfo.getRichName()
            stack = itemsBonus.pack.getStack()
            msg = Lg().g(460) + u"<a href = 'event:%d'><u>%s</u></a> x %d" % (
                itemtemplateid, itemname, stack)
            msgbox.append(msg)
        msgbox.append(' \n')
        return u''.join(msgbox)
    def doFightBound(self,challengers,monster,monindex):
        '''执行战斗奖励
        '''
#        ruleInfo = monster.getRule()
        temlist,rule = monster.getRule()
        for temId in temlist:
            self._owner.quest.killMonster(temId)
        msgHead = Lg().g(458)%(monindex+1)
        msgbox = []
        msgbox.append(msgHead)
        monstercnt = len(temlist)
        dropoutid = monster.formatInfo['dropoutid']
        expBonus = monster.formatInfo.get('expbound',100)*monstercnt
        itemsBonus = dropout.getDropByid(dropoutid)
        members = challengers.getMembers()
        for mem in members:
            if mem['characterType']==3:#宠物
                pet = self._owner.pet._pets.get(mem['chaId'])
                pet.level.addExp(expBonus)
                msg = Lg().g(459)%pet.baseInfo.getName()
            if mem['characterType']==1:
                expEff = self._owner.attribute.getExpEff()#经验加成
                plexp = expBonus* expEff
                self._owner.level.addExp(plexp,update = 0)
                msg = Lg().g(459)%self._owner.baseInfo.getNickName()
            msgbox.append(msg)
        msgbox[-1] = msgbox[-1][:-1]

        if itemsBonus:
            self._owner.pack.putNewItemInPackage(itemsBonus)
            itemtemplateid = itemsBonus.baseInfo.itemTemplateId
            itemname = itemsBonus.baseInfo.getRichName()
            stack = itemsBonus.pack.getStack()
            msg =Lg().g(460)+ u"<a href = 'event:%d'><u>%s</u></a> x %d"%(itemtemplateid,itemname,stack)
            msgbox.append(msg)
        msgbox.append(' \n')
        return u''.join(msgbox)
Пример #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'不存在怪物实例'}
     fightInfo = {}
     fightType = 1
     sendList = self.getSendList()
     players = [PlayersManager().getPlayerByID(playerId) for playerId in self._playerlist]
     monster = self._monsters.get(monsterId,None)
     deffen = []
     if not monster:
         return {'result':False,'message':u'不存在怪物实例'}
     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)
     matrixId = monster.getMatrixId()
     ruleInfo = monster.getRule()
     if not ruleInfo:
         deffen.append(monster)
         defenders = BattleSide(deffen)
     else:
         temlist,rule = ruleInfo
         for tem in temlist:
             _monser = self.createMonster(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:
         self.dropMonster(monsterId)
     elif data.battleResult == 3:
         fightType = 3
         monster = self._monsters[monsterId]
         for player in self._playerlist:
             pl = PlayersManager().getPlayerByID(player)
             pl.baseInfo.initPosition(self.getInitPosition())
         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(self.getInitPosition())
             self.pushFightFailHelp(pl)
         monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
     if not self._monsters and self._type ==2:
         fightType = 4
         #print '通关副本'
     settlementData = []
     dropoutid = monster.formatInfo['dropoutid']
     for player in data.fighters.values():
         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
     
     return {'result':True,'data':fightInfo}
Пример #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'不存在怪物实例'}
        fightInfo = {}
        fightType = 1
        sendList = self.getSendList()
        players = [
            PlayersManager().getPlayerByID(playerId)
            for playerId in self._playerlist
        ]
        monster = self._monsters.get(monsterId, None)
        deffen = []
        if not monster:
            return {'result': False, 'message': u'不存在怪物实例'}
        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)
        matrixId = monster.getMatrixId()
        ruleInfo = monster.getRule()
        if not ruleInfo:
            deffen.append(monster)
            defenders = BattleSide(deffen)
        else:
            temlist, rule = ruleInfo
            for tem in temlist:
                _monser = self.createMonster(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:
            self.dropMonster(monsterId)
        elif data.battleResult == 3:
            fightType = 3
            monster = self._monsters[monsterId]
            for player in self._playerlist:
                pl = PlayersManager().getPlayerByID(player)
                pl.baseInfo.initPosition(self.getInitPosition())
            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(self.getInitPosition())
                self.pushFightFailHelp(pl)
            monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
        if not self._monsters and self._type == 2:
            fightType = 4
            #print '通关副本'
        settlementData = []
        dropoutid = monster.formatInfo['dropoutid']
        for player in data.fighters.values():
            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

        return {'result': True, 'data': fightInfo}