def produceMonster(self,monsterId,position = (300,400),camp=0):
     '''产生一个怪物
     @param monsterId: int 怪物的模板id
     '''
     monster = Monster(templateId = monsterId,id = self.__tag)
     monster.baseInfo.setPosition(position)
     monster.setCamp(camp)
     self.addMonster(monster)
Exemple #2
0
 def initMainBanners(self):
     '''初始化城镇的主帅旗帜
     '''
     sencename = self.getSceneGuildName()
     position = (1000, 800)
     monster = Monster(id=1, templateId=15013)
     if sencename:
         monstername = monster.baseInfo.getName()
         monster.baseInfo.setName(u'【%s】%s' % (sencename, monstername))
     monster.baseInfo.setStaticPosition(position)
     monster.setMconfig(1)
     self.addMonster(monster)
Exemple #3
0
 def initMainBanners(self):
     '''初始化城镇的主帅旗帜
     '''
     sencename = self.getSceneGuildName()
     position = (1000,800)
     monster = Monster(id = 1,templateId = 15013)
     if sencename:
         monstername = monster.baseInfo.getName()
         monster.baseInfo.setName( u'【%s】%s'%(sencename,monstername))
     monster.baseInfo.setStaticPosition(position)
     monster.setMconfig(1)
     self.addMonster(monster)
Exemple #4
0
 def produceMonster(self):
     '''产生怪物
     '''
     while True:
         mconfigId = yield
         configinfo = dbMap.ALL_MAP_MONSTER.get(mconfigId)
         templateId = configinfo.get('monster')
         position = (configinfo.get('position_x'),configinfo.get('position_y'))
         rule = configinfo.get('rule',[])
         monster = Monster(id = self._tag,templateId = templateId)
         monster.baseInfo.setStaticPosition(position)
         monster.setRule(rule)
         monster.setMconfig(mconfigId)
         self.addMonster(monster)
Exemple #5
0
def getMonsterItemByid(instanceid):
    '''根据副本id获取组队副本需要的信息
    @param id: int 副本id
    '''
    result=dbInstance_d.getInstance_dByid(instanceid)
    ditems=[] #存储掉落物品实例
    ms=[] #存储怪物实例
    if result:
        dropitems=result.get('dropitem',None)
        if dropitems:
            for itemid in dropitems:
                itm=Item(itemid)
                val=[]
                val.append(itm.baseInfo.getBaseQuality()) #物品品质
                val.append(itm.baseInfo.getName()) #物品名称
                del itm
                ditems.append(val)
        monsters=result.get('moster',None)
        if monsters:
            for mosterid in monsters:
                ms.append( Monster(templateId=mosterid))
        result['dropitem']=ditems
        result['moster']=ms
        data={"result":True,"message":Lg().g(166),"data":result}
        return data
    return None
    
Exemple #6
0
 def produceBanners(self,bannerId):
     '''生成副旗
     @param bannerId: 副旗的ID
     '''
     positions = {2:(500,800),3:(1500,800),4:(1000,500),5:(1000,1100)}
     position = positions[bannerId]
     sencename = self.getSceneGuildName()
     monster = Monster(id = bannerId,templateId = 15014)
     if sencename:
         monstername = monster.baseInfo.getName()
         monster.baseInfo.setName( u'【%s】%s'%(sencename,monstername))
     monster.baseInfo.setStaticPosition(position)
     monster.setMconfig(bannerId)
     try:
         self.addMonster(monster)
     except Exception:
         print 'ok'
Exemple #7
0
 def produceBanners(self, bannerId):
     '''生成副旗
     @param bannerId: 副旗的ID
     '''
     positions = {
         2: (500, 800),
         3: (1500, 800),
         4: (1000, 500),
         5: (1000, 1100)
     }
     position = positions[bannerId]
     sencename = self.getSceneGuildName()
     monster = Monster(id=bannerId, templateId=15014)
     if sencename:
         monstername = monster.baseInfo.getName()
         monster.baseInfo.setName(u'【%s】%s' % (sencename, monstername))
     monster.baseInfo.setStaticPosition(position)
     monster.setMconfig(bannerId)
     try:
         self.addMonster(monster)
     except Exception:
         print 'ok'
Exemple #8
0
    def doZhangJie(self,zhangjieid):
        '''章节战斗
        @param zhangjieid: int 章节的
        '''
        if zhangjieid>self.currentZJ:
            return {'result':False,'message':u'当前章节未被激活'}
        from app.scense.core.fight.fight_new import Fight
        zhanjieInfo = db_zhanyi.ALL_ZHANGJIE_INFO.get(self.currentZJ)
        levelrequired = zhanjieInfo.get('levelrequired')
        if self._owner.level.getLevel()<levelrequired:
            return {'result':False,'message':u'当前等级不足'}
        ruleInfo = eval(zhanjieInfo.get('mconfig'))
        temlist,rule = ruleInfo[0],ruleInfo[1]
        i = 100
        challengers = BattleSide([self._owner])
        deffen = []
        for tem in temlist:
            i+=1 
            monser = Monster(id = i,templateId = tem)
            deffen.append(monser)
        defenders = BattleSide(deffen,state = 0)
        defenders.setMatrixPositionBatch(rule)
        data = Fight( challengers, defenders, 600)
        data.DoFight()
        if data.battleResult == 1 and zhangjieid==self.currentZJ:#如果战斗胜利
