Example #1
0
        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));

            //---------------------------------------------
        }
Example #2
0
        //-------------------------------------------------
        #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));

            //---------------------------------------------
        }
Example #3
0
        /// <summary>
        /// Save Player's troops(Update them to the server.)
        /// </summary>
        /// <param name="troops"></param>
        public async static void SavePlayerTroops(Troop[] troops)
        {
            StrongString myString   = GetForServer(troops);
            string       targetFile = ThereIsServer.GameObjects.MyProfile.Username +
                                      EndFileName;
            var ExistingFile =
                await ThereIsServer.Actions.GetAllContentsByRef(ThereIsServer.ServersInfo.MyServers[0],
                                                                targetFile);

            if (ExistingFile.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed)
            {
                NoInternetConnectionSandBox.PrepareConnectionClosedSandBox();
                return;
            }
            await ThereIsServer.Actions.UpdateFile(ThereIsServer.ServersInfo.MyServers[0],
                                                   targetFile,
                                                   new DataBaseUpdateRequest("By SAO", QString.Parse(myString), ExistingFile.Sha));
        }
Example #4
0
        /// <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);
            string       targetFile = ThereIsServer.GameObjects.MyProfile.Username +
                                      EndFileName;

            return(await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[0],
                                                          targetFile,
                                                          new DataBaseCreation("CreatingThePlayerSoldiers", QString.Parse(myString))));
        }
Example #5
0
        //-------------------------------------------------
        public static async Task <DataBaseDataChangedInfo> CreateKingdomInfo(SAO_Kingdoms index)
        {
            KingdomInfo kingdomInfo = new KingdomInfo(index)
            {
                Index        = (uint)index,
                KingdomName  = index.ToString(),
                KingsPower   = Unit.GetBasicUnit(),
                KingdomLevel = 0,
            };

            return
                (await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[(uint)index],
                                                        KingdomInfoFileName, new DataBaseCreation("Created By SAO_Game",
                                                                                                  QString.Parse(kingdomInfo.GetForServer(), false))));
        }
Example #6
0
        //-------------------------------------------------
        #region static mathods region
        //These methods are server and online working
        //so you should use await keyword for them.
        public static async Task <RepositoryContentChangeSet> CreateKingdomThrone(KingdomInfo kingdomInfo)
        {
            KingdomThrone kingdomThrone = new KingdomThrone()
            {
                King_PlayerName             = ThereIsConstants.Path.NotSet, // 1
                Queen_PlayerName            = ThereIsConstants.Path.NotSet, // 2
                MinisterOfWar_PlayerName    = ThereIsConstants.Path.NotSet, // 3
                MinisterOfWealth_PlayerName = ThereIsConstants.Path.NotSet, // 4
                Hierarch_PlayerName         = ThereIsConstants.Path.NotSet, // 5
                Guardians_Chief_PlayerName  = ThereIsConstants.Path.NotSet, // 6
                Clown_PlayerName            = ThereIsConstants.Path.NotSet, // 7
            };

            return(await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[kingdomInfo.Index],
                                                          KingdomThroneFileName, new DataBaseCreation("BY SAO_Game",
                                                                                                      QString.Parse(kingdomThrone.GetForServer()))));
        }
Example #7
0
        //-------------------------------------------------
        #region static Methods Region
        public static async Task <DataBaseDataChangedInfo> CreatePowerRankings(KingdomInfo kingdom)
        {
            PowerRankings powerRankings = new PowerRankings()
            {
                Kingdom      = kingdom,
                PlayerNames  = new StrongString[MAXIMUM_RANKS],
                PlayerPowers = new Unit[MAXIMUM_RANKS]
            };

            for (int i = 0; i < MAXIMUM_RANKS; i++)
            {
                powerRankings.PlayerNames[i]  = ThereIsConstants.Path.NotSet;
                powerRankings.PlayerPowers[i] = Unit.GetBasicUnit();
            }
            return(await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[kingdom.Index],
                                                          PowerRankingsFileName, new DataBaseCreation("Created_BY_SAO",
                                                                                                      QString.Parse(powerRankings.GetForServer()))));
        }
Example #8
0
 //-------------------------------------------------
 #region Constructor's Region
 public DataBaseCredential(QString value) :
     base(value.GetValue())
 {
     // do nothing here, (for now) ...
 }
Example #9
0
        //-------------------------------------------------
        #region Constants Region

        #endregion
        //-------------------------------------------------
        #region Contructors Region
        public DataBaseCreation(StrongString theMessage,
                                QString theContext) :
            base(theMessage.GetValue(), theContext.GetString())
        {
            // do nothing here...
        }
Example #10
0
        /// <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();
            }
        }
Example #11
0
            //------------------------------------------------
            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;
            }
Example #12
0
            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();
            }
