コード例 #1
0
 /// <summary>
 /// Get the string value of these Troops for the Server DataBase.
 /// </summary>
 /// <param name="myTroops"></param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="NullReferenceException"></exception>
 /// <returns></returns>
 public static StrongString GetForServer(PlayerResources myPlayerResources)
 {
     if (myPlayerResources == null)
     {
         throw new ArgumentNullException();
     }
     return(myPlayerResources.GetForServer());
 }
コード例 #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));

            //---------------------------------------------
        }
コード例 #3
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));

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