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
        public static async Task <bool> CreateKingdomRankings(KingdomInfo kingdom)
        {
            await PowerRankings.CreatePowerRankings(kingdom);

            await LevelRankings.CreateLevelRankings(kingdom);

            return(true);
        }
Esempio n. 3
0
        public static async Task <bool> DeleteRankings(LTW_Kingdoms _kingdom_)
        {
            var _b1 = await PowerRankings.DeletePowerRankings(_kingdom_);

            var _b2 = await LevelRankings.DeleteLevelRankings(_kingdom_);

            return(_b1 && _b2);
        }
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 <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);
        }