def __init__(self,builder,pos): rescources=[0,0,0] self.player=builder.player if self.place=="vertex": world.getCell(pos[0],pos[1]).verticies[pos[2]]=self elif self.place=="edge": world.getCell(pos[0],pos[1]).edges[pos[2]]=self else:raise MyError("unknown place type: "+self.place) self.pos=pos if builder: for n in range(3): builder.resources[n]-=self.cost[n] check(builder.resources[n]>=0,"does not have enough resources to build this") for x,y,cell in self.visible(): self.player.seen[x,y]=cell self.player.buildings.append(self)
def visible(self): for dx,dy in hexSpiral(self.LOS): x,y=self.pos[0]+dx,self.pos[1]+dy yield x,y,world.getCell(x,y)