Empire research initialisation
* When an empire is created, all technologies that have no dependencies will be added as ongoing research with default priority and no points in the empire research table.
This commit is contained in:
parent
1f3c7a9202
commit
8c0b4abd1e
2 changed files with 40 additions and 1 deletions
legacyworlds-server-data/db-structure/tests/admin/040-functions/040-empire
|
@ -27,6 +27,28 @@ BEGIN;
|
|||
100 , 0.2 , 0.5
|
||||
);
|
||||
|
||||
/*
|
||||
* We also need 3 technologies (tech1, tech2 and tech3), and a chain of
|
||||
* dependencies between them (i.e. tech3 -> tech2 -> tech1). Disabling
|
||||
* unused fields in defs.technologies makes things easier.
|
||||
*/
|
||||
ALTER TABLE defs.technologies
|
||||
ALTER technology_category_id DROP NOT NULL ,
|
||||
ALTER technology_discovery_id DROP NOT NULL ,
|
||||
ALTER technology_description_id DROP NOT NULL ,
|
||||
ALTER technology_price DROP NOT NULL ,
|
||||
ALTER technology_points DROP NOT NULL;
|
||||
SELECT _create_test_strings( 3 , 'tech' );
|
||||
INSERT INTO defs.technologies ( technology_name_id )
|
||||
VALUES ( _get_string( 'tech1' ) ) ,
|
||||
( _get_string( 'tech2' ) ) ,
|
||||
( _get_string( 'tech3' ) );
|
||||
INSERT INTO defs.technology_dependencies(
|
||||
technology_name_id , technology_name_id_depends
|
||||
) VALUES ( _get_string( 'tech2' ) , _get_string( 'tech1' ) ) ,
|
||||
( _get_string( 'tech3' ) , _get_string( 'tech2' ) );
|
||||
|
||||
|
||||
/* We replace the emp.mining_get_input() and emp.mining_compute_extraction()
|
||||
* functions with something we control fully.
|
||||
*/
|
||||
|
@ -49,7 +71,7 @@ BEGIN;
|
|||
$$;
|
||||
|
||||
/***** TESTS BEGIN HERE *****/
|
||||
SELECT plan( 8 );
|
||||
SELECT plan( 9 );
|
||||
|
||||
SELECT emp.create_empire( _get_emp_name( 'testEmp1' ) ,
|
||||
_get_map_name( 'testPlanet1' ) ,
|
||||
|
@ -92,6 +114,15 @@ BEGIN;
|
|||
FROM emp.resources
|
||||
WHERE empire_id = _get_emp_name( 'testEmp1' );
|
||||
|
||||
SELECT diag_test_name( 'emp.create_empire() - Empire technologies have been initialised' );
|
||||
SELECT set_eq( $$
|
||||
SELECT technology_name_id , emptech_state::TEXT , emptech_points , emptech_priority
|
||||
FROM emp.technologies_v2
|
||||
WHERE empire_id = _get_emp_name( 'testEmp1' );
|
||||
$$ , $$ VALUES(
|
||||
_get_string( 'tech1' ) , 'RESEARCH' , 0.0 , 2
|
||||
) $$ );
|
||||
|
||||
SELECT diag_test_name( 'emp.create_empire() - Resource mining has been updated' );
|
||||
SELECT is( pres_income::DOUBLE PRECISION , 42::DOUBLE PRECISION )
|
||||
FROM verse.planet_resources
|
||||
|
|
Reference in a new issue