public static char GetChar(UnMovableCell landcell, MovableCell moveCell) { if (moveCell.Type == Cell.CellType.Ant && landcell.Type == Cell.CellType.Hill) return (char)(((Ant)moveCell).CommandNumber + 'A'); if (moveCell.Type == Cell.CellType.Ant) return (char)(((Ant)moveCell).CommandNumber + 'a'); if (landcell.Type == Cell.CellType.Hill) { var hill = (Hill)landcell; return (char)(hill.CommandNumber + '0'); } return moveCell.Type == CellType.Empty ? (char) landcell.Type : (char) moveCell.Type; }
private void InitCell(Point point, char c) { KilledAntsMap[point] = new List<Cell>(); if (c >= '0' && c <= '9') { int command = c - '0'; var hill = new Hill(point, command, this); Armies[command].Hills.Add(hill); OriginalMap[point] = hill; ObjectsMap[point] = new Empty(point, this); } else if (c >= 'a' && c <= 'j') { int command = c - 'a'; var ant = new Ant(point, command, this); Armies[command].Ants.Add(ant); OriginalMap[point] = new UnMovableCell(point, Cell.CellType.Land, this); ObjectsMap[point] = ant; } else if (c >= 'A' && c <= 'J') { int command = c - 'A'; var hill = new Hill(point, command, this); Armies[command].Hills.Add(hill); var ant = new Ant(point, command, this); Armies[command].Ants.Add(ant); OriginalMap[point] = hill; ObjectsMap[point] = ant; } else if (c == '*') { var food = new Food(point, this); Food.Add(food); OriginalMap[point] = new UnMovableCell(point, Cell.CellType.Land, this); ObjectsMap[point] = food; } else if (c == '!') { OriginalMap[point] = new UnMovableCell(point, Cell.CellType.Land, this); ObjectsMap[point] = new Empty(point, this); KilledAntsMap[point].Add(new Ant(point, -1, this).GetDead()); } else if (c == '%') { OriginalMap[point] = new UnMovableCell(point, Cell.CellType.Water, this); ObjectsMap[point] = new Empty(point, this); } else if (c == '.') { OriginalMap[point] = new UnMovableCell(point, Cell.CellType.Land, this); ObjectsMap[point] = new Empty(point, this); } else { OriginalMap[point] = new UnMovableCell(point, Cell.CellType.Unseen, this); ObjectsMap[point] = new Empty(point, this); } }