| 1234567891011121314151617181920212223242526272829 |
- using System;
- namespace DevilLink2.Core
- {
- /// <summary>Immutable tile identity with board-controlled location. IDs are unique within a board.</summary>
- public sealed class Tile
- {
- internal Board Owner { get; set; }
- public int Id { get; }
- public TileSymbol Symbol { get; }
- public int Row { get; private set; }
- public int Column { get; private set; }
- public GridPosition Position => new GridPosition(Row, Column);
- internal void SetPosition(int row, int column)
- {
- Row = row; Column = column;
- }
- public Tile(int id, TileSymbol symbol, int row, int column)
- {
- if (id <= 0) throw new ArgumentOutOfRangeException(nameof(id));
- if (!Enum.IsDefined(typeof(TileSymbol), symbol)) throw new ArgumentOutOfRangeException(nameof(symbol));
- if (row < 0) throw new ArgumentOutOfRangeException(nameof(row));
- if (column < 0) throw new ArgumentOutOfRangeException(nameof(column));
- Id = id; Symbol = symbol; Row = row; Column = column;
- }
- }
- }
|