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

            pa.SetUser(m_UserId);
            ArenaRankLogic ar = new ArenaRankLogic();
            PlayerLogic    p  = new PlayerLogic();

            foreach (var report in pa.MyArena.BattleReports)
            {
                p.SetUser(report.EnemyId);
                PBArenaBattleReport pbreport = new PBArenaBattleReport()
                {
                    BattleEndTime = report.BattleTime,
                    Win           = report.IsWin,
                    IsActive      = report.IsActive
                };
                pbreport.Enemy = new PBArenaPlayerAndTeamInfo()
                {
                    Rank = ar.GetPlayerRank(report.EnemyId)
                };
                pbreport.Enemy.PlayerInfo = new PBPlayerInfo()
                {
                    Id           = report.EnemyId,
                    Name         = p.MyPlayer.Name,
                    PortraitType = p.MyPlayer.PortraitType,
                    Level        = p.MyPlayer.Level
                };
                m_ResponsePacket.Reports.Add(pbreport);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public override bool TakeAction()
        {
            PlayerArenaLogic pa = new PlayerArenaLogic();

            pa.SetUser(m_UserId);
            Dictionary <int, int> itemDict;
            int rewardMoney;

            if (!pa.GetLivenessReward(m_RequestPacket.RewardIndex, out itemDict, out rewardMoney))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "you can not get this reward";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            p.AddMoney(rewardMoney);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            pp.GetItems(itemDict, ReceiveItemMethodType.None, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            m_ResponsePacket.RewardId      = m_RequestPacket.RewardIndex;
            m_ResponsePacket.PlayerInfo    = new PBPlayerInfo()
            {
                Id    = p.MyPlayer.Id,
                Money = p.MyPlayer.Money
            };
            return(true);
        }
Ejemplo n.º 3
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.º 4
0
        public override bool TakeAction()
        {
            var         allActivities = CacheSet.ActivityTable.GetAllData();
            PlayerLogic p             = new PlayerLogic();

            p.SetUser(m_UserId);
            foreach (var activity in allActivities)
            {
                PBActivityInfo activityInfo = new PBActivityInfo();
                activityInfo.Id     = activity.Id;
                activityInfo.Status = LobbyServerUtils.GetActivityStatus(activity, p.MyPlayer.Level);
                if (activityInfo.Status == (int)ActivityStatusType.Hidden)
                {
                    continue;
                }
                switch ((ActivityType)activity.Id)
                {
                case ActivityType.TurnOverChess:
                    PlayerChessLogic pc = new PlayerChessLogic();
                    pc.SetUser(m_UserId);
                    activityInfo.Progress   = pc.MyChess.Count == 0 ? 0 : 1;
                    activityInfo.CountLimit = 1;
                    break;

                case ActivityType.OfflineArena:
                    PlayerArenaLogic pa = new PlayerArenaLogic();
                    pa.SetUser(m_UserId);
                    activityInfo.Progress   = pa.MyArena.ChallengeCount;
                    activityInfo.CountLimit = GameConsts.Arena.DailyChallengeCount;
                    break;

                case ActivityType.GearFoundry:
                    PlayerFoundryLogic pf = new PlayerFoundryLogic();
                    pf.SetUser(m_UserId);
                    activityInfo.Progress   = pf.GetProgress();
                    activityInfo.CountLimit = 1;
                    break;

                case ActivityType.CosmosCrack:
                    PlayerCosmosCrackLogic pcc = new PlayerCosmosCrackLogic();
                    pcc.SetUser(m_UserId);
                    var cosmosInfo = pcc.GetCosmosCrackInstanceInfo();
                    activityInfo.Progress   = cosmosInfo == null ? 0 : cosmosInfo.PassedRoundCount;
                    activityInfo.CountLimit = cosmosInfo == null ? 0 : GameConfigs.GetInt("Cosmos_Crack_Round_Limit", 10);
                    break;

                default:
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "invalid activity type";
                    return(false);
                }
                m_ResponsePacket.ActivityInfo.Add(activityInfo);
            }
            return(true);
        }
Ejemplo n.º 5
0
        public override bool TakeAction()
        {
            PlayerArenaLogic pa = new PlayerArenaLogic();

            pa.SetUser(m_UserId);
            if (!pa.StartBattle(m_RequestPacket.EnemyPlayerId, m_RequestPacket.MyRank, m_RequestPacket.EnemyRank, m_RequestPacket.IsRevenge))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You can not enter battle";
                return(false);
            }
            return(true);
        }
        public void Execute()
        {
            var arenaData       = CacheSet.ArenaRankCache.FindAll();
            PlayerArenaLogic pa = new PlayerArenaLogic();

            foreach (var arena in arenaData)
            {
                pa.SetUser(arena.PlayerId);
                pa.ResetChallengeCount();
                if (DateTime.UtcNow.DayOfWeek == DayOfWeek.Sunday)
                {
                    pa.ResetLivenessReward();
                }
            }
        }
Ejemplo n.º 7
0
 protected override void OnDisconnected(GameSession session)
 {
     if (session.UserId != 0)
     {
         PlayerLogic p = new PlayerLogic();
         p.SetUser(session.UserId);
         p.OffLine();
         PVPLogic.StopSingleMatch(session.UserId);
         PlayerArenaLogic pa = new PlayerArenaLogic();
         pa.SetUser(session.UserId);
         if (pa.MyArena.EnemyId > 0)
         {
             int token;
             pa.EndBattle(pa.MyArena.EnemyId, false, false, out token);
         }
     }
     base.OnDisconnected(session);
     TraceLog.ReleaseWrite("Client '{0}' disconnect OK.", session.RemoteAddress);
 }
Ejemplo n.º 8
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);
        }