Resources information on planet list
* Added resource information records to the planet list's response. * Added a database view and the corresponding row mapper and DAO method which can be used as the data source for the planet list's resource information. For now this view always returns 0 for both civilian and military investments. * Added new tab to display resource information on the planet list page. The old version of the economy tab will be kept until the corresponding data no longer exists. * The following SQL scripts must be re-executed to upgrade a database: -> 040-functions/167-planet-list.sql
This commit is contained in:
parent
bf6bea5a79
commit
96670d45be
15 changed files with 1079 additions and 31 deletions
legacyworlds-server-data/db-structure/tests
admin/040-functions/167-planet-list
user/040-functions/167-planet-list
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Tests for emp.plist_resources_view
|
||||
*/
|
||||
BEGIN;
|
||||
\i utils/strings.sql
|
||||
\i utils/resources.sql
|
||||
\i utils/accounts.sql
|
||||
\i utils/naming.sql
|
||||
\i utils/universe.sql
|
||||
|
||||
/* Create a couple of resources, three planets and two empire names */
|
||||
SELECT _create_resources( 2 , 'resource' );
|
||||
SELECT _create_raw_planets( 3 , 'planet' );
|
||||
SELECT _create_emp_names( 2 , 'empire' );
|
||||
|
||||
/* One of the empires possesses two planets */
|
||||
SELECT emp.create_empire( _get_emp_name( 'empire1' ) ,
|
||||
_get_map_name( 'planet1' ) ,
|
||||
200.0 );
|
||||
INSERT INTO emp.planets( empire_id , planet_id )
|
||||
VALUES ( _get_emp_name( 'empire1' ) , _get_map_name( 'planet2' ) );
|
||||
|
||||
/* First planet has income for one resource and upkeep for the other */
|
||||
INSERT INTO verse.planet_resources ( planet_id , resource_name_id , pres_income )
|
||||
VALUES ( _get_map_name( 'planet1' ) , _get_string( 'resource1' ) , 0.23 );
|
||||
INSERT INTO verse.planet_resources ( planet_id , resource_name_id , pres_upkeep )
|
||||
VALUES ( _get_map_name( 'planet1' ) , _get_string( 'resource2' ) , 0.22 );
|
||||
|
||||
/* Second planet has no income or upkeep */
|
||||
INSERT INTO verse.planet_resources ( planet_id , resource_name_id )
|
||||
SELECT _get_map_name( 'planet2' ) , resource_name_id
|
||||
FROM defs.resources;
|
||||
|
||||
/* The second empire has no planets */
|
||||
INSERT INTO emp.empires( name_id , cash )
|
||||
VALUES ( _get_emp_name( 'empire2' ) , 123 );
|
||||
|
||||
/* Third planet has income and upkeep for all resources */
|
||||
INSERT INTO verse.planet_resources ( planet_id , resource_name_id , pres_income , pres_upkeep )
|
||||
SELECT _get_map_name( 'planet3' ) , resource_name_id ,
|
||||
4 + row_number( ) OVER( ) * 2 , row_number( ) OVER( ) * 2 + 5
|
||||
FROM defs.resources;
|
||||
|
||||
-- ***** TESTS BEGIN HERE *****
|
||||
SELECT plan( 4 );
|
||||
|
||||
SELECT diag_test_name( 'emp.plist_resources_view - No rows for neutral planets' );
|
||||
SELECT is_empty( $$
|
||||
SELECT * FROM emp.plist_resources_view
|
||||
WHERE planet_id = _get_map_name( 'planet3' );
|
||||
$$ );
|
||||
|
||||
SELECT diag_test_name( 'emp.plist_resources_view - No rows for empires with no planets' );
|
||||
SELECT is_empty( $$
|
||||
SELECT * FROM emp.plist_resources_view
|
||||
WHERE empire_id = _get_emp_name( 'empire2' );
|
||||
$$ );
|
||||
|
||||
SELECT diag_test_name( 'emp.plist_resources_view - No rows for owned planets with zero income and upkeep' );
|
||||
SELECT is_empty( $$
|
||||
SELECT * FROM emp.plist_resources_view
|
||||
WHERE planet_id = _get_map_name( 'planet2' );
|
||||
$$ );
|
||||
|
||||
SELECT diag_test_name( 'emp.plist_resources_view - Rows for owned planets with income and upkeep' );
|
||||
SELECT set_eq( $$
|
||||
SELECT empire_id , resource_name , pres_income , pres_upkeep ,
|
||||
civ_investment , mil_investment
|
||||
FROM emp.plist_resources_view
|
||||
WHERE planet_id = _get_map_name( 'planet1' );
|
||||
$$ , $$ VALUES(
|
||||
_get_emp_name( 'empire1' ) , 'Test string #1' , 165 , 0 , 0 , 0
|
||||
) , (
|
||||
_get_emp_name( 'empire1' ) , 'Test string #2' , 0 , 159 , 0 , 0
|
||||
) $$ );
|
||||
|
||||
SELECT * FROM finish( );
|
||||
ROLLBACK;
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Test privileges on emp.plist_resources_view
|
||||
*/
|
||||
BEGIN;
|
||||
SELECT plan( 1 );
|
||||
|
||||
SELECT diag_test_name( 'emp.plist_resources_view - SELECT privilege' );
|
||||
SELECT lives_ok( 'SELECT * FROM emp.plist_resources_view' );
|
||||
|
||||
SELECT * FROM finish( );
|
||||
ROLLBACK;
|
Reference in a new issue