public Hole(int row, int col) { coord = new Coordinate(); isFilled = false; canBePlayed = false; marbleInHole = new Marble(Color.Empty); coord.Row = row; coord.Col = col; }
public bool MakeMoveOnBoard(string move) { bool results = false; string color = move[0].ToString(); int row = Convert.ToInt32(move[1].ToString()); int col = Convert.ToInt32(move[2].ToString()); Coordinate moveCoord = new Coordinate(row, col); Color c; if (color == "R") { c = Color.Red; } else { c = Color.Blue; } Marble m = new Marble(c); foreach (Tile t in tiles) { foreach (Hole h in t.Holes) { if (h.Coord.Row == moveCoord.Row && h.Coord.Col == moveCoord.Col) { if (!h.IsFilled && h.CanBePlayed) { h.MarbleInHole = m; h.IsFilled = true; //Console.WriteLine("Placed a " + color + " marble at (" + moveCoord.Row + "," + moveCoord.Col + ")"); if (c == Color.Red) { t.NumOfRedMarbles++; ResetLastPlayer1Tile(); t.LastPlayedOnByPlayer1 = true; } else { t.NumOfBlueMarbles++; ResetLastPlayer2Tile(); t.LastPlayedOnByPlayer2 = true; } DisableImpossibleMoves(moveCoord.Row, moveCoord.Col); results = true; } } } } return(results); }
public bool MakeMoveOnBoard(string move) { bool results = false; string color = move[0].ToString(); int row = Convert.ToInt32(move[1].ToString()); int col = Convert.ToInt32(move[2].ToString()); Coordinate moveCoord = new Coordinate(row, col); Color c; if (color == "R") c = Color.Red; else c = Color.Blue; Marble m = new Marble(c); foreach (Tile t in tiles) { foreach (Hole h in t.Holes) { if (h.Coord.Row == moveCoord.Row && h.Coord.Col == moveCoord.Col) { if (!h.IsFilled && h.CanBePlayed) { h.MarbleInHole = m; h.IsFilled = true; //Console.WriteLine("Placed a " + color + " marble at (" + moveCoord.Row + "," + moveCoord.Col + ")"); if (c == Color.Red) { t.NumOfRedMarbles++; ResetLastPlayer1Tile(); t.LastPlayedOnByPlayer1 = true; } else { t.NumOfBlueMarbles++; ResetLastPlayer2Tile(); t.LastPlayedOnByPlayer2 = true; } DisableImpossibleMoves(moveCoord.Row, moveCoord.Col); results = true; } } } } return results; }