Universe generator: resource providers

* The universe generator has been modified to generate resource
providers. The code attempts to keep the universe balanced according to
the natural resources definitions.
This commit is contained in:
Emmanuel BENOîT 2012-01-06 10:05:47 +01:00
parent e7d2072813
commit b054a379a9
24 changed files with 1105 additions and 6 deletions
legacyworlds-server-data/db-structure/tests/admin/functions/053-generator-basics

View file

@ -0,0 +1,41 @@
/*
* Test the verse.list_random_planets_in() function
*/
BEGIN;
/* We need two systems with one planet each. Systems will be located at
* (0,0) and (1,1).
*/
\i utils/strings.sql
\i utils/accounts.sql
\i utils/naming.sql
\i utils/universe.sql
SELECT _create_raw_planets( 10 , 'test' );
/***** TESTS BEGIN HERE *****/
SELECT plan( 5 );
SELECT diag_test_name( 'verse.list_random_planets_in() - Empty set if count = 0' );
SELECT is_empty( $$
SELECT * FROM verse.list_random_planets_in( ROW( 0 , 0 , 1 , 1 ) , 0 )
$$ );
SELECT diag_test_name( 'verse.list_random_planets_in() - Empty set if outside of existing universe' );
SELECT is_empty( $$
SELECT * FROM verse.list_random_planets_in( ROW( 2 , 2 , 3 , 3 ) , 2 )
$$ );
SELECT diag_test_name( 'verse.list_random_planets_in() - Requested count > actual count' );
SELECT is( COUNT(*) , 5::BIGINT )
FROM verse.list_random_planets_in( ROW( 1 , 1 , 2 , 2 ) , 7 );
SELECT diag_test_name( 'verse.list_random_planets_in() - Requested count = actual count' );
SELECT is( COUNT(*) , 5::BIGINT )
FROM verse.list_random_planets_in( ROW( 1 , 1 , 2 , 2 ) , 5 );
SELECT diag_test_name( 'verse.list_random_planets_in() - Requested count < actual count' );
SELECT is( COUNT(*) , 4::BIGINT )
FROM verse.list_random_planets_in( ROW( 1 , 1 , 2 , 2 ) , 4 );
SELECT * FROM finish( );
ROLLBACK;