Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            PlayerArenaLogic pa = new PlayerArenaLogic();
            ArenaRankLogic   ar = new ArenaRankLogic();

            pa.SetUser(m_UserId);
            m_ResponsePacket.ArenaTokenCount = pa.MyArena.ArenaTokenCount;
            m_ResponsePacket.ChallengeCount  = pa.MyArena.ChallengeCount;
            m_ResponsePacket.ClaimedFlags.AddRange(pa.MyArena.ClaimedLivenessRewardFlag);
            m_ResponsePacket.MyRank   = ar.GetPlayerRank(m_UserId);
            m_ResponsePacket.WinCount = pa.MyArena.WinCount;
            var         matchPlayers = ar.GetMatchPlayers(m_UserId);
            PlayerLogic p            = new PlayerLogic();

            foreach (var player in matchPlayers)
            {
                PBArenaPlayerAndTeamInfo enemy = new PBArenaPlayerAndTeamInfo();
                enemy.Rank = player.RankId;
                p.SetUser(player.PlayerId);
                enemy.PlayerInfo = new PBPlayerInfo()
                {
                    Id           = player.PlayerId,
                    Name         = p.MyPlayer.Name,
                    Level        = p.MyPlayer.Level,
                    PortraitType = p.MyPlayer.PortraitType
                };
                m_ResponsePacket.Enemies.Add(enemy);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public bool StartBattle(int enemyId, int myRank, int enemyRank, bool IsRevenge)
        {
            if (m_Arena.ChallengeCount < 1)
            {
                return(false);
            }
            int            userId = m_UserId;
            ArenaRankLogic ar     = new ArenaRankLogic();

            if (!IsRevenge && enemyRank != ar.GetPlayerRank(enemyId))
            {
                return(false);
            }
            SetUser(enemyId);
            if (m_Arena.EnemyId > 0)
            {
                SetUser(userId);
                return(false);
            }
            if (!IsRevenge)
            {
                m_Arena.EnemyId = userId;
            }
            SetUser(userId);
            if (!IsRevenge)
            {
                m_Arena.EnemyId         = enemyId;
                m_Arena.ChallengeCount -= 1;
            }
            return(true);
        }
Ejemplo n.º 3
0
 public static void InitServer()
 {
     DataTableLoader.LoadDataTables("Lobby");
     (new SyncTimer(RoomServerManager.CheckServerStates, 60000, 60000)).Start();
     (new SyncTimer(Cronjobs.CheckAndDo, 60000, 60000)).Start();
     (new SyncTimer(UpdateServerLoadToMaster, 60000, 60000)).Start();
     (new SyncTimer(PVPLogic.ExecuteMatch, 10000, 10000)).Start();
     RoomServerManager.InitRoomServerList();
     RoomServerManager.InitRoomList();
     GameConfigs.Reload();
     ArenaRankLogic.InitRankList();
     AllQualitiesOfGears.LoadGears();
     InitRanking();
     RegisterLobbyServer();
 }
Ejemplo n.º 4
0
        public override bool TakeAction()
        {
            ArenaRankLogic   ar = new ArenaRankLogic();
            List <ArenaRank> rankList;

            if (ar.TryGetRankList(m_RequestPacket.PageIndex, out rankList))
            {
                m_ResponsePacket.IsLastPage = false;
            }
            else
            {
                m_ResponsePacket.IsLastPage = true;
            }
            m_ResponsePacket.MyRank = ar.GetPlayerRank(m_UserId);
            PlayerLogic   p  = new PlayerLogic();
            HeroTeamLogic ht = new HeroTeamLogic();

            foreach (var player in rankList)
            {
                PBArenaPlayerAndTeamInfo enemy = new PBArenaPlayerAndTeamInfo();
                enemy.Rank = player.RankId;
                p.SetUser(player.PlayerId);
                enemy.PlayerInfo = new PBPlayerInfo()
                {
                    Id           = player.PlayerId,
                    Name         = p.MyPlayer.Name,
                    Level        = p.MyPlayer.Level,
                    PortraitType = p.MyPlayer.PortraitType
                };
                ht.SetUser(player.PlayerId);
                var team = ht.GetTeam();
                foreach (int hero in team)
                {
                    PBLobbyHeroInfo heroInfo = new PBLobbyHeroInfo()
                    {
                        Type = hero
                    };
                    enemy.HeroTeam.Add(heroInfo);
                }
                m_ResponsePacket.Enemies.Add(enemy);
            }
            m_ResponsePacket.PageIndex = m_RequestPacket.PageIndex;
            return(true);
        }
Ejemplo n.º 5
0
        public bool EndBattle(int enemyId, bool isWin, bool isRevenge, out int token)
        {
            int userId = m_UserId;

            token = 0;
            if (isRevenge)
            {
                SetUser(enemyId);
                AddBattleReport(userId, false, !isWin);
                SetUser(userId);
                return(true);
            }
            if (m_Arena.EnemyId <= 0)
            {
                SetUser(enemyId);
                m_Arena.EnemyId = 0;
                SetUser(userId);
                return(false);
            }

            SetUser(enemyId);
            if (m_Arena.EnemyId <= 0)
            {
                SetUser(userId);
                m_Arena.EnemyId = 0;
                return(false);
            }
            token           = GetTokenCount(isWin);
            m_Arena.EnemyId = 0;
            AddBattleReport(userId, false, !isWin);
            SetUser(userId);
            if (isWin)
            {
                ArenaRankLogic ar = new ArenaRankLogic();
                ar.SwapRank(userId, enemyId);
                m_Arena.WinCount += 1;
                PlayerAchievementLogic.GetInstance(userId).UpdateAchievement(AchievementType.PvpWinCount);
            }
            m_Arena.ArenaTokenCount += token;
            m_Arena.EnemyId          = 0;
            AddBattleReport(enemyId, true, isWin);
            PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.CompleteOfflineArena, 1);
            return(true);
        }
