Example #1
0
        private void CloseCreate_Click(object sender, RoutedEventArgs e)
        {
            GameConnectingWindow connWin = new GameConnectingWindow();

            Close();
            connWin.Show();
        }
Example #2
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            ClientClass   client   = new ClientClass();
            IRestResponse response = client.newHero(UserInfo.UserLogin, UserInfo.UserSession, Hero);

            if (response.IsSuccessful)
            {
                MessageBox.Show(response.Content);
                GameConnectingWindow connWin = new GameConnectingWindow();
                Close();
                connWin.Show();
            }
            else
            {
                MessageBox.Show(response.Content);
            }
        }
Example #3
0
        private void DisconnectButton_Click(object sender, RoutedEventArgs e)
        {
            ClientClass   client   = new ClientClass();
            IRestResponse response = client.DelConnect(UserInfo.UserLogin, UserInfo.UserSession);

            if (response.IsSuccessful)
            {
                UserInfo.UserGame = "";
                GameConnectingWindow connWin = new GameConnectingWindow();
                Close();
                connWin.ShowDialog();
            }
            else
            {
                MessageBox.Show(response.Content);
            }
        }
        private void Authorization_Button(object sender, RoutedEventArgs e)
        {
            string login = loginText.Text;
            string pass  = passText.Password;

            // Посылаем запрос auth
            ClientClass   client   = new ClientClass();
            IRestResponse response = client.Authorization(login, pass);

            if (response.IsSuccessful)
            {
                ClientClass   clientManual   = new ClientClass();
                IRestResponse responseManual = client.Manual();
                if (responseManual.IsSuccessful)
                {
                    ManualInf.manual = JsonConvert.DeserializeObject <Manual>(responseManual.Content);
                }
                else
                {
                    MessageBox.Show(responseManual.Content);
                }

                // Запоминаем инфу юзера
                ServerResponse serverResponse = JsonConvert.DeserializeObject <ServerResponse>(response.Content);
                UserInfo.UserLogin   = login;
                UserInfo.UserRole    = serverResponse.role;
                UserInfo.UserSession = serverResponse.session;

                User user = new User();
                user.Login   = login;
                user.Session = serverResponse.session;
                ClientClass   clientReconnect   = new ClientClass(); // Посылаем запрос connect
                IRestResponse responseReconnect = clientReconnect.Connect(user, 0);
                if (responseReconnect.IsSuccessful)                  // Проверка на реконнект
                {
                    ServerResponse serverResponseReconnect = JsonConvert.DeserializeObject <ServerResponse>(responseReconnect.Content);
                    switch (UserInfo.UserRole)
                    {
                    case 1:
                        UserInfo.UserGame = serverResponseReconnect.game;
                        GmConnect gmConnectWin = new GmConnect();
                        Close();
                        gmConnectWin.ShowDialog();
                        break;

                    case 2:
                        HeroCard hero = new HeroCard();
                        UserInfo.UserGame = serverResponseReconnect.game;
                        hero = serverResponseReconnect.hero;
                        MainMenu mainWin = new MainMenu(hero);
                        Close();
                        mainWin.ShowDialog();
                        break;
                    }
                }
                else // Игры не существует
                {
                    switch (UserInfo.UserRole)
                    {
                    case 1:
                        GmConnect gmConnectWin = new GmConnect();
                        Close();
                        gmConnectWin.ShowDialog();
                        break;

                    case 2:
                        GameConnectingWindow connectWin = new GameConnectingWindow();
                        Close();
                        connectWin.ShowDialog();
                        break;
                    }
                }
            }
            else // Ошибка авторизации
            {
                MessageBox.Show(response.Content);
            }
        }