Esempio n. 1
0
        //-------------------------------------------------
        #region static Methods Region
        public static async Task <DataBaseDataChangedInfo> CreatePowerRankings(KingdomInfo kingdom)
        {
            PowerRankings powerRankings = new PowerRankings()
            {
                Kingdom      = kingdom,
                PlayerNames  = new StrongString[MAXIMUM_RANKS],
                PlayerPowers = new Unit[MAXIMUM_RANKS],
                PlayerUIDs   = new UID[MAXIMUM_RANKS],
            };

            for (int i = 0; i < MAXIMUM_RANKS; i++)
            {
                powerRankings.PlayerNames[i]  = ThereIsConstants.Path.NotSet;
                powerRankings.PlayerPowers[i] = Unit.GetBasicUnit();
                powerRankings.PlayerUIDs[i]   = UID.GenerateNullUID();
            }
            //---------------------------------------------
            var _s      = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(kingdom.Provider);
            var _target = PowerRankings_LOC;
            var _req    = new DataBaseCreation(MESSAGE, QString.Parse(powerRankings.GetForServer()));

            return(await ThereIsServer.Actions.CreateData(_s, _target, _req));

            //---------------------------------------------
        }
Esempio n. 2
0
        //-------------------------------------------------
        #region static mathods region
        //These methods are server and online working
        //so you should use await keyword for them.
        public static async Task <DataBaseDataChangedInfo> CreateKingdomThrone(KingdomInfo kingdomInfo)
        {
            var _notSet = new StrongString[]
            {
                ThereIsConstants.Path.NotSet, // 0
                ThereIsConstants.Path.NotSet, // 1
                ThereIsConstants.Path.NotSet, // 2
                ThereIsConstants.Path.NotSet, // 3
                ThereIsConstants.Path.NotSet, // 4
                ThereIsConstants.Path.NotSet, // 5
                ThereIsConstants.Path.NotSet, // 6
            };
            KingdomThrone kingdomThrone = new KingdomThrone()
            {
                PlayerNames = _notSet,
                PlayerUIDs  = UID.GenerateNullUIDs(MAXIMUM_POSITION),
            };
            //---------------------------------------------
            var _s      = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(kingdomInfo.Provider);
            var _target = KingdomThrone_LOC;
            var _req    = new DataBaseCreation(MESSAGE, QString.Parse(kingdomThrone.GetForServer()));

            return(await ThereIsServer.Actions.CreateData(_s, _target, _req));

            //---------------------------------------------
        }
Esempio n. 3
0
        public static async Task <bool> CreateKingdomRankings(KingdomInfo kingdom)
        {
            await PowerRankings.CreatePowerRankings(kingdom);

            await LevelRankings.CreateLevelRankings(kingdom);

            return(true);
        }
Esempio n. 4
0
 //-----------------------------------------
 //-----------------------------------------
 public static async Task <KingdomRankings> GetKingdomRankings(KingdomInfo kingdom)
 {
     return(new KingdomRankings()
     {
         Kingdom = kingdom,
         LevelRankings = await LevelRankings.GetLevelRankings(kingdom),
         PowerRankings = await PowerRankings.GetPowerRankings(kingdom),
     });
 }
Esempio n. 5
0
        public static async Task <LevelRankings> GetLevelRankings(KingdomInfo kingdom)
        {
            LevelRankings levelRankings = new LevelRankings()
            {
                Kingdom        = kingdom,
                PlayerNames    = new StrongString[MAXIMUM_RANKS],
                PlayerLevels   = new uint[MAXIMUM_RANKS],
                PlayerTotalExp = new Unit[MAXIMUM_RANKS],
                PlayerUIDs     = new UID[MAXIMUM_RANKS],
            };
            //---------------------------------------------
            var _s       = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(levelRankings.Provider);
            var _target  = LevelRankings_LOC;
            var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

            //---------------------------------------------
            if (existing.DoesNotExist)
            {
                await CreateLevelRankings(kingdom);

                //---------------------------------------------
                existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

                //---------------------------------------------
                if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
                {
                    NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                    return(null);
                }
            }
            else
            {
                if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
                {
                    NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                    return(null);
                }
            }
            StrongString[] myStrings = existing.Decode().Split(OutCharSeparator);
            StrongString[] InStrings;
            for (int i = 0; i < MAXIMUM_RANKS; i++)
            {
                InStrings = myStrings[i].Split(InCharSeparator);
                levelRankings.PlayerNames[i]    = InStrings[0];
                levelRankings.PlayerLevels[i]   = InStrings[1].ToUInt16();
                levelRankings.PlayerTotalExp[i] = Unit.ConvertToUnit(InStrings[2]);
                levelRankings.PlayerUIDs[i]     = UID.GetUID(InStrings[3]);
            }
            return(levelRankings);
        }
