def __init__(self): level_str = make_level() self.width = level_str.index('\n') self.height = level_str.count('\n') self.level = [] self.teams = set() self.players = set() self.projectiles = set() self.graph = Graph() self.starts = set() for y in range(0, self.height): row = [] for x in range(0, self.width): type_id = level_str[y * (self.width + 1) + x] row.append(Point( x=x, y=y, type_id=type_id, theme_id=('金' if type_id in 'iwX' else None), orientation=None )) self.level.append(row) for pt in self.all_points: if pt.type_id == 'X': self.starts.add(pt) self.set_node(pt)
def handle_noargs(self, **kwargs): level = make_level() width = level.index('\n') height = level.count('\n') print(width, height) print(level) types = {} # Point.objects.all().delete() for x in range(0, width): for y in range(0, height): t = level[y * (width + 1) + x] # ptype = PointType.objects.find(t) # Point.objects.create(x=x, y=y, type=ptype, clear=None) types.setdefault(t, 0) types[t] += 1 # Point.objects.update(version=1) for t, count in list(types.items()): print('%s: %s' % (t, count))