Emmanuel BENOîT
bf6bea5a79
* The quantities of resources extracted from mines will now be updated as soon as they have a reason to. This includes planet assignment, abandonment, ownership changes, and updates to mining priorities. * The mining update will now remove the current resource income from the providers, and only then re-compute all extracted quantities. This is more logical and corresponds to the way the other game updates work. * Fixed bug in extraction computation where the size of the planet's happy population was used instead of the happy/total ratio when adjusting the mining production for riots. * The following SQL scripts must be re-executed to upgrade a database: -> 040-functions/040-empire.sql -> 040-functions/145-resource-providers.sql -> 040-functions/147-empire-mining.sql -> 050-updates/120-planet-mining.sql
61 lines
No EOL
2.8 KiB
PL/PgSQL
61 lines
No EOL
2.8 KiB
PL/PgSQL
/*
|
|
* Test the emp.mset_toggle_source( INT , INT ) function
|
|
*/
|
|
BEGIN;
|
|
/*
|
|
* Create a pair of natural resources, three planets, an empire owning two
|
|
* of the planets, and resource providers for one of the resources on the
|
|
* neutral planet and on one of the owned planets.
|
|
*/
|
|
\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 , 'resource' );
|
|
SELECT _create_raw_planets( 3 , 'planet' );
|
|
SELECT _create_emp_names( 1 , 'empire' );
|
|
SELECT emp.create_empire( _get_emp_name( 'empire1' ) ,
|
|
_get_map_name( 'planet1' ) ,
|
|
200.0 );
|
|
SELECT _create_resource_provider( 'planet1' , 'resource1' );
|
|
SELECT _create_resource_provider( 'planet2' , 'resource1' );
|
|
INSERT INTO emp.planets ( empire_id , planet_id )
|
|
VALUES ( _get_emp_name( 'empire1' ) , _get_map_name( 'planet3' ) );
|
|
|
|
|
|
-- ***** TESTS BEGIN HERE *****
|
|
SELECT plan( 8 );
|
|
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Return value on bad empire identifier' );
|
|
SELECT ok( NOT emp.mset_toggle_source( _get_bad_emp_name( ) , _get_map_name( 'planet1' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Return value on bad planbet identifier' );
|
|
SELECT ok( NOT emp.mset_toggle_source( _get_emp_name( 'empire1' ) , _get_bad_map_name( ) ) );
|
|
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Return value when the empire does not own the planet' );
|
|
SELECT ok( NOT emp.mset_toggle_source( _get_emp_name( 'empire1' ) , _get_map_name( 'planet2' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Return value when the planet has no resource providers' );
|
|
SELECT ok( NOT emp.mset_toggle_source( _get_emp_name( 'empire1' ) , _get_map_name( 'planet3' ) ) );
|
|
|
|
DELETE FROM emp.planet_mining_settings;
|
|
UPDATE emp.mining_settings
|
|
SET empmset_weight = 0;
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Return value when activating' );
|
|
SELECT ok( emp.mset_toggle_source( _get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Mining settings inserted after activation' );
|
|
SELECT set_eq(
|
|
$$ SELECT * FROM emp.planet_mining_settings $$ ,
|
|
$$ VALUES ( _get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , _get_string( 'resource1' ) , 0 ) $$
|
|
);
|
|
|
|
DELETE FROM emp.planet_mining_settings;
|
|
INSERT INTO emp.planet_mining_settings VALUES (
|
|
_get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , _get_string( 'resource1' ) , 2
|
|
);
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Return value when de-activating' );
|
|
SELECT ok( emp.mset_toggle_source( _get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_toggle_source() - Mining settings deleted after de-activation' );
|
|
SELECT is_empty( $$ SELECT * FROM emp.planet_mining_settings $$ );
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |