コード例 #1
0
ファイル: Message.py プロジェクト: cahirwpz/tpserver-py
	def __call__( self, request ):
		Container = self.model.use( 'Board' )

		container = Container.ById( request.id )

		if container:
			if self.authorize( container ):
				slot = request.slot if request.slot < len( container.messages ) else -1

				message = self.fromPacket( request ) 

				if slot == -1:
					container.messages.append( message )
				else:
					container.messages.insert( slot, message )

				Model.add( container )

				if slot == -1:
					slot = len( container.messages )

				response = self.Okay( request, "Message posted on %s with id = %d in slot %d." % ( Container.__origname__, request.id, slot ) )
			else:
				debug( "No permission for %s with id %s.", Container.__origname__, request.id ) 
				response = self.Fail( request, "PermissionDenied", "You cannot access %s with id = %d." % ( Container.__origname__, request.id ) )
		else:
			debug( "No such %s with id %s.", Container.__origname__, request.id ) 
			response = self.Fail( request, "NoSuchThing", "No %s with id = %d." % ( Container.__origname__, request.id ) )

		return response 
コード例 #2
0
ファイル: Ruleset.py プロジェクト: cahirwpz/tpserver-py
    def addPlayer(self, username, password, email="N/A", comment=""):
        """
		Create a player for this game.

		The default function creates a new user, a board for the user and adds a
		welcome message. It returns the newly created user object.
		"""
        Player, Board, Message = self.model.use("Player", "Board", "Message")

        player = Player(username=username, password=password, email=email, comment=comment)

        board = Board(
            owner=player,
            name="Private message board for %s" % username,
            description="This board is used so that stuff you own (such as fleets and planets) can inform you of what is happening in the universe.",
        )

        board.messages.append(
            Message(
                subject="Welcome to the Universe!",
                body="Welcome, %s, to the python Thousand Parsec server. Hope you have fun!"
                "This game is currently playing version %s of %s." % (username, self.version, self.name),
                turn=self.game.turn,
            )
        )

        Model.add(player, board)

        return player
コード例 #3
0
ファイル: __init__.py プロジェクト: cahirwpz/tpserver-py
    def initModel(self):
        Ruleset.initModel(self)

        universe = self.generator.createUniverse(name="The Universe")
        ships = self.generator.createShipClasses()

        Model.add(universe, ships)
コード例 #4
0
ファイル: message.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Board, Message = self.model.use( 'Board', 'Message' )

		board = Board(
			owner		= self.players[0],
			name        = "First message board for %s" % self.players[0].username,
			description = "Board for testing purposes." )

		board.messages.append(
			Message(
				subject = "First",
				body	= "Test message generated in first turn",
				turn    = 1 ))

		board.messages.append(
			Message(
				subject = "Second",
				body	= "Test message generated in second turn",
				turn    = 2 ))

		board.messages.append(
			Message(
				subject = "Third",
				body	= "Test message generated in third turn",
				turn    = 3 ))

		self.board = board

		Model.add( board )
コード例 #5
0
ファイル: objects.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Universe, StarSystem, Planet, Fleet = self.model.use( 'Universe', 'StarSystem', 'Planet', 'Fleet' )

		universe = Universe(
				name = "The Universe",
				size = 10**8,
				age  = 0 )

		system = StarSystem(
				name		= "The Star System",
				parent		= universe,
				position	= Vector3D( 0, 0, 0 ),
				size		= 10**4)

		planet = Planet(
				name		= "The Planet",
				parent		= system,
				position	= Vector3D( system.position.x + 5,
										system.position.y + 7 ),
				size		= 10**2,
				owner		= self.players[0] )

		fleet = Fleet(
				parent   = planet,
				size     = 3,
				name     = "The Fleet",
				ships    = [],
				damage   = 0,
				position = planet.position,
				owner    = self.players[0])

		self.objects = [ universe, system, planet, fleet ]

		Model.add( self.objects )
