コード例 #1
0
ファイル: Action1043.cs プロジェクト: JoeChen999/scut
        public override bool TakeAction()
        {
            var pdq         = PlayerDailyQuestLogic.GetInstance(m_UserId);
            var RewardItems = pdq.CompleteDailyQuest(m_RequestPacket.QuestId);

            if (RewardItems == null)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You can not claim this achievement";
                return(false);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            pp.GetItems(RewardItems, ReceiveItemMethodType.None, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);

            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id     = p.MyPlayer.Id,
                Exp    = p.MyPlayer.Exp,
                Level  = p.MyPlayer.Level,
                Coin   = p.MyPlayer.Coin,
                Money  = p.MyPlayer.Money,
                Spirit = p.MyPlayer.Spirit
            };
            m_ResponsePacket.QuestId = m_RequestPacket.QuestId;
            return(true);
        }
コード例 #2
0
        public static PlayerDailyQuestLogic GetInstance(int userId)
        {
            if (m_Instances.ContainsKey(userId) && m_Instances[userId] != null)
            {
                return(m_Instances[userId]);
            }
            PlayerDailyQuestLogic pdq = new PlayerDailyQuestLogic(userId);

            m_Instances.Add(userId, pdq);
            return(pdq);
        }
コード例 #3
0
 public bool GetReward(int level)
 {
     if (!m_Foundry.CanReceiveRewards[level] || m_Foundry.HasReceivedRewards[level])
     {
         return(false);
     }
     m_Foundry.HasReceivedRewards[level] = true;
     m_Foundry.CanReceiveRewards[level]  = false;
     PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.ClaimGearFoundryReward, 1);
     return(true);
 }
コード例 #4
0
        public CacheDictionary <int, int> LeaveInstance(int instanceId)
        {
            if (m_CosmosCrack.PassedRoundCount >= GameConfigs.GetInt("Cosmos_Crack_Round_Limit", 10) || !m_CosmosCrack.ChosenInstance.ContainsKey(instanceId))
            {
                return(null);
            }
            var retval = m_CosmosCrack.ChosenInstance[instanceId].RewardItem;

            RefreshCosmosCrackInstance();
            m_CosmosCrack.PassedRoundCount += 1;
            PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.CompleteCosmosCrack, 1);
            return(retval);
        }
コード例 #5
0
        private void SetDailyQuestInfo()
        {
            var pdq = PlayerDailyQuestLogic.GetInstance(m_UserId);

            m_ResponsePacket.DailyQuestInfo = new PBDailyQuestInfo();
            foreach (var trackingQuest in pdq.TrackingDailyQuests)
            {
                m_ResponsePacket.DailyQuestInfo.TrackingDailyQuests.Add(new PBTrackingDailyQuest()
                {
                    QuestId       = trackingQuest.Key,
                    ProgressCount = trackingQuest.Value.Progress
                });
            }
            m_ResponsePacket.DailyQuestInfo.CompletedDailyQuests.AddRange(pdq.CompletedDailyQuests);
        }
コード例 #6
0
 public void InstanceCompleted(int instanceId, int stars)
 {
     if (m_InstanceProgress.Progress.ContainsKey(instanceId))
     {
         if (m_InstanceProgress.Progress[instanceId] < stars)
         {
             m_InstanceProgress.Progress[instanceId] = stars;
         }
     }
     else
     {
         m_InstanceProgress.Progress.Add(instanceId, stars);
         PlayerAchievementLogic.GetInstance(m_InstanceProgress.UserId).UpdateAchievement(AchievementType.InstanceCompletedCount);
     }
     PlayerDailyQuestLogic.GetInstance(m_InstanceProgress.UserId).UpdateDailyQuest(DailyQuestType.CompleteInstance, 1);
 }
コード例 #7
0
ファイル: PlayerArenaLogic.cs プロジェクト: JoeChen999/scut
        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);
        }
コード例 #8
0
ファイル: Action1044.cs プロジェクト: JoeChen999/scut
        public override bool TakeAction()
        {
            PlayerDailyQuestLogic pdq = PlayerDailyQuestLogic.GetInstance(m_UserId);

            if (pdq.ResetDailyQuestInfo())
            {
                m_ResponsePacket.DailyQuestInfo = new PBDailyQuestInfo();
                foreach (var trackingQuest in pdq.TrackingDailyQuests)
                {
                    m_ResponsePacket.DailyQuestInfo.TrackingDailyQuests.Add(new PBTrackingDailyQuest()
                    {
                        QuestId       = trackingQuest.Key,
                        ProgressCount = trackingQuest.Value.Progress
                    });
                }
                m_ResponsePacket.DailyQuestInfo.CompletedDailyQuests.AddRange(pdq.CompletedDailyQuests);
            }
            return(true);
        }
