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

            pe.SetUser(m_UserId);
            int         curLevel = pe.GetLevel();
            PlayerLogic p        = new PlayerLogic();

            p.SetUser(m_UserId);

            if (p.MyPlayer.Level < GameConfigs.GetInt("Epigraph_Required_Level_" + curLevel))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "your level is not reached require";
                return(false);
            }
            pe.UnlockSlot();
            foreach (var epigraph in pe.GetEpigraphs())
            {
                PBEpigraphInfo epInfo = new PBEpigraphInfo();
                epInfo.Type  = epigraph.Type;
                epInfo.Level = epigraph.Level;
                m_ResponsePacket.Epigraphs.Add(epInfo);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public static bool ProcessMessage(int userId, string message, out string newMessage)
        {
            newMessage = "";
            PlayerChat pc = CacheSet.PlayerChatCache.FindKey(userId.ToString(), userId);

            if (pc == null)
            {
                pc                   = new PlayerChat();
                pc.UserId            = userId;
                pc.LastWorldChatTime = 0;
                pc.Content           = "";
                CacheSet.PlayerChatCache.Add(pc);
            }
            int sizeLimit = GameConfigs.GetInt("World_Chat_Max_Length") == 0 ? 60 : GameConfigs.GetInt("World_Chat_Max_Length");

            if (message.Length > sizeLimit)
            {
                return(false);
            }
            message = message.Trim();
            if (string.IsNullOrEmpty(message))
            {
                return(false);
            }
            newMessage = WordServer.Filter(message);
            return(true);
        }
Ejemplo n.º 3
0
        public override bool TakeAction()
        {
            int deductEnergy = PlayerInstanceLogic.GetInstanceEnergy(m_RequestPacket.InstanceType);
            PlayerInstanceLogic playerInstance = new PlayerInstanceLogic();

            playerInstance.SetUser(m_UserId);
            InstanceProgressLogic instanceProgress = new InstanceProgressLogic();

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

            player.SetUser(m_UserId);
            long nextRecoverTime;

            if (playerInstance.MyInstance != null)
            {
                playerInstance.LeaveInstance();
            }
            if (!player.DeductEnergy(deductEnergy, out nextRecoverTime))
            {
                ErrorCode = (int)ErrorType.EnergyNotEnough;
                ErrorInfo = "Energy not Enough";
                return(false);
            }
            var instanceData = CacheSet.InstanceTable.GetData(m_RequestPacket.InstanceType);

            if (GameConfigs.GetInt("Need_Check_Instance_Prerequisite", 1) > 0 && (instanceData.PrerequisitePlayerLevel > player.MyPlayer.Level || (instanceData.PrerequisiteInstanceId > 0 && !instanceProgress.IsInstanceCompleted(instanceData.PrerequisiteInstanceId))))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Pre-instance is not completed";
                return(false);
            }
            m_ResponsePacket.InstanceType = m_RequestPacket.InstanceType;
            PBPlayerInfo playerInfo = new PBPlayerInfo();

            playerInfo.Id     = player.MyPlayer.Id;
            playerInfo.Energy = player.MyPlayer.Energy;
            playerInfo.NextEnergyRecoveryTime = nextRecoverTime;
            m_ResponsePacket.PlayerInfo       = playerInfo;
            var dropInfo = playerInstance.EnterInstance(m_RequestPacket.InstanceType);

            if (dropInfo == null)
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "Package slot full";
                return(false);
            }
            m_ResponsePacket.DropInfo.AddRange(dropInfo);

            foreach (var item in playerInstance.MyInstance.DropList)
            {
                m_ResponsePacket.ItemInfo.Add(new PBItemInfo()
                {
                    Type  = item.Key,
                    Count = item.Value
                });
            }
            return(true);
        }
Ejemplo n.º 4
0
        public int GetNPCAndPlayerDeltaLevel(int instanceId)
        {
            int    range    = GameConfigs.GetInt("Cosmos_Crack_NPC_Level_Range", 5);
            int    minlevel = (0 - range) + (m_CosmosCrack.ChosenInstance[instanceId].RewardLevel - 1) * (range * 2 / MaxRewardLevel);
            int    maxlevel = (0 + range) - (MaxRewardLevel - m_CosmosCrack.ChosenInstance[instanceId].RewardLevel) * (range * 2 / MaxRewardLevel);
            Random random   = new Random();

            return(random.Next(minlevel, maxlevel));
        }
