/// <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))); }
public static async Task <DataBaseDataChangedInfo> SavePlayerTroops(Troop[] troops, Player _p) { StrongString myString = GetForServer(troops); //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Troops_Server(_p.Socket); var _target = _p.UID.GetValue() + EndFileName; var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } //--------------------------------------------- var _req = new DataBaseUpdateRequest(TROOP_MESSAGE, QString.Parse(myString), existing.Sha); return(await ThereIsServer.Actions.UpdateData(_s, _target, _req)); //--------------------------------------------- }
/// <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)); //--------------------------------------------- }
public async Task <DataBaseDataChangedInfo> UpdatePlayerInfo(DataBaseContent existing) { try { //----------------------------------------- var _target = UID.GetValue() + PI_Server_LOC; var _s = ThereIsServer.ServersInfo.ServerManager.Get_PlayerInfo_Server(Socket); //----------------------------------------- if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } var _req = new DataBaseUpdateRequest(MESSAGE, QString.Parse(PlayerInfoGetForServer()), existing.Sha); return(await ThereIsServer.Actions.UpdateData(_s, _target, _req)); } catch { return(null); } }
//------------------------------------------------- #region Servering Methods Region public async Task <bool> ReloadPlayerInfo() { if (IsEmpty) { return(true); } var targetFile = PlayerName + FileEndName; var existingFile = await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0], targetFile); await Task.Delay(50); if (existingFile.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } SetParams(existingFile.Decode()); return(true); }
/// <summary> /// Save Player's troops(Update them to the server.) /// </summary> /// <param name="troops"></param> public static async void SavePlayerTroops(MagicalTroop troops) { StrongString myString = GetForServer(troops); //--------------------------------------------- var _p = ThereIsServer.GameObjects.MyProfile; var _s = ThereIsServer.ServersInfo.ServerManager.Get_MagicalTroops_Server(_p.Socket); var _target = _p.UID.GetValue() + MT_Server_LOC; var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return; } //--------------------------------------------- var _req = new DataBaseUpdateRequest(MTROOPS_MESSAGE, QString.Parse(myString), existing.Sha); await ThereIsServer.Actions.UpdateData(_s, _target, _req); //--------------------------------------------- }
//------------------------------------------------ private async void LogOuttWorker(object sender, EventArgs e) { ((Timer)sender).Enabled = false; ((Timer)sender).Dispose(); //MessageBox.Show("I am"); var targetFile = _username + endFileName; var ExistingFile = await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0], targetFile); if (ExistingFile.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return; } StrongString[] myStrings = ExistingFile.Decode().Split(charSeparater); StrongString myString = string.Empty; for (int i = 0; i < myStrings.Length; i++) { if (_token == myStrings[i]) { Father.HasLogin = true; continue; } else { myString += charSeparater + myStrings[i]; continue; } } await ThereIsServer.Actions.UpdateFile(ThereIsServer.ServersInfo.MyServers[0], targetFile, new DataBaseUpdateRequest("By SAO123", QString.Parse(myString), ExistingFile.Sha)); ThereIsConstants.Actions.ClearingPlayerProfile(); Father.IsSecuredMeWorkingOver = true; }
public static async Task <KingdomThrone> GetKingdomThrone(KingdomInfo kingdom) { KingdomThrone kingdomThrone = new KingdomThrone(); var Existing = await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[kingdom.Index], KingdomThroneFileName); if (Existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } StrongString[] myStrings = Existing.Decode().Split(CharSeparator); kingdomThrone.King_PlayerName = myStrings[0]; kingdomThrone.Queen_PlayerName = myStrings[1]; kingdomThrone.MinisterOfWar_PlayerName = myStrings[2]; kingdomThrone.MinisterOfWealth_PlayerName = myStrings[3]; kingdomThrone.Hierarch_PlayerName = myStrings[4]; kingdomThrone.Guardians_Chief_PlayerName = myStrings[5]; kingdomThrone.Clown_PlayerName = myStrings[6]; return(kingdomThrone); }
//------------------------------------------------- #region Online Method's Region /// <summary> /// Update the hero's info. /// even if you did not change any information, /// this method will do it's work. /// so don't use it if you did not change any information. /// </summary> /// <returns></returns> public async Task <DataBaseDataChangedInfo> UpdateHero() { StrongString myString = GetForServer(); //--------------------------------------------- var _p = ThereIsServer.GameObjects.MyProfile; var _target = _p.UID.GetValue() + LOC_SEPARATOR + HeroID + SERVER_LOC; var _s = ThereIsServer.ServersInfo.ServerManager.Get_HeroInfo_Server(this); var _existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (_existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); // don't set ServerSettings.IsWaitingForServerChecking = false; } //--------------------------------------------- var _req = new DataBaseUpdateRequest(HERO_MESSAGE, QString.Parse(myString), _existing.Sha); return(await ThereIsServer.Actions.UpdateData(_s, _target, _req)); //--------------------------------------------- }
public async Task <DataBaseDataChangedInfo> UpdatePowerRankings() { //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(Provider); var _target = PowerRankings_LOC; var existiong = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existiong.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); // don't set ServerSettings.IsWaitingForServerChecking = false; } //--------------------------------------------- var _req = new DataBaseUpdateRequest(MESSAGE, QString.Parse(GetForServer()), existiong.Sha); return(await ThereIsServer.Actions.UpdateData(_s, _target, _req)); //--------------------------------------------- }
public async Task <bool> ReloadChatConfiguration() { var existingFile = await ThereIsServer.Actions.GetAllContentsByRef( ThereIsServer.ServersInfo.MyServers[BasicDataBaseNum + (int)TheChannel], DataBaseLocation); if (existingFile.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); // don't set ServerSettings.IsWaitingForServerChecking = false; } StrongString[] myTStrings = existingFile.Decode().Split(OutCharSeparator); StrongString[] myStrings = myTStrings[ConfigurationPosition].Split(InCharSeparator); StrongString[] banTime = myTStrings[BanTimePosition].Split(InCharSeparator); Status = (ChatChannelStatus)myStrings[0].ToInt32(); ItemPrice = myStrings[1].GetValue(); MinimumLvl = myStrings[2].ToUInt16(); BanList = ChatBlockList.Parse(myTStrings[BanListPosition]); SetLimitationTime(banTime); return(true); }
//--------------------------------------- private async void PriLinkStartWorker(object sender, EventArgs e) { ((Timer)sender).Enabled = false; ((Timer)sender).Dispose(); //MessageBox.Show("I am"); var targetFile = _username + endFileName; var ExistingFile = await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0], targetFile); if (ExistingFile.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return; } StrongString[] myStrings = ExistingFile.Decode().Split(charSeparater); for (int i = 2; i < myStrings.Length; i++) { if (_token == myStrings[i]) { Father.HasLogin = true; break; } else { continue; } } if (Father.IsOnSecondStepOfLinkStart) { ProfileInfo myInfo = ProfileInfo.FromFile(ThereIsConstants.Path.ProfileInfo_File_Path); myInfo.LastLogin = ThereIsConstants.AppSettings.GlobalTiming.GetForServer().GetValue(); ProfileInfo.UpdateInfo(myInfo, ThereIsConstants.Path.ProfileInfo_File_Path); } Father.IsSecuredMeWorkingOver = true; }
//------------------------------------------------- #region static Method's Region public static async Task <bool> DeletePlayer(UID _uid_) { //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Player_Server(_uid_.TheSocket); var _target = _uid_.GetValue() + EndFileName_Player; var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.DoesNotExist) { return(true); } if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } //--------------------------------------------- var _req = new DataBaseDeleteRequest(PLAYER_MESSAGE, existing.Sha.GetStrong()); return(await ThereIsServer.Actions.DeleteData(_s, _target, _req)); //--------------------------------------------- }
public async Task <bool> DeleteHero(UID _uid_) { //--------------------------------------------- var _target = _uid_.GetValue() + LOC_SEPARATOR + HeroID + SERVER_LOC; var _s = ThereIsServer.ServersInfo.ServerManager.Get_HeroInfo_Server(this); var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.DoesNotExist) { return(true); } if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } //--------------------------------------------- var _req = new DataBaseDeleteRequest(HERO_MESSAGE, existing.Sha.GetStrong()); return(await ThereIsServer.Actions.DeleteData(_s, _target, _req)); //--------------------------------------------- }
private void MyTest_FormClosed(object sender, FormClosedEventArgs e) { if (sender is NoInternetConnectionSandBox) { NoInternetConnectionSandBox Father = (NoInternetConnectionSandBox)sender; if (Father.ClosedForRetry) { } else { Close(); } } else if (sender is ServerBreakSandBox) { ServerBreakSandBox Father = (ServerBreakSandBox)sender; if (Father.ClosedForRetry) { } else { Close(); } } else if (sender is UpdatingServerSandBox) { UpdatingServerSandBox Father = (UpdatingServerSandBox)sender; if (Father.ClosedForRetry) { } else { Close(); } } }
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); }
/// <summary> /// Use this function to load datas which are necessary for <see cref="PlayerInfo"/>, /// which are saved at: <see cref="PlayerInfo.FileEndName"/> at the Server. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void LoadPlayerInfoTimer_Tick(object sender, EventArgs e) { ((Timer)sender).Enabled = false; ((Timer)sender).Dispose(); //----------------------------------------------- var targetFile = Username + FileEndName; var existingFile = await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0], targetFile); if (existingFile.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return; // don't set ServerSettings.IsWaitingForServerChecking = false; } SetPlayerInfoParams(existingFile.Decode()); // Update the LastSeen of the player. LastSeen = ThereIsConstants.AppSettings.GlobalTiming; await UpdatePlayerInfo(); ((CreateProfileSandBox)ThereIsConstants.Forming.TheMainForm.ShowingSandBox).IsSignInEnded1 = true; GC.Collect(); }
/// <summary> /// Updating the Player info to the Server. /// All of them will be updated. /// </summary> public async Task <DataBaseDataChangedInfo> UpdatePlayerInfo() { try { var targetFile = PlayerName + FileEndName; var Existing = await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0], targetFile); if (Existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } return(await ThereIsServer.Actions.UpdateFile(ThereIsServer.ServersInfo.MyServers[0], targetFile, new DataBaseUpdateRequest("By API", QString.Parse(PlayerInfoGetForServer()), Existing.Sha))); } catch { throw new Exception(); } }
private async void LoginToTheProfileWorker(object sender, EventArgs e) { ((Timer)sender).Enabled = false; ((Timer)sender).Dispose(); //MessageBox.Show("I am"); var targetFile = _username + endFileName; var ExistingFile = await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0], targetFile); if (ExistingFile.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return; } StrongString myString = ExistingFile.Decode(); Father.HasLogin = (_password == myString.Split(charSeparater)[1]); if (!Father.HasLogin) { Father.IsSecuredMeWorkingOver = true; return; } StrongString[] myStrings = myString.Split(charSeparater); StrongString myToken = GenerateToken(); if (myStrings.Length >= 7) { StrongString myAnotherString; bool ThisTokenAlreadyExists = false; for (int i = 3; i < myStrings.Length; i++) { myAnotherString = myStrings[i]; myStrings[i - 1] = myAnotherString; if (myToken == myAnotherString) { ThisTokenAlreadyExists = true; } } if (!ThisTokenAlreadyExists) { myStrings[6] = myToken; myString = charSeparater; for (int i = 0; i < myStrings.Length; i++) { myString += charSeparater + myStrings[i]; } await ThereIsServer.Actions.UpdateFile(ThereIsServer.ServersInfo.MyServers[0], targetFile, new DataBaseUpdateRequest("By SAO", QString.Parse(myString), ExistingFile.Sha)); } else { // impossible to reach this branch of the code... } } else { myString = charSeparater; for (int i = 0; i < myStrings.Length; i++) { myString += myStrings[i] + charSeparater; } myString += myToken; await ThereIsServer.Actions.UpdateFile(ThereIsServer.ServersInfo.MyServers[0], targetFile, new DataBaseUpdateRequest("By SAO", QString.Parse(myString), ExistingFile.Sha)); } Father.IsSecuredMeWorkingOver = true; if (!Directory.Exists(ThereIsConstants.Path.Profile_Folder_Path)) { Directory.CreateDirectory(ThereIsConstants.Path.Profile_Folder_Path); } ProfileInfo myInfo = new ProfileInfo(_username.GetValue(), myToken.GetValue(), ThereIsConstants.AppSettings.GlobalTiming.GetForServer().GetValue()); ProfileInfo.UpdateInfo(myInfo, ThereIsConstants.Path.ProfileInfo_File_Path); AccountInfo myAccInfo = new AccountInfo(1, ThereIsConstants.AppSettings.GlobalTiming.GetForServer().GetValue()); AccountInfo.UpdateInfo(myAccInfo, ThereIsConstants.Path.AccountInfo_File_Path); GC.Collect(); }
//-------------------------- /// <summary> /// Checking for Existance, setting the <see cref="CreateProfileSandBox.DoesPlayerExists"/> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void CheckingForExistingUserTimer_Tick(object sender, EventArgs e) { ((Timer)sender).Enabled = false; ((Timer)sender).Dispose(); var targetFile = Username + ThereIsServer.ServersInfo.EndCheckingFileName; HasAccExist = await ThereIsServer.Actions.DeleteFile(ThereIsServer.ServersInfo.MyServers[0], targetFile, new DataBaseDeleteRequest("DeletedForCheckingBySAO", "NoSHA")); if (ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return; } if (HasAccExist) { if (ThereIsConstants.Forming.TheMainForm.IsShowingSandBox) { CreateProfileSandBox mySand = (CreateProfileSandBox)ThereIsConstants.Forming.TheMainForm.ShowingSandBox; mySand.IsCheckingForExistingEnded = true; mySand.DoesPlayerExists = true; } return; } else { if (ThereIsConstants.Forming.TheMainForm.IsShowingSandBox) { CreateProfileSandBox mySand = (CreateProfileSandBox)ThereIsConstants.Forming.TheMainForm.ShowingSandBox; mySand.IsCheckingForExistingEnded = true; mySand.DoesPlayerExists = false; } } /* * * try * { * await ThereIsServer.ServersInfo.Server1.ServerClient. * Repository.Content.DeleteFile(ThereIsServer.ServersInfo.Server1.Owner, * ThereIsServer.ServersInfo.Server1.Repo, targetFile, * new DeleteFileRequest("DeletedForCheckingBySAO", "NoSHA")); * await ThereIsServer.ServersInfo.Server1.ServerClient. * Repository.Content.CreateFile(ThereIsServer.ServersInfo.Server1.Owner, * ThereIsServer.ServersInfo.Server1.Repo, targetFile, * new CreateFileRequest("ReCreatedBySAO", "SAO")); * HasAccExist = true; * * if (ThereIsConstants.Forming.TheMainForm.IsShowingSandBox) * { * CreateProfileSandBox mySand = * (CreateProfileSandBox)ThereIsConstants.Forming.TheMainForm.ShowingSandBox; * mySand.IsCheckingForExistingEnded = true; * mySand.DoesPlayerExists = true; * } * return; * } * catch(NotFoundException) * { * * HasAccExist = false; * if (ThereIsConstants.Forming.TheMainForm.IsShowingSandBox) * { * CreateProfileSandBox mySand = * (CreateProfileSandBox)ThereIsConstants.Forming.TheMainForm.ShowingSandBox; * mySand.IsCheckingForExistingEnded = true; * mySand.DoesPlayerExists = false; * } * } * catch(ApiException) * { * HasAccExist = true; * if (ThereIsConstants.Forming.TheMainForm.IsShowingSandBox) * { * CreateProfileSandBox mySand = * (CreateProfileSandBox)ThereIsConstants.Forming.TheMainForm.ShowingSandBox; * mySand.IsCheckingForExistingEnded = true; * mySand.DoesPlayerExists = true; * } * return; * } */ }