Esempio n. 6
0
        public static async Task <PowerRankings> GetPowerRankings(KingdomInfo kingdom)
        {
            PowerRankings powerRankings = new PowerRankings()
            {
                Kingdom      = kingdom,
                PlayerNames  = new StrongString[MAXIMUM_RANKS],
                PlayerPowers = new Unit[MAXIMUM_RANKS],
                PlayerUIDs   = new UID[MAXIMUM_RANKS],
            };
            //---------------------------------------------
            var _s       = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(kingdom.Provider);
            var _target  = PowerRankings_LOC;
            var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

            //---------------------------------------------
            if (existing.DoesNotExist)
            {
                await CreatePowerRankings(kingdom);

                //---------------------------------------------
                existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

                //---------------------------------------------
                if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
                {
                    NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                    return(null); // don't set ServerSettings.IsWaitingForServerChecking = false;
                }
            }
            else
            {
                if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
                {
                    NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                    return(null); // don't set ServerSettings.IsWaitingForServerChecking = false;
                }
            }
            StrongString[] myStrings = existing.Decode().Split(OutCharSeparator);
            StrongString[] InStrings;
            for (int i = 0; i < MAXIMUM_RANKS; i++)
            {
                InStrings = myStrings[i].Split(InCharSeparator);
                powerRankings.PlayerNames[i]  = InStrings[NAME_INDEX];
                powerRankings.PlayerPowers[i] = Unit.ConvertToUnit(InStrings[POWER_INDEX]);
                powerRankings.PlayerUIDs[i]   = UID.GetUID(InStrings[UID_INDEX]);
            }
            return(powerRankings);
        }
Esempio n. 7
0
        //-------------------------------------------------
        #region static Method's Region
        public static async Task <DataBaseDataChangedInfo> CreateKingdomInfo(LTW_Kingdoms index)
        {
            KingdomInfo kingdomInfo = new KingdomInfo(index)
            {
                Index        = (uint)index,
                KingdomName  = index.ToString(),
                KingsPower   = Unit.GetBasicUnit(),
                KingdomLevel = 0,
            };
            //---------------------------------------------
            var _s      = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(index);
            var _target = KingdomInfo_LOC;
            var _req    = new DataBaseCreation(MESSAGE, QString.Parse(kingdomInfo.GetForServer()));

            return(await ThereIsServer.Actions.CreateData(_s, _target, _req));

            //---------------------------------------------
        }
Esempio n. 8
0
        public static async Task <KingdomThrone> GetKingdomThrone(KingdomInfo kingdom)
        {
            KingdomThrone kingdomThrone = new KingdomThrone();
            //---------------------------------------------
            var _s        = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(kingdom.Provider);
            var _target   = KingdomThrone_LOC;
            var _existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

            //---------------------------------------------
            if (_existing.DoesNotExist)
            {
                await CreateKingdomThrone(kingdom);

                //---------------------------------------------
                _existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

                //---------------------------------------------
                if (_existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
                {
                    NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                    return(null);
                }
            }
            else
            {
                if (_existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
                {
                    NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                    return(null);
                }
            }
            StrongString[] myStrings = _existing.Decode().Split(OutCharSeparator);
            kingdomThrone.PlayerNames = new StrongString[myStrings.Length];
            kingdomThrone.PlayerUIDs  = new UID[myStrings.Length];
            StrongString[] anothers;
            for (int i = 0; i < myStrings.Length; i++)
            {
                anothers = myStrings[i].Split(InCharSeparator);
                kingdomThrone.PlayerNames[i] = anothers[NAME_INNER_INDEX];
                kingdomThrone.PlayerUIDs[i]  = UID.GetUID(anothers[UID_INNER_INDEX]);
            }
            return(kingdomThrone);
        }
Esempio n. 9
0
        public static async Task <KingdomInfo> GetKingdomInfo(LTW_Kingdoms _kingdom_)
        {
            KingdomInfo kingdomInfo = new KingdomInfo(_kingdom_)
            {
                Index = (uint)_kingdom_,
            };
            //---------------------------------------------
            var _s        = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(kingdomInfo.Provider);
            var _target   = KingdomInfo_LOC;
            var _existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

            //---------------------------------------------
            if (_existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
            {
                NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                return(null); // don't set ServerSettings.IsWaitingForServerChecking = false;
            }
            kingdomInfo.SetParams(_existing.Decode());
            kingdomInfo.Rankings = await KingdomRankings.GetKingdomRankings(kingdomInfo);

            kingdomInfo.Throne = await KingdomThrone.GetKingdomThrone(kingdomInfo);

            return(kingdomInfo);
        }