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); } } } }
public Player(int id, string playerName, int teamId) { this.id = id; this.name = playerName; this.teamId = teamId; playerPieces = new PieceCollection(); }
static void testSetCreation() { DominoSet set = new DominoSet(); PieceCollection pieces = set.getPieces(); Console.WriteLine("Total Pieces {0}", pieces.getCount()); Console.WriteLine(pieces.ToString()); }
public PieceCollection getUnpickedPieces() { PieceCollection unassigned = new PieceCollection(); foreach (Piece p in pieces) { if (!p.picked) { unassigned.addPiece(p); } } return(unassigned); }
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++; } } }