Esempio n. 1
0
        public override bool TakeAction()
        {
            PlayerChessLogic playerChess = new PlayerChessLogic();

            playerChess.SetUser(m_UserId);
            Transaction t = new Transaction();

            t.DumpEntity(playerChess.MyChess);
            if (playerChess.MyChess.HP.ContainsKey(playerChess.MyChess.MyTeam[0]) && playerChess.MyChess.HP[playerChess.MyChess.MyTeam[0]] == 0)
            {
                m_ResponsePacket.Success = false;
                return(true);
            }
            foreach (int heroId in playerChess.MyChess.MyTeam)
            {
                if (playerChess.MyChess.HP.ContainsKey(heroId) && playerChess.MyChess.HP[heroId] == 0)
                {
                    playerChess.MyChess.MyTeam.Remove(heroId);
                }
            }
            if (playerChess.MyChess.MyTeam.Count == 0)
            {
                t.RollBack();
                m_ResponsePacket.Success = false;
                return(true);
            }
            m_ResponsePacket.HeroTeam = new PBHeroTeamInfo();
            m_ResponsePacket.HeroTeam.HeroType.AddRange(playerChess.MyChess.MyTeam);
            m_ResponsePacket.Success        = true;
            m_ResponsePacket.InstanceTypeId = 1;
            return(true);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public override bool TakeAction()
        {
            PlayerChessLogic playerChess = new PlayerChessLogic();

            playerChess.SetUser(m_UserId);
            if (!RefreshData(playerChess))
            {
                return(false);
            }

            if (m_RequestPacket.HasEnemyAnger)
            {
                playerChess.SetEnemyAnger(m_RequestPacket.FieldId, m_RequestPacket.EnemyAnger);
            }
            if (m_RequestPacket.EnemyHeroesHP.Count > 0)
            {
                playerChess.SetEnemyStatus(m_RequestPacket.FieldId, m_RequestPacket.EnemyHeroesHP);
            }
            if (m_RequestPacket.HasMyAnger)
            {
                playerChess.SetMyAnger(m_RequestPacket.MyAnger);
            }
            if (m_RequestPacket.MyHeroesStatus.Count > 0)
            {
                playerChess.SetMyHeroStatus(m_RequestPacket.MyHeroesStatus);
                m_ResponsePacket.MyHeroesStatus.AddRange(m_RequestPacket.MyHeroesStatus);
            }
            if (m_RequestPacket.HasBattleWon && !m_RequestPacket.BattleWon)
            {
                m_ResponsePacket.Success = true;
                return(true);
            }
            GetReward(playerChess);
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_UserId);
            player.MyPlayer.Money      += m_GotMoney;
            player.MyPlayer.Coin       += m_GotCoin;
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Coin = player.MyPlayer.Coin, Money = player.MyPlayer.Money
            };
            return(true);
        }
Esempio n. 4
0
        public override bool TakeAction()
        {
            PlayerChessLogic playerChess = new PlayerChessLogic();

            playerChess.SetUser(m_UserId);
            if (m_RequestPacket.IsReset)
            {
                if (!playerChess.Reset())
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "have not token";
                    return(false);
                }
            }
            if (playerChess.MyChess.LastResetTime < DateTime.Today)
            {
                playerChess.ResetToken();
            }
            SetResponseData(playerChess.MyChess);
            return(true);
        }
Esempio n. 5
0
        public override bool TakeAction()
        {
            PlayerChessLogic playerChess = new PlayerChessLogic();

            playerChess.SetUser(m_UserId);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId);
            foreach (int heroId in m_RequestPacket.HeroTeamInfo.HeroType)
            {
                playerHero.SetHero(heroId);
                if (playerHero.GetHeroInfo() == null)
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong heroId";
                    return(false);
                }
            }
            playerChess.ChangeTeam(m_RequestPacket.HeroTeamInfo.HeroType);
            m_ResponsePacket.HeroTeamInfo = new PBHeroTeamInfo();
            m_ResponsePacket.HeroTeamInfo.HeroType.AddRange(m_RequestPacket.HeroTeamInfo.HeroType);
            return(true);
        }
