def tiaozhuan(dynamicId,characterid,csz):
    '''场景间的跳转或者进入副本
    '''
    player = PlayersManager().getPlayerByID(characterid)
    if not player:
        return {'result':False,'message':Lg().g(18)}
    doorinfo = dbMap.ALL_DOOR_INFO.get(csz)#获取传送门的信息
    lastscene = MapManager().getMapId(player.baseInfo.getTown())
    if doorinfo.get('functionType')==1:#跳转场景
        placeId = doorinfo.get('nextmap')
        position = (doorinfo.get('init_x'),doorinfo.get('init_y'))
        player.baseInfo.setTown( placeId)
        player.baseInfo.setState(0)
        PlayersManager().addPlayer(player)
        defencelog_app.isReward(player.baseInfo.id, player.getDynamicId())
        scene = MapManager().getMapId(placeId)
        scenename = scene.getSceneName()
        chatnoderemote.callRemote('JoinRoom',characterid,placeId,scenename)
        scene.addPlayer(characterid)
        player.quest.setNpcList(scene._npclist)
        player.baseInfo.initPosition(position)
        scene.pushEnterPlace([dynamicId])
        result = {'result':True}
    else:
        instanceId = doorinfo.get('famID')
        result = instance_app.enterInstance1(player,dynamicId, characterid, instanceId,0)
    if result.get('result'):
        lastscene.dropPlayer(characterid)
Exemple #2
0
def enterPlace_601(dynamicId, characterId, placeId,force,player):
    '''进入场景'''
    state = 0
    if not player:
        player = PlayerCharacter(characterId,dynamicId = dynamicId)
        player.setlastOnline(datetime.datetime.now())
        pushPlayerGonggaoXinxi(player)
    else:
        player = cPickle.loads(player)
        player.startAllTimer()
        state = 1
    #判断是否满足进入场景的需求
    sceneInfo = dbMap.ALL_MAP_INFO.get(placeId,{})
    levelRequired = sceneInfo['level']
    if player.level.getLevel()<sceneInfo['level']:
        msg = Lg().g(607)%levelRequired
        pushOtherMessage(905, msg, [dynamicId])
        return {'result':False,'message':Lg().g(332)}
    player.baseInfo.setTown( placeId)
    player.baseInfo.setState(0)
    PlayersManager().addPlayer(player)
    defencelog_app.isReward(player.baseInfo.id, player.getDynamicId())
    scene = MapManager().getMapId(placeId)
    scenename = scene.getSceneName()
    chatnoderemote.callRemote('JoinRoom',characterId,placeId,scenename)
    scene.addPlayer(characterId)
    player.quest.setNpcList(scene._npclist)
    scene.pushEnterPlace([dynamicId])
#    if not state:
#        publicnoderemote.callRemote('addPcharacter',characterId,getNodeId())
#    else:
#        publicnoderemote.callRemote('updatePCharacterNodeId',characterId,getNodeId())
    return {'result':True,'message':'','data':{'placeId':placeId}}
Exemple #3
0
def FightWithPlayer(dynamicId, characterId, tid):
    '''玩家PK
    @param dynamicId: int 客户端的动态id
    @param characterId: int 角色的id
    @param tid: int 对方的id
    '''
    res = CanDoServer(characterId)
    if not res['result']:
        return res
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result': False, 'message': Lg().g(18)}
    toplayer = PlayersManager().getPlayerByID(tid)
    if not toplayer:
        return {'result': False, 'message': Lg().g(66)}
    guildid = player.guild.getID()
    tguildid = toplayer.guild.getID()
    town = player.baseInfo.getTown()
    ttown = toplayer.baseInfo.getTown()
    if not player.pvp.checktime():
        return {'result': False, 'message': u"PK战斗CD中"}
    if not toplayer.pvp.checktime():
        return {'result': False, 'message': u"对方PK战斗CD中"}
    if town != ttown:
        return {'result': False, 'message': u"不在统一场景无法进行战斗"}
    if player.guild.getID() == toplayer.guild.getID() or 0 in [
            guildid, tguildid
    ]:
        return {'result': False, 'message': u"不允许本国之间战斗"}
    level = player.level.getLevel()
    tlevel = player.level.getLevel()
    if level < 25 or tlevel < 25:
        return {'result': False, 'message': u"低于25级不能进行战斗"}
    player.pvp.recordtime()
    toplayer.pvp.recordtime()
    data = DoFight([player], [toplayer], now_X=550)
    #战后的处理
    battleresult = data.battleResult
    nowscene = MapManager().getMapId(ttown)  #获取当前场景
    if battleresult == 1:  #如果主动方胜利
        nowscene.dropPlayer(tid)  #在当前场景中移除被攻击的玩家
        toscene = MapManager().getMapId(1000)  #扔回其他场景
        toscene.addPlayer(tid)
        toscene.pushEnterPlace([toplayer.dynamicId])
        toplayer.baseInfo.setTown(1000)
    else:
        nowscene.dropPlayer(characterId)  #在当前场景中移主动攻击的玩家
        toscene = MapManager().getMapId(1000)  #扔回其他场景
        toscene.addPlayer(characterId)
        toscene.pushEnterPlace([player.dynamicId])
        player.baseInfo.setTown(1000)
    return {
        'result': True,
        'data': data,
        'sendlist': [dynamicId, toplayer.dynamicId]
    }
