Planet resources

* Added missing table that should store a planet's resources data
(income and upkeep for each type of resource).

* Modified resource definition functions and universe generator to
initialise planet resource records as well

* Heavy clean-up in resource definition function unit tests
This commit is contained in:
Emmanuel BENOîT 2012-01-10 12:30:47 +01:00
parent 37555841ce
commit b49bc1a44f
11 changed files with 465 additions and 378 deletions
legacyworlds-server-data/db-structure/parts/030-data

View file

@ -135,6 +135,52 @@ ALTER TABLE verse.planet_money
FOREIGN KEY (planet_id) REFERENCES verse.planets;
/*
* Planet resource changes
* ------------------------
*
* This table stores the results of planet resource updates. It will then be
* used to update the owning empires' resources.
*
* This table applies to both basic and natural resources.
*/
CREATE TABLE verse.planet_resources(
/* Identifier of the planet */
planet_id INT NOT NULL ,
/* Identifier of the resource type */
resource_name_id INT NOT NULL ,
/* Quantity of that resource which was somehow gained at the last game
* update.
*/
pres_income DOUBLE PRECISION NOT NULL
DEFAULT 0
CHECK( pres_income >= 0 ) ,
/* Quantity of that resource used by the planet's various buildings at the
* last game update.
*/
pres_upkeep DOUBLE PRECISION NOT NULL
DEFAULT 0
CHECK( pres_upkeep >= 0 ) ,
/* Primary key on (planet,type of resource) */
PRIMARY KEY( planet_id , resource_name_id )
);
CREATE INDEX idx_pres_resource
ON verse.planet_resources( resource_name_id );
ALTER TABLE verse.planet_resources
ADD CONSTRAINT fk_pres_planet
FOREIGN KEY ( planet_id ) REFERENCES verse.planets ,
ADD CONSTRAINT fk_pres_resource
FOREIGN KEY ( resource_name_id ) REFERENCES defs.resources;
--
-- Buildings
--