コード例 #6
0
ファイル: board.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Board = self.model.use( 'Board' )

		board1 = Board(
			owner       = self.players[0],
			name        = "First message board for %s" % self.players[0].username,
			description = "Board for testing purposes." )

		board2 = Board(
			owner       = self.players[0],
			name        = "Second message board for %s" % self.players[0].username,
			description = "Board for testing purposes." )

		board3 = Board(
			owner       = self.players[1],
			name        = "Message board for %s" % self.players[1].username,
			description = "Board for testing purposes." )

		board4 = Board(
			owner		= None,
			name		= "Public message board.",
			description = "Board for testing purposes." )

		self.boards = [ board1, board2, board3, board4 ]

		Model.add( self.boards )
コード例 #7
0
ファイル: category.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Category = self.model.use( 'Category' )

		self.cat = Category(
				name = "Public",
				description = "Public category for testing purposes." )

		Model.add( self.cat )
コード例 #8
0
ファイル: category.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Category = self.model.use( 'Category' )

		self.cat = Category(
				name = "Private2",
				owner = self.players[1],
				description = "Private category for testing purposes." )

		Model.add( self.cat )
コード例 #9
0
ファイル: gamemanager.py プロジェクト: cahirwpz/tpserver-py
	def initialise( self ):
		Model.add( self.__game )

		self.ruleset.loadModelConstants()
		self.ruleset.initModelConstants()
		self.ruleset.loadModel()
		self.ruleset.initModel()

		info( "Game '%s' initialised successfully.", self.name )
コード例 #10
0
ファイル: category.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		self.cat_name = "Test"

		Category = self.model.use( 'Category' )

		self.other_cat = Category(
				name = self.cat_name,
				owner = self.players[1],
				description = "Private Category for testing purposes." )

		Model.add( self.other_cat )
コード例 #11
0
ファイル: Ruleset.py プロジェクト: cahirwpz/tpserver-py
    def initModelConstants(self):
        ObjectType, OrderType, ObjectOrder = self.model.use("ObjectType", "OrderType", "ObjectOrder")

        Model.add(OrderType(id=_1, name=_2.__name__) for _1, _2 in enumerate(self.OrderTypes))

        ObjectOrderList = []

        for ObjectName, OrderNameList in self.ObjectOrders.iteritems():
            for _1 in OrderNameList:
                ObjectOrderList.append((ObjectType.ByName(ObjectName), OrderType.ByName(_1.__name__)))

        Model.add(ObjectOrder(object_type=_1, order_type=_2) for _1, _2 in ObjectOrderList)
コード例 #12
0
ファイル: category.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		self.cat_name = "Test"

		Category = self.model.use( 'Category' )

		self.cat = Category(
				name = self.cat_name,
				description = "Public category for testing purposes." )

		self.wrong_cat = None

		Model.add( self.cat )
コード例 #13
0
ファイル: __init__.py プロジェクト: cahirwpz/tpserver-py
	def addPlayer( self, username, password, email = 'Unknown', comment = 'A TimTrader Player' ):
		"""
		Create a Solar System, Planet, and initial Fleet for the player, positioned randomly within the Universe.
		"""
		user, system, planet, fleet = Ruleset.addPlayer( self, username, password, email, comment )

		ResourceType = self.game.objects.use( 'ResourceType' )

		# Get the player's planet object and add the empire capital
		planet.resources = {
				ResourceType.ByName('Header Quarter') : { 'accessible' : 1 },
				ResourceType.ByName('Credit')         : { 'accessible' : 10000 } }

		Model.add( planet )
コード例 #14
0
ファイル: __init__.py プロジェクト: cahirwpz/tpserver-py
    def addPlayer(self, username, password, email="Unknown", comment="A Minisec Player"):
        """
		Create a Solar System, Planet, and initial Fleet for the player, positioned randomly within the Universe.
		"""
        user = Ruleset.addPlayer(self, username, password, email, comment)

        Object = self.model.use("Object")

        universe = Object.ByType("Universe")[0]
        system = self.generator.createStarSystem(parent=universe, name="%s Solar System" % username)
        planet = self.generator.createPlanet(parent=system, name="%s Planet" % username, owner=user)
        fleet = self.generator.createFleet(parent=planet, name="%s First Fleet" % username, owner=user)

        Model.add(universe, system, planet, fleet)

        return (user, system, planet, fleet)
