Exemple #1
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],
            };
            var Existing = await ThereIsServer.Actions.GetAllContentsByRef(
                ThereIsServer.ServersInfo.MyServers[kingdom.Index], LevelRankingsFileName);

            await Task.Delay(100);

            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]);
            }

            return(levelRankings);
        }
Exemple #2
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]
            };
            var Existing = await ThereIsServer.Actions.GetAllContentsByRef(
                ThereIsServer.ServersInfo.MyServers[kingdom.Index], PowerRankingsFileName);

            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[0];
                powerRankings.PlayerPowers[i] = Unit.ConvertToUnit(InStrings[1]);
            }
            return(powerRankings);
        }
Exemple #3
0
        //-------------------------------------------------
        #region static Method's Region
        public static async Task <DataBaseDataChangedInfo> CreateLevelRankings(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],
            };

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

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

            //---------------------------------------------
        }
Exemple #4
0
        public static async Task <bool> CreateKingdomRankings(KingdomInfo kingdom)
        {
            await PowerRankings.CreatePowerRankings(kingdom);

            await LevelRankings.CreateLevelRankings(kingdom);

            return(true);
        }
Exemple #5
0
 //-----------------------------------------
 //-----------------------------------------
 public static async Task <KingdomRankings> GetKingdomRankings(KingdomInfo kingdom)
 {
     return(new KingdomRankings()
     {
         Kingdom = kingdom,
         LevelRankings = await LevelRankings.GetLevelRankings(kingdom),
         PowerRankings = await PowerRankings.GetPowerRankings(kingdom),
     });
 }
Exemple #6
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);
        }
Exemple #7
0
        //-------------------------------------------------
        public static async Task <DataBaseDataChangedInfo> CreateKingdomInfo(SAO_Kingdoms index)
        {
            KingdomInfo kingdomInfo = new KingdomInfo(index)
            {
                Index        = (uint)index,
                KingdomName  = index.ToString(),
                KingsPower   = Unit.GetBasicUnit(),
                KingdomLevel = 0,
            };

            return
                (await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[(uint)index],
                                                        KingdomInfoFileName, new DataBaseCreation("Created By SAO_Game",
                                                                                                  QString.Parse(kingdomInfo.GetForServer(), false))));
        }
Exemple #8
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);
        }
Exemple #9
0
        //-------------------------------------------------
        #region static mathods region
        //These methods are server and online working
        //so you should use await keyword for them.
        public static async Task <RepositoryContentChangeSet> CreateKingdomThrone(KingdomInfo kingdomInfo)
        {
            KingdomThrone kingdomThrone = new KingdomThrone()
            {
                King_PlayerName             = ThereIsConstants.Path.NotSet, // 1
                Queen_PlayerName            = ThereIsConstants.Path.NotSet, // 2
                MinisterOfWar_PlayerName    = ThereIsConstants.Path.NotSet, // 3
                MinisterOfWealth_PlayerName = ThereIsConstants.Path.NotSet, // 4
                Hierarch_PlayerName         = ThereIsConstants.Path.NotSet, // 5
                Guardians_Chief_PlayerName  = ThereIsConstants.Path.NotSet, // 6
                Clown_PlayerName            = ThereIsConstants.Path.NotSet, // 7
            };

            return(await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[kingdomInfo.Index],
                                                          KingdomThroneFileName, new DataBaseCreation("BY SAO_Game",
                                                                                                      QString.Parse(kingdomThrone.GetForServer()))));
        }
Exemple #10
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]
            };

            for (int i = 0; i < MAXIMUM_RANKS; i++)
            {
                powerRankings.PlayerNames[i]  = ThereIsConstants.Path.NotSet;
                powerRankings.PlayerPowers[i] = Unit.GetBasicUnit();
            }
            return(await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[kingdom.Index],
                                                          PowerRankingsFileName, new DataBaseCreation("Created_BY_SAO",
                                                                                                      QString.Parse(powerRankings.GetForServer()))));
        }
Exemple #11
0
        //-------------------------------------------------
        #region static Method's Region
        public static async Task <DataBaseDataChangedInfo> CreateKingdomInfo(SAO_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));

            //---------------------------------------------
        }
Exemple #12
0
        public static async Task <KingdomInfo> GetKingdomInfo(uint index)
        {
            KingdomInfo kingdomInfo = new KingdomInfo((SAO_Kingdoms)index)
            {
                Index = index,
            };
            var Existing =
                await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[index],
                                                                KingdomInfoFileName);

            await Task.Delay(300);

            if (Existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
            {
                NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                return(null); // don't set ServerSettings.IsWaitingForServerChecking = false;
            }
            kingdomInfo.SetParams(Existing.Decode());
            return(kingdomInfo);
        }
Exemple #13
0
        public static async Task <KingdomThrone> GetKingdomThrone(KingdomInfo kingdom)
        {
            KingdomThrone kingdomThrone = new KingdomThrone();
            var           Existing      =
                await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[kingdom.Index],
                                                                KingdomThroneFileName);

            if (Existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
            {
                NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                return(null);
            }
            StrongString[] myStrings = Existing.Decode().Split(CharSeparator);
            kingdomThrone.King_PlayerName             = myStrings[0];
            kingdomThrone.Queen_PlayerName            = myStrings[1];
            kingdomThrone.MinisterOfWar_PlayerName    = myStrings[2];
            kingdomThrone.MinisterOfWealth_PlayerName = myStrings[3];
            kingdomThrone.Hierarch_PlayerName         = myStrings[4];
            kingdomThrone.Guardians_Chief_PlayerName  = myStrings[5];
            kingdomThrone.Clown_PlayerName            = myStrings[6];
            return(kingdomThrone);
        }
Exemple #14
0
        public static async Task <KingdomInfo> GetKingdomInfo(SAO_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);
        }