Research weight computations

* Added game.research.weightBase constant

* Added view which computes the weights for each in-progress research

* Added view which computes total weights per empire
This commit is contained in:
Emmanuel BENOîT 2012-03-01 12:42:05 +01:00
parent c9d8a077bd
commit a14601df37
8 changed files with 150 additions and 1 deletions
legacyworlds-server-data/db-structure/parts/040-functions

View file

@ -319,6 +319,44 @@ CREATE VIEW emp.technology_visibility_view
/*
* Research weights
* -----------------
*
* This view computes weights based on priorities for each in-progress
* research.
*
* Columns:
* empire_id The empire's identifier
* technology_name_id The technology's identifier
* emptech_weight The weight
*/
DROP VIEW IF EXISTS emp.research_weights_view CASCADE;
CREATE VIEW emp.research_weights_view
AS SELECT empire_id , technology_name_id ,
POW( sys.get_constant( 'game.research.weightBase' ) ,
emptech_priority ) AS emptech_weight
FROM emp.technologies_v2
WHERE emptech_state = 'RESEARCH';
/*
* Total research weights
* -----------------------
*
* This view computes total research weights for each empire with in-progress
* research.
*
* Columns:
* empire_id The empire's identifier
* emptech_total_weight The total research weight
*/
DROP VIEW IF EXISTS emp.research_total_weights_view CASCADE;
CREATE VIEW emp.research_total_weights_view
AS SELECT empire_id , SUM( emptech_weight ) AS emptech_total_weight
FROM emp.research_weights_view
GROUP BY empire_id;
/*
* Empire research and technologies
* ---------------------------------