Exemplo n.º 1
0
    def exe(self, owner, skill, objDest, param):
        #TODO
        from model import PlayerModel
        newX = owner.x + 2
        newY = owner.y + 2
        if not owner.mapObj.canMove(newX, newY):
            newX = owner.x
            newY = owner.y
        player = PlayerModel.Player()
        player.forkFrom(owner, self.paramPropRate)
        player.arenaCtrl.destPlayerRef = weakref.ref(objDest)
        player.session = owner.session
        owner.mapObj.playerEnterMap(player, newX, newY)
        from model import ArenaModel
        player.fsm.changeState(ffext.singleton(ArenaModel.ArenaStateAttack))
        beginTm = ffext.getTime()

        def cb():
            if ffext.getTime() - beginTm >= 20 or player.isDeath():
                player.mapObj.playerLeaveMap(player)
                player.session = None
            else:
                try:
                    player.fsm.update(player, ffext.getTimeMs())
                except:
                    pass
                ffext.timer(1000, cb)

        ffext.timer(1000, cb)
        return
Exemplo n.º 2
0
        def cb(dbSet):
            db = dbSet['player']
            dbitem = dbSet['item']
            dbPet = dbSet['pet']
            session = ffext.SessionNone()
            player = PlayerModel.Player(db.result[0])
            session.setPlayer(player)
            player.session = session
            if dbitem.isOk():
                player.itemCtrl.fromData(dbitem.result)
            player.petCtrl.fromData(dbPet.result)
            player.direction = Base.Direction.RIGHT
            player.arenaCtrl.destPlayerRef = weakref.ref(playerSrc)
            #状态机
            player.fsm = MonsterAI.FSM(player)

            def goTo():
                mapObj.copyMapHandler.autoPlayerRef = weakref.ref(player)
                mapObj.playerEnterMap(player, 69, 72)
                player.fsm.changeState(ffext.singleton(ArenaStateAttack))

            ffext.timer(1000, goTo)
            return
Exemplo n.º 3
0
    def callback(dbSet):
        #异步载入数据库,需要验证session是否仍然有效,有可能下线了
        db = dbSet['player']
        if session.isValid() == False or session.player:
            return False

        if len(db.result) == 0:
            ffext.dump('no this role')
            return False
        else:
            player = PlayerModel.Player(db.result[0])
            #ffext.dump(dbSet)
            session.setPlayer(player)
            if x != 0 and y != 0:
                player.x = x
                player.y = y

            #载入数据
            ffext.dump('load player =%s' % (session.player.name))
            session.verify_id(session.player.uid)
            dbTask = dbSet['task']
            dbitem = dbSet['item']
            dbFriend = dbSet['friend']
            dbEnemy = dbSet['enemy']
            dbGuild = dbSet['guild']
            dbPet = dbSet['pet']
            dbMail = dbSet['mail']
            dbLoginAct = dbSet['login_activity']
            if dbTask.isOk():
                player.taskCtrl.fromData(dbTask.result)
            if dbitem.isOk():
                player.itemCtrl.fromData(dbitem.result)
                #TaskHandler.processQueryTask(session)
            #初始化好友信息、仇人信息,屏蔽信息
            if dbFriend.isOk():
                player.friendCtrl.fromDataFriend(dbFriend.result)
            if dbEnemy.isOk():
                player.friendCtrl.fromDataEnemy(dbEnemy.result)
            #初始化行会信息
            if dbGuild.isOk():
                player.guildCtrl.fromData(dbGuild.result)
            player.petCtrl.fromData(dbPet.result)
            if dbMail.isOk():
                player.mailCtrl.fromData(dbMail.result)
            if dbLoginAct.isOk():
                player.loginActCtrl.fromData(dbLoginAct.result)
        # 发送属性数据
        PlayerModel.sendPropUpdateMsg(player)
        #发消息通知,通知上线
        tmpReq = MsgDef.EnterMapReq(player.mapname, player.x, player.y)
        processEnterMapReq(session, tmpReq, True)
        #发送技能数据
        SkillHandler.processQuerySkill(session)
        #发送包裹数据
        ItemHandler.processQueryPkg(session)
        #发送装备数据
        ItemHandler.processQueryEquip(session)
        #发送任务数据
        TaskHandler.processQueryTask(session)
        #发送好友数据
        FriendHandler.processListFriend(
            session,
            MsgDef.FriendListMsgReq(MsgDef.FriendListClientCmd.GET_FRIENDLIST))
        #发送行会数据
        GuildHandler.processGuildInfo(session)
        #发送结义数据
        TeamHandler.processBrotherOps(
            session,
            MsgDef.BrotherOpsReq(MsgDef.BrotherClientCmd.GET_BROTHERLIST))
        #发送安全码
        processMoneyBankOps(session)
        processQueryPet(session)
        from handler import MarryHandler
        MarryHandler.processMarryOPS(
            session,
            MsgDef.MarriageOpsReq(MsgDef.MarriageClientCmd.MARRY_QUERY_STATUS))
        SkillHandler.processAttackModeReq(session)  #发送攻击模式
        from handler import MailHandler
        MailHandler.processMarryOPS(session, MsgDef.MailOpsReq(0))
        #msg = MsgDef.UpdateSkillPosReq({320:1})
        #SkillHandler.processUpdateSkillPosReq(session, msg)
        #结义数据
        # if player.brotherCtrl:
        #     BrotherModel.handleQueryBrother(player)

        player.checkTimeAfterInit()
        # 登录(old)-记录log
        LogModel.logLoginData(accountid, player.uid, player.name,
                              LogModel.LoginOpType.LOGIN_PLAYER,
                              LogModel.LoginReason.OLD_LOGIN)
        return