def do(self): builder = Object(self.oid) # FIXME: Check that this is a planet # FIXME: Check that this planet has the headquarter resource if False: print "Could not do a build order because it was on a planet headquaters. (This should not happen.)" self.remove() # Check that there are enough components to build this ship... # Build new fleet object fleet = Object(type='tp.server.rules.minisec.objects.Fleet') # Check if there is a design which matches this amount of components. If not create it... # Type Fleet fleet.parent = builder.id fleet.posx = builder.posx fleet.posy = builder.posy fleet.posz = builder.posz fleet.size = 1 fleet.owner = builder.owner fleet.ships = self.ships fleet.insert() fleet.name = self.name fleet.save() message = Message() message.slot = -1 message.bid = builder.owner message.subject = "Fleet built" message.body = """\ A new ship (%s) has been built and is orbiting %s. """ % (fleet.name, builder.name) message.insert() self.remove()
def resetModel(self): for name in ["Board", "Object", "Design", "Component", "Property", "ResourceType", "Category", "Player"]: Object = self.model.use(name) Model.remove(Object.query().all())