public GridBoard PurchaseGridTicket(GridBoard grid, int ticketId) { string response = this.Client.PlayGridTicket(ticketId, grid.GameId, grid.Type); GridBoard newGrid = GetGridFromResponse(response, grid.Type); return(newGrid); }
private GridBoard GetGridFromResponse(string response, GridType type) { GridBoard grid = null; MatchCollection matches = GridRegex.Matches(response); foreach (Match match in matches) { // Only need to get this once if (grid == null) { int gameId = int.Parse(match.Groups["grid_id"].Value); grid = new GridBoard(gameId, type); } int id = int.Parse(match.Groups["ticket"].Value);; Cell cell = new Cell(id); string color = match.Groups["color"].Value; if (type == GridType.TheSlums) { if (color == "#F7BB09") { cell.State = CellState.Award; } else if (color == "#730000") { cell.State = CellState.Empty; } else if (color == "#644B76") { cell.State = CellState.Item; } else { cell.State = CellState.Hidden; } } grid.AddCell(cell); } return(grid); }