Exemplo n.º 1
0
        public void JoinTheGame(int roomId, int startingChip)
        {
            ActionCommMessage toSend = new ActionCommMessage(user.id, _sessionId,
                                                             CommunicationMessage.ActionType.Join, startingChip, roomId);

            _eventHandler.SendNewEvent(toSend);
        }
Exemplo n.º 2
0
        public void StartTheGame(int roomId)
        {
            ActionCommMessage toSend =
                new ActionCommMessage(user.id, _sessionId, CommunicationMessage.ActionType.StartGame, -1, roomId);

            _eventHandler.SendNewEvent(toSend);
        }
Exemplo n.º 3
0
        public bool NotifyAction(ResponeCommMessage msg)
        {
            ActionCommMessage original = msg.OriginalMsg as ActionCommMessage;

            if (original != null)
            {
                switch (original.MoveType)
                {
                case CommunicationMessage.ActionType.Join:
                    ReceivedJoin((JoinResponseCommMessage)msg);
                    break;

                case CommunicationMessage.ActionType.Spectate:
                    ReceivedSpectate((JoinResponseCommMessage)msg);
                    break;

                case CommunicationMessage.ActionType.Leave:
                    ReceivedLeave(msg);
                    break;

                case CommunicationMessage.ActionType.SpectatorLeave:
                    ReceivedSpectetorLeave(msg);
                    break;

                default:
                    GeneralCase(msg.GameData);
                    break;
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        public void SpectateRoom(int roomId)
        {
            ActionCommMessage toSend = new ActionCommMessage(user.id, _sessionId, CommunicationMessage.ActionType.Spectate,
                                                             -1, roomId);

            _eventHandler.SendNewEvent(toSend);
        }
Exemplo n.º 5
0
        public bool startTheGame(int roomId)
        {
            ActionCommMessage toSend = new ActionCommMessage(_userId, TexasHoldemShared.CommMessages.CommunicationMessage.ActionType.StartGame, -1, roomId);

            _eventHandler.SendNewEvent(toSend);
            return(true);
        }
Exemplo n.º 6
0
 public void NotifyChosenMove(CommunicationMessage.ActionType move, int amount, int roomId)
 {
     if (move.Equals(CommunicationMessage.ActionType.Fold))
     {
         ActionCommMessage response = new ActionCommMessage(user.id, _sessionId, move, amount, roomId);
         _eventHandler.SendNewEvent(response);
     }
     if ((move.Equals(CommunicationMessage.ActionType.Bet)) && (amount >= 0))
     {
         ActionCommMessage response = new ActionCommMessage(user.id, _sessionId, move, amount, roomId);
         _eventHandler.SendNewEvent(response);
     }
 }
Exemplo n.º 7
0
        public void handleChosenAction(TexasHoldemShared.CommMessages.CommunicationMessage.ActionType Caction, int Camount, int roomId)
        {
            TexasHoldemShared.CommMessages.CommunicationMessage.ActionType ChosenOption = Caction;
            int amount = Camount;

            if (amount > -1)
            {
                ActionCommMessage response       = new ActionCommMessage(_userId, ChosenOption, amount, roomId);
                string            parsedResponse = XmlParser.SerializeMsg(response);
                _handler.addMsgToSend(parsedResponse);
            }
            else
            {
                Console.WriteLine("illegal");
            }
        }
Exemplo n.º 8
0
        public ResponeCommMessage HandleEvent(ActionCommMessage msg)
        {
            if (_sessionIdHandler != null)
            {
                ResponeCommMessage             response = null;
                IEnumerator <ActionResultInfo> iter;
                switch (msg.MoveType)
                {
                case CommunicationMessage.ActionType.Bet:
                case CommunicationMessage.ActionType.Fold:
                case CommunicationMessage.ActionType.HandCard:
                case CommunicationMessage.ActionType.Leave:
                case CommunicationMessage.ActionType.StartGame:
                case CommunicationMessage.ActionType.SpectatorLeave:
                    iter     = _gameService.DoAction(msg.UserId, msg.MoveType, msg.Amount, msg.RoomId);
                    response = SendMessages(msg.UserId, iter, msg);
                    break;

                case CommunicationMessage.ActionType.Join:
                    iter = _gameService.DoAction(msg.UserId, msg.MoveType, msg.Amount, msg.RoomId);

                    response = SendMessagesJoin(msg.UserId, iter, msg);
                    break;

                case CommunicationMessage.ActionType.Spectate:
                    iter     = _gameService.AddSpectatorToRoom(msg.UserId, msg.RoomId);
                    response = SendMessagesJoin(msg.UserId, iter, msg);
                    break;
                }
                if (response != null)
                {
                    return(response);
                }
            }
            return(new ResponeCommMessage(msg.UserId, msg.SessionId, false, msg));
        }
Exemplo n.º 9
0
 public ResponeCommMessage HandleEvent(ActionCommMessage msg)
 {
     GotClientToServerMsg(msg);
     return(new ResponeCommMessage(msg.UserId, msg.SessionId, false, msg));
 }
Exemplo n.º 10
0
 public void HandleEvent(ActionCommMessage msg)
 {
     Console.WriteLine("ActionCommMessage is client to server message");
 }