示例#1
0
        public override bool TakeAction()
        {
            DTInstanceStory instanceData = CacheSet.InstanceStoryTable.GetData(m_RequestPacket.InstanceId);
            PlayerHeroLogic ph           = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(instanceData.HeroId);
            if (ph.GetHeroInfo() == null)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You can not enter this instance";
                return(false);
            }
            PlayerStoryInstanceLogic ps = new PlayerStoryInstanceLogic();

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

            foreach (int dropId in instanceData.DropIds)
            {
                var itemDict = ps.GetDropItems(dropId, m_RequestPacket.StarLevel);
                dropItems = GameUtils.MergeItemDict(dropItems, itemDict) as CacheDictionary <int, int>;
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            pp.GetItems(dropItems, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            m_ResponsePacket.Count         = ps.GetCount();
            m_ResponsePacket.StarLevel     = m_RequestPacket.StarLevel;
            return(true);
        }
示例#2
0
        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);
        }
示例#3
0
        public override bool TakeAction()
        {
            PlayerInstanceLogic pi = new PlayerInstanceLogic();

            pi.SetUser(m_UserId);
            var dropDict = pi.OpenInInstanceChest(m_RequestPacket.ChestIndex);

            foreach (var goods in dropDict)
            {
                m_ResponsePacket.GoodsInfo.Add(new PBItemInfo()
                {
                    Type  = goods.Key,
                    Count = goods.Value
                });
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PBReceivedItems receivedItems;

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

            p.SetUser(m_UserId);
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id             = p.MyPlayer.Id,
                Coin           = p.MyPlayer.Coin,
                Money          = p.MyPlayer.Money,
                Spirit         = p.MyPlayer.Spirit,
                MeridianEnergy = p.MyPlayer.StarEnergy
            };
            return(true);
        }
        private List <PBKeyValuePair> ProcessClaimReward(List <PBKeyValuePair> Params, out PBReceivedItems receivedItems, out PBPlayerInfo playerInfo, out List <PBLobbyHeroInfo> heroInfos)
        {
            receivedItems = null;
            playerInfo    = null;
            heroInfos     = null;
            int dayCnt = CacheSet.OperationActivitySevenDayTable.Count;

            if (DateTime.UtcNow.Date == new DateTime(m_SevenDayCheckIn.LastClaimedTime).Date || m_SevenDayCheckIn.ClaimedCount >= dayCnt)
            {
                return(null);
            }
            List <PBKeyValuePair> retval = new List <PBKeyValuePair>();

            retval.AddRange(Params);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_SevenDayCheckIn.UserId);
            var reward = CacheSet.OperationActivitySevenDayTable.GetData(m_SevenDayCheckIn.ClaimedCount + 1);

            pp.GetItems(new Dictionary <int, int>()
            {
                { reward.RewardId, reward.RewardCount }
            }, ReceiveItemMethodType.None, out receivedItems);
            m_SevenDayCheckIn.ClaimedCount   += 1;
            m_SevenDayCheckIn.LastClaimedTime = DateTime.UtcNow.Ticks;
            retval.Add(new PBKeyValuePair()
            {
                Key = "ClaimedCnt", Value = m_SevenDayCheckIn.ClaimedCount.ToString()
            });
            retval.Add(new PBKeyValuePair()
            {
                Key = "HasClaimed", Value = "true"
            });
            return(retval);
        }
示例#5
0
        public override bool TakeAction()
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);

            if (!pp.DeductInventory(new ItemListItem()
            {
                Id = m_RequestPacket.ItemId, Count = 1
            }))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough item";
                return(false);
            }
            int exp = int.Parse(CacheSet.ItemTable.GetData(m_RequestPacket.ItemId).FunctionParams);

            ph.AddSkillExp(m_RequestPacket.SkillIndex, exp);
            var hero = ph.GetHeroInfo();

            m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
            {
                Type = hero.HeroType
            };
            m_ResponsePacket.HeroInfo.SkillExps.AddRange(hero.SkillExps);
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = m_RequestPacket.ItemId,
                Count = pp.MyPackage.Inventories[m_RequestPacket.ItemId]
            };
            return(true);
        }
示例#6
0
        public override bool TakeAction()
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            int pieceId = pp.UpgradeEpigraph(m_RequestPacket.Id);

            if (pieceId == -1)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You can not upgrade this epigraph";
                return(false);
            }
            m_ResponsePacket.EpigraphInfo = new PBEpigraphInfo()
            {
                Type  = m_RequestPacket.Id,
                Level = pp.MyPackage.Epigraphs[m_RequestPacket.Id]
            };
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = pieceId,
                Count = pp.MyPackage.Inventories[pieceId]
            };
            return(true);
        }
示例#7
0
        public ItemListItem OpenMail(int Id)
        {
            if (!m_Mails.Mails.ContainsKey(Id))
            {
                return(null);
            }
            if (m_Mails.Mails[Id].ExpireTime < DateTime.UtcNow.Ticks)
            {
                return(null);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            ItemListItem reward = new ItemListItem();

            reward.Id    = m_Mails.Mails[Id].AttachedId;
            reward.Count = m_Mails.Mails[Id].AttachedCount;
            if (!pp.CheckPackageSlot(new Dictionary <int, int>()
            {
                { reward.Id, reward.Count }
            }))
            {
                return(null);
            }
            m_Mails.Mails.Remove(Id);
            return(reward);
        }
        private void InitGearLevelAchievementProgress(TrackingAchievement achievement)
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            int       progress = 0;
            GearLogic g        = new GearLogic();

            foreach (var hero in ph.GetHeroList())
            {
                foreach (var gear in hero.Value.Gears)
                {
                    g.SetGear(gear.Value);
                    if (g.MyGear.Level >= achievement.Params[0])
                    {
                        progress++;
                    }
                }
            }
            foreach (var gear in pp.MyPackage.Gears)
            {
                g.SetGear(gear.Key);
                if (g.MyGear.Level >= achievement.Params[0])
                {
                    progress++;
                }
            }
            achievement.Progress = progress;
        }
示例#9
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);
        }
示例#10
0
        public List <PBDropInfo> EnterInstance(int instanceId)
        {
            if (m_InstanceDrop != null)
            {
                CacheSet.InstanceDropCache.Delete(m_InstanceDrop);
            }
            List <PBDropInfo> dropInfo;

            m_InstanceDrop            = new PlayerInstanceDrop();
            m_InstanceDrop.UserId     = m_UserId;
            m_InstanceDrop.InstanceId = instanceId;
            DTInstance instanceData = CacheSet.InstanceTable.GetData(instanceId);

            m_InstanceDrop.ChestList.AddRange(instanceData.InInstanceChests);
            m_InstanceDrop.DropList = GenerateDropList(instanceId, false, out dropInfo);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(m_InstanceDrop.DropList))
            {
                return(null);
            }
            CacheSet.InstanceDropCache.Add(m_InstanceDrop);
            return(dropInfo);
            //RedisConnectionPool.Process(c => c.Expire("$Genesis.GameServer.LobbyServer.PlayerInstanceDrop", 3600));
        }
示例#11
0
        public override bool TakeAction()
        {
            var heroData = CacheSet.HeroTable.GetData(m_RequestPacket.HeroId);
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            ItemListItem item = new ItemListItem();

            item.Id    = heroData.StarLevelUpItemId;
            item.Count = heroData.StarLevelUpItemCount[0];
            if (!package.DeductInventory(item))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "you have not enough item";
                return(false);
            }
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            ph.AddNewHero(m_RequestPacket.HeroId, ReceiveItemMethodType.HeroPieceCompose);
            var heroInfo = ph.GetHeroInfo();

            m_ResponsePacket.NewHero = new PBLobbyHeroInfo()
            {
                Type               = heroInfo.HeroType,
                Level              = heroInfo.HeroLv,
                ElevationLevel     = heroInfo.ElevationLevel,
                ConsciousnessLevel = heroInfo.ConsciousnessLevel,
                Exp       = heroInfo.HeroExp,
                StarLevel = heroInfo.HeroStarLevel
            };
            return(true);
        }
示例#12
0
        public CacheDictionary <int, int> CompleteDailyQuest(int id)
        {
            var aData             = CacheSet.DailyQuestTable.GetData(id);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(aData.RewardItems))
            {
                return(null);
            }
            if (aData == null)
            {
                TraceLog.WriteError("DataTable Error: can not find Id:" + id.ToString());
                return(null);
            }
            if (!m_DailyQuestInfo.TrackingDailyQuests.ContainsKey(id))
            {
                TraceLog.WriteError("You don not have this quest, Id:" + id.ToString());
                return(null);
            }
            var completedQuest = m_DailyQuestInfo.TrackingDailyQuests[id];

            if (completedQuest.Progress < completedQuest.RequiredProgress)
            {
                TraceLog.WriteError("You have not completed this achievement, Id:" + id.ToString());
                return(null);
            }
            m_DailyQuestInfo.CompletedDailyQuests.Add(id);
            m_DailyQuestInfo.TrackingDailyQuests.Remove(id);
            return(aData.RewardItems);
        }
示例#13
0
        private void GetInstanceReward(PlayerInstanceLogic instance)
        {
            int         instanceId = instance.MyInstance.InstanceId;
            PlayerLogic player     = new PlayerLogic();

            player.SetUser(m_UserId);
            long nextRecoverTime;

            if (!m_RequestPacket.Win)
            {
                int feedbackEnergy = PlayerInstanceLogic.GetFeedBackEnergy(instanceId);
                player.AddEnergy(feedbackEnergy, out nextRecoverTime);
                m_ResponsePacket.PlayerInfo        = new PBPlayerInfo();
                m_ResponsePacket.PlayerInfo.Energy = player.MyPlayer.Energy;
                m_ResponsePacket.PlayerInfo.NextEnergyRecoveryTime = nextRecoverTime;
                return;
            }
            DTInstance instanceData = PlayerInstanceLogic.GetInstanceData(instanceId);

            player.MyPlayer.Coin += instanceData.Coin;
            player.AddExp(instanceData.PlayerExp);
            m_ResponsePacket.PlayerInfo       = new PBPlayerInfo();
            m_ResponsePacket.PlayerInfo.Id    = player.MyPlayer.Id;
            m_ResponsePacket.PlayerInfo.Coin  = player.MyPlayer.Coin;
            m_ResponsePacket.PlayerInfo.Exp   = player.MyPlayer.Exp;
            m_ResponsePacket.PlayerInfo.Level = player.MyPlayer.Level;
            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,
                    Might = playerHero.MyHeros.Heros[heroId].Might,
                });
            }
            m_ResponsePacket.InstanceType = instance.MyInstance.InstanceId;
            CacheDictionary <int, int> dropDict = instance.GetDropList();
            PlayerPackageLogic         package  = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            package.GetItems(dropDict, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
        }
示例#14
0
        public override bool TakeAction()
        {
            GearLogic gear = new GearLogic();

            gear.SetGear(m_RequestPacket.GearId);
            int materialId             = CacheSet.GearTable.GetData(gear.MyGear.TypeId).StrengthenItemId;
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            if (!package.DeductInventory(new ItemListItem()
            {
                Id = materialId, Count = 1
            }))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Not enough material";
                return(false);
            }
            if (!gear.Strengthen(m_UserId))
            {
                m_ResponsePacket.ItemInfo = new PBItemInfo()
                {
                    Type  = materialId,
                    Count = package.MyPackage.Inventories[materialId]
                };
                m_ResponsePacket.LevelUpedGear = null;
                m_ResponsePacket.HeroInfo      = null;
                return(true);
            }

            if (m_RequestPacket.HeroType > 0)
            {
                PlayerHeroLogic ph = new PlayerHeroLogic();
                ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
                ph.RefreshMight();
                var heroInfo = ph.GetHeroInfo();
                m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Might = heroInfo.Might
                };
            }
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = materialId,
                Count = package.MyPackage.Inventories[materialId]
            };
            m_ResponsePacket.LevelUpedGear = new PBGearInfo()
            {
                Id              = m_RequestPacket.GearId,
                Type            = gear.MyGear.TypeId,
                Level           = gear.MyGear.Level,
                StrengthenLevel = gear.MyGear.StrengthenLevel
            };
            return(true);
        }
示例#15
0
        public override bool TakeAction()
        {
            PlayerMailLogic pm = new PlayerMailLogic();

            pm.SetUser(m_UserId);
            Dictionary <int, int> itemReward = new Dictionary <int, int>();
            PlayerLogic           p          = new PlayerLogic();

            p.SetUser(m_UserId);
            m_ResponsePacket.AllSuccessful = true;
            foreach (int id in m_RequestPacket.OpenEmailIds)
            {
                var reward = pm.OpenMail(id);
                if (reward == null)
                {
                    m_ResponsePacket.AllSuccessful = false;
                    continue;
                }
                else
                {
                    m_ResponsePacket.OpenedEmailIds.Add(id);
                }
                if (reward.Id < GameConsts.MinGearId)
                {
                    GetPlayerReward(reward, p);
                }
                else
                {
                    if (itemReward.ContainsKey(reward.Id))
                    {
                        itemReward[reward.Id] += reward.Count;
                    }
                    else
                    {
                        itemReward.Add(reward.Id, reward.Count);
                    }
                }
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            pp.GetItems(itemReward, ReceiveItemMethodType.None, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            m_ResponsePacket.PlayerInfo    = new PBPlayerInfo()
            {
                Id             = m_UserId,
                Coin           = p.MyPlayer.Coin,
                Money          = p.MyPlayer.Money,
                Energy         = p.MyPlayer.Energy,
                MeridianEnergy = p.MyPlayer.StarEnergy
            };
            return(true);
        }
示例#16
0
        public override bool TakeAction()
        {
            PlayerEpigraphLogic pe = new PlayerEpigraphLogic();

            pe.SetUser(m_UserId);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (m_RequestPacket.DressedEpigraph != null)
            {
                int type  = m_RequestPacket.DressedEpigraph.Type;
                int level = m_RequestPacket.DressedEpigraph.Level;
                if (!pp.DeductEpigraph(type, level))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "you do not have this epigraph";
                    return(false);
                }
                pe.DressEpigraph(type, level, m_RequestPacket.Index);
                m_ResponsePacket.Index           = m_RequestPacket.Index;
                m_ResponsePacket.DressedEpigraph = m_RequestPacket.DressedEpigraph;
                return(true);
            }
            else if (m_RequestPacket.UndressedEpigraph != null)
            {
                int type  = m_RequestPacket.UndressedEpigraph.Type;
                int level = m_RequestPacket.UndressedEpigraph.Level;
                if (!pe.UndressEpigraph(type, level, m_RequestPacket.Index))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "you do not have this epigraph";
                    return(false);
                }
                pp.AddEpigraph(type, level);
                m_ResponsePacket.Index             = m_RequestPacket.Index;
                m_ResponsePacket.UndressedEpigraph = m_RequestPacket.UndressedEpigraph;
                return(true);
            }
            else
            {
                int type  = m_RequestPacket.UndressedEpigraph.Type;
                int level = m_RequestPacket.UndressedEpigraph.Level;
                if (!pe.UndressEpigraph(type, level, m_RequestPacket.Index))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "you do not have this epigraph";
                    return(false);
                }
                pe.DressEpigraph(type, level, m_RequestPacket.Index);
                m_ResponsePacket.Index             = m_RequestPacket.Index;
                m_ResponsePacket.DressedEpigraph   = m_RequestPacket.DressedEpigraph;
                m_ResponsePacket.UndressedEpigraph = m_RequestPacket.UndressedEpigraph;
                return(true);
            }
        }
示例#17
0
        public override bool TakeAction()
        {
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            SetItemInfo(package);
            SetGearInfo(package);
            SetSoulInfo(package);
            SetEpigraphInfo(package);
            return(true);
        }
