Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 private StrongString GenerateNew()
 {
     LoginS_Index        = Randomic.GetRandom(MIN_T, MAX_0);
     PlayerInfoS_Index   = Randomic.GetRandom(MIN_T, MAX_1);
     MeS_Index           = Randomic.GetRandom(MIN_T, MAX_2);
     PlayerS_Index       = Randomic.GetRandom(MIN_T, MAX_3);
     TroopS_Index        = Randomic.GetRandom(MIN_T, MAX_4);
     MagicalTroopS_Index = Randomic.GetRandom(MIN_T, MAX_5);
     ResourcesS_Index    = Randomic.GetRandom(MIN_T, MAX_6);
     PlayerHeroesS_Index = Randomic.GetRandom(MIN_T, MAX_7);
     SecuredMeS_Index    = Randomic.GetRandom(MIN_T, MAX_8);
     PlayerItemsS_Index  = Randomic.GetRandom(MIN_T, MAX_9);
     return(SumSalvation());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Generate a new random Hero with
        /// the Element.
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static Hero GenerateHero(PlayerElement element)
        {
            Hero myHero = new Hero();
            int  Range1 =
                Convert.ToInt32(
                    myHero.MyRes.GetString(element.ToString() + RangeStringInRes + 1));
            int Range2 =
                Convert.ToInt32(
                    myHero.MyRes.GetString(element.ToString() + RangeStringInRes + 2));
            int nowInt = Randomic.GetRandom(Range1, Range2);

            myHero.SetHeroFromBlank(nowInt.ToString());
            myHero.ServerIndex = Randomic.GetRandom(ServerManager.MIN_T, ServerManager.MAX_HEROES_INFO_SERVERS);
            return(myHero); // not completed yet.
        }
Ejemplo n.º 4
0
 //-------------------------------------------------
 #region Set Method's Region
 private void SetParams(StrongString _value)
 {
     StrongString[] myStrings = _value.Split(CharSeparator);
     if (myStrings.Length > INDEX_0)
     {
         LoginS_Index = myStrings[INDEX_0].ToInt32();
     }
     else
     {
         LoginS_Index = Randomic.GetRandom(MIN_T, MAX_0);
     }
     if (myStrings.Length > INDEX_1)
     {
         PlayerInfoS_Index = myStrings[INDEX_1].ToInt32();
     }
     else
     {
         PlayerInfoS_Index = Randomic.GetRandom(MIN_T, MAX_1);
     }
     if (myStrings.Length > INDEX_2)
     {
         MeS_Index = myStrings[INDEX_2].ToInt32();
     }
     else
     {
         MeS_Index = Randomic.GetRandom(MIN_T, MAX_2);
     }
     if (myStrings.Length > INDEX_3)
     {
         PlayerS_Index = myStrings[INDEX_3].ToInt32();
     }
     else
     {
         PlayerS_Index = Randomic.GetRandom(MIN_T, MAX_3);
     }
     if (myStrings.Length > INDEX_4)
     {
         TroopS_Index = myStrings[INDEX_4].ToInt32();
     }
     else
     {
         TroopS_Index = Randomic.GetRandom(MIN_T, MAX_4);
     }
     if (myStrings.Length > INDEX_5)
     {
         MagicalTroopS_Index = myStrings[INDEX_5].ToInt32();
     }
     else
     {
         MagicalTroopS_Index = Randomic.GetRandom(MIN_T, MAX_5);
     }
     if (myStrings.Length > INDEX_6)
     {
         ResourcesS_Index = myStrings[INDEX_6].ToInt32();
     }
     else
     {
         ResourcesS_Index = Randomic.GetRandom(MIN_T, MAX_6);
     }
     if (myStrings.Length > INDEX_7)
     {
         PlayerHeroesS_Index = myStrings[INDEX_7].ToInt32();
     }
     else
     {
         PlayerHeroesS_Index = Randomic.GetRandom(MIN_T, MAX_7);
     }
     if (myStrings.Length > INDEX_8)
     {
         SecuredMeS_Index = myStrings[INDEX_8].ToInt32();
     }
     else
     {
         SecuredMeS_Index = Randomic.GetRandom(MIN_T, MAX_8);
     }
     if (myStrings.Length > INDEX_9)
     {
         PlayerItemsS_Index = myStrings[INDEX_9].ToInt32();
     }
     else
     {
         PlayerItemsS_Index = Randomic.GetRandom(MIN_T, MAX_9);
     }
 }