Example #13
0
            //------------------------------------------------
            //---------------------------------------

            /// <summary>
            /// This function will create the Security data in
            /// location <see cref="endFileName"/>
            /// at the server.
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private async void CreatingTheProfileSecurityWorker(object sender, EventArgs e)
            {
                ((Timer)sender).Enabled = false;
                ((Timer)sender).Dispose();
                //MessageBox.Show("I am");
                var          targetFile = _username + endFileName;
                StrongString myString   =
                    _username + charSeparater +
                    _password + charSeparater +
                    _token + charSeparater;
                await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[0],
                                                       targetFile,
                                                       new DataBaseCreation("Testing for Creating", QString.Parse(myString)));

                Father.IsSecuredMeWorkingOver = true;
                if (!Directory.Exists(ThereIsConstants.Path.Profile_Folder_Path))
                {
                    Directory.CreateDirectory(ThereIsConstants.Path.Profile_Folder_Path);
                }
                ProfileInfo myInfo = new ProfileInfo(_username.GetValue(), _token.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();
            }
Example #14
0
        /// <summary>
        /// Information for parameters at: <see cref="PlayerInfo"/>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void CreatePlayerInfoTimer_Tick(object sender, EventArgs e)
        {
            ((Timer)sender).Enabled = false;
            ((Timer)sender).Dispose();
            //-----------------------------------------------
            PlayerName          = Username;                                  // 1
            PlayerLevel         = 0;                                         // 2
            PlayerLVLRanking    = 0;                                         // 3
            PlayerPowerRanking  = 0;                                         // 4
            PlayerGuildName     = NotSetString;                              // 5
            GuildPosition       = GuildPosition.NotJoined;                   // 6
            LastSeen            = ThereIsConstants.AppSettings.GlobalTiming; // 7
            PlayerPower         = new Unit(0);                               // 8
            PlayerIntro         = NotSetString;                              // 9
            PlayerAvatar        = Avatar.GetDefaultAvatar();                 // 10
            PlayerAvatarFrame   = AvatarFrame.GetDefaultAvatarFrame();       // 11
            PlayerVIPlvl        = 0;                                         // 12
            PlayerCurrentExp    = Unit.GetBasicUnit();                       // 13
            PlayerTotalExp      = Unit.GetBasicUnit();                       // 14
            PlayerCurrentVIPExp = Unit.GetBasicUnit();                       // 15
            ThePlayerElement    = PlayerElement.NotSet;                      // 16
            PlayerKingdom       = SAO_Kingdoms.NotSet;                       // 17
            SocialPosition      = SocialPosition.GetSocialPosition();        // 18
            //-----------------------------------------------
            var targetFile = Username + FileEndName;
            await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[0],
                                                   targetFile,
                                                   new DataBaseCreation("Testing for Creating",
                                                                        QString.Parse(PlayerInfoGetForServer())));

            //------------------------------------------------------
            StrongString myString = string.Empty;

#pragma warning disable IDE0059
            SecuredMe Hi = new SecuredMe(ref myString);
#pragma warning restore IDE0059
            await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[0],
                                                   Username + ThereIsServer.ServersInfo.EndCheckingFileName,
                                                   new DataBaseCreation("ReCreatedBySAO", QString.Parse(myString)));

            //------------------------------------------------------



            ((CreateProfileSandBox)ThereIsConstants.Forming.TheMainForm.ShowingSandBox).IsCreatingEnded1 = true;
            IsWaitingForSecuredWorking = true;

#pragma warning disable IDE0059
            SecuredMe MeSecured = new SecuredMe(true, Username, Password, this);
#pragma warning restore IDE0059
            GC.Collect();
        }
Example #15
0
 //-------------------------------------------------
 #region static Methods Region
 public static DataBaseContent GetBaseContent(RepositoryContent content, string procedural)
 {
     return(new DataBaseContent(content, QString.Parse(procedural.ToStrong())));
 }
Example #16
0
        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();
            return(await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[BasicDataBaseNum + (int)channel],
                                                          DataBaseLocation, new DataBaseCreation("Created By SAO_Game",
                                                                                                 QString.Parse(configuration.GetForServer(), false))));
        }
Example #17
0
 public DataBaseCreation(StrongString theMessage,
                         string theContext) : this(theMessage, QString.Parse(theContext.ToStrong()))
 {
 }
Example #18
0
 //-------------------------------------------------
 #region Constructor's Region
 public DataBaseClient(DataBaseHeader header, QString cridental) :
     base(header)
 {
     Credentials = new DataBaseCredential(cridental);
     SetRequestTimeout(ThereIsConstants.AppSettings.DefaultDataBaseTimeOut);
 }
Example #19
0
 public static IDateProvider <DateTime, Trigger, StrongString> ToDateTime(QString value)
 {
     return(ToDateTime(value.GetStrong()));
 }
Example #20
0
 //-------------------------------------------------
 #region Constructors Region
 public DataBaseHeader(QString name) :
     base(name.GetValue())
 {
     // do nothing here (for now)...
 }
Example #21
0
 //-------------------------------------------------
 #region Online and non-static Methods region
 public async Task <RepositoryContentChangeSet> UpdateKingdomThrone()
 {
     return(await ThereIsServer.Actions.CreateFile(ThereIsServer.ServersInfo.MyServers[Kingdom.Index],
                                                   KingdomThroneFileName, new DataBaseCreation("BY SAO_Game", QString.Parse(GetForServer()))));
 }