コード例 #15
0
ファイル: Category.py プロジェクト: cahirwpz/tpserver-py
	def __call__( self, request ):
		"""
		Request:  AddCategory :: Category
		Response: Category | Fail
		"""
		category = self.fromPacket( request )

		Category = self.model.use( 'Category' )

		if Category.query().filter( and_( Category.name == category.name,
					or_( Category.owner_id == self.player.id, Category.owner_id == None ))).count():
			return self.Fail( request, "PermissionDenied",
					"Category named %s already exists!" % category.name )

		Model.add( category )

		return self.toPacket( request, category )
コード例 #16
0
ファイル: __init__.py プロジェクト: cahirwpz/tpserver-py
	def initModel( self ):
		Ruleset.initialise( self )

		ResourceType = self.game.objects.use( 'ResourceType' )

		# Create all the resources, they consist of,
		#  - One resource for each resource specified in resources.csv
		#  - One resource for each factory specified  in prodcon.csv

		ResourceType.FromCSV( os.path.join( self.files, "resources.csv" ) )

		resources = []

		for factory in ProducersConsumers.loadfile(os.path.join(self.files, "prodcon.csv")):
			# FIXME: Make these auto generated resources much nicer...
			# Ignore the special case factories which are also goods.

			r = ResourceType.ByName( factory.name )

			if r is None:
				r = ResourceType(
						name_singular	= factory.name,
						name_plural		= factory.name,
						description		= "",		
						weight			= 1000,
						size			= 1000 )
			else:
				r.description += "\n"

			r.description += "Converts"

			for product in factory.products:
				# FIXME: Should also display if usage of this resource is required to grow....
				r.description += "\n\t%s -> %s" % product

			r.products = factory.products

			resources.append( r )

		Model.add( *resources )
コード例 #17
0
ファイル: resource.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		ResourceType = self.model.use( 'ResourceType' )

		hq = ResourceType(
				id            = 9,
				name_singular = "Headquarters",
				description   = "The famous headquarters for a big trading conglomerate." )

		credit = ResourceType(
				id            = 3,
				name_singular = "Credit",
				name_plural   = "Credits",
				description   = "The root of all evil, money." )

		uranium = ResourceType(
				id            = 7,
				name_singular = "Uranium",
				name_plural   = "Uranium",
				unit_singular = "kt",
				unit_plural   = "kt",
				description   = "A heavy metal used in weapons.",
				weight        = 1,
				size          = 1 )

		weapon = ResourceType(
				id            = 4,
				name_singular = "Weapon",
				name_plural   = "Weapons",
				unit_singular = "part",
				unit_plural   = "parts",
				description   = "A ship component for destroying other ships.",
				weight        = 1,
				size          = 1 )

		self.resources = [ hq, credit, uranium, weapon ]

		Model.add( self.resources )
コード例 #18
0
ファイル: category.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Category = self.model.use( 'Category' )

		misc = Category(
				name = "Misc",
				description = "Things which dont fit into any other category." )

		production = Category(
				name = "Production",
				owner = self.players[0],
				description = "Things which deal with the production of stuff." )

		combat = Category(
				name = "Combat",
				owner = self.players[1],
				description = "Things which deal with combat between ships." )

		designs = Category(
				name = "Designs",
				description = "A category which has all the designs." )

		self.categories = [ misc, production, combat, designs ]

		Model.add( self.categories )
コード例 #19
0
ファイル: testenv.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		if 'test_minisecplus' not in GameManager():
			GameManager().addGame( 'test_minisecplus', 'Test Game (minisecplus)',
				'minisecplus', 'admin@localhost', 'Test game used for testing purposes')

		self.game = GameManager()[ 'test_minisecplus' ]

		Player = self.model.use( 'Player' )

		player1 = Player(
			username	= '******',
			password	= '******',
			email		= 'player1@localhost',
			comment		= 'Player used for testing purposes.' )

		player2 = Player(
			username	= '******',
			password	= '******',
			email		= 'player2@localhost',
			comment		= 'Player used for testing purposes.' )

		self.players = [ player1, player2 ]

		Model.add( self.players )
