public void ScoreRow(BoardRow row, int wallPosition, DiscardPile discardPile) { if (Board.PatternLineFull(row)) { var tile = Board.PatternLines[row].First(); Board.PatternLines[row].Remove(tile); if (!Board.Wall.Place(tile, (int)(row) - 1, wallPosition)) { discardPile.Put(tile); } discardPile.Put(Board.PatternLines[row]); Board.PatternLines[row].Clear(); } if (Board.Wall.RowFull(row)) { OnPlayerEvent(TriggeredGameEndCondition); } if (Board.AllPatternLinesProcessed()) { OnPlayerEvent(ScoredThisRound); } }
/// <summary> /// Display a board row. /// </summary> /// <param name="row">The row to be displayed.</param> private void DisplayBoardRow(BoardRow row) { // Go through the squares and display them for (int i = 0; i < row.Squares.Length; i++) { DisplayBoardSquare(row.Squares[i]); } }
public void CreateNewBoard() { Board = new BoardRow[Columns]; for (int i = 0; i < Columns; i++) { Board[i] = new BoardRow(Rows); } }
public void CreateNewBoard() { board = new BoardRow[columns]; for (int i = 0; i < columns; i++) { board[i] = new BoardRow(rows); } }
public DissolvingRowEntity(DissolvingBoardRowRenderer dissolvingBoardRowRenderer, BoardRow boardRow) { Alive = true; Transform = new Transform(); _dissolvingBoardRowRenderer = dissolvingBoardRowRenderer; _boardRow = boardRow; _disolveAnimation = new Animation(TimeSpan.FromMilliseconds(300)); _disolveAnimation.Start(); }
public bool RowFull(BoardRow row) { for (int i = 0; i < 5; i++) { if (Slots[(int)row - 1, i] == null) { return(false); } } return(true); }
public int IndexOf(BoardRow row, TileColor tileColor) { for (int i = 0; i < 5; i++) { if (SlotConfiguration[(int)row - 1, i].Equals(tileColor)) { return(i); } } throw new AzulGameplayException("No such color on the board row."); }
public BoardRow AddBoardRow(string BoardText) { BoardRow rowBoardRow = ((BoardRow)(this.NewRow())); object[] columnValuesArray = new object[] { BoardText }; rowBoardRow.ItemArray = columnValuesArray; this.Rows.Add(rowBoardRow); return(rowBoardRow); }
//TODO: remove, this is just a testing helper: public List <TileColor> GetFreeTileColorsInRow(BoardRow row) { var l = new List <TileColor>(); for (int i = 0; i < 5; i++) { if (Slots[(int)row - 1, i] == null) { l.Add(SlotConfiguration[(int)row - 1, i]); } } return(l); }
public void PlacePendingTiles(BoardRow boardRow, DiscardPile discardPile) { if (pendingTiles.Count == 0) { throw new AzulGameplayException("No tiles staged for placing."); } var surplusTiles = Board.PlaceOnPatternLine(boardRow, pendingTiles); if (surplusTiles.Count > 0) { discardPile.Put(surplusTiles); } pendingTiles.Clear(); }
/// <summary> /// Creates a new instance of <see cref="UIFelliRow"/>. /// </summary> /// <param name="name">The name given to the element. This is basically an ID.</param> /// <param name="position">The anchor position of this element.</param> /// <param name="row">The game board's row.</param> /// <param name="squareSpacing">The spacing between squares.</param> /// <param name="colorBg">The background color of the element.</param> /// <param name="colorFg">The foreground color of the element.</param> public UIFelliRow(string name, UIPosition position, BoardRow row, int squareSpacing, ConsoleColor colorBg = UISettings.ColorBoardRowBg, ConsoleColor colorFg = UISettings.ColorConsoleFg) : base(name, position, colorBg, colorFg) { this.row = row; this.squares = new UIFelliSquare[row.Squares.Length]; this.squareSpacing = squareSpacing; for (int i = 0; i < row.Squares.Length; i++) { this.squares[i] = new UIFelliSquare($"felliSquare{i}", this.TopLeft, row.Squares[i]); } }
/// <summary> /// Add a row to the board, either cutting off the end or padding it with null so that the length corresponds /// to the length of the row where it is to be insertetd. The row is inserted at the top or at the bottom /// as specified by atTop. /// </summary> /// <param name="balls">The new list of balls to add.</param> /// <param name="atTop">If true, the new row will be added at the top, if false it /// will be added at the bottom.</param> private void AddRow(List <Ball> balls, bool atTop) { // The max number of balls is set to the maximum number for the top or bottom row based on atTop int rowMax = atTop ? mColumns[(int)NextTypeTop] : mColumns[(int)NextTypeBottom]; // If the number of balls in the list is not equal to the row length where it is to be inserted - fix it. if (balls.Count != rowMax) { for (int i = balls.Count; i < rowMax; ++i) { balls.Add(null); } if (balls.Count > rowMax) { balls.RemoveRange(rowMax, balls.Count - rowMax); } } // Insert row at the top or bottom based on atTop, if at top - update all the positions. BoardRow newRow; if (atTop) { newRow = new BoardRow(NextTypeTop, balls); mBalls.Insert(0, newRow); UpdatePositions(); } else { newRow = new BoardRow(NextTypeBottom, balls); mBalls.Insert(mBalls.Count, newRow); } // Update the number of balls array with the newly added balls. foreach (Ball ball in newRow.Row) { if (ball != null) { ChangeNumberOfBalls(ball.Colour, true); } } }
public List <Tile> PlaceOnPatternLine(BoardRow boardRow, List <Tile> tiles) { //if(patternLines[boardRow].Exists(t => t.TileColor != tiles.First().TileColor)) { // throw new AzulGameplayException(string.Format("Cannot place tiles on {0} as it already contains tile(s) of another color.", boardRow)); //} var full = patternLines[boardRow].Count == (int)boardRow; if (!full) { var x = Math.Min(tiles.Count, (int)boardRow - patternLines[boardRow].Count); List <Tile> fittingTiles = tiles.GetRange(0, x); patternLines[boardRow].AddRange(fittingTiles); var remainingTiles = tiles.Except(fittingTiles).ToList(); return(PlaceOnFloorLine(remainingTiles)); } return(PlaceOnFloorLine(tiles)); }
private IPlayer GetDomainatingPlayer(BoardRow boardRow, out IList <Coordinate> playersCoordinates) { Dictionary <IPlayer, List <Coordinate> > scoreboard = new Dictionary <IPlayer, List <Coordinate> >(); foreach (Coordinate boardRowSpot in boardRow.Spots) { IPlayer player = this.Board.Spots[boardRowSpot.Level][boardRowSpot.X, boardRowSpot.Y].Player; if (player == null) { continue; } List <Coordinate> playerCoordinates; if (scoreboard.ContainsKey(player)) { playerCoordinates = scoreboard[player]; } else { playerCoordinates = new List <Coordinate>(); scoreboard.Add(player, playerCoordinates); } playerCoordinates.Add(boardRowSpot); } IPlayer dominator = null; playersCoordinates = null; int max = int.MinValue; foreach (KeyValuePair <IPlayer, List <Coordinate> > keyValuePair in scoreboard) { if (keyValuePair.Value.Count > max) { max = keyValuePair.Value.Count; playersCoordinates = keyValuePair.Value; dominator = keyValuePair.Key; } } return(dominator); }
public void RemoveBoardRow(BoardRow row) { this.Rows.Remove(row); }
public BoardRowChangeEvent(BoardRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public void AddBoardRow(BoardRow row) { this.Rows.Add(row); }
public bool PatternLineFull(BoardRow row) { return(PatternLines[row].Count == (int)row); }