示例#18
0
        public override bool TakeAction()
        {
            PlayerChanceLogic pc = new PlayerChanceLogic();

            pc.SetUserAndType(m_UserId, m_RequestPacket.ChanceType);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            Dictionary <int, int> dropDict = new Dictionary <int, int>();

            if (!pp.CheckPackageSlot(dropDict))
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "package is full";
                return(false);
            }
            var items = pc.OpenAllChance();

            if (items == null)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "you can not open this";
                return(false);
            }
            m_ResponsePacket.ChanceType = m_RequestPacket.ChanceType;
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id    = p.MyPlayer.Id,
                Coin  = p.MyPlayer.Coin,
                Money = p.MyPlayer.Money,
            };

            foreach (var iteminfo in items)
            {
                m_ResponsePacket.OpenedIndex.Add(iteminfo.Key);
                m_ResponsePacket.OpenedGoodInfo.Add(new PBItemInfo()
                {
                    Type  = iteminfo.Value.ItemId,
                    Count = iteminfo.Value.ItemCount
                });
                GetItems(iteminfo.Value);
            }

            ReceiveItemMethodType type = m_RequestPacket.ChanceType == (int)ChanceType.Money ? ReceiveItemMethodType.CoinChance : ReceiveItemMethodType.MoneyChance;
            PBReceivedItems       receivedItems;

            pp.GetItems(m_DropItems, type, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            return(true);
        }
示例#19
0
        public CacheDictionary <int, int> CompleteAchievement(int id, out TrackingAchievement newAchievement)
        {
            newAchievement = null;
            var aData             = CacheSet.AchievementTable.GetData(id);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(aData.RewardItems))
            {
                return(null);
            }
            if (aData == null)
            {
                TraceLog.WriteError("DataTable Error: can not find Id:" + id.ToString());
                return(null);
            }
            if (!m_AchievementInfo.TrackingAchievements.ContainsKey(aData.AchievementType))
            {
                TraceLog.WriteError("You don not have this achievement, Id:" + id.ToString());
                return(null);
            }
            var completedAchievement = m_AchievementInfo.TrackingAchievements[aData.AchievementType];

            if (completedAchievement.Id != id)
            {
                TraceLog.WriteError("You don not have this achievement, Id:" + id.ToString());
                return(null);
            }
            if (completedAchievement.Progress < completedAchievement.RequiredProgress)
            {
                TraceLog.WriteError("You have not completed this achievement, Id:" + id.ToString());
                return(null);
            }
            m_AchievementInfo.CompletedAchievements.Add(id);
            var nextAchievementData = CacheSet.AchievementTable.GetData(a => a.PreAchievementId == id);

            m_AchievementInfo.TrackingAchievements.Remove(aData.AchievementType);
            if (nextAchievementData != null)
            {
                TrackingAchievement ta = new TrackingAchievement()
                {
                    Id = nextAchievementData.Id,
                    RequiredProgress = nextAchievementData.TargetProgressCount,
                };
                ta.Params.AddRange(nextAchievementData.Params);
                m_AchievementIniters[nextAchievementData.AchievementType](ta);
                newAchievement = ta;
                m_AchievementInfo.TrackingAchievements.Add(nextAchievementData.AchievementType, ta);
            }
            return(aData.RewardItems);
        }
示例#20
0
        public override bool TakeAction()
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroId);
            foreach (var iteminfo in m_RequestPacket.Items)
            {
                ItemListItem item = new ItemListItem()
                {
                    Id    = iteminfo.Type,
                    Count = iteminfo.Count
                };
                DTItem             itemData = CacheSet.ItemTable.GetData(item.Id);
                PlayerPackageLogic pp       = new PlayerPackageLogic();
                pp.SetUser(m_UserId);
                if (!pp.DeductInventory(item))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "You have not enough item";
                    return(false);
                }

                switch ((ItemFunctions)itemData.FunctionId)
                {
                case ItemFunctions.AddHeroExp:
                    ph.AddExp(int.Parse(itemData.FunctionParams) * item.Count);
                    var heroInfo = ph.GetHeroInfo();
                    m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                    {
                        Type  = heroInfo.HeroType,
                        Level = heroInfo.HeroLv,
                        Exp   = heroInfo.HeroExp,
                        Might = heroInfo.Might,
                    };
                    break;

                case ItemFunctions.HeroPiece:
                    AddSpirit(item.Count);
                    break;

                default:
                    break;
                }
                m_ResponsePacket.ItemInfo.Add(new PBItemInfo()
                {
                    Type  = item.Id,
                    Count = pp.MyPackage.Inventories[item.Id]
                });
            }
            return(true);
        }