#            self._owner.quest.cleanZhanYi(zhangjieid)#通知战役通关任务
            zhanyilist = ZYManage().zhanyiSet.keys()
            zhanyilist.sort()
            zy = ZYManage().getZhanYiInfoById(self.currentZY)
            zhangjielist = zy.zhangjieSet.keys()
            zhangjielist.sort()
            index = zhangjielist.index(self.currentZJ)
            if index>=len(zhangjielist)-1:
                zhanyiindex = zhanyilist.index(self.currentZY)
                if zhanyiindex<len(zhanyilist)-1:
                    zhanyiindex = zhanyilist.index(self.currentZY)
                    self.currentZY = zhanyilist[zhanyiindex+1]
                    zy = ZYManage().getZhanYiInfoById(self.currentZY)
                    zhangjielist = zy.zhangjieSet.keys()
                    zhangjielist.sort()
                    self.currentZJ = zhangjielist[0]
            else:
                self.currentZJ = zhangjielist[index+1]
        if data.battleResult == 1:
            self._owner.quest.cleanZhanYi(zhangjieid)#通知战役通关任务
        return {'result':True,'data':{'fight':data}}
 def climb(self):
     '''开始爬塔
     '''
     nowtime = datetime.datetime.now()
     if self.lasttime and minusDatetimeForSecond(nowtime,
                                                 self.lasttime) <= 30:
         return {'result': False, 'message': Lg().g(497)}
     self.lasttime = nowtime
     layer = self.nowLayers
     towerinfo = dbtower.ALL_TOWER_INFO.get(layer)
     if not towerinfo:
         return {'result': False, 'message': Lg().g(498)}
     monsterlist, eyes = towerinfo.get('rule', [[15001], [5]])
     matrixid = towerinfo.get('matrixid', 100001)
     deffen = []
     for index in range(len(monsterlist)):
         monster = Monster(id=1000 + index, templateId=monsterlist[index])
         deffen.append(monster)
     challengers = BattleSide([self._owner])
     defenders = BattleSide(deffen)
     defenders.setMatrixPositionBatch(eyes)
     fig = Fight(challengers, defenders, 550)
     fig.DoFight()
     bounds = {}
     if fig.battleResult == 1:  #胜利
         self.succedHandle()  #胜利后的处理
         bounds = self.doTowerBound(layer)  #进行胜利后的奖励处理
     else:  #失败后的处理
         pass
     msg = u''
     msglist = []
     exp = bounds.get('exp')
     item = bounds.get('item')
     bounds['name'] = self._owner.baseInfo.getName()
     if exp:
         msglist.append(Lg().g(499) + u':%d\n' % exp)
     if item:
         msglist.append(Lg().g(500) + u':%s' % item.baseInfo.getName())
     if msglist:
         msg = msg.join(msglist)
     else:
         msg = Lg().g(143)
     data = {'message': msg, 'fight': fig, 'bound': bounds}
     return {'result': True, 'data': data}
Exemple #10
0
 def produceMonster(self):
     '''产生怪物
     '''
     while True:
         mconfigId = yield
         configinfo = dbMap.ALL_MAP_MONSTER.get(mconfigId)
         templateId = configinfo.get('monster')
         position = (configinfo.get('position_x'),
                     configinfo.get('position_y'))
         rule = configinfo.get('rule', [])
         monster = Monster(id=self._tag, templateId=templateId)
         monster.baseInfo.setStaticPosition(position)
         monster.setRule(rule)
         monster.setMconfig(mconfigId)
         self.addMonster(monster)
Exemple #11
0
def getInstance_dByid(instanceid):
    '''根据副本id获取组队副本需要的信息
    @param id: int 副本id
    '''
    result=dbInstance_d.getInstance_dByid(instanceid)
    ditems=[] #存储掉落物品实例
    ms=[] #存储怪物实例
    if result:
        dropitems=result.get('dropitem',None)
        if dropitems:
            for itemid in dropitems:
                ditems.append(Item(itemid))
        monsters=result.get('moster',None)
        if monsters:
            for mosterid in monsters:
                ms.append( Monster(templateId=mosterid))
        result['dropitem']=ditems
        result['moster']=ms
        data={"result":True,"message":Lg().g(166),"data":result}
        return data
    return None
Exemple #12
0
def getInfo(typeid):
    '''根据多人副本类型id获取多人副本信息'''
    all=dbTeamInstance.teamInstanceAll #所有多人副本信息
    info=all.get(typeid)
    zy=info.get('resourceid')#资源id
    width=info.get('width')#场景宽度
    height=info.get('height')#场景高度
    mostersList=info.get('mosters')#[[怪物id,阵法位置(1-9)],[怪物id,阵法位置(1-9)]]
    MosterList=[]#怪物实例列表
    mosterwz={}#key:怪物动态di,value:怪物位置
    sa=0
    for mid in mostersList:
        sa+=1
        MosterList.append(Monster(id=sa,templateId=mid[0]))
        mosterwz[sa]=mid[1]
    rs={}
    rs['zy']=zy
    rs['width']=width
    rs['height']=height
    rs['MosterList']=MosterList
    rs['mosterwz']=mosterwz
    return rs
Exemple #13
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
Exemple #14
0
 def createMonster(self, temlateId):
     '''随机生成一个怪物'''
     self._identitytag += 1
     monster = Monster(id=self._identitytag, templateId=temlateId)
     return monster
Exemple #15
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}