コード例 #20
0
ファイル: property.py プロジェクト: cahirwpz/tpserver-py
    def setUp(self):
        Property, Category = self.model.use("Property", "Category")

        misc = Category(id=7, name="Misc", description="Things which dont fit into any other category.")

        production = Category(id=16, name="Production", description="Things which deal with the production of stuff.")

        combat = Category(id=3, name="Combat", description="Things which deal with combat between ships.")

        designs = Category(id=12, name="Designs", description="A category which has all the designs.")

        speed = Property(
            id=10,
            categories=[misc, designs],
            name="speed",
            display_name="Speed",
            description="The maximum number of parsecs the ship can move each turn.",
            calculate="",
        )

        cost = Property(
            id=13,
            categories=[production],
            name="cost",
            display_name="Cost",
            description="The number of components needed to build the ship",
            calculate="",
        )

        hp = Property(
            id=4,
            categories=[combat],
            name="hp",
            display_name="Hit Points",
            description="The amount of damage the ship can take.",
            calculate="",
        )

        backup_damage = Property(
            id=7,
            categories=[combat],
            name="backup-damage",
            display_name="Backup Damage",
            description="The amount of damage that the ship will do when using it's backup weapon. (IE When it draws a battle round.)",
            calculate="",
        )

        primary_damage = Property(
            id=2,
            categories=[combat],
            name="primary-damage",
            display_name="Primary Damage",
            description="The amount of damage that the ship will do when using it's primary weapon. (IE When it wins a battle round.)",
            calculate="",
        )

        escape = Property(
            id=9,
            categories=[misc, designs],
            name="escape",
            display_name="Escape Chance",
            description="The chance the ship has of escaping from battle.",
            calculate="",
        )

        colonise = Property(
            id=99,
            categories=[misc, designs],
            name="colonise",
            display_name="Can Colonise Planets",
            description="Can the ship colonise planets?",
            calculate="",
        )

        self.categories = [misc, production, combat, designs]
        self.properties = [speed, cost, hp, backup_damage, primary_damage, escape, colonise]

        Model.add(self.categories, self.properties)
