Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Use infobubbles from Phobos for traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
Artefact2 committed Dec 9, 2015
1 parent b7f9e0f commit 4234f26
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 114 deletions.
2 changes: 2 additions & 0 deletions README-Datadump.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ itself.

* Run the `./bin/reverence_insert` script.

* Optionally insert traits with `./bin/insert_traits`. Requires a Phobos dump.

~~~~
# Import the schema
psql osmium osmium_user < pgsql/eve.sql
Expand Down
73 changes: 73 additions & 0 deletions bin/insert_traits
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env php
<?php
/* Osmium
* Copyright (C) 2015 Romain "Artefact2" Dalmaso <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

require __DIR__.'/../inc/root.php';

if($argc !== 2) {
fprintf(STDERR, "Usage: %s <path-to-infobubbles.json>\n");
die(1);
}

$info = json_decode(file_get_contents($argv[1]), true);
if($info === false || json_last_error() !== JSON_ERROR_NONE) {
die(2);
}

\Osmium\Db\query('BEGIN;');
\Osmium\Db\query(
'TRUNCATE TABLE eve.infotypebonuses, eve.infotypeelements, eve.infoelements;'
);

foreach($info['infoBubbleElements'] as $id => $element) {
\Osmium\Db\query_params(
'INSERT INTO eve.infoelements (elementid, name, description) VALUES ($1, $2, $3);',
[ $id, $element['name_en-us'], $element['description_en-us'], ]
);
}

foreach($info['infoBubbleTypeElements'] as $typeid => $e) {
foreach($e['elements'] as $prio => $eid) {
\Osmium\Db\query_params(
'INSERT INTO eve.infotypeelements (typeid, elementid, priority) VALUES ($1, $2, $3);',
[ $typeid, $eid, $prio ]
);

}
}

foreach($info['infoBubbleTypeBonuses'] as $typeid => $data) {
foreach($data as $source => $bonii) {
foreach($bonii as $prio => $bonus) {
\Osmium\Db\query_params(
'INSERT INTO eve.infotypebonuses (
typeid, sourcetypeid, sourceother, priority, name, unitid, bonus
) VALUES ($1, $2, $3, $4, $5, $6, $7);', [
$typeid,
(int)$source >= 0 ? $source : null,
(int)$source < 0 ? $source : null,
$prio,
$bonus['name_en-us'],
(isset($bonus['unitID']) && $bonus['unitID'] > 0) ? $bonus['unitID'] : null,
isset($bonus['bonus']) ? $bonus['bonus'] : null,
]);
}
}
}

\Osmium\Db\query('COMMIT;');
46 changes: 0 additions & 46 deletions bin/reverence_insert
Original file line number Diff line number Diff line change
Expand Up @@ -256,49 +256,3 @@ processRows("eve.averagemarketprices", {
"typeid": "typeID",
"averageprice": "averagePrice",
}, makeAveragePrices());



trlabels = { v:k for k, v in cfg._localization.languageLabels.iteritems() }
trrows = cfg._localization.primary

def makeTranslatedMessages():
for k, v in trrows.iteritems():
yield {
"nameID": k,
"label": trlabels[k] if k in trlabels else None,
"message": v[0],
}

processRows("eve.tramessages", {
"nameid": "nameID",
"label": "label",
"message": "message",
}, makeTranslatedMessages())



def makeTypeBonuses():
for id, row in cfg.fsdTypeOverrides.iteritems():
if not hasattr(row, "infoBubbleTypeBonuses"):
continue

for source, bonuses in row.infoBubbleTypeBonuses.iteritems():
for bonus in bonuses.itervalues():
yield {
"typeID": id,
"sourceTypeID": source if source >= 0 else None,
"sourceOther": source if source < 0 else None,
"bonus": bonus.bonus if hasattr(bonus, "bonus") else None,
"nameID": bonus.nameID,
"unitID": bonus.unitID if hasattr(bonus, "unitID") else None,
}

processRows("eve.fsdtypebonuses", {
"typeid": "typeID",
"sourcetypeid": "sourceTypeID",
"sourceother": "sourceOther",
"bonus": "bonus",
"nameid": "nameID",
"unitid": "unitID",
}, makeTypeBonuses())
13 changes: 6 additions & 7 deletions inc/dom-formatter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Osmium
* Copyright (C) 2014 Romain "Artefact2" Dalmaso <[email protected]>
* Copyright (C) 2014, 2015 Romain "Artefact2" Dalmaso <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -256,12 +256,11 @@ function formatCCPTagSoup($text) {
function formatTypeTraits($shiptypeid) {
$traitsq = \Osmium\Db\query_params(
'SELECT COALESCE(sourcetypeid, sourceother) AS source,
bonus, t.message, u.unitid, u.displayname
FROM eve.fsdtypebonuses ftb
JOIN eve.tramessages t ON t.nameid = ftb.nameid
LEFT JOIN eve.dgmunits u ON u.unitid = ftb.unitid
WHERE ftb.typeid = $1
ORDER BY sourcetypeid ASC, t.nameid ASC',
bonus, name AS message, u.unitid, u.displayname
FROM eve.infotypebonuses itb
LEFT JOIN eve.dgmunits u ON u.unitid = itb.unitid
WHERE itb.typeid = $1
ORDER BY source ASC, priority ASC',
array($shiptypeid)
);

Expand Down
10 changes: 5 additions & 5 deletions inc/fit-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ function get_tank(&$fit, $ehp, $capdelta, $reload = false) {
/** @internal */
function get_remote_effects() {
static $remoteeffects = array(
'hull' => [ [ [ EFFECT_RemoteHullRepair, 'structureDamageAmount' ] ], 'HP' ],
'armor' => [ [ [ EFFECT_TargetArmorRepair, 'armorDamageAmount' ] ], 'HP' ],
'shield' => [ [ [ EFFECT_ShieldTransfer, 'shieldBonus' ] ], 'HP' ],
'hull' => [ [ [ EFFECT_RemoteHullRepairFalloff, 'structureDamageAmount' ] ], 'HP' ],
'armor' => [ [ [ EFFECT_RemoteArmorRepairFalloff, 'armorDamageAmount' ] ], 'HP' ],
'shield' => [ [ [ EFFECT_RemoteShieldTransferFalloff, 'shieldBonus' ] ], 'HP' ],
'capacitor' => [ [ [ EFFECT_EnergyTransfer, 'powerTransferAmount' ] ], 'GJ' ],
'neutralization' => [ [ [ EFFECT_EnergyDestabilizationNew, 'energyDestabilizationAmount' ] ], "GJ" ],
'leech' => [ [ [ EFFECT_Leech, 'powerTransferAmount' ] ], "GJ" ],
'neutralization' => [ [ [ EFFECT_EnergyNeutralizerFalloff, 'energyDestabilizationAmount' ] ], "GJ" ],
'leech' => [ [ [ EFFECT_EnergyNosferatuFalloff, 'powerTransferAmount' ] ], "GJ" ],
);

return $remoteeffects;
Expand Down
10 changes: 5 additions & 5 deletions inc/fit-names.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@

const EFFECT_ArmorRepair = 27;
const EFFECT_EMPWave = 38;
const EFFECT_EnergyDestabilizationNew = 2303;
const EFFECT_EnergyNeutralizerFalloff = 6187;
const EFFECT_EnergyNosferatuFalloff = 6197;
const EFFECT_EnergyTransfer = 31;
const EFFECT_FighterMissile = 4729;
const EFFECT_FueledArmorRepair = 5275;
const EFFECT_FueledShieldBoosting = 4936;
const EFFECT_HiPower = 12;
const EFFECT_Leech = 3250;
const EFFECT_LoPower = 11;
const EFFECT_MedPower = 13;
const EFFECT_MiningLaser = 67;
const EFFECT_ProjectileFired = 34;
const EFFECT_RemoteHullRepair = 3041;
const EFFECT_RemoteArmorRepairFalloff = 6188;
const EFFECT_RemoteHullRepairFalloff = 6185;
const EFFECT_RemoteShieldTransferFalloff = 6186;
const EFFECT_RigSlot = 2663;
const EFFECT_ShieldBoosting = 4;
const EFFECT_ShieldTransfer = 18;
const EFFECT_StructureRepair = 26;
const EFFECT_SubSystem = 3772;
const EFFECT_TargetArmorRepair = 592;
const EFFECT_TargetAttack = 10;
const EFFECT_UseMissiles = 101;

Expand Down
2 changes: 1 addition & 1 deletion inc/root.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
const JS_STATICVER = 35;

/** Bump this when clientdata.json is updated */
const CLIENT_DATA_STATICVER = 47;
const CLIENT_DATA_STATICVER = 48;

define(__NAMESPACE__.'\CACHE_DIRECTORY', ROOT.'/cache');

Expand Down
114 changes: 67 additions & 47 deletions pgsql/eve.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,41 @@ CREATE TABLE dgmunits (


--
-- Name: fsdtypebonuses; Type: TABLE; Schema: eve; Owner: -; Tablespace:
-- Name: infoelements; Type: TABLE; Schema: eve; Owner: -; Tablespace:
--

CREATE TABLE fsdtypebonuses (
CREATE TABLE infoelements (
elementid integer NOT NULL,
name text NOT NULL,
description text NOT NULL
);


--
-- Name: infotypebonuses; Type: TABLE; Schema: eve; Owner: -; Tablespace:
--

CREATE TABLE infotypebonuses (
typeid integer NOT NULL,
sourcetypeid integer,
sourceother integer,
bonus double precision,
nameid integer NOT NULL,
priority integer NOT NULL,
name text NOT NULL,
unitid integer,
CONSTRAINT fsdtypebonuses_bonus_has_unit CHECK (((bonus IS NULL) OR (unitid IS NOT NULL))),
CONSTRAINT fsdtypebonuses_source_check CHECK ((((sourcetypeid IS NOT NULL) AND (sourceother IS NULL)) OR ((sourcetypeid IS NULL) AND (sourceother IS NOT NULL))))
bonus double precision,
CONSTRAINT infotypebonuses_bonus_has_unit CHECK (((bonus IS NULL) OR (unitid IS NOT NULL))),
CONSTRAINT infotypebonuses_has_source CHECK ((((sourcetypeid IS NOT NULL) AND (sourceother IS NULL)) OR ((sourcetypeid IS NULL) AND (sourceother IS NOT NULL))))
);


--
-- Name: infotypeelements; Type: TABLE; Schema: eve; Owner: -; Tablespace:
--

CREATE TABLE infotypeelements (
typeid integer NOT NULL,
elementid integer NOT NULL,
priority integer NOT NULL
);


Expand Down Expand Up @@ -191,17 +214,6 @@ CREATE TABLE invtypes (
);


--
-- Name: tramessages; Type: TABLE; Schema: eve; Owner: -; Tablespace:
--

CREATE TABLE tramessages (
nameid integer NOT NULL,
label text,
message text NOT NULL
);


--
-- Name: averagemarketprices_pkey; Type: CONSTRAINT; Schema: eve; Owner: -; Tablespace:
--
Expand Down Expand Up @@ -250,6 +262,22 @@ ALTER TABLE ONLY dgmunits
ADD CONSTRAINT dgmunits_pkey PRIMARY KEY (unitid);


--
-- Name: infoelements_pkey; Type: CONSTRAINT; Schema: eve; Owner: -; Tablespace:
--

ALTER TABLE ONLY infoelements
ADD CONSTRAINT infoelements_pkey PRIMARY KEY (elementid);


--
-- Name: infotypeelements_pkey; Type: CONSTRAINT; Schema: eve; Owner: -; Tablespace:
--

ALTER TABLE ONLY infotypeelements
ADD CONSTRAINT infotypeelements_pkey PRIMARY KEY (typeid, elementid);


--
-- Name: invcategories_pkey; Type: CONSTRAINT; Schema: eve; Owner: -; Tablespace:
--
Expand Down Expand Up @@ -298,22 +326,6 @@ ALTER TABLE ONLY invtypes
ADD CONSTRAINT invtypes_pkey PRIMARY KEY (typeid);


--
-- Name: tramessages_label_uniq; Type: CONSTRAINT; Schema: eve; Owner: -; Tablespace:
--

ALTER TABLE ONLY tramessages
ADD CONSTRAINT tramessages_label_uniq UNIQUE (label);


--
-- Name: tramessages_pkey; Type: CONSTRAINT; Schema: eve; Owner: -; Tablespace:
--

ALTER TABLE ONLY tramessages
ADD CONSTRAINT tramessages_pkey PRIMARY KEY (nameid);


--
-- Name: dgmattribs_attributename_idx; Type: INDEX; Schema: eve; Owner: -; Tablespace:
--
Expand Down Expand Up @@ -371,10 +383,10 @@ CREATE INDEX dgmtypeeffects_typeid_idx ON dgmtypeeffects USING btree (typeid);


--
-- Name: fsdtypebonuses_typeid_idx; Type: INDEX; Schema: eve; Owner: -; Tablespace:
-- Name: infotypebonuses_typeid_sourcetypeid_idx; Type: INDEX; Schema: eve; Owner: -; Tablespace:
--

CREATE INDEX fsdtypebonuses_typeid_idx ON fsdtypebonuses USING btree (typeid);
CREATE INDEX infotypebonuses_typeid_sourcetypeid_idx ON infotypebonuses USING btree (typeid, sourcetypeid);


--
Expand Down Expand Up @@ -552,35 +564,43 @@ ALTER TABLE ONLY dgmtypeeffects


--
-- Name: fsdtypebonuses_nameid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
-- Name: infotypebonuses_sourcetypeid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
--

ALTER TABLE ONLY infotypebonuses
ADD CONSTRAINT infotypebonuses_sourcetypeid_fkey FOREIGN KEY (sourcetypeid) REFERENCES invtypes(typeid);


--
-- Name: infotypebonuses_typeid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
--

ALTER TABLE ONLY fsdtypebonuses
ADD CONSTRAINT fsdtypebonuses_nameid_fkey FOREIGN KEY (nameid) REFERENCES tramessages(nameid);
ALTER TABLE ONLY infotypebonuses
ADD CONSTRAINT infotypebonuses_typeid_fkey FOREIGN KEY (typeid) REFERENCES invtypes(typeid);


--
-- Name: fsdtypebonuses_sourcetypeid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
-- Name: infotypebonuses_unitid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
--

ALTER TABLE ONLY fsdtypebonuses
ADD CONSTRAINT fsdtypebonuses_sourcetypeid_fkey FOREIGN KEY (sourcetypeid) REFERENCES invtypes(typeid);
ALTER TABLE ONLY infotypebonuses
ADD CONSTRAINT infotypebonuses_unitid_fkey FOREIGN KEY (unitid) REFERENCES dgmunits(unitid);


--
-- Name: fsdtypebonuses_typeid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
-- Name: infotypeelements_elementid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
--

ALTER TABLE ONLY fsdtypebonuses
ADD CONSTRAINT fsdtypebonuses_typeid_fkey FOREIGN KEY (typeid) REFERENCES invtypes(typeid);
ALTER TABLE ONLY infotypeelements
ADD CONSTRAINT infotypeelements_elementid_fkey FOREIGN KEY (elementid) REFERENCES infoelements(elementid);


--
-- Name: fsdtypebonuses_unitid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
-- Name: infotypeelements_typeid_fkey; Type: FK CONSTRAINT; Schema: eve; Owner: -
--

ALTER TABLE ONLY fsdtypebonuses
ADD CONSTRAINT fsdtypebonuses_unitid_fkey FOREIGN KEY (unitid) REFERENCES dgmunits(unitid);
ALTER TABLE ONLY infotypeelements
ADD CONSTRAINT infotypeelements_typeid_fkey FOREIGN KEY (typeid) REFERENCES invtypes(typeid);


--
Expand Down
Loading

0 comments on commit 4234f26

Please sign in to comment.