コード例 #9
0
 public void DealPvpResult(int result, int score)
 {
     if (m_Pvp.RemainingCount > 0)
     {
         m_Pvp.RemainingCount -= 1;
     }
     if (m_Pvp.SinglePvpScore + score <= 0)
     {
         m_Pvp.SinglePvpScore = 0;
     }
     else
     {
         m_Pvp.SinglePvpScore += score;
     }
     m_Pvp.RoomId       = 0;
     m_Pvp.RoomServerId = 0;
     if (result == 1)
     {
         PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.CompleteSinglePvp, 1);
     }
 }
コード例 #10
0
ファイル: PlayerFriendsLogic.cs プロジェクト: JoeChen999/scut
        public bool SendEnergy(int friendId)
        {
            int userId = m_UserId;

            if (m_Friends.SendCount >= GameConsts.Social.MaxSendCount)
            {
                return(false);
            }
            if (!m_Friends.Friends.ContainsKey(friendId) || m_Friends.Friends[friendId].CanSendEnergy == false)
            {
                return(false);
            }
            SetUser(friendId);
            if (!m_Friends.Friends.ContainsKey(userId))
            {
                return(false);
            }
            m_Friends.Friends[userId].CanReceiveEnergy = true;
            SetUser(userId);
            m_Friends.Friends[friendId].CanSendEnergy = false;
            m_Friends.SendCount += 1;
            PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.GiftEnergyToFriend, 1);
            return(true);
        }
コード例 #11
0
ファイル: Action1028.cs プロジェクト: JoeChen999/scut
        public override bool TakeAction()
        {
            InstanceProgressLogic ip = new InstanceProgressLogic();

            ip.SetUser(m_UserId);
            if (!(ip.GetInstanceProgress()).ContainsKey(m_RequestPacket.InstanceId))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not passed this instance";
                return(false);
            }
            PlayerInstanceLogic pi = new PlayerInstanceLogic();

            pi.SetUser(m_UserId);
            CacheDictionary <int, int> dropItems = new CacheDictionary <int, int>();

            for (int i = 0; i < m_RequestPacket.Count; i++)
            {
                PBInstanceDrop    instanceDrop = new PBInstanceDrop();
                List <PBDropInfo> dropList     = new List <PBDropInfo>();
                List <PBDropInfo> dropPack;
                var dropDict = pi.GenerateDropList(m_RequestPacket.InstanceId, true, out dropPack);
                GameUtils.MergeItemDict(dropItems, dropDict);
                foreach (var dropItem in dropDict)
                {
                    PBDropInfo item = new PBDropInfo()
                    {
                        DropId    = dropItem.Key,
                        DropCount = dropItem.Value
                    };
                    instanceDrop.Items.Add(item);
                }
                m_ResponsePacket.Drops.Add(instanceDrop);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(dropItems))
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "Package full";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            int  energy = PlayerInstanceLogic.GetInstanceEnergy(m_RequestPacket.InstanceId);
            long nextRecoverTime;

            if (!p.DeductEnergy(energy * m_RequestPacket.Count, out nextRecoverTime))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough energy";
                return(false);
            }
            PBReceivedItems receivedItems;

            pp.GetItems(dropItems, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            DTInstance instanceData = PlayerInstanceLogic.GetInstanceData(m_RequestPacket.InstanceId);

            p.AddCoin(instanceData.Coin * m_RequestPacket.Count);
            p.AddExp(instanceData.PlayerExp * m_RequestPacket.Count);
            m_ResponsePacket.Count      = m_RequestPacket.Count;
            m_ResponsePacket.InstanceId = m_RequestPacket.InstanceId;
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id     = m_UserId,
                Coin   = p.MyPlayer.Coin,
                Exp    = p.MyPlayer.Exp,
                Level  = p.MyPlayer.Level,
                Energy = p.MyPlayer.Energy,
                NextEnergyRecoveryTime = nextRecoverTime
            };
            HeroTeamLogic heroTeam = new HeroTeamLogic();

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

            playerHero.SetUser(m_UserId);
            foreach (int heroId in heroTeam.MyHeroTeam.Team)
            {
                if (heroId == 0)
                {
                    continue;
                }
                //playerHero.SetHero(heroId).AddExp(instanceData.HeroExp);
                m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo()
                {
                    Type  = heroId,
                    Exp   = playerHero.MyHeros.Heros[heroId].HeroExp,
                    Level = playerHero.MyHeros.Heros[heroId].HeroLv
                });
            }
            PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.CleanOutInstance, m_RequestPacket.Count);
            return(true);
        }
