Exemple #1
0
        //-------------------------------------------------
        #region static Method's Region
        public static MagicalTroop ParseToMagicalTroop(StrongString theString)
        {
            StrongString[] myStrings      = theString.Split(InCharSeparator);
            MagicalTroop   myMagicalTroop = new MagicalTroop(Unit.ConvertToUnit(myStrings[0]),
                                                             myStrings[1].ToUInt16(), Unit.ConvertToUnit(myStrings[2]));

            return(myMagicalTroop);
        }
Exemple #2
0
        public static StrongString GetForServer(MagicalTroop troops)
        {
            StrongString myString =
                troops.Count.GetForServer() + InCharSeparator +
                troops.Level.ToString() + InCharSeparator +
                troops.Power.GetForServer() + InCharSeparator;

            return(myString);
        }
Exemple #3
0
        /// <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));

            //---------------------------------------------
        }
Exemple #4
0
        /// <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);

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