In-game resources views

* Added session records to carry resource information over to the
clients

* Added SQL support code for the various views

* Added interface and implementation of the resource information access
component

* Hooked resources information queries into both the empire and planet
management component

* Added resources display to planet and overview pages
This commit is contained in:
Emmanuel BENOîT 2012-02-04 10:43:12 +01:00
parent 56eddcc4f0
commit 597429fadf
45 changed files with 3211 additions and 52 deletions
legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources

View file

@ -0,0 +1,47 @@
/*
* Tests for defs.resource_category_weight_view
*/
BEGIN;
/*
* We need a few resources, with a known average per category. Some of the
* resources must not belong to any category.
*/
\i utils/strings.sql
SELECT _create_test_strings( 5 , 'resource' );
SELECT _create_test_strings( 5 , 'resDesc' );
SELECT _create_test_strings( 2 , 'resCat' );
INSERT INTO defs.resources(
resource_name_id , resource_description_id ,
resource_category_id , resource_weight
) VALUES (
_get_string( 'resource1' ) , _get_string( 'resDesc1' ) ,
_get_string( 'resCat1' ) , 2
) , (
_get_string( 'resource2' ) , _get_string( 'resDesc2' ) ,
_get_string( 'resCat1' ) , 4
) , (
_get_string( 'resource3' ) , _get_string( 'resDesc3' ) ,
_get_string( 'resCat2' ) , 3
) , (
_get_string( 'resource4' ) , _get_string( 'resDesc4' ) ,
_get_string( 'resCat2' ) , 5
) , (
_get_string( 'resource5' ) , _get_string( 'resDesc5' ) ,
NULL , 150
);
SELECT plan( 1 );
SELECT diag_test_name( 'defs.resource_category_weight_view - Resulting set contains correct values' );
SELECT set_eq(
$$ SELECT * FROM defs.resource_category_weight_view $$ ,
$$ VALUES (
_get_string( 'resCat1' ) , 3
) , (
_get_string( 'resCat2' ) , 4
) $$
);
SELECT * FROM finish( );
ROLLBACK;

View file

@ -0,0 +1,57 @@
/*
* Tests for defs.ordered_resources_view
*/
BEGIN;
/*
* We need:
* - one resource without category with weight 1,
* - one resource with category 1 and weight 2,
* - one resource with weight 4 and no category,
* - two resourcew with weights 3 and 7 and category 2.
*/
\i utils/strings.sql
SELECT _create_test_strings( 5 , 'resource' );
SELECT _create_test_strings( 5 , 'resDesc' );
SELECT _create_test_strings( 2 , 'resCat' );
INSERT INTO defs.resources(
resource_name_id , resource_description_id ,
resource_category_id , resource_weight
) VALUES (
_get_string( 'resource1' ) , _get_string( 'resDesc1' ) ,
NULL , 1
) , (
_get_string( 'resource2' ) , _get_string( 'resDesc2' ) ,
_get_string( 'resCat1' ) , 2
) , (
_get_string( 'resource3' ) , _get_string( 'resDesc3' ) ,
NULL , 4
) , (
_get_string( 'resource4' ) , _get_string( 'resDesc4' ) ,
_get_string( 'resCat2' ) , 3
) , (
_get_string( 'resource5' ) , _get_string( 'resDesc5' ) ,
_get_string( 'resCat2' ) , 7
);
SELECT plan( 1 );
SELECT diag_test_name( 'defs.ordered_resources_view - Resources are in the correct order' );
SELECT set_eq(
$$ SELECT resource_name_id , resource_ordering
FROM defs.ordered_resources_view $$ ,
$$ VALUES (
_get_string( 'resource1' ) , 1
) , (
_get_string( 'resource2' ) , 2
) , (
_get_string( 'resource3' ) , 3
) , (
_get_string( 'resource4' ) , 4
) , (
_get_string( 'resource5' ) , 5
) $$
);
SELECT * FROM finish( );
ROLLBACK;