Exemplo n.º 1
0
        /// <summary>
        /// Create player's troops for the first time.
        /// </summary>
        /// <param name="troops"></param>
        public static async Task <DataBaseDataChangedInfo> CreatePlayerResources(PlayerResources playerResources)

        {
            StrongString myString   = GetForServer(playerResources);
            string       targetFile = ThereIsServer.GameObjects.MyProfile.Username +
                                      EndFileName;

            return
                (await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[0], targetFile,
                                                        new DataBaseCreation("CreatingThePlayerResources",
                                                                             QString.Parse(myString, false))));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create player's troops for the first time.
        /// </summary>
        /// <param name="troops"></param>
        public static async Task <DataBaseDataChangedInfo> CreatePlayerResources(PlayerResources playerResources)
        {
            StrongString myString = playerResources.GetForServer();
            //---------------------------------------------
            var _me       = ThereIsServer.GameObjects.MyProfile;
            var _target   = _me.UID.GetValue() + EndFileName;
            var _s        = ThereIsServer.ServersInfo.ServerManager.Get_Resources_Server(_me.Socket);
            var _creation = new DataBaseCreation(RES_MESSAGE, QString.Parse(myString));

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

            //---------------------------------------------
        }
Exemplo n.º 3
0
        /// <summary>
        /// Save Player's troops(Update them to the server.)
        /// </summary>
        /// <param name="troops"></param>
        public static async Task <DataBaseDataChangedInfo> SavePlayerResources(PlayerResources playerResources)
        {
            StrongString myString   = GetForServer(playerResources);
            string       targetFile = ThereIsServer.GameObjects.MyProfile.Username +
                                      EndFileName;
            var ExistingFile =
                await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0],
                                                                targetFile);

            if (ExistingFile == null || ThereIsServer.ServerSettings.HasConnectionClosed)
            {
                NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                return(null); // don't set ServerSettings.IsWaitingForServerChecking = false;
            }
            var minNow = ExistingFile[0];

            return(await ThereIsServer.Actions.UpdateFile(ThereIsServer.ServersInfo.MyServers[0],
                                                          targetFile,
                                                          new DataBaseUpdateRequest("By SAO",
                                                                                    QString.Parse(myString, false), minNow.Sha)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Save Player's Resources(Update them to the server.)
        /// </summary>
        /// <param name="troops"></param>
        public static async Task <DataBaseDataChangedInfo> SavePlayerResources(PlayerResources _r, Player _p)
        {
            StrongString myString = _r.GetForServer();
            //---------------------------------------------
            var _s        = ThereIsServer.ServersInfo.ServerManager.Get_Resources_Server(_p.Socket);
            var _target   = _p.UID.GetValue() + EndFileName;
            var _existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target);

            //---------------------------------------------
            if (_existing == null || ThereIsServer.ServerSettings.HasConnectionClosed)
            {
                NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                return(null); // don't set ServerSettings.IsWaitingForServerChecking = false;
            }
            //---------------------------------------------
            var _req = new DataBaseUpdateRequest(RES_MESSAGE, QString.Parse(myString), _existing.Sha);

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

            //---------------------------------------------
        }