Ejemplo n.º 5
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.º 6
0
 private int GetOpenCost(int count)
 {
     for (int i = 1; i <= GameConfigs.GetInt("Chess_Bomb_Period_Count", 5); i++)
     {
         if (count < GameConfigs.GetInt("Chess_Bomb_Period_" + i, 5))
         {
             return(GameConfigs.GetInt("Chess_Bomb_Cost_" + i, 0));
         }
     }
     return(0);
 }
Ejemplo n.º 7
0
 public void AddSoul(int soulId, int soulType)
 {
     if (m_Package.Souls.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
     {
         PlayerMailLogic pm = new PlayerMailLogic();
         pm.SetUser(m_UserId);
         pm.AddNewMail("package full", soulType, 1);
         pm.SendNotification();
     }
     m_Package.Souls.Add(soulId, soulType);
 }
Ejemplo n.º 8
0
 public void ResetLivenessReward()
 {
     m_Arena.ModifyLocked(() =>
     {
         m_Arena.WinCount = 0;
         for (int i = 0; i < GameConfigs.GetInt("Offline_Arena_Liveness_Reward_Count", 3); i++)
         {
             m_Arena.ClaimedLivenessRewardFlag[i] = false;
         }
     });
 }
Ejemplo n.º 9
0
 public void SetUser(int userId)
 {
     m_Instance = CacheSet.PlayerStoryInstanceCache.FindKey(userId.ToString(), userId);
     if (m_Instance == null)
     {
         m_Instance        = new PlayerStoryInstance();
         m_Instance.UserId = userId;
         m_Instance.Count  = GameConfigs.GetInt("Story_Instance_Daily_Count", 5);
         CacheSet.PlayerStoryInstanceCache.Add(m_Instance);
     }
 }
Ejemplo n.º 10
0
 public void AddGear(int gear, int gearType)
 {
     if(m_Package.Gears.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
     {
         PlayerMailLogic pm = new PlayerMailLogic();
         pm.SetUser(m_UserId);
         pm.AddNewMail("package full", gearType, 1);
         pm.SendNotification();
     }
     m_Package.Gears.Add(gear, gearType);
 }
Ejemplo n.º 11
0
 public void AddEpigraph(int Type, int Level)
 {
     if (m_Package.Epigraphs.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
     {
         PlayerMailLogic pm = new PlayerMailLogic();
         pm.SetUser(m_UserId);
         pm.AddNewMail("package full", Type, 1);
         pm.SendNotification();
     }
     m_Package.Epigraphs.Add(Type, Level);
 }
Ejemplo n.º 12
0
 private int GetTokenCount(bool IsWin)
 {
     if (IsWin)
     {
         return(GameConfigs.GetInt("Arena_Token_For_Winner", 2));
     }
     else
     {
         return(GameConfigs.GetInt("Arena_Token_For_Loser", 1));
     }
 }
Ejemplo n.º 13
0
 public bool EnterInstance(int instanceId)
 {
     if (m_CosmosCrack.PassedRoundCount >= GameConfigs.GetInt("Cosmos_Crack_Round_Limit", 10))
     {
         return(false);
     }
     if (!m_CosmosCrack.ChosenInstance.ContainsKey(instanceId))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
 public bool Invited(int inviter)
 {
     if (m_Friends.Invitations.Contains(inviter) || m_Friends.Friends.ContainsKey(inviter) || m_Friends.Friends.Count >= GameConfigs.GetInt("Max_Friend_Count", 50))
     {
         return(false);
     }
     if (m_Friends.Invitations.Count >= GameConfigs.GetInt("Max_Friend_Invitation_Count", 20))
     {
         m_Friends.Invitations.RemoveAt(0);
     }
     m_Friends.Invitations.Add(inviter);
     return(true);
 }
Ejemplo n.º 16
0
        private void AddSpirit(int pieceCount)
        {
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            int spirit = pieceCount * GameConfigs.GetInt("Spirits_Per_Piece", 1);

            p.AddSpirit(spirit);
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id     = m_UserId,
                Spirit = p.MyPlayer.Spirit
            };
        }
Ejemplo n.º 17
0
        public bool GetLivenessReward(int id, out Dictionary <int, int> itemDict, out int rewardMoney)
        {
            rewardMoney = 0;
            itemDict    = new Dictionary <int, int>();
            switch (id)
            {
            case 0:
                if (m_Arena.ClaimedLivenessRewardFlag[0] || m_Arena.WinCount < GameConfigs.GetInt("Offline_Arena_Liveness_Reward_Win_Count_0", 2))
                {
                    return(false);
                }
                rewardMoney = 10;
                itemDict.Add(111001, 1);
                itemDict.Add(171001, 1);
                itemDict.Add(202101, 1);
                m_Arena.ClaimedLivenessRewardFlag[0] = true;
                break;

            case 1:
                if (m_Arena.ClaimedLivenessRewardFlag[1] || m_Arena.WinCount < GameConfigs.GetInt("Offline_Arena_Liveness_Reward_Win_Count_1", 3))
                {
                    return(false);
                }
                rewardMoney = 50;
                itemDict.Add(111002, 1);
                itemDict.Add(171002, 1);
                itemDict.Add(202101, 2);
                m_Arena.ClaimedLivenessRewardFlag[1] = true;
                break;

            case 2:
                if (m_Arena.ClaimedLivenessRewardFlag[2] || m_Arena.WinCount < GameConfigs.GetInt("Offline_Arena_Liveness_Reward_Win_Count_2", 4))
                {
                    return(false);
                }
                rewardMoney = 200;
                itemDict.Add(111003, 1);
                itemDict.Add(171003, 1);
                itemDict.Add(202101, 3);
                m_Arena.ClaimedLivenessRewardFlag[2] = true;
                break;

            default:
                return(false);
            }
            return(true);
        }
Ejemplo n.º 18
0
        public bool ResetRewards(bool IsFree)
        {
            RandomDropLogic random = RandomDropLogic.GetInstance();
            PlayerLogic     player = new PlayerLogic();

            player.SetUser(m_UserId);
            m_Chance.OpenedChanceRewards.Clear();
            m_Chance.UnopenedChanceRewards.Clear();
            switch (m_Type)
            {
            case ChanceType.Coin:
                if (!IsFree)
                {
                    if (!player.DeductCoin(GameConfigs.GetInt("ChanceRefreshCost0")))
                    {
                        return(false);
                    }
                }
                for (int i = GameConsts.Chance.MinCoinChancePackId; i <= GameConsts.Chance.MaxCoinChancePackId; i++)
                {
                    m_Chance.UnopenedChanceRewards.Add(i, random.GetChanceRewards(i));
                }
                m_Chance.TotalFreeCount = 0;
                break;

            case ChanceType.Money:
                if (!IsFree)
                {
                    if (!player.DeductMoney(GameConfigs.GetInt("ChanceRefreshCost1")))
                    {
                        return(false);
                    }
                }
                for (int i = GameConsts.Chance.MinMoneyChancePackId; i <= GameConsts.Chance.MaxMoneyChancePackId; i++)
                {
                    m_Chance.UnopenedChanceRewards.Add(i - GameConsts.Chance.MaxCoinChancePackId, random.GetChanceRewards(i));
                }
                m_Chance.TotalFreeCount = 0;
                break;

            default:
                break;
            }
            m_Chance.OpenedChanceRewards.Clear();
            return(true);
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
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.º 21
0
        public void AddNewMail(string message, int AttachId, int AttachCount)
        {
            if (CacheSet.ItemTable.GetData(AttachId) == null && CacheSet.GearTable.GetData(AttachId) == null && CacheSet.SoulTable.GetData(AttachId) == null && CacheSet.EpigraphTable.GetData(AttachId) == null)
            {
                return;
            }
            DBProvider db = new DBProvider("Game");
            Dictionary <string, object> values = new Dictionary <string, object>();

            values["Message"]     = message;
            values["AttachType"]  = AttachId;
            values["AttachCount"] = AttachCount;
            values["BeginTime"]   = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
            DateTime expireDay = DateTime.UtcNow.AddDays(GameConfigs.GetInt("Mail_Expire_Days", 7));

            values["ExpireTime"] = expireDay.ToString("yyyy-MM-dd HH:mm:ss");
            values["ToUser"]     = m_UserId;
            db.Insert("mails", values);
        }
Ejemplo n.º 22
0
        public static bool SendWorld(Player sender, string message)
        {
            int        time = GameConfigs.GetInt("World_Chat_CoolDown_Seconds", 30);
            PlayerChat pc   = CacheSet.PlayerChatCache.FindKey(sender.Id.ToString(), sender.Id);

            if (DateTime.UtcNow.Ticks - pc.LastWorldChatTime < time * GameConsts.TicksPerSecond)
            {
                return(false);
            }
            byte[] buffer     = GenPackage((int)ChatType.World, sender, message);
            var    allOLUsers = GameSession.GetOnlineAll();

            foreach (var user in allOLUsers)
            {
                user.SendAsync(buffer, 0, buffer.Length);
            }
            pc.LastWorldChatTime = DateTime.UtcNow.Ticks;
            return(true);
        }
Ejemplo n.º 23
0
 public void AddInventory(ItemListItem item)
 {
     if (m_Package.Inventories.ContainsKey(item.Id))
     {
         m_Package.Inventories[item.Id] += item.Count;
         if (m_Package.Inventories[item.Id] > GameConfigs.GetInt("Inventory_Item_Max_Count", 9999))
         {
             int count = m_Package.Inventories[item.Id] - GameConfigs.GetInt("Inventory_Item_Max_Count", 9999);
             m_Package.Inventories[item.Id] = GameConfigs.GetInt("Inventory_Item_Max_Count", 9999);
             PlayerMailLogic pm = new PlayerMailLogic();
             pm.SetUser(m_UserId);
             pm.AddNewMail("package full", item.Id, item.Count);
             pm.SendNotification();
         }
     }
     else
     {
         m_Package.Inventories.Add(item.Id, item.Count);
     }
 }
Ejemplo n.º 24
0
        public static bool IsOpen(int userId)
        {
            TimeSpan startTime      = TimeSpan.Parse(GameConfigs.GetString("Pvp_Start_Time_Everyday", "4:00:00"));
            TimeSpan endTime        = TimeSpan.Parse(GameConfigs.GetString("Pvp_End_Time_Everyday", "16:00:00"));
            DateTime todayStartTime = DateTime.Today.Add(startTime);
            DateTime todayEndTime   = DateTime.Today.Add(endTime);
            DateTime now            = DateTime.UtcNow;

            if (now < todayStartTime || now > todayEndTime)
            {
                return(false);
            }
            PlayerLogic p = new PlayerLogic().SetUser(userId);

            if (p.MyPlayer.Level < GameConfigs.GetInt("Pvp_Require_Player_Level", 30))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 25
0
        public bool Foundry()
        {
            int userId = m_UserId;

            if (m_Foundry.NextFoundryTime > DateTime.UtcNow.Ticks)
            {
                return(false);
            }
            int roomId   = m_Foundry.CurrentRoomId;
            var roomInfo = CacheSet.FoundryRoomCache.FindKey(roomId);

            if (roomInfo == null)
            {
                return(false);
            }
            if (roomInfo.Level >= GameConfigs.GetInt("Gear_Foundry_Level_Count", 3) && roomInfo.Progress >= GameConfigs.GetInt("Gear_Foundry_Progress_Count_2", 5))
            {
                return(false);
            }
            m_Foundry.FoundryCount   += 1;
            m_Foundry.NextFoundryTime = DateTime.UtcNow.Add(CoolDownTime).Ticks;
            roomInfo.ModifyLocked(() =>
            {
                roomInfo.Progress += 1;
                if (roomInfo.Progress >= GameConfigs.GetInt("Gear_Foundry_Progress_Count_" + roomInfo.Level, 5) && roomInfo.Level < GameConfigs.GetInt("Gear_Foundry_Level_Count", 3))
                {
                    foreach (int playerId in roomInfo.Players)
                    {
                        SetUser(playerId);
                        if (!m_Foundry.HasReceivedRewards[roomInfo.Level])
                        {
                            m_Foundry.CanReceiveRewards[roomInfo.Level] = true;
                        }
                    }
                    roomInfo.Level   += 1;
                    roomInfo.Progress = 0;
                }
            });
            SetUser(userId);
            return(true);
        }
Ejemplo n.º 26
0
        public PBGearFoundryInfo GetAllFoundryData()
        {
            PBGearFoundryInfo retData = new PBGearFoundryInfo()
            {
                TeamId = m_Foundry.CurrentRoomId,
                NextFoundryTimeInTicks = m_Foundry.NextFoundryTime,
            };

            for (int i = 0; i < GameConfigs.GetInt("Gear_Foundry_Level_Count", 3); i++)
            {
                retData.RewardFlags.Add(m_Foundry.CanReceiveRewards[i]);
            }
            var roomInfo = GetRoomInfo();

            if (roomInfo != null)
            {
                PlayerLogic p = new PlayerLogic();
                foreach (int playerId in roomInfo.Players)
                {
                    p.SetUser(playerId);
                    SetUser(playerId);
                    retData.Players.Add(new PBGearFoundryPlayerInfo()
                    {
                        Player = new PBPlayerInfo()
                        {
                            Id           = playerId,
                            Name         = p.MyPlayer.Name,
                            PortraitType = p.MyPlayer.PortraitType
                        },
                        FoundryCount = m_Foundry.FoundryCount,
                    });
                }
                retData.Progress = new PBGearFoundryProgressInfo()
                {
                    CurrentLevel    = roomInfo.Level,
                    CurrentProgress = roomInfo.Progress,
                };
            }
            return(retData);
        }
Ejemplo n.º 27
0
        public Gears GetComposeResult(int quality, int position, int userId)
        {
            Random        r = new Random();
            List <DTGear> gearList;

            if (position == 0)
            {
                if (r.Next(100) > GameConfigs.GetInt("Gear_Compose_Success_Rate_" + quality.ToString(), 50))
                {
                    return(null);
                }
                gearList = CacheSet.GearTable.GetAllData(t => t.Quality == quality + 1);
            }
            else
            {
                gearList = CacheSet.GearTable.GetAllData(t => t.Quality == quality + 1 && t.Type == position);
            }
            int randomIndex = r.Next(gearList.Count);

            AddNewGear(gearList[randomIndex].Id, userId, ReceiveItemMethodType.GearCompose);
            return(m_Gear);
        }
Ejemplo n.º 28
0
        public ItemListItem AddNewHero(int heroId, ReceiveItemMethodType method = ReceiveItemMethodType.None)
        {
            Hero playerHero;
            var  HeroData = CacheSet.HeroTable.GetData(heroId);

            if (m_MyHeros.Heros.TryGetValue(heroId, out playerHero))
            {
                int          itemId = HeroData.StarLevelUpItemId;
                ItemListItem item   = new ItemListItem()
                {
                    Id    = itemId,
                    Count = GameConfigs.GetInt("Hero_Piece_Count_For_Star_Level_" + HeroData.DefaultStarLevel, 10)
                };
                return(item);
            }
            else
            {
                Hero hero = new Hero();
                int  star = HeroData.DefaultStarLevel;//TODO read config
                hero.HeroType           = heroId;
                hero.HeroExp            = 0;
                hero.HeroLv             = 1;
                hero.HeroStarLevel      = star;
                hero.ConsciousnessLevel = 0;
                hero.ElevationLevel     = 0;
                m_HeroId = heroId;
                hero.SkillLevels.AddRange(new int[] { 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 });
                hero.SkillExps.AddRange(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
                m_MyHeros.ModifyLocked(() =>
                {
                    m_MyHeros.Heros[heroId] = hero;
                    m_Hero = m_MyHeros.Heros[heroId];
                    RefreshMight();
                });
                PlayerAchievementLogic.GetInstance(m_UserId).UpdateAchievement(AchievementType.HeroCount, MyHeros.Heros.Count);
                AnnouncementLogic.PushReceiveHeroAnnouncement(m_UserId, method, hero.HeroType);
            }
            return(null);
        }
Ejemplo n.º 29
0
 public bool CheckPackageSlot(IDictionary<int, int> gotItems)
 {
     foreach(var item in gotItems)
     {
         if (IsItem(item.Key) && m_Package.Inventories.ContainsKey(item.Key) && m_Package.Inventories[item.Key] + item.Value > GameConfigs.GetInt("Inventory_Item_Max_Count", 9999))
         {
             return false;
         }
         else if (IsItem(item.Key) && !m_Package.Inventories.ContainsKey(item.Key) && m_Package.Inventories.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
         {
             return false;
         }
         else if (IsGear(item.Key) && m_Package.Gears.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
         {
             return false;
         }
         else if (IsSoul(item.Key) && m_Package.Souls.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 30
0
        public bool TryGetRankList(int pageIndex, out List <ArenaRank> rankList)
        {
            rankList = new List <ArenaRank>();
            int playerCount = GameConfigs.GetInt("Arena_Rank_Player_Count_Per_Page", 20);
            int startIndex  = playerCount * pageIndex + 1;
            int endIndex    = playerCount * (pageIndex + 1);
            int i;

            for (i = startIndex; i <= endIndex; i++)
            {
                var rankPlayer = CacheSet.ArenaRankCache.FindKey(i);
                if (rankPlayer == null)
                {
                    return(false);
                }
                rankList.Add(rankPlayer);
            }
            if (CacheSet.ArenaRankCache.FindKey(i) == null)
            {
                return(false);
            }
            return(true);
        }