public static Ficha GeneratePiece() { Ficha ficha = new Ficha(); ficha.Color = Ficha.GetRandomColorFicha(); return(ficha); }
public static Tablero GenerateBoardFromString(string tableroStr) { string[] lineas = tableroStr.Split('\n'); Tablero t = Tablero.GenerateBoard(lineas.Length); int filaIndex = 0; foreach (string linea in lineas) { string lineaLimpia = linea.Trim().ToUpper(); int colIndex = 0; foreach (char ficharChar in lineaLimpia) { if (ficharChar == 'X') { t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex); } if (ficharChar == '1') { t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Rojo)); } if (ficharChar == '2') { t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Azul)); } if (ficharChar == '3') { t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Verde)); } if (ficharChar == '4') { t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Amarillo)); } if (ficharChar == 'R') { t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(Ficha.GetRandomColorFicha())); } colIndex++; } filaIndex++; } return(t); }