コード例 #21
0
ファイル: design.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Component, ComponentProperty = self.model.use( 'Component', 'ComponentProperty' )
		Design, DesignComponent, DesignProperty = self.model.use( 'Design', 'DesignComponent', 'DesignProperty' )
		Category, Property = self.model.use( 'Category', 'Property' )

		misc = Category(
				name = "Misc",
				description = "Things which dont fit into any other category." )

		ship = Category(
				name = "Ship",
				description = "Things which deal with space ships." )

		combat = Category(
				name = "Combat",
				description = "Things which deal with combat between ships." )

		self.categories = [ misc, ship, combat ]

		experience = Property(
			categories   = [ misc ],
			name         = "experience",
			display_name = "XP",
			description  = "Experience points of a unit (gained in battles).",
			calculate    = "(lambda (design) (0))" )

		age = Property(
			categories   = [ misc ],
			name         = "age",
			display_name = "Turn",
			description  = "The age of a unit (in turns).",
			calculate    = "(lambda (design) (0))" )

		speed = Property(
			categories   = [ misc ],
			name         = "speed",
			display_name = "Speed",
			description  = "The maximum number of parsecs the ship can move each turn.",
			calculate    = "(lambda (design) (1.0))" )

		hp = Property(
			categories   = [ combat ],
			name         = "hp",
			display_name = "Hit Points",
			description  = "The amount of damage the ship can take.",
			calculate    = "(lambda (design) (1.0))" )

		backup_damage = Property(
			categories   = [ combat ],
			name         = "backup-damage",
			display_name = "Backup Damage",
			description  = "The amount of damage that the ship will do when using it's backup weapon. (IE When it draws a battle round.)",
			calculate    = "(lambda (design) (1.0))" )

		primary_damage = Property(
			categories   = [ combat ],
			name         = "primary-damage",
			display_name = "Primary Damage",
			description  = "The amount of damage that the ship will do when using it's primary weapon. (IE When it wins a battle round.)",
			calculate    = "(lambda (design) (1.0))" )

		escape = Property(
			categories   = [ ship ],
			name         = "escape",
			display_name = "Escape Chance",
			description  = "The chance the ship has of escaping from battle.",
			calculate    = "(lambda (design) (1.0))" )

		colonise = Property(
			categories   = [ ship ],
			name         = "colonise",
			display_name = "Can Colonise Planets",
			description  = "Can the ship colonise planets?",
			calculate    = """(lambda (design) ("Yes"))""" )

		self.properties = [ experience, age, speed, hp, backup_damage, primary_damage, escape, colonise ]

		missile = Component(
			name        = "Missile",
			description = "Missile which does 1HP of damage.",
			categories  = [ combat ],
			properties  = { primary_damage : None })

		laser = Component(
			name        = "Laser",
			description = "Lasers which do 1HP of damage.",
			categories  = [ combat ],
			properties  = { backup_damage : """(lambda (design) 0.25)""" })

		armor_plate = Component(
			name        = "Armor Plate",
			description = "Armor Plate which absorbes 1HP of damage.",
			categories  = [ combat ],
			properties  = { hp : None })

		colonisation_pod = Component(
			name        = "Colonisation Pod",
			description = "A part which allows a ship to colonise a planet.",
			categories  = [ ship ],
			properties  = { colonise : None })

		escape_thrusters = Component(
			name        = "Escape Thrusters",
			description = "A part which allows a ship to escape combat.",
			categories  = [ ship ],
			properties  = { escape : """(lambda (design) 0.25)""" })

		primary_engine = Component(
			name        = "Primary Engine",
			description = "A part which allows a ship to move through space.",
			categories  = [ ship ],
			properties  = { speed : """(lambda (design) 1000000)""" })

		self.components = [ missile, laser, armor_plate, colonisation_pod, escape_thrusters, primary_engine ]

		scout = Design(
			name        = "Scout",
			description = "A fast light ship with advanced sensors.",
			comment     = "Send this ship to explore unknown solar systems.",
			categories  = [ ship ],
			properties  = { age : "(lambda (design) 0)" },
			components  = {
				escape_thrusters : 4,
				armor_plate      : 2,
				primary_engine   : 5 })

		frigate = Design(
			name        = "Frigate",
			description = "A general purpose ship with weapons and ability to colonise new planets.",
			comment     = "Built it often and colonise every habitable planet you can!",
			categories  = [ ship ],
			properties  = {
				age        : "(lambda (design) 0)",
				experience : "(lambda (design) 0)" },
			components  = {
				armor_plate      : 4,
				primary_engine   : 2,
				colonisation_pod : 1,
				missile          : 2 })

		battleship = Design(
			name        = "Battleship",
			description = "A heavy ship which main purpose is to crush the other ships.",
			comment     = "This is really a powerful ship!",
			categories  = [ ship ],
			properties  = {
				age        : "(lambda (design) 0)",
				experience : "(lambda (design) 0)" },
			components  = {
				armor_plate    : 6,
				primary_engine : 3,
				missile        : 3,
				laser          : 4 })

		self.designs = [ scout, frigate, battleship ]

		Model.add( self.categories, self.properties,
				self.components, self.designs )
コード例 #22
0
ファイル: Ruleset.py プロジェクト: cahirwpz/tpserver-py
    def initModelConstants(self):
        ObjectType = self.model.use("ObjectType")

        Model.add(ObjectType(id=_1, name=_2.__name__) for _1, _2 in enumerate(self.ObjectTypes))
コード例 #23
0
ファイル: Ruleset.py プロジェクト: cahirwpz/tpserver-py
    def initModelConstants(self):
        ReferenceType = self.model.use("ReferenceType")

        Model.add(ReferenceType(id=_1, name=_2) for _1, _2 in self.ReferenceTypeMap.items())
コード例 #24
0
ファイル: Ruleset.py プロジェクト: cahirwpz/tpserver-py
    def initModelConstants(self):
        ParameterType = self.model.use("ParameterType")

        Model.add(ParameterType(id=_1, name=_2[0].__name__) for _1, _2 in self.ParameterTypeMap.items())