コード例 #12
0
        private bool RefreshData(PlayerChessLogic playerChess)
        {
            int         costFieldCount     = 0;
            int         freeFieldCount     = 0;
            int         totalCostFreeCount = 0;
            Transaction t = new Transaction();

            t.DumpEntity(playerChess.MyChess);
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            foreach (var field in m_RequestPacket.ModifiedChessField)
            {
                var oldField = playerChess.MyChess.ChessBoard[field.Index];
                int oldColor = oldField.Color == ChessFieldColor.Empty || oldField.Color == ChessFieldColor.EmptyGray || oldField.Color == ChessFieldColor.RewardGray ?
                               (int)ChessFieldColor.EmptyGray : (int)oldField.Color;
                if (field.Color != oldColor)
                {
                    t.RollBack();
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "illegal params";
                    return(false);
                }
                if (field.Color == (int)ChessFieldColor.EmptyGray)
                {
                    RewardChessField oldRewardField = oldField as RewardChessField;
                    if (!oldRewardField.IsOpened && field.IsOpened)
                    {
                        if (!oldRewardField.IsFree)
                        {
                            if (m_RequestPacket.ModifiedChessField.Count == 1)
                            {
                                costFieldCount += 1;
                            }
                            else
                            {
                                freeFieldCount += 1;
                            }
                        }
                        else
                        {
                            freeFieldCount += 1;
                        }
                        m_GotCoin       += oldRewardField.RewardCoin;
                        m_GotMoney      += oldRewardField.RewardMoney;
                        m_GotStarEnergy += oldRewardField.RewardStarEnergy;
                        foreach (var reward in oldRewardField.RewardItems)
                        {
                            if (m_GotItems.ContainsKey(reward.Key))
                            {
                                m_GotItems[reward.Key] += reward.Value;
                            }
                            else
                            {
                                m_GotItems.Add(reward);
                            }
                        }
                        PlayerPackageLogic pp = new PlayerPackageLogic();
                        pp.SetUser(m_UserId);
                        if (!pp.CheckPackageSlot(m_GotItems))
                        {
                            ErrorCode = (int)ErrorType.PackageSlotFull;
                            ErrorInfo = "item count if full";
                            return(false);
                        }
                        playerChess.DeductOpenCount();
                    }
                    oldRewardField.IsFree   = field.IsFree;
                    oldRewardField.IsOpened = field.IsOpened;
                    oldRewardField.ParentId = field.Parent;
                }
                else
                {
                    BattleChessField oldBattleField = oldField as BattleChessField;
                    if (!oldBattleField.IsOpened && field.IsOpened)
                    {
                        m_ResponsePacket.FreeCount = oldBattleField.Count;
                        costFieldCount            += 1;
                        oldBattleField.IsOpened    = field.IsOpened;
                        PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.WinTurnOverChessBattle, 1);
                    }
                    else
                    {
                        if (field.FreeCount < 0 || field.FreeCount > oldBattleField.Count)
                        {
                            ErrorCode = (int)ErrorType.CannotOpenChance;
                            ErrorInfo = "illegal params";
                            return(false);
                        }
                        totalCostFreeCount  += oldBattleField.Count - field.FreeCount;
                        oldBattleField.Count = field.FreeCount;
                    }
                    oldBattleField.ChildrenId.AddRange(field.Children);
                }
            }
            if (freeFieldCount != totalCostFreeCount)
            {
                t.RollBack();
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "illegal params";
                return(false);
            }
            if (costFieldCount > 1)
            {
                t.RollBack();
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "illegal params";
                return(false);
            }
            playerChess.MyChess.Count -= costFieldCount;
            return(true);
        }