Ejemplo n.º 6
0
 public void SetUser(int userId)
 {
     m_UserId = userId;
     m_Arena  = CacheSet.PlayerArenaCache.FindKey(userId.ToString(), userId);
     if (m_Arena == null)
     {
         m_Arena                 = new PlayerArena();
         m_Arena.UserId          = userId;
         m_Arena.WinCount        = 0;
         m_Arena.ArenaTokenCount = 0;
         m_Arena.ChallengeCount  = GameConsts.Arena.DailyChallengeCount;
         for (int i = 0; i < GameConfigs.GetInt("Offline_Arena_Liveness_Reward_Count", 3); i++)
         {
             m_Arena.ClaimedLivenessRewardFlag.Add(false);
         }
         CacheSet.PlayerArenaCache.Add(m_Arena);
         ArenaRankLogic.AddNewPlayer(userId);
     }
 }
Ejemplo n.º 7
0
        public override bool TakeAction()
        {
            PlayerArenaLogic pa = new PlayerArenaLogic();

            pa.SetUser(m_UserId);
            m_ResponsePacket.ChallengeCount = pa.MyArena.ChallengeCount;
            int token;

            if (!pa.EndBattle(m_RequestPacket.EnemyPlayerId, m_RequestPacket.Win, m_RequestPacket.IsRevenge, out token))
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "player is not in battle";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            p.AddArenaToken(token);
            m_ResponsePacket.Me = new PBPlayerInfo()
            {
                Id         = m_UserId,
                ArenaToken = p.MyPlayer.ArenaToken
            };
            p.SetUser(m_RequestPacket.EnemyPlayerId);
            ArenaRankLogic ar = new ArenaRankLogic();

            m_ResponsePacket.MyRank = ar.GetPlayerRank(m_UserId);
            m_ResponsePacket.Win    = m_RequestPacket.Win;
            m_ResponsePacket.Enemy  = new PBArenaPlayerAndTeamInfo()
            {
                Rank = ar.GetPlayerRank(m_RequestPacket.EnemyPlayerId)
            };
            m_ResponsePacket.Enemy.PlayerInfo = new PBPlayerInfo()
            {
                Id           = m_RequestPacket.EnemyPlayerId,
                Name         = p.MyPlayer.Name,
                PortraitType = p.MyPlayer.PortraitType,
                Level        = p.MyPlayer.Level
            };

            return(true);
        }