コード例 #25
0
ファイル: order.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Order = self.model.use( 'Order' )

		self.orders = []

		Model.add( self.orders )
コード例 #26
0
ファイル: component.py プロジェクト: cahirwpz/tpserver-py
	def setUp( self ):
		Component, ComponentProperty = self.model.use( 'Component', 'ComponentProperty' )
		Category, Property = self.model.use( 'Category', 'Property' )

		misc = Category(
				name = "Misc",
				description = "Things which dont fit into any other category." )

		ship = Category(
				name = "Ship",
				description = "Things which deal with ship's equipment." )

		combat = Category(
				name = "Combat",
				description = "Things which deal with combat between ships." )

		protection = Category(
				name = "Protection",
				description = "Things which deal with ship's protection." )

		self.categories = [ misc, ship, combat, protection ]

		speed = Property(
			categories   = [ ship ],
			name         = "speed",
			display_name = "Speed",
			description  = "The maximum number of parsecs the ship can move each turn.",
			calculate    = """(lambda (design) 1.0)""" )

		hp = Property(
			categories   = [ combat ],
			name         = "hp",
			display_name = "Hit Points",
			description  = "The amount of damage the ship can take.",
			calculate    = """(lambda (design) 1.0)""" )

		damage = Property(
			categories   = [ combat ],
			name         = "damage",
			display_name = "Damage",
			description  = "The amount of damage that the ship will do when using its weapon.",
			calculate    = """(lambda (design) 1.0)""" )

		escape = Property(
			categories   = [ ship ],
			name         = "escape",
			display_name = "Escape Chance",
			description  = "The chance the ship has of escaping from battle.",
			calculate    = """(lambda (design) 1.0)""" )

		self.properties = [ speed, hp, damage, escape ]

		missile = Component(
			id          = 9,
			name        = "Missile",
			description = "Missile which does 1HP of damage.",
			categories  = [ combat ],
			properties  = { 
				damage : """(lambda (design) 1.0)""",
				speed  : """(lambda (design) 1.0)""" })

		laser = Component(
			id          = 1,
			name        = "Laser",
			description = "Lasers which do 1HP of damage.",
			categories  = [ combat ],
			properties  = { damage : """(lambda (design) 1.0)""" })

		armor_plate = Component(
			id          = 4,
			name        = "Armor Plate",
			description = "Armor Plate which absorbes 1HP of damage.",
			categories  = [ ship, protection ] )

		primary_engine = Component(
			id          = 7,
			name        = "Primary Engine",
			description = "A part which allows a ship to move through space.",
			categories  = [ ship ],
			properties  = { speed : """(lambda (design) 1.0)""" })

		self.components = [ missile, laser, armor_plate, primary_engine ]

		Model.add( self.categories, self.properties, self.components )
