/////////// Board Pattern ////////// // // [0] [1] [2] // [3] [4] [5] // [6] [7] [8] // public bool AddNewMills(ReactiveCollection <Tile> tiles, TileStatus ts, Tile movedTile) { Mill currentMill = null; checkMill(0, 1, 2, movedTile, ts, tiles, ref currentMill); checkMill(3, 4, 5, movedTile, ts, tiles, ref currentMill); checkMill(6, 7, 8, movedTile, ts, tiles, ref currentMill); checkMill(0, 3, 6, movedTile, ts, tiles, ref currentMill); checkMill(1, 4, 7, movedTile, ts, tiles, ref currentMill); checkMill(2, 5, 8, movedTile, ts, tiles, ref currentMill); // Check validity if (currentMill == null) { return(false); } currentMill.Turn = Turn; if (currentMill.First != movedTile && currentMill.Second != movedTile && currentMill.Third != movedTile) { return(false); } PreviousMills.Add(currentMill); return(true); }
private void checkMill(int a, int b, int c, Tile movedTile, TileStatus ts, ReactiveCollection <Tile> tiles, ref Mill tofill) { if (tiles[a].Status == ts && tiles[b].Status == ts && tiles[c].Status == ts && (movedTile == tiles[a] || movedTile == tiles[b] || movedTile == tiles[c])) { tofill = new Mill(tiles[a], tiles[b], tiles[c]); } }