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