コード例 #27
0
ファイル: __init__.py プロジェクト: cahirwpz/tpserver-py
	def initModel( self ):
		Ruleset.initModel( self )

		Category, Property, ResourceType = self.model.use( 'Category', 'Property', 'ResourceType' )
		Component, ComponentProperty     = self.model.use( 'Component', 'ComponentProperty' )
		Design, DesignComponent          = self.model.use( 'Design', 'DesignComponent' )

		ResourceType.FromCSV( os.path.join( self.files, "resources.csv" ) )
		Category.FromCSV( os.path.join( self.files, "categories.csv" ) )

		misc       = Category.ByName('Misc')
		production = Category.ByName('Production')
		combat     = Category.ByName('Combat')

		universe = self.generator.createUniverse( name = "The Universe" )

		speed = Property(
			categories   = [ misc ],
			name         = "speed",
			display_name = "Speed",
			description  = "The maximum number of parsecs the ship can move each turn.",
			calculate    = """\
(lambda (design bits) 
	(let ((n (apply + bits)))
		(cons n (string-append (number->string (/ n 1000000)) " kpcs"))))""" )

		cost = Property(
			categories   = [ production ],
			name         = "cost",
			display_name = "Cost",
			description  = "The number of components needed to build the ship",
			calculate    = """\
(lambda (design bits) 
	(let ((n (apply + bits))) 
		(cons n (string-append (number->string n) " turns"))))""" )

		hp = Property(
			categories   = [ combat ],
			name         = "hp",
			display_name = "Hit Points",
			description  = "The amount of damage the ship can take.",
			calculate    = """\
(lambda (design bits) 
	(let ((n (apply + bits))) 
		(cons n (string-append (number->string n) " HP"))))""" )

		backup_damage = Property(
			categories   = [ combat ],
			name         = "backup-damage",
			display_name = "Backup Damage",
			description  = "The amount of damage that the ship will do when using it's backup weapon. (IE When it draws a battle round.)",
			calculate    = """\
(lambda (design bits) 
	(let ((n (apply + bits))) 
		(cons n (string-append (number->string n) " HP"))))""" )

		primary_damage = Property(
			categories   = [ combat ],
			name         = "primary-damage",
			display_name = "Primary Damage",
			description  = "The amount of damage that the ship will do when using it's primary weapon. (IE When it wins a battle round.)",
			calculate    = """\
(lambda (design bits) 
	(let ((n (apply + bits))) 
		(cons n (string-append (number->string n) " HP"))))""" )

		escape = Property(
			categories   = [ misc ],
			name         = "escape",
			display_name = "Escape Chance",
			description  = "The chance the ship has of escaping from battle.",
			calculate    = """\
(lambda (design bits) 
	(let ((n (apply + bits))) 
		(cons n (string-append (number->string (* n 100)) " %"))))""" )

		colonise = Property(
			categories   = [ misc ],
			name         = "colonise",
			display_name = "Can Colonise Planets",
			description  = "Can the ship colonise planets?",
			calculate    = """\
(lambda (design bits) 
	(let ((n (apply + bits))) 
		(cons n 
			(if (> n 1) "Yes" "No"))))""" )

		missile = Component(
			name        = "Missile",
			description = "Missile which does 1HP of damage.",
			categories  = [ combat ],
			properties  = { primary_damage : None })

		laser = Component(
			name        = "Laser",
			description = "Lasers which do 1HP of damage.",
			categories  = [ combat ],
			properties  = { backup_damage : """(lambda (design) 0.25)""" })

		armor_plate = Component(
			name        = "Armor Plate",
			description = "Armor Plate which absorbes 1HP of damage.",
			categories  = [ combat ],
			properties  = { hp : None })

		colonisation_pod = Component(
			name        = "Colonisation Pod",
			description = "A part which allows a ship to colonise a planet.",
			categories  = [ misc ],
			properties  = { colonise : None })

		escape_thrusters = Component(
			name        = "Escape Thrusters",
			description = "A part which allows a ship to escape combat.",
			categories  = [ misc ],
			properties  = { escape : """(lambda (design) 0.25)""" })

		primary_engine = Component(
			name        = "Primary Engine",
			description = "A part which allows a ship to move through space.",
			categories  = [ misc ],
			properties  = { speed : """(lambda (design) 1000000)""" })

		scout = Design(
			name        = "Scout",
			description = "A fast light ship with advanced sensors.",
			categories  = [ misc ],
			components  = {
				escape_thrusters : 4,
				armor_plate      : 2,
				primary_engine   : 5 })

		frigate = Design(
			name         = "Frigate",
			description  = "A general purpose ship with weapons and ability to colonise new planets.",
			categories   = [ misc ],
			components   = {
				armor_plate      : 4,
				primary_engine   : 2,
				colonisation_pod : 1,
				missile          : 2 })

		battleship = Design(
			name        = "Battleship",
			description = "A heavy ship who's main purpose is to blow up other ships.",
			categories  = [ misc ],
			components  = {
				armor_plate    : 6,
				primary_engine : 3,
				missile        : 3,
				laser          : 4 })

		# FIXME: Need to populate the database with the MiniSec design stuff,
		#  - Firepower
		#  - Armor/HP
		#  - Speed
		#  - Sensors (scouts ability to disappear)....

		Model.add( universe, speed, cost, hp, backup_damage, primary_damage,
				escape, colonise, missile, laser, armor_plate,
				colonisation_pod, escape_thrusters, primary_engine, scout,
				frigate, battleship)