public static HexTile ImportRow(CsvReader csv, int id) { try { HexTile tile = new HexTile { Id = id, Symbol = SymbolConverter.Get(csv.GetField(1)[0].ToString()), ImageUrl = csv.GetField(0) }; int merge = 2450; //int offset = id >= merge ? 1 : 0; int offset = 1; //tile.ForceDelete = id >= merge; tile.ForceDelete = false; // Import the wall. string wall = csv.GetField(2); tile.Walls = new bool[6]; tile.Walls[0] = !wall.Contains((1 - offset).ToString()); tile.Walls[1] = !wall.Contains((2 - offset).ToString()); tile.Walls[2] = !wall.Contains((3 - offset).ToString()); tile.Walls[3] = !wall.Contains((4 - offset).ToString()); tile.Walls[4] = !wall.Contains((5 - offset).ToString()); tile.Walls[5] = !wall.Contains((6 - offset).ToString()); for (int i = 0; i < 6; i++) { tile.Nodes[i] = SmallHexGroup.Import(csv, i); } tile.Status = csv.GetField(9); // Populate the URL for checking. string data = ""; for (int i = 0; i < 9; i++) { data += $"{csv.GetField(i)}\t"; } tile.Url = BaseUrl + Convert.ToBase64String(Encoding.ASCII.GetBytes(data)); return(tile); } catch (Exception ex) { return(null); } }
public static SmallHexGroup Import(CsvReader csv, int index) { SmallHexGroup group = new SmallHexGroup(); string node = csv.GetField(3 + index).Replace(" ", "").Replace(",", "").Replace("\r", "").Replace("\n", ""); group.IsValid = node.Length == 7; if (!group.IsValid) { return(group); } for (int i = 0; i < 7; i++) { group.HexTiles[i] = new SmallHexTile { Symbol = SymbolConverter.Get(node[i].ToString()) }; } return(group); }
public HexTileForMerge(HexTile tile, bool ourFormat = true) { ImageUrl = tile.ImageUrl; Center = tile.Symbol.ToString(); List <int> nums = new List <int>(); for (int i = 0; i < 6; i++) { if (tile.Walls[i]) { continue; } nums.Add(ourFormat ? i : i + 1); } Holes = string.Join(",", nums); for (int i = 0; i < 6; i++) { Links[i] = string.Join("", tile.Nodes[i].HexTiles.Select(t => SymbolConverter.Get(t.Symbol))); } }