//------------------------------------------------- #region static Method's Region public static async Task <DataBaseDataChangedInfo> CreateLevelRankings(KingdomInfo kingdom) { LevelRankings levelRankings = new LevelRankings() { Kingdom = kingdom, PlayerNames = new StrongString[MAXIMUM_RANKS], PlayerLevels = new uint[MAXIMUM_RANKS], PlayerTotalExp = new Unit[MAXIMUM_RANKS], PlayerUIDs = new UID[MAXIMUM_RANKS], }; for (int i = 0; i < MAXIMUM_RANKS; i++) { levelRankings.PlayerNames[i] = ThereIsConstants.Path.NotSet; levelRankings.PlayerLevels[i] = 0; levelRankings.PlayerTotalExp[i] = Unit.GetBasicUnit(); levelRankings.PlayerUIDs[i] = UID.GenerateNullUID(); } //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(levelRankings.Provider); var _target = LevelRankings_LOC; var _req = new DataBaseCreation(MESSAGE, QString.Parse(levelRankings.GetForServer())); return(await ThereIsServer.Actions.CreateData(_s, _target, _req)); //--------------------------------------------- }
//------------------------------------------------- #region static Method's Region public static async Task <bool> GenerateFirstGeneration() { IServerProvider <QString, DataBaseClient> _s; StrongString _target = ServerManager.Generation_Location_Name; StrongString myString; DataBaseCreation _req; int first_index; for (int i = MIN_SERVER_INDEX; i <= MAX_SERVER_INDEX; i++) { _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Generation_Server(i); if (!await ThereIsServer.Actions.Exists(_s, _target)) { first_index = i + BASE_UID_SERVER_INDEX_SHOW; myString = first_index.ToString(INDEX_FORMAT) + FIRST_GENERATION; _req = new DataBaseCreation(UID_MESSAGE, QString.Parse(myString)); await ThereIsServer.Actions.CreateData(_s, _target, _req); } else { continue; } } return(true); }
//------------------------------------------------- #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)); //--------------------------------------------- }
//------------------------------------------------- #region Online and non-static Methods region public async Task <DataBaseDataChangedInfo> UpdateKingdomThrone() { var _s = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(Provider); var _target = KingdomThrone_LOC; var _req = new DataBaseCreation(MESSAGE, QString.Parse(GetForServer())); return(await ThereIsServer.Actions.CreateData(_s, _target, _req)); }
//------------------------------------------------- #region static Methods Region /// <summary> /// Create player's troops for the first time. /// Notice: you shoul use this function when player has already selected his /// Element, so he should has at least one hero to load after it. /// </summary> /// <param name="troops"></param> public static async Task <DataBaseDataChangedInfo> CreatePlayerHero(Hero hero) { StrongString myString = hero.GetForServer(); var _p = ThereIsServer.GameObjects.MyProfile; var _s = ThereIsServer.ServersInfo.ServerManager.Get_HeroInfo_Server(hero); var _target = _p.UID.GetValue() + LOC_SEPARATOR + hero.HeroID + SERVER_LOC; var _creation = new DataBaseCreation(HERO_MESSAGE, QString.Parse(myString)); return(await ThereIsServer.Actions.CreateData(_s, _target, _creation)); }
/// <summary> /// Create player's troops for the first time. /// </summary> /// <param name="troops"></param> public async static Task <DataBaseDataChangedInfo> CreatePlayerTroops(Troop[] troops) { //--------------------------------------------- StrongString myString = GetForServer(troops); var _p = ThereIsServer.GameObjects.MyProfile; var _s = ThereIsServer.ServersInfo.ServerManager.Get_Troops_Server(_p.Socket); var _target = _p.UID.GetValue() + EndFileName; var _creation = new DataBaseCreation(TROOP_MESSAGE, QString.Parse(myString)); return(await ThereIsServer.Actions.CreateData(_s, _target, _creation)); //--------------------------------------------- }
/// <summary> /// Create player's troops for the first time. /// </summary> /// <param name="troops"></param> public static async Task <DataBaseDataChangedInfo> CreatePlayerMagicalTroops(MagicalTroop troops) { StrongString myString = GetForServer(troops); //--------------------------------------------- var _me = ThereIsServer.GameObjects.MyProfile; var _target = _me.UID.GetValue() + MT_Server_LOC; var _s = ThereIsServer.ServersInfo.ServerManager.Get_MagicalTroops_Server(_me.Socket); var _req = new DataBaseCreation(MTROOPS_MESSAGE, QString.Parse(myString)); return(await ThereIsServer.Actions.CreateData(_s, _target, _req)); //--------------------------------------------- }
/// <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> /// use this method just for generating a new UID. /// </summary> /// <param name="_username_"></param> /// <param name="_socket_"></param> /// <returns></returns> public static async Task <UID> GenerateUID(StrongString _username_, IPlayerSocket _socket_) { int myIndex = Randomic.GetRandom(MIN_SERVER_INDEX, MAX_SERVER_INDEX); var _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Generation_Server(myIndex); StrongString _target = ServerManager.Generation_Location_Name; UID uid; ulong _value; for (var i = 0; ; i++) { var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } _value = existing.Decode().ToUInt64(); _value++; var _req = new DataBaseUpdateRequest(UID_MESSAGE, _value.ToString(UID_FORMAT), existing.Sha.GetStrong()); var _result = await ThereIsServer.Actions.UpdateDataOnce(_s, _target, _req); if (_result.IsDeadCallBack) { continue; } if (ThereIsServer.ServerSettings.HasConnectionClosed || i >= MAX_TRY) { return(null); } break; } //---------------------- uid = new UID(myIndex, _value, _socket_, _username_); _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Server(uid); _target = uid.GetValue() + UID_Lcation_Name; var _creation = new DataBaseCreation(UID_MESSAGE, QString.Parse(uid.GetForServer())); await ThereIsServer.Actions.CreateData(_s, _target, _creation); //---------------------- _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Server(_username_); _target = _username_ + USERNAME_TO_UID; _creation = new DataBaseCreation(UID_MESSAGE, QString.Parse(uid.GetValue())); await ThereIsServer.Actions.CreateData(_s, _target, _creation); //---------------------- return(uid); }
//------------------------------------------------- #region static Method's Region public static async Task <DataBaseDataChangedInfo> CreateKingdomInfo(LTW_Kingdoms index) { KingdomInfo kingdomInfo = new KingdomInfo(index) { Index = (uint)index, KingdomName = index.ToString(), KingsPower = Unit.GetBasicUnit(), KingdomLevel = 0, }; //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Kingdom_Server(index); var _target = KingdomInfo_LOC; var _req = new DataBaseCreation(MESSAGE, QString.Parse(kingdomInfo.GetForServer())); return(await ThereIsServer.Actions.CreateData(_s, _target, _req)); //--------------------------------------------- }
public static async Task <DataBaseDataChangedInfo> CreateNewConfiguration(ChatChannels channel) { ChatConfiguration configuration = new ChatConfiguration(channel) { Status = ChatChannelStatus.FreeForAll, ItemPrice = "notSet", MinimumLvl = 0, BanList = ChatBlockList.GenerateBlankChatBlockList(), }; configuration.SetLimitationTime(); //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Channel_Server(channel); var _req = new DataBaseCreation(MESSAGE, QString.Parse(configuration.GetForServer())); return(await ThereIsServer.Actions.CreateData(_s, DataBaseLocation, _req)); //--------------------------------------------- }