"Buildables" depend on tech graph
* Modified buildable definitions and loader to use technologies from the tech graph as dependencies instead of the old research system * Modified planet-related views and functions accordingly
This commit is contained in:
parent
76a01cbf1c
commit
070d55dc05
6 changed files with 89 additions and 104 deletions
|
@ -10,21 +10,26 @@
|
||||||
-- "Buildables"
|
-- "Buildables"
|
||||||
--
|
--
|
||||||
CREATE TABLE tech.buildables(
|
CREATE TABLE tech.buildables(
|
||||||
name_id INT NOT NULL PRIMARY KEY ,
|
name_id INT NOT NULL PRIMARY KEY ,
|
||||||
description_id INT NOT NULL ,
|
description_id INT NOT NULL ,
|
||||||
cost INT NOT NULL CHECK( cost > 0 ) ,
|
technology_name_id INT ,
|
||||||
work INT NOT NULL CHECK( work > 0 ) ,
|
cost INT NOT NULL CHECK( cost > 0 ) ,
|
||||||
upkeep INT NOT NULL CHECK( upkeep >= 0 )
|
work INT NOT NULL CHECK( work > 0 ) ,
|
||||||
|
upkeep INT NOT NULL CHECK( upkeep >= 0 )
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX idx_buildables_description
|
CREATE INDEX idx_buildables_description
|
||||||
ON tech.buildables (description_id);
|
ON tech.buildables (description_id);
|
||||||
|
CREATE INDEX idx_buildables_technology
|
||||||
|
ON tech.buildables ( technology_name_id );
|
||||||
|
|
||||||
ALTER TABLE tech.buildables
|
ALTER TABLE tech.buildables
|
||||||
ADD CONSTRAINT fk_buildables_name
|
ADD CONSTRAINT fk_buildables_name
|
||||||
FOREIGN KEY (name_id) REFERENCES defs.strings ,
|
FOREIGN KEY (name_id) REFERENCES defs.strings ,
|
||||||
ADD CONSTRAINT fk_buildables_description
|
ADD CONSTRAINT fk_buildables_description
|
||||||
FOREIGN KEY (description_id) REFERENCES defs.strings;
|
FOREIGN KEY (description_id) REFERENCES defs.strings ,
|
||||||
|
ADD CONSTRAINT fk_buildables_technology
|
||||||
|
FOREIGN KEY (technology_name_id) REFERENCES defs.technologies;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
|
@ -374,10 +374,8 @@ GRANT EXECUTE
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE VIEW tech.basic_buildables
|
CREATE VIEW tech.basic_buildables
|
||||||
AS SELECT b.* FROM tech.buildables b
|
AS SELECT * FROM tech.buildables
|
||||||
LEFT OUTER JOIN tech.buildable_requirements r
|
WHERE technology_name_id IS NULL;
|
||||||
ON r.buildable_id = b.name_id
|
|
||||||
WHERE r.buildable_id IS NULL;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -385,7 +383,8 @@ CREATE VIEW tech.basic_buildables
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE VIEW tech.buildings_view
|
CREATE VIEW tech.buildings_view
|
||||||
AS SELECT b.name_id , b.description_id , b.cost , b.work , b.upkeep ,
|
AS SELECT b.name_id , b.description_id , b.technology_name_id ,
|
||||||
|
b.cost , b.work , b.upkeep ,
|
||||||
bld.workers , bld.output_type , bld.output
|
bld.workers , bld.output_type , bld.output
|
||||||
FROM tech.buildables b
|
FROM tech.buildables b
|
||||||
INNER JOIN tech.buildings bld
|
INNER JOIN tech.buildings bld
|
||||||
|
@ -397,7 +396,8 @@ CREATE VIEW tech.buildings_view
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE VIEW tech.ships_view
|
CREATE VIEW tech.ships_view
|
||||||
AS SELECT b.name_id , b.description_id , b.cost , b.work , b.upkeep ,
|
AS SELECT b.name_id , b.description_id , b.technology_name_id ,
|
||||||
|
b.cost , b.work , b.upkeep ,
|
||||||
s.flight_time , s.power
|
s.flight_time , s.power
|
||||||
FROM tech.buildables b
|
FROM tech.buildables b
|
||||||
INNER JOIN tech.ships s
|
INNER JOIN tech.ships s
|
||||||
|
@ -502,51 +502,48 @@ GRANT EXECUTE ON FUNCTION tech.uoc_level( TEXT , INT , TEXT , TEXT , INT , INT )
|
||||||
-- bdc Cost
|
-- bdc Cost
|
||||||
-- bdw Work
|
-- bdw Work
|
||||||
-- bdu Upkeep
|
-- bdu Upkeep
|
||||||
-- bdtn Dependency (name)
|
-- _tech Technology dependency
|
||||||
-- bdtl Dependency (level)
|
|
||||||
--
|
--
|
||||||
-- Returns:
|
-- Returns:
|
||||||
-- the buildable's identifier
|
-- the buildable's identifier
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION tech.uoc_buildable( bdn TEXT , bdd TEXT , bdc INT , bdw INT , bdu INT , bdtn TEXT , bdtl INT )
|
CREATE OR REPLACE FUNCTION tech.uoc_buildable( bdn TEXT , bdd TEXT , bdc INT , bdw INT , bdu INT , _tech TEXT )
|
||||||
RETURNS INT
|
RETURNS INT
|
||||||
STRICT
|
STRICT
|
||||||
VOLATILE
|
VOLATILE
|
||||||
SECURITY INVOKER
|
SECURITY INVOKER
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
nid INT;
|
nid INT;
|
||||||
did INT;
|
did INT;
|
||||||
tdid INT;
|
_tech_id INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
-- Get the various translations
|
-- Get the various translations
|
||||||
SELECT INTO nid id FROM defs.strings WHERE name = bdn;
|
SELECT INTO nid id FROM defs.strings WHERE name = bdn;
|
||||||
SELECT INTO did id FROM defs.strings WHERE name = bdd;
|
SELECT INTO did id FROM defs.strings WHERE name = bdd;
|
||||||
IF bdtn <> '' THEN
|
IF _tech <> '' THEN
|
||||||
SELECT INTO tdid tl.id FROM tech.levels tl
|
SELECT INTO _tech_id technology_name_id
|
||||||
INNER JOIN defs.strings s
|
FROM defs.technologies
|
||||||
ON s.id = tl.line_id
|
INNER JOIN defs.strings s
|
||||||
WHERE s.name = bdtn AND tl.level = bdtl;
|
ON s.id = technology_name_id
|
||||||
|
WHERE s.name = _tech;
|
||||||
|
ELSE
|
||||||
|
_tech_id := NULL;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Create or update the definition
|
-- Create or update the definition
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO tech.buildables ( name_id , description_id , cost , work , upkeep )
|
INSERT INTO tech.buildables ( name_id , description_id , technology_name_id , cost , work , upkeep )
|
||||||
VALUES ( nid , did , bdc , bdw , bdu );
|
VALUES ( nid , did , _tech_id , bdc , bdw , bdu );
|
||||||
EXCEPTION
|
EXCEPTION
|
||||||
WHEN unique_violation THEN
|
WHEN unique_violation THEN
|
||||||
UPDATE tech.buildables SET description_id = did , cost = bdc , work = bdw , upkeep = bdu
|
UPDATE tech.buildables
|
||||||
|
SET description_id = did , technology_name_id = _tech_id ,
|
||||||
|
cost = bdc , work = bdw , upkeep = bdu
|
||||||
WHERE name_id = nid;
|
WHERE name_id = nid;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
-- Set dependencies
|
|
||||||
DELETE FROM tech.buildable_requirements WHERE buildable_id = nid;
|
|
||||||
IF bdtn <> '' THEN
|
|
||||||
INSERT INTO tech.buildable_requirements ( buildable_id , level_id )
|
|
||||||
VALUES ( nid , tdid );
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
RETURN nid;
|
RETURN nid;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
@ -577,7 +574,7 @@ CREATE OR REPLACE FUNCTION tech.uoc_building( bdn TEXT , bdd TEXT , bdc INT , bd
|
||||||
DECLARE
|
DECLARE
|
||||||
bdid INT;
|
bdid INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
bdid := tech.uoc_buildable( bdn , bdd , bdc , bdw , bdu , '' , 0 );
|
bdid := tech.uoc_buildable( bdn , bdd , bdc , bdw , bdu , '' );
|
||||||
|
|
||||||
PERFORM buildable_id FROM tech.ships WHERE buildable_id = bdid;
|
PERFORM buildable_id FROM tech.ships WHERE buildable_id = bdid;
|
||||||
IF FOUND THEN
|
IF FOUND THEN
|
||||||
|
@ -611,13 +608,12 @@ GRANT EXECUTE ON FUNCTION tech.uoc_building( TEXT , TEXT , INT , INT , INT , INT
|
||||||
-- bdwk Workers
|
-- bdwk Workers
|
||||||
-- bdot Output type
|
-- bdot Output type
|
||||||
-- bdo Output
|
-- bdo Output
|
||||||
-- bdtn Dependency (name)
|
-- _tech Technology dependency
|
||||||
-- bdtl Dependency (level)
|
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION tech.uoc_building( bdn TEXT , bdd TEXT , bdc INT , bdw INT ,
|
CREATE OR REPLACE FUNCTION tech.uoc_building( bdn TEXT , bdd TEXT , bdc INT , bdw INT ,
|
||||||
bdu INT , bdwk INT , bdot building_output_type , bdo INT ,
|
bdu INT , bdwk INT , bdot building_output_type , bdo INT ,
|
||||||
bdtn TEXT , bdtl INT )
|
_tech TEXT )
|
||||||
RETURNS VOID
|
RETURNS VOID
|
||||||
STRICT
|
STRICT
|
||||||
VOLATILE
|
VOLATILE
|
||||||
|
@ -626,7 +622,7 @@ CREATE OR REPLACE FUNCTION tech.uoc_building( bdn TEXT , bdd TEXT , bdc INT , bd
|
||||||
DECLARE
|
DECLARE
|
||||||
bdid INT;
|
bdid INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
bdid := tech.uoc_buildable( bdn , bdd , bdc , bdw , bdu , bdtn , bdtl );
|
bdid := tech.uoc_buildable( bdn , bdd , bdc , bdw , bdu , _tech );
|
||||||
|
|
||||||
PERFORM buildable_id FROM tech.ships WHERE buildable_id = bdid;
|
PERFORM buildable_id FROM tech.ships WHERE buildable_id = bdid;
|
||||||
IF FOUND THEN
|
IF FOUND THEN
|
||||||
|
@ -644,7 +640,7 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
GRANT EXECUTE ON FUNCTION tech.uoc_building( TEXT , TEXT , INT , INT , INT , INT , building_output_type , INT , TEXT , INT ) TO :dbuser;
|
GRANT EXECUTE ON FUNCTION tech.uoc_building( TEXT , TEXT , INT , INT , INT , INT , building_output_type , INT , TEXT ) TO :dbuser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -671,7 +667,7 @@ CREATE OR REPLACE FUNCTION tech.uoc_ship( sn TEXT , sd TEXT , sc INT , sw INT ,
|
||||||
DECLARE
|
DECLARE
|
||||||
bdid INT;
|
bdid INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
bdid := tech.uoc_buildable( sn , sd , sc , sw , su , '' , 0 );
|
bdid := tech.uoc_buildable( sn , sd , sc , sw , su , '' );
|
||||||
|
|
||||||
PERFORM buildable_id FROM tech.buildings WHERE buildable_id = bdid;
|
PERFORM buildable_id FROM tech.buildings WHERE buildable_id = bdid;
|
||||||
IF FOUND THEN
|
IF FOUND THEN
|
||||||
|
@ -704,12 +700,11 @@ GRANT EXECUTE ON FUNCTION tech.uoc_ship( TEXT , TEXT , INT , INT , INT , INT , I
|
||||||
-- su Upkeep
|
-- su Upkeep
|
||||||
-- sp Power
|
-- sp Power
|
||||||
-- sft Orbital flight time
|
-- sft Orbital flight time
|
||||||
-- stdn Tech line name
|
-- _tech Technology dependency
|
||||||
-- stdl Tech level
|
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION tech.uoc_ship( sn TEXT , sd TEXT , sc INT , sw INT ,
|
CREATE OR REPLACE FUNCTION tech.uoc_ship( sn TEXT , sd TEXT , sc INT , sw INT ,
|
||||||
su INT , sp INT , sft INT , stdn TEXT , stdl INT )
|
su INT , sp INT , sft INT , _tech TEXT )
|
||||||
RETURNS VOID
|
RETURNS VOID
|
||||||
STRICT
|
STRICT
|
||||||
VOLATILE
|
VOLATILE
|
||||||
|
@ -718,7 +713,7 @@ CREATE OR REPLACE FUNCTION tech.uoc_ship( sn TEXT , sd TEXT , sc INT , sw INT ,
|
||||||
DECLARE
|
DECLARE
|
||||||
bdid INT;
|
bdid INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
bdid := tech.uoc_buildable( sn , sd , sc , sw , su , stdn , stdl );
|
bdid := tech.uoc_buildable( sn , sd , sc , sw , su , _tech );
|
||||||
|
|
||||||
PERFORM buildable_id FROM tech.buildings WHERE buildable_id = bdid;
|
PERFORM buildable_id FROM tech.buildings WHERE buildable_id = bdid;
|
||||||
IF FOUND THEN
|
IF FOUND THEN
|
||||||
|
@ -736,6 +731,6 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
GRANT EXECUTE ON FUNCTION tech.uoc_ship( TEXT , TEXT , INT , INT , INT , INT , INT , TEXT , INT ) TO :dbuser;
|
GRANT EXECUTE ON FUNCTION tech.uoc_ship( TEXT , TEXT , INT , INT , INT , INT , INT , TEXT ) TO :dbuser;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -468,8 +468,8 @@ AS $$
|
||||||
SELECT bv.name_id AS id , t1.translated_string AS name , t2.translated_string AS description ,
|
SELECT bv.name_id AS id , t1.translated_string AS name , t2.translated_string AS description ,
|
||||||
bv.cost AS cost ,
|
bv.cost AS cost ,
|
||||||
( CASE
|
( CASE
|
||||||
WHEN ceil( pdat.p_work ) = 0 THEN NULL
|
WHEN ceil( pdat.p_work ) = 0 THEN NULL
|
||||||
ELSE ceil( bv.work / pdat.p_work )
|
ELSE ceil( bv.work / pdat.p_work )
|
||||||
END )::BIGINT AS time_to_build ,
|
END )::BIGINT AS time_to_build ,
|
||||||
bv.upkeep AS upkeep , bv.workers AS workers , bv.output_type AS p_type , bv.output AS p_value
|
bv.upkeep AS upkeep , bv.workers AS workers , bv.output_type AS p_type , bv.output AS p_value
|
||||||
FROM (
|
FROM (
|
||||||
|
@ -478,11 +478,10 @@ AS $$
|
||||||
INNER JOIN tech.basic_buildables bb USING( name_id )
|
INNER JOIN tech.basic_buildables bb USING( name_id )
|
||||||
UNION SELECT bv.*
|
UNION SELECT bv.*
|
||||||
FROM tech.buildings_view bv
|
FROM tech.buildings_view bv
|
||||||
INNER JOIN tech.buildable_requirements r ON r.buildable_id = bv.name_id
|
|
||||||
INNER JOIN tech.levels l ON l.id = r.level_id
|
|
||||||
INNER JOIN emp.planets ep ON ep.planet_id = $1
|
INNER JOIN emp.planets ep ON ep.planet_id = $1
|
||||||
INNER JOIN emp.technologies t
|
INNER JOIN emp.technologies_v2 _emptech
|
||||||
ON t.empire_id = ep.empire_id AND t.line_id = l.line_id AND t.level > l.level
|
USING ( technology_name_id , empire_id )
|
||||||
|
WHERE emptech_state = 'KNOWN'
|
||||||
) AS bv , (
|
) AS bv , (
|
||||||
SELECT verse.adjust_production( ( p.population * sys.get_constant( 'game.work.wuPerPopUnit' ) )::REAL , ( ph.current / p.population )::REAL ) AS p_work ,
|
SELECT verse.adjust_production( ( p.population * sys.get_constant( 'game.work.wuPerPopUnit' ) )::REAL , ( ph.current / p.population )::REAL ) AS p_work ,
|
||||||
c.language_id AS language
|
c.language_id AS language
|
||||||
|
@ -530,11 +529,10 @@ AS $$
|
||||||
INNER JOIN tech.basic_buildables bb USING( name_id )
|
INNER JOIN tech.basic_buildables bb USING( name_id )
|
||||||
UNION SELECT bv.*
|
UNION SELECT bv.*
|
||||||
FROM tech.ships_view bv
|
FROM tech.ships_view bv
|
||||||
INNER JOIN tech.buildable_requirements r ON r.buildable_id = bv.name_id
|
|
||||||
INNER JOIN tech.levels l ON l.id = r.level_id
|
|
||||||
INNER JOIN emp.planets ep ON ep.planet_id = $1
|
INNER JOIN emp.planets ep ON ep.planet_id = $1
|
||||||
INNER JOIN emp.technologies t
|
INNER JOIN emp.technologies_v2 t
|
||||||
ON t.empire_id = ep.empire_id AND t.line_id = l.line_id AND t.level > l.level
|
USING ( empire_id , technology_name_id )
|
||||||
|
WHERE emptech_state = 'KNOWN'
|
||||||
) AS bv , (
|
) AS bv , (
|
||||||
SELECT verse.adjust_production( verse.get_raw_production( $1 , 'WORK' ) , ( ph.current / p.population )::REAL ) AS p_work ,
|
SELECT verse.adjust_production( verse.get_raw_production( $1 , 'WORK' ) , ( ph.current / p.population )::REAL ) AS p_work ,
|
||||||
c.language_id AS language
|
c.language_id AS language
|
||||||
|
@ -689,8 +687,8 @@ CREATE OR REPLACE FUNCTION verse.add_military_item( p_id INT , s_id INT , s_cnt
|
||||||
DECLARE
|
DECLARE
|
||||||
e_id INT;
|
e_id INT;
|
||||||
qlen INT;
|
qlen INT;
|
||||||
dep_level INT;
|
_needed INT;
|
||||||
has_level INT;
|
_known INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF s_cnt < 1 THEN
|
IF s_cnt < 1 THEN
|
||||||
RETURN;
|
RETURN;
|
||||||
|
@ -709,16 +707,16 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Check technologies
|
-- Check technologies
|
||||||
SELECT INTO dep_level , has_level l.level , t.level
|
SELECT INTO _needed , _known
|
||||||
|
b.technology_name_id , t.technology_name_id
|
||||||
FROM tech.ships s
|
FROM tech.ships s
|
||||||
LEFT OUTER JOIN tech.buildable_requirements r
|
INNER JOIN tech.buildables b
|
||||||
ON r.buildable_id = s.buildable_id
|
ON b.name_id = s.buildable_id
|
||||||
LEFT OUTER JOIN tech.levels l
|
LEFT OUTER JOIN emp.technologies_v2 t
|
||||||
ON l.id = r.level_id
|
ON t.empire_id = e_id AND t.technology_name_id = b.technology_name_id
|
||||||
LEFT OUTER JOIN emp.technologies t
|
AND t.emptech_state = 'KNOWN'
|
||||||
ON t.empire_id = e_id AND t.line_id = l.line_id AND t.level > l.level
|
|
||||||
WHERE s.buildable_id = s_id;
|
WHERE s.buildable_id = s_id;
|
||||||
IF NOT FOUND OR ( has_level IS NULL AND dep_level IS NOT NULL ) THEN
|
IF NOT FOUND OR ( _known IS NULL AND _needed IS NOT NULL ) THEN
|
||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -755,8 +753,8 @@ CREATE OR REPLACE FUNCTION verse.construct_buildings( p_id INT , b_id INT , b_cn
|
||||||
DECLARE
|
DECLARE
|
||||||
e_id INT;
|
e_id INT;
|
||||||
qlen INT;
|
qlen INT;
|
||||||
dep_level INT;
|
_needed INT;
|
||||||
has_level INT;
|
_known INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF b_cnt < 1 THEN
|
IF b_cnt < 1 THEN
|
||||||
RETURN;
|
RETURN;
|
||||||
|
@ -775,16 +773,16 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Check technologies
|
-- Check technologies
|
||||||
SELECT INTO dep_level , has_level l.level , t.level
|
SELECT INTO _needed , _known
|
||||||
FROM tech.buildings b
|
b.technology_name_id , t.technology_name_id
|
||||||
LEFT OUTER JOIN tech.buildable_requirements r
|
FROM tech.buildings s
|
||||||
ON r.buildable_id = b.buildable_id
|
INNER JOIN tech.buildables b
|
||||||
LEFT OUTER JOIN tech.levels l
|
ON b.name_id = s.buildable_id
|
||||||
ON l.id = r.level_id
|
LEFT OUTER JOIN emp.technologies_v2 t
|
||||||
LEFT OUTER JOIN emp.technologies t
|
ON t.empire_id = e_id AND t.technology_name_id = b.technology_name_id
|
||||||
ON t.empire_id = e_id AND t.line_id = l.line_id AND t.level > l.level
|
AND t.emptech_state = 'KNOWN'
|
||||||
WHERE b.buildable_id = b_id;
|
WHERE s.buildable_id = b_id;
|
||||||
IF NOT FOUND OR ( has_level IS NULL AND dep_level IS NOT NULL ) THEN
|
IF NOT FOUND OR ( _known IS NULL AND _needed IS NOT NULL ) THEN
|
||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,15 @@
|
||||||
</building>
|
</building>
|
||||||
<building name="indFactory" description="indFactoryDescription" type="CASH" output="1" workers="500">
|
<building name="indFactory" description="indFactoryDescription" type="CASH" output="1" workers="500">
|
||||||
<cost build="500" upkeep="20" work="28800" />
|
<cost build="500" upkeep="20" work="28800" />
|
||||||
<tech name="civTech" level="1" />
|
<require-technology>indFactTech</require-technology>
|
||||||
</building>
|
</building>
|
||||||
<building name="reanimationCentre" description="reanimationCentreDescription" type="POP" output="1" workers="300">
|
<building name="reanimationCentre" description="reanimationCentreDescription" type="POP" output="1" workers="300">
|
||||||
<cost build="4000" upkeep="200" work="57600" />
|
<cost build="4000" upkeep="200" work="57600" />
|
||||||
<tech name="civTech" level="2" />
|
<require-technology>reanimationTech</require-technology>
|
||||||
</building>
|
</building>
|
||||||
<building name="superTurret" description="superTurretDescription" type="DEF" output="500" workers="1">
|
<building name="superTurret" description="superTurretDescription" type="DEF" output="500" workers="1">
|
||||||
<cost build="4000" upkeep="10" work="20000" />
|
<cost build="4000" upkeep="10" work="20000" />
|
||||||
<tech name="civTech" level="3" />
|
<require-technology>superTurretTech</require-technology>
|
||||||
</building>
|
</building>
|
||||||
|
|
||||||
<ship name="fighter" description="fighterDescription" time="3" power="10">
|
<ship name="fighter" description="fighterDescription" time="3" power="10">
|
||||||
|
@ -29,15 +29,15 @@
|
||||||
</ship>
|
</ship>
|
||||||
<ship name="cruiser" description="cruiserDescription" time="5" power="100">
|
<ship name="cruiser" description="cruiserDescription" time="5" power="100">
|
||||||
<cost build="500" upkeep="80" work="5000" />
|
<cost build="500" upkeep="80" work="5000" />
|
||||||
<tech name="milTech" level="1" />
|
<require-technology>cruisersTech</require-technology>
|
||||||
</ship>
|
</ship>
|
||||||
<ship name="bCruiser" description="bCruiserDescription" time="4" power="335">
|
<ship name="bCruiser" description="bCruiserDescription" time="4" power="335">
|
||||||
<cost build="2500" upkeep="320" work="25000" />
|
<cost build="2500" upkeep="320" work="25000" />
|
||||||
<tech name="milTech" level="2" />
|
<require-technology>bCruisersTech</require-technology>
|
||||||
</ship>
|
</ship>
|
||||||
<ship name="dreadnought" description="dreadnoughtDescription" time="6" power="5000">
|
<ship name="dreadnought" description="dreadnoughtDescription" time="6" power="5000">
|
||||||
<cost build="12500" upkeep="1280" work="125000" />
|
<cost build="12500" upkeep="1280" work="125000" />
|
||||||
<tech name="milTech" level="3" />
|
<require-technology>dreadnoughtsTech</require-technology>
|
||||||
</ship>
|
</ship>
|
||||||
|
|
||||||
</buildables>
|
</buildables>
|
|
@ -26,7 +26,7 @@
|
||||||
<xs:complexType name="buildable" abstract="true">
|
<xs:complexType name="buildable" abstract="true">
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="cost" type="cost" />
|
<xs:element name="cost" type="cost" />
|
||||||
<xs:element name="tech" type="tech" minOccurs="0" />
|
<xs:element name="require-technology" type="xs:string" minOccurs="0" />
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
<xs:attribute name="name" use="required" type="xs:string" />
|
<xs:attribute name="name" use="required" type="xs:string" />
|
||||||
<xs:attribute name="description" use="required" type="xs:string" />
|
<xs:attribute name="description" use="required" type="xs:string" />
|
||||||
|
|
|
@ -52,7 +52,8 @@ public class ImportBuildables
|
||||||
|
|
||||||
public CostData cost;
|
public CostData cost;
|
||||||
|
|
||||||
public TechData tech;
|
@XStreamAlias( "require-technology" )
|
||||||
|
public String tech;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "serial" )
|
@SuppressWarnings( "serial" )
|
||||||
|
@ -70,18 +71,6 @@ public class ImportBuildables
|
||||||
public int work;
|
public int work;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "serial" )
|
|
||||||
@XStreamAlias( "tech" )
|
|
||||||
public static class TechData
|
|
||||||
implements Serializable
|
|
||||||
{
|
|
||||||
@XStreamAsAttribute
|
|
||||||
public String name;
|
|
||||||
|
|
||||||
@XStreamAsAttribute
|
|
||||||
public int level;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings( "serial" )
|
@SuppressWarnings( "serial" )
|
||||||
@XStreamAlias( "building" )
|
@XStreamAlias( "building" )
|
||||||
public static class BuildingData
|
public static class BuildingData
|
||||||
|
@ -163,7 +152,7 @@ public class ImportBuildables
|
||||||
|
|
||||||
// Load Hibernate bean
|
// Load Hibernate bean
|
||||||
String[] cfg = {
|
String[] cfg = {
|
||||||
"configuration/transactions.xml"
|
"configuration/transactions.xml"
|
||||||
};
|
};
|
||||||
return new ClassPathXmlApplicationContext( cfg , true , ctx );
|
return new ClassPathXmlApplicationContext( cfg , true , ctx );
|
||||||
}
|
}
|
||||||
|
@ -195,8 +184,7 @@ public class ImportBuildables
|
||||||
this.uocBuildingDep.addParameter( "workers" , Types.INTEGER );
|
this.uocBuildingDep.addParameter( "workers" , Types.INTEGER );
|
||||||
this.uocBuildingDep.addParameter( "output_type" , "building_output_type" );
|
this.uocBuildingDep.addParameter( "output_type" , "building_output_type" );
|
||||||
this.uocBuildingDep.addParameter( "output" , Types.INTEGER );
|
this.uocBuildingDep.addParameter( "output" , Types.INTEGER );
|
||||||
this.uocBuildingDep.addParameter( "dep_name" , Types.VARCHAR );
|
this.uocBuildingDep.addParameter( "_technology" , Types.VARCHAR );
|
||||||
this.uocBuildingDep.addParameter( "dep_level" , Types.INTEGER );
|
|
||||||
|
|
||||||
this.uocShipNoDep = new StoredProc( dataSource , "tech" , "uoc_ship" );
|
this.uocShipNoDep = new StoredProc( dataSource , "tech" , "uoc_ship" );
|
||||||
this.uocShipNoDep.addParameter( "name" , Types.VARCHAR );
|
this.uocShipNoDep.addParameter( "name" , Types.VARCHAR );
|
||||||
|
@ -215,8 +203,7 @@ public class ImportBuildables
|
||||||
this.uocShipDep.addParameter( "upkeep" , Types.INTEGER );
|
this.uocShipDep.addParameter( "upkeep" , Types.INTEGER );
|
||||||
this.uocShipDep.addParameter( "power" , Types.INTEGER );
|
this.uocShipDep.addParameter( "power" , Types.INTEGER );
|
||||||
this.uocShipDep.addParameter( "flight_time" , Types.INTEGER );
|
this.uocShipDep.addParameter( "flight_time" , Types.INTEGER );
|
||||||
this.uocShipDep.addParameter( "dep_name" , Types.VARCHAR );
|
this.uocShipDep.addParameter( "_technology" , Types.VARCHAR );
|
||||||
this.uocShipDep.addParameter( "dep_level" , Types.INTEGER );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,7 +228,7 @@ public class ImportBuildables
|
||||||
ship.cost.upkeep , ship.power , ship.time );
|
ship.cost.upkeep , ship.power , ship.time );
|
||||||
} else {
|
} else {
|
||||||
this.uocShipDep.execute( ship.name , ship.description , ship.cost.build , ship.cost.work ,
|
this.uocShipDep.execute( ship.name , ship.description , ship.cost.build , ship.cost.work ,
|
||||||
ship.cost.upkeep , ship.power , ship.time , ship.tech.name , ship.tech.level );
|
ship.cost.upkeep , ship.power , ship.time , ship.tech );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +243,7 @@ public class ImportBuildables
|
||||||
} else {
|
} else {
|
||||||
this.uocBuildingDep.execute( building.name , building.description , building.cost.build ,
|
this.uocBuildingDep.execute( building.name , building.description , building.cost.build ,
|
||||||
building.cost.work , building.cost.upkeep , building.workers , building.type.toString( ) ,
|
building.cost.work , building.cost.upkeep , building.workers , building.type.toString( ) ,
|
||||||
building.output , building.tech.name , building.tech.level );
|
building.output , building.tech );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue