예제 #1
0
        public void pickPieces(DominoSet dominoSet)
        {
            Random          rnd             = new Random();
            int             pickedPieces    = 0;
            PieceCollection availablePieces = dominoSet.getUnpickedPieces();

            // there is a special case for when there are 7 pieces left
            if (availablePieces.getCount() == 7)
            {
                playerPieces = availablePieces;
            }
            else
            {
                while (pickedPieces < 7)
                {
                    Piece pickedPiece = availablePieces.getPieceById(rnd.Next(0, availablePieces.getCount()));
                    if (!pickedPiece.picked)
                    {
                        playerPieces.addPiece(pickedPiece);
                        pickedPieces++;
                        dominoSet.markPickedPiece(pickedPiece);
                    }
                }
            }
        }
예제 #2
0
 public Player(int id, string playerName, int teamId)
 {
     this.id      = id;
     this.name    = playerName;
     this.teamId  = teamId;
     playerPieces = new PieceCollection();
 }
예제 #3
0
        static void testSetCreation()
        {
            DominoSet       set    = new DominoSet();
            PieceCollection pieces = set.getPieces();

            Console.WriteLine("Total Pieces {0}", pieces.getCount());
            Console.WriteLine(pieces.ToString());
        }
예제 #4
0
        public PieceCollection getUnpickedPieces()
        {
            PieceCollection unassigned = new PieceCollection();

            foreach (Piece p in pieces)
            {
                if (!p.picked)
                {
                    unassigned.addPiece(p);
                }
            }
            return(unassigned);
        }
예제 #5
0
        public DominoSet()
        {
            pieces = new PieceCollection();
            int pieceId = 0;

            //Create the pieces
            for (int upperValue = 0; upperValue < 7; upperValue++)
            {
                for (int lowerValue = upperValue; lowerValue < 7; lowerValue++)
                {
                    pieces.addPiece(new Piece(upperValue, lowerValue, pieceId));
                    pieceId++;
                }
            }
        }