コード例 #1
0
ファイル: KingdomThrone.cs プロジェクト: TeaInside/LTW-client
        //-------------------------------------------------
        #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));

            //---------------------------------------------
        }
コード例 #2
0
        public static async Task <bool> Delete(LTW_Kingdoms _kingdom_)
        {
            var  _s = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(_kingdom_);
            var  _target = KingdomInfo_LOC;
            bool _del1 = false, _del2, _del3;

            if (await ThereIsServer.Actions.Exists(_s, _target))
            {
                var _existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

                var _req = new DataBaseDeleteRequest(MESSAGE, _existing.Sha.GetStrong());
                _del1 = await ThereIsServer.Actions.DeleteData(_s, _target, _req);
            }
            _del2 = await KingdomRankings.DeleteRankings(_kingdom_);

            _del3 = await KingdomThrone.DeleteThrone(_kingdom_);

            return(_del1 && _del2 && _del3);
        }
コード例 #3
0
ファイル: KingdomThrone.cs プロジェクト: TeaInside/LTW-client
        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);
        }
コード例 #4
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);
        }