Ejemplo n.º 8
0
        public override bool TakeAction()
        {
            ArenaRankLogic ar           = new ArenaRankLogic();
            var            matchPlayers = ar.GetMatchPlayers(m_UserId);
            PlayerLogic    p            = new PlayerLogic();

            foreach (var player in matchPlayers)
            {
                PBArenaPlayerAndTeamInfo enemy = new PBArenaPlayerAndTeamInfo();
                enemy.Rank = player.RankId;
                p.SetUser(player.PlayerId);
                enemy.PlayerInfo = new PBPlayerInfo()
                {
                    Id           = player.PlayerId,
                    Name         = p.MyPlayer.Name,
                    Level        = p.MyPlayer.Level,
                    PortraitType = p.MyPlayer.PortraitType
                };
                m_ResponsePacket.Enemies.Add(enemy);
            }
            return(true);
        }
Ejemplo n.º 9
0
        public override bool TakeAction()
        {
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_RequestPacket.EnemyPlayerId);
            ArenaRankLogic ar = new ArenaRankLogic();

            m_ResponsePacket.EnemyInfo            = new PBArenaPlayerAndTeamInfo();
            m_ResponsePacket.EnemyInfo.PlayerInfo = new PBPlayerInfo()
            {
                Id           = p.MyPlayer.Id,
                Name         = p.MyPlayer.Name,
                PortraitType = p.MyPlayer.PortraitType,
                Level        = p.MyPlayer.Level,
            };
            m_ResponsePacket.EnemyInfo.Rank = ar.GetPlayerRank(m_RequestPacket.EnemyPlayerId);
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_RequestPacket.EnemyPlayerId);
            HeroTeamLogic ht = new HeroTeamLogic();

            ht.SetUser(m_RequestPacket.EnemyPlayerId);
            GearLogic gear = new GearLogic();
            SoulLogic soul = new SoulLogic();

            foreach (int heroId in ht.GetTeam())
            {
                if (heroId == 0)
                {
                    continue;
                }
                ph.SetHero(heroId);
                Hero            heroInfo = ph.GetHeroInfo();
                PBLobbyHeroInfo pbhero   = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Level = heroInfo.HeroLv,
                    ConsciousnessLevel = heroInfo.ConsciousnessLevel,
                    ElevationLevel     = heroInfo.ElevationLevel,
                    StarLevel          = heroInfo.HeroStarLevel,
                };
                pbhero.SkillLevels.AddRange(heroInfo.SkillLevels);
                foreach (var equipedGear in heroInfo.Gears)
                {
                    gear.SetGear(equipedGear.Value);
                    PBGearInfo heroGear = new PBGearInfo()
                    {
                        Id              = gear.MyGear.Id,
                        Type            = gear.MyGear.TypeId,
                        Level           = gear.MyGear.Level,
                        StrengthenLevel = gear.MyGear.StrengthenLevel
                    };
                    pbhero.GearInfo.Add(heroGear);
                }
                foreach (var equipedSoul in heroInfo.Souls)
                {
                    soul.SetSoul(equipedSoul.Value);
                    PBSoulInfo heroSoul = new PBSoulInfo()
                    {
                        Id   = soul.MySoul.Id,
                        Type = soul.MySoul.TypeId
                    };
                    pbhero.SoulInfo.Add(heroSoul);
                }
                m_ResponsePacket.EnemyInfo.HeroTeam.Add(pbhero);
            }
            return(true);
        }