Esempio n. 6
0
        public override bool TakeAction()
        {
            PlayerChessLogic playerChess = new PlayerChessLogic();

            playerChess.SetUser(m_UserId);
            if (!(playerChess.MyChess.ChessBoard[m_RequestPacket.ChessFieldIndex] is BattleChessField))
            {
                m_ResponsePacket.Success = false;
                return(true);
            }
            BattleChessField targetField = playerChess.MyChess.ChessBoard[m_RequestPacket.ChessFieldIndex] as BattleChessField;

            m_ResponsePacket.Anger = targetField.EnemyAnger;
            PlayerLogic player = new PlayerLogic();

            player.SetUser(targetField.EnemyPlayerId);
            m_ResponsePacket.EnemyInfo = new PBPlayerInfo()
            {
                Id    = player.MyPlayer.Id,
                Name  = player.MyPlayer.Name,
                Level = player.MyPlayer.Level,
                Might = player.MyPlayer.Might,
            };
            GearLogic gearlogic = new GearLogic();
            int       i         = 0;

            foreach (var hero in targetField.EnemyPlayerHeroTeam)
            {
                PBLobbyHeroInfo enemyHero = new PBLobbyHeroInfo()
                {
                    Type               = hero.HeroType,
                    Level              = hero.HeroLv,
                    StarLevel          = hero.HeroStarLevel,
                    ConsciousnessLevel = hero.ConsciousnessLevel,
                    ElevationLevel     = hero.ElevationLevel,
                };
                enemyHero.SkillLevels.AddRange(hero.SkillLevels);

                foreach (var gear in hero.Gears)
                {
                    gearlogic.SetGear(gear.Value);
                    PBGearInfo enemyGear = new PBGearInfo()
                    {
                        Id    = gearlogic.MyGear.Id,
                        Type  = gearlogic.MyGear.TypeId,
                        Level = gearlogic.MyGear.Level
                    };
                    enemyHero.GearInfo.Add(enemyGear);
                }
                if (targetField.EnemyHeroHP.Count > i)
                {
                    PBLobbyHeroStatus enemyStatus = new PBLobbyHeroStatus()
                    {
                        Type  = hero.HeroType,
                        CurHP = targetField.EnemyHeroHP[i]
                    };
                    m_ResponsePacket.HeroesStatus.Add(enemyStatus);
                }
                m_ResponsePacket.HeroesInfo.Add(enemyHero);
                m_ResponsePacket.ChessFieldIndex = m_RequestPacket.ChessFieldIndex;
                i++;
            }
            m_ResponsePacket.Success = true;
            return(true);
        }
Esempio n. 7
0
        public override bool TakeAction()
        {
            PlayerChessLogic chess = new PlayerChessLogic();

            chess.SetUser(m_UserId);
            int coin;
            int money;
            int starEnergy;
            Dictionary <int, int> rewardItems = chess.BombAll(out coin, out money, out starEnergy);

            if (rewardItems == null)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Money not enough";
                return(false);
            }
            chess.MyChess.GotCoin            += coin;
            m_ResponsePacket.RewardCoins      = coin;
            chess.MyChess.GotMoney           += money;
            m_ResponsePacket.RewardMoney      = money;
            chess.MyChess.GotStarEnergy      += starEnergy;
            m_ResponsePacket.RewardStarEnergy = starEnergy;
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            package.GetItems(rewardItems, ReceiveItemMethodType.TurnOverChess, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            foreach (var gear in m_ResponsePacket.ReceivedItems.GearInfo)
            {
                chess.MyChess.GotGears.Add(gear.Id);
            }
            foreach (var inventory in m_ResponsePacket.ReceivedItems.ItemInfo)
            {
                if (chess.MyChess.GotItems.ContainsKey(inventory.Type))
                {
                    chess.MyChess.GotItems[inventory.Type] += inventory.Count;
                }
                else
                {
                    chess.MyChess.GotItems.Add(inventory.Type, inventory.Count);
                }
            }
            foreach (var soul in m_ResponsePacket.ReceivedItems.SoulInfo)
            {
                chess.MyChess.GotSouls.Add(soul.Id);
            }
            foreach (var epigraph in m_ResponsePacket.ReceivedItems.EpigraphInfo)
            {
                chess.MyChess.GotEpigraphs.Add(epigraph.Type);
            }
            m_ResponsePacket.Success = true;
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_UserId);
            player.MyPlayer.Coin       += coin;
            player.MyPlayer.Money      += money;
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Coin = player.MyPlayer.Coin, Money = player.MyPlayer.Money
            };
            return(true);
        }