public void ResetRecordsTest(string record, int darkCount, int lightCount) { var positions = CellPosition.ParseList(record); var table = new Table(); table.Reset(positions); Assert.Equal(darkCount, table.Cells.Count(x => x.State == CellState.Dark)); Assert.Equal(lightCount, table.Cells.Count(x => x.State == CellState.Light)); }
private void Awake() { _records = _records.ToLower().Trim(); var records = CellPosition.ParseList(_records); FirstPlayer = Table.Reset(records); foreach (var cell in Table.Cells) { _cellViews.Add(CreateTableCellView(cell)); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); var table = new Table(); var player = Player.Dark; string record = req.Query["record"]; if (!string.IsNullOrEmpty(record)) { var pts = CellPosition.ParseList(record.ToLower().Trim()); player = table.Reset(pts); } else { table.Reset(); } var random = new Random(); var placableCells = table.GetPlaceableCells(player).ToArray(); if (placableCells.Length == 0) { // pass or gameover. return(new OkObjectResult(record)); } var index = random.Next(placableCells.Length); var next = placableCells[index]; if (table.TryPlace(next, player)) { return(new OkObjectResult(record + next.ToString())); } else { // TODO: Error return(new EmptyResult()); } }