示例#21
0
        public override bool TakeAction()
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            SoulLogic soul = new SoulLogic();

            soul.SetSoul(m_RequestPacket.Id);
            int type     = soul.MySoul.TypeId;
            var soulData = CacheSet.SoulTable.GetData(type);

            if (soulData.UpgradedId == -1)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "This soul can not be upgraded";
                return(false);
            }
            ItemListItem cost = new ItemListItem();

            cost.Id    = soulData.StrengthenItemId;
            cost.Count = soulData.StrengthenItemCount;
            if (!pp.DeductInventory(cost))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Not enough item";
                return(false);
            }
            soul.Upgrade(soulData.UpgradedId, pp);
            if (m_RequestPacket.HeroType > 0)
            {
                PlayerHeroLogic ph = new PlayerHeroLogic();
                ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
                ph.RefreshMight();
                m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = m_RequestPacket.HeroType,
                    Might = ph.GetHeroInfo().Might
                };
            }
            m_ResponsePacket.SoulInfo = new PBSoulInfo()
            {
                Id   = soul.MySoul.Id,
                Type = soul.MySoul.TypeId
            };
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = cost.Id,
                Count = pp.MyPackage.Inventories[cost.Id]
            };
            return(true);
        }
示例#22
0
        private void AddSoul(int soulType)
        {
            SoulLogic          soul    = new SoulLogic();
            int                soulId  = soul.AddNewSoul(soulType);
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            package.AddSoul(soulId, soulType);
            m_ResponsePacket.SoulInfo = new PBSoulInfo()
            {
                Id   = soulId,
                Type = soulType,
            };
        }
示例#23
0
        private void AddEpigraph(int type)
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            ItemListItem item;

            pp.GetNewEpigraph(type, out item);
            m_ResponsePacket.EpigraphInfo = new PBEpigraphInfo()
            {
                Type  = type,
                Level = pp.MyPackage.Epigraphs[type]
            };
        }
示例#24
0
        private void AddGear(int gearType)
        {
            GearLogic          gear   = new GearLogic();
            int                gearId = gear.AddNewGear(gearType, m_UserId, ReceiveItemMethodType.None);
            PlayerPackageLogic pp     = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            pp.AddGear(gearId, gearType);
            m_ResponsePacket.GearInfo = new PBGearInfo()
            {
                Id              = gearId,
                Type            = gearType,
                Level           = gear.MyGear.Level,
                StrengthenLevel = gear.MyGear.StrengthenLevel
            };
        }
示例#25
0
        private void AddItem(int itemId, int count)
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            ItemListItem item = new ItemListItem();

            item.Id    = itemId;
            item.Count = count;
            pp.AddInventory(item);
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = itemId,
                Count = pp.MyPackage.Inventories[itemId]
            };
        }
示例#26
0
        public override bool TakeAction()
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_UserId);
            int totalCoin = 0;

            foreach (var item in m_RequestPacket.SoldItems)
            {
                ItemListItem tmpItem = new ItemListItem()
                {
                    Id    = item.Type,
                    Count = item.Count
                };
                if (!pp.DeductInventory(tmpItem))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "You have not enough item";
                    return(false);
                }
                DTItem itemData = CacheSet.ItemTable.GetData(item.Type);
                totalCoin += item.Count * itemData.Price;
                m_ResponsePacket.ItemInfo.Add(item);
            }
            foreach (var gear in m_RequestPacket.SoldGears)
            {
                if (!pp.DeductGear(gear.Id))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "You have not this gear";
                    return(false);
                }
                DTGear gearData = CacheSet.GearTable.GetData(gear.Type);
                totalCoin += gearData.Price;
                m_ResponsePacket.GearInfo.Add(gear);
            }
            player.AddCoin(totalCoin);
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id   = player.MyPlayer.Id,
                Coin = player.MyPlayer.Coin
            };
            return(true);
        }
