Ejemplo n.º 1
0
        public void SendAllowedMoves()
        {
            if (FirstUser.Player.IsHisTurn)
            {
                List <BoardPosition> tempList = Gameboard.GetAllLegalMoves(FirstUser.Player.DiskColor);
                string tempString             = "";
                int    count = 1;
                foreach (BoardPosition aux in tempList)
                {
                    if (count == tempList.Count)
                    {
                        tempString += aux.Row.ToString() + ':' + aux.Column;

                        continue;
                    }
                    tempString += aux.Row.ToString() + ':' + aux.Column + '|';
                    count++;
                }
                MessageRoomPacket Packet = new MessageRoomPacket(GameProtocol.BoardMoves(), ID, tempString);
                Othello.Server.SendPacket(FirstUser.Socket, Packet.getData());
            }
            else if (SecondUser.Player.IsHisTurn)
            {
                List <BoardPosition> tempList = Gameboard.GetAllLegalMoves(SecondUser.Player.DiskColor);
                string tempString             = "";
                int    count = 1;
                foreach (BoardPosition aux in tempList)
                {
                    if (count == tempList.Count)
                    {
                        tempString += aux.Row.ToString() + ':' + aux.Column;

                        continue;
                    }
                    tempString += aux.Row.ToString() + ':' + aux.Column + '|';
                    count++;
                }
                MessageRoomPacket Packet = new MessageRoomPacket(GameProtocol.BoardMoves(), ID, tempString);
                Othello.Server.SendPacket(SecondUser.Socket, Packet.getData());
            }
        }
Ejemplo n.º 2
0
        private void SendLegalMoves(User x)
        {
            if (x.Player.IsHisTurn)
            {
                List <BoardPosition> tempList = Gameboard.GetAllLegalMoves(x.Player.DiskColor);
                string tempString             = "";
                int    count = 1;
                foreach (BoardPosition aux in tempList)
                {
                    if (count == tempList.Count)
                    {
                        tempString += aux.Row.ToString() + ':' + aux.Column + '!' + Gameboard.GetNumberOfChanges(aux.Row, aux.Column, x.Player.DiskColor);

                        continue;
                    }
                    tempString += aux.Row.ToString() + ':' + aux.Column + '!' + Gameboard.GetNumberOfChanges(aux.Row, aux.Column, x.Player.DiskColor) + '|';
                    count++;
                }
                MessageRoomPacket movesPacket = new MessageRoomPacket(GameProtocol.BoardMoves(), ID, tempString);
                //DelayPacket(100);
                Othello.Server.SendPacket(x.Socket, movesPacket.getData());
            }
        }