Emmanuel BENOîT
4e1bb91780
* Added structures for resource definitions, natural resources definitions, resource providers, empire resources and empire mining settings (both empire-wide and planet-specific). * Added a few common utility functions to the SQL test suite. These functions allow test initialisation to be a little shorter. * Added "MINE" production type and an associated building definition. The production will not be added to the XML dump or to the output of the planets summary page, as this is extremely temporary.
63 lines
No EOL
1.4 KiB
PL/PgSQL
63 lines
No EOL
1.4 KiB
PL/PgSQL
/*
|
|
* Utility functions used by unit tests
|
|
*
|
|
* Resources and natural resources
|
|
*/
|
|
|
|
|
|
/*
|
|
* Function that creates some quantity of resources
|
|
* All resources are created using the specified prefix for the strings
|
|
*/
|
|
CREATE FUNCTION _create_resources( _quantity INT , _prefix TEXT )
|
|
RETURNS VOID
|
|
AS $$
|
|
DECLARE
|
|
i INT;
|
|
BEGIN
|
|
PERFORM _create_test_strings( _quantity , _prefix );
|
|
PERFORM _create_test_strings( _quantity , _prefix || 'Description' );
|
|
|
|
i := 0;
|
|
WHILE i < _quantity
|
|
LOOP
|
|
i := i + 1;
|
|
INSERT INTO defs.resources (
|
|
resource_name_id , resource_description_id , resource_weight
|
|
) VALUES (
|
|
_get_string( _prefix || i::TEXT ) ,
|
|
_get_string( _prefix || 'Description' || i::TEXT ) ,
|
|
i
|
|
);
|
|
END LOOP;
|
|
END;
|
|
$$ LANGUAGE PLPGSQL;
|
|
|
|
|
|
/*
|
|
* Function that creates some quantity of /natural/ resources
|
|
* All resources are created using the specified prefix for the strings
|
|
*/
|
|
CREATE FUNCTION _create_natural_resources( _quantity INT , _prefix TEXT )
|
|
RETURNS VOID
|
|
AS $$
|
|
DECLARE
|
|
i INT;
|
|
BEGIN
|
|
PERFORM _create_resources( _quantity , _prefix );
|
|
|
|
i := 0;
|
|
WHILE i < _quantity
|
|
LOOP
|
|
i := i + 1;
|
|
INSERT INTO defs.natural_resources(
|
|
resource_name_id , natres_p_presence , natres_quantity_avg ,
|
|
natres_quantity_dev , natres_difficulty_avg ,
|
|
natres_difficulty_dev , natres_recovery_avg ,
|
|
natres_recovery_dev
|
|
) VALUES (
|
|
_get_string( _prefix || i::TEXT ) , 0.5 , 100 , 1 , 0.5 , 0.05 , 0.5 , 0.05
|
|
);
|
|
END LOOP;
|
|
END;
|
|
$$ LANGUAGE PLPGSQL; |