示例#27
0
        public override bool TakeAction()
        {
            var          heroData    = CacheSet.HeroTable.GetData(m_RequestPacket.HeroType);
            ItemListItem composeItem = new ItemListItem()
            {
                Id    = heroData.StarLevelUpItemId,
                Count = GameConfigs.GetInt("Pieces_Per_Hero", 10)
            };
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.DeductInventory(composeItem))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough pieces";
                return(false);
            }
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            if (ph.AddNewHero(m_RequestPacket.HeroType, ReceiveItemMethodType.HeroPieceCompose) != null)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "You have already got this hero";
                return(false);
            }
            m_ResponsePacket.HeroPieceItem = new PBItemInfo()
            {
                Type  = composeItem.Id,
                Count = pp.MyPackage.Inventories[composeItem.Id]
            };
            Hero newHero = ph.GetHeroInfo();

            m_ResponsePacket.NewHero = new PBLobbyHeroInfo()
            {
                Type               = m_RequestPacket.HeroType,
                Level              = newHero.HeroLv,
                Exp                = newHero.HeroExp,
                ElevationLevel     = newHero.ElevationLevel,
                ConsciousnessLevel = newHero.ConsciousnessLevel,
                StarLevel          = newHero.HeroStarLevel
            };
            m_ResponsePacket.NewHero.SkillLevels.AddRange(newHero.SkillLevels);
            return(true);
        }
示例#28
0
        public override bool TakeAction()
        {
            var pa = PlayerAchievementLogic.GetInstance(m_UserId);
            TrackingAchievement nextAchievement;
            PackageFullReason   reason;
            var RewardItems = pa.CompleteAchievement(m_RequestPacket.AchievementId, out nextAchievement);

            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;
            if (nextAchievement != null)
            {
                m_ResponsePacket.NextTrackingAchievement = new PBTrackingAchievement()
                {
                    AchievementId = nextAchievement.Id,
                    ProgressCount = nextAchievement.Progress,
                };
            }
            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.AchievementId = m_RequestPacket.AchievementId;
            return(true);
        }
示例#29
0
        public override bool TakeAction()
        {
            PlayerChanceLogic pc = new PlayerChanceLogic();

            pc.SetUserAndType(m_UserId, m_RequestPacket.ChanceType);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            Dictionary <int, int> dropDict = new Dictionary <int, int>();

            if (!pp.CheckPackageSlot(dropDict))
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "package is full";
                return(false);
            }
            var item = pc.OpenChance(m_RequestPacket.OpenIndex, m_RequestPacket.UseFree);

            if (item == null)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "you can not open this";
                return(false);
            }
            m_ResponsePacket.ChanceType     = m_RequestPacket.ChanceType;
            m_ResponsePacket.OpenedIndex    = m_RequestPacket.OpenIndex;
            m_ResponsePacket.OpenedGoodInfo = new PBItemInfo()
            {
                Type  = item.ItemId,
                Count = item.ItemCount
            };
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id    = p.MyPlayer.Id,
                Coin  = p.MyPlayer.Coin,
                Money = p.MyPlayer.Money,
            };
            m_ResponsePacket.NextFreeTime = pc.MyChance.NextFreeTime;
            GetReward(item);
            return(true);
        }
示例#30
0
        public override bool TakeAction()
        {
            DTHero          heroData   = CacheSet.HeroTable.GetData(m_RequestPacket.HeroType);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            if (!playerHero.DataCheck())
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "wrong HeroId";
                return(false);
            }

            Hero myHero = playerHero.GetHeroInfo();
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            ItemListItem item = new ItemListItem();

            item.Id    = heroData.StarLevelUpItemId;
            item.Count = heroData.StarLevelUpItemCount[myHero.HeroStarLevel];
            if (!package.DeductInventory(item))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "not enough piece";
                return(false);
            }
            playerHero.StarLevelUp();
            myHero = playerHero.GetHeroInfo();
            m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
            {
                Type      = m_RequestPacket.HeroType,
                StarLevel = myHero.HeroStarLevel,
                Might     = myHero.Might,
            };
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = item.Id,
                Count = package.MyPackage.Inventories[item.Id]
            };
            return(true);
        }