Esempio n. 1
0
        public void JoinRoom(AvailableRoom room)
        {
            string password    = string.Empty;
            bool   attemptJoin = true;

            if (room.RequiresPassword)
            {
                Pages.RoomPasswordEntry passwordEntryWindow = new Pages.RoomPasswordEntry();
                passwordEntryWindow.ShowDialog();
                password    = passwordEntryWindow.LatestPassword;
                attemptJoin = passwordEntryWindow.PasswordEntered;
                passwordEntryWindow.Reset();
                passwordEntryWindow = null;
            }

            if (attemptJoin)
            {
                JoinRoomOutcome outcome = client.JoinRoom(room, password);
                switch (outcome)
                {
                case JoinRoomOutcome.Success:
                    ShowChatPage();
                    chatPage.OutputTextSafe(string.Format("Joined '{0}', type '/help' for a list of commnads.", room.Name), false);
                    break;

                case JoinRoomOutcome.Fail:
                    MessageBox.Show("Could not join the room.", "Join Error");
                    break;

                case JoinRoomOutcome.InvalidPassword:
                    MessageBox.Show("Invalid password.", "Join Error");
                    break;
                }
            }
        }
Esempio n. 2
0
        public void HostRoom(string roomName, string roomPassword)
        {
            JoinRoomOutcome outcome = client.CreateRoom(roomName, roomPassword);

            switch (outcome)
            {
            case JoinRoomOutcome.Success:
                ShowChatPage();
                chatPage.OutputTextSafe(string.Format("Joined '{0}', type '/help' for a list of commnads.", roomName), false);
                break;

            case JoinRoomOutcome.Fail:
                MessageBox.Show("Could not join the room.", "Join Error");
                break;
            }
        }
Esempio n. 3
0
        public static void JoinGame(JoinRoomOutcome outcome)
        {
            switch (outcome)
            {
            case JoinRoomOutcome.Success:
                Logger.Info("You have joined game room");
                break;

            case JoinRoomOutcome.NoSuchRoomExists:
                Logger.Error("No room with given guid exists");
                break;

            case JoinRoomOutcome.UserAlreadyInRoom:
                Logger.Error("User with same username allready exists");
                break;
            }
        }
Esempio n. 4
0
        public void Start()
        {
            string action;

            Console.WriteLine("Do you want to join a game or host it?\n \n'J' to Join, 'H' to Host ");
            while (true)
            {
                action = Console.ReadLine();
                if (action != null && action.ToLower() == "h")
                {
                    RoomGuid = _warriorClient.HostGame();
                    WarriorLogger.GameHost(RoomGuid);
                    break;
                }
                if (action != null && action.ToLower() == "j")
                {
                    string guid = Console.ReadLine();

                    if (Guid.TryParse(guid, out RoomGuid))
                    {
                        JoinRoomOutcome joinOutcome = _warriorClient.JoinGame(RoomGuid);
                        WarriorLogger.JoinGame(joinOutcome);
                        break;
                    }
                    WarriorLogger.WrongRoomGuid();
                }
                else
                {
                    WarriorLogger.WrongLetter();
                }
            }
            while (!_bothUsersOnline)
            {
                _bothUsersOnline = _warriorClient.AreBothUsersOnline();
                Thread.Sleep(100);
            }

            Thread checkGetAttackedThread = new Thread(_warriorClient.GetMyInfo);

            checkGetAttackedThread.Start();

            Fight();
        }