Mining settings
* Changed the way mining settings work: use a priority value (between 0 and 4) as the weight. Leaving them as they were before would have caused numerous problems (and a lot of unnecessary code to work around them) * Empire mining settings will be created along with the empire's own record. By default all natural resources will have weight = 2. * Added a set of four stored procedures which can be used to update an empire's mining settings, including planet-specific settings. The emp.mset_update_start() function can be used to start an update (on an empire's settings if there is only one parameter, or on a planet's settings if there are two parameters); the emp.mset_update_set() and emp.mset_update_apply() functions are then used to modify the settings and apply the changes, respectively.
This commit is contained in:
parent
3e109b13bc
commit
afc66166e0
15 changed files with 745 additions and 55 deletions
legacyworlds-server-data/db-structure/tests/admin/040-functions/040-empire
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Test the emp.create_empire() function
|
||||
*/
|
||||
BEGIN;
|
||||
/* We need a pair of natural resources, a basic resource, a planet
|
||||
* and an empire name.
|
||||
*/
|
||||
\i utils/strings.sql
|
||||
\i utils/resources.sql
|
||||
\i utils/accounts.sql
|
||||
\i utils/naming.sql
|
||||
\i utils/universe.sql
|
||||
SELECT _create_natural_resources( 2 , 'natRes' );
|
||||
SELECT _create_resources( 1 , 'basicRes' );
|
||||
SELECT _create_raw_planets( 1 , 'testPlanet' );
|
||||
SELECT _create_emp_names( 1 , 'testEmp' );
|
||||
|
||||
/***** TESTS BEGIN HERE *****/
|
||||
SELECT plan( 7 );
|
||||
|
||||
SELECT emp.create_empire( _get_emp_name( 'testEmp1' ) ,
|
||||
_get_map_name( 'testPlanet1' ) ,
|
||||
200.0 );
|
||||
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire exists' );
|
||||
SELECT is( COUNT(*)::INT , 1 ) FROM emp.empires
|
||||
WHERE name_id = _get_emp_name( 'testEmp1' );
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire cash' );
|
||||
SELECT is( cash , 200.0::REAL ) FROM emp.empires
|
||||
WHERE name_id = _get_emp_name( 'testEmp1' );
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire debt' );
|
||||
SELECT is( debt , 0.0::REAL ) FROM emp.empires
|
||||
WHERE name_id = _get_emp_name( 'testEmp1' );
|
||||
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire mining settings include all natural resources' );
|
||||
SELECT is( COUNT(*)::INT , 2 )
|
||||
FROM defs.natural_resources
|
||||
INNER JOIN emp.mining_settings
|
||||
USING ( resource_name_id )
|
||||
WHERE empire_id = _get_emp_name( 'testEmp1' );
|
||||
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire mining settings do not include basic resources' );
|
||||
SELECT is( COUNT(*)::INT , 2 )
|
||||
FROM defs.resources
|
||||
INNER JOIN emp.mining_settings
|
||||
USING ( resource_name_id )
|
||||
WHERE empire_id = _get_emp_name( 'testEmp1' );
|
||||
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire mining settings are all set to the same value' );
|
||||
SELECT is( COUNT( _temp.* )::INT , 1 )
|
||||
FROM ( SELECT DISTINCT empmset_weight
|
||||
FROM emp.mining_settings
|
||||
WHERE empire_id = _get_emp_name( 'testEmp1' )
|
||||
) AS _temp;
|
||||
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire update records' );
|
||||
SELECT is( _eur.quantity , _utv.quantity)
|
||||
FROM (
|
||||
SELECT COUNT(*) AS quantity FROM emp.updates
|
||||
WHERE empire_id = _get_emp_name( 'testEmp1' )
|
||||
) AS _eur , (
|
||||
SELECT COUNT(*) AS quantity
|
||||
FROM unnest( enum_range( NULL::update_type ) ) AS _row
|
||||
WHERE _row::TEXT LIKE 'EMPIRE_%'
|
||||
) AS _utv;
|
||||
|
||||
SELECT * FROM finish( );
|
||||
ROLLBACK;
|
Reference in a new issue