Ejemplo n.º 1
0
	def do(self):
		builder = Object(self.oid)

		if not hasattr(builder, "owner"):
			print "Could not do a build order because it was on an unownable object."
			self.remove()
		
		if self.turns() > 1:
			# Add another year to worked...
			self.worked += 1
			print "Worked %s, %s left until built." % (self.worked, self.turns())
			self.save()
			return
			
		# Build new fleet object
		fleet = Object(type='tp.server.rules.minisec.objects.Fleet')

		# 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 fleet (%s) has been built and is orbiting %s.
It consists of:
""" % (fleet.name, builder.name)

		for type, number in fleet.ships.items():
			if number > 1:
				message.body += "%s %ss" % (number, Fleet.ship_types[type])
			else:
				message.body += "%s %s" % (number, Fleet.ship_types[type])

		message.insert()

		self.remove()
Ejemplo n.º 2
0
	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()