Exemple #4
0
def backScnee(pid, instanceid, boo):
    '''角色退出殖民战斗,返回城镇场景
    @param pid: int 角色id
    @param instanceid: int 副本id
    @param boo: bool 战斗结果
    '''
    player = PlayersManager().getPlayerByID(pid)
    player.msgbox.AfterFightMsgHandle()
    sceneId = player.baseInfo.getTown()
    scene = MapManager().getMapId(sceneId)
    scene.addPlayer(pid)
    scene.pushEnterPlace([player.getDynamicId()])
def backScnee(pid, instanceid, boo):
    """角色退出殖民战斗,返回城镇场景
    @param pid: int 角色id
    @param instanceid: int 副本id
    @param boo: bool 战斗结果
    """
    player = PlayersManager().getPlayerByID(pid)
    player.msgbox.AfterFightMsgHandle()
    sceneId = player.baseInfo.getTown()
    scene = MapManager().getMapId(sceneId)
    scene.addPlayer(pid)
    scene.pushEnterPlace([player.getDynamicId()])
Exemple #6
0
def FightWithPlayer(dynamicId,characterId,tid):
    '''玩家PK
    @param dynamicId: int 客户端的动态id
    @param characterId: int 角色的id
    @param tid: int 对方的id
    '''
    res = CanDoServer(characterId)
    if not res['result']:
        return res
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result':False,'message':Lg().g(18)}
    toplayer = PlayersManager().getPlayerByID(tid)
    if not toplayer:
        return {'result':False,'message':Lg().g(66)}
    guildid = player.guild.getID()
    tguildid = toplayer.guild.getID()
    town = player.baseInfo.getTown()
    ttown = toplayer.baseInfo.getTown()
    if not player.pvp.checktime():
        return {'result':False,'message':u"PK战斗CD中"}
    if not toplayer.pvp.checktime():
        return {'result':False,'message':u"对方PK战斗CD中"}
    if town!=ttown:
        return {'result':False,'message':u"不在统一场景无法进行战斗"}
    if player.guild.getID()== toplayer.guild.getID() or 0 in [guildid,tguildid]:
        return {'result':False,'message':u"不允许本国之间战斗"}
    level = player.level.getLevel()
    tlevel = player.level.getLevel()
    if level<25 or tlevel<25:
        return {'result':False,'message':u"低于25级不能进行战斗"}
    player.pvp.recordtime()
    toplayer.pvp.recordtime()
    data = DoFight([player], [toplayer], now_X=550)
    #战后的处理
    battleresult = data.battleResult
    nowscene = MapManager().getMapId(ttown)#获取当前场景
    if battleresult==1:#如果主动方胜利
        nowscene.dropPlayer(tid)#在当前场景中移除被攻击的玩家
        toscene = MapManager().getMapId(1000)#扔回其他场景
        toscene.addPlayer(tid)
        toscene.pushEnterPlace([toplayer.dynamicId])
        toplayer.baseInfo.setTown(1000)
    else:
        nowscene.dropPlayer(characterId)#在当前场景中移主动攻击的玩家
        toscene = MapManager().getMapId(1000)#扔回其他场景
        toscene.addPlayer(characterId)
        toscene.pushEnterPlace([player.dynamicId])
        player.baseInfo.setTown(1000)
    return {'result':True,'data':data,'sendlist':[dynamicId,toplayer.dynamicId]}
def closeInstance(dynamicId,characterId):
    '''关闭副本
    @param characterId: int  角色Id
    '''
    player = PlayersManager().getPlayerByID(characterId)
    if not player:
        return {'result':False}
    tag=player.baseInfo.getInstancetag() #副本动态Id
    if not tag:
        return {'result':False}
    InstanceManager().dropInstanceById(tag)
    sceneId = player.baseInfo.getTown()
    scene = MapManager().getMapId(sceneId)
    scene.addPlayer(characterId)
    player.quest.setNpcList(scene._npclist)
    player.baseInfo.setInstancetag(0)
    player.baseInfo.setState(0)
    scene.pushEnterPlace([dynamicId])
#    player.updatePlayerDBInfo()#将角色信息写入数据库
#    player.stopAllTimer()#停止所有定时器
    return {'result':True}
Exemple #8
0
def goto(characterId,argument):
    '''跳转场景
    @param characterId: int 角色的ID
    '''
    if len(argument)<1:
        return 
    player = PlayersManager().getPlayerByID(characterId)
    if not player:
        return
    from app.scense.core.map.MapManager import MapManager
    placeId = int(argument[0])
    lastscene = MapManager().getMapId(player.baseInfo.getTown())
    scene = MapManager().getMapId(placeId)
    if not scene:
        return
    player.baseInfo.setTown( placeId)
    player.baseInfo.setState(0)
    player.baseInfo.initPosition((300,300))
    scene.addPlayer(characterId)
    player.quest.setNpcList(scene._npclist)
    dynamicId = player.dynamicId
    scene.pushEnterPlace([dynamicId])
    lastscene.dropPlayer(characterId)