adding relics to sample data
This commit is contained in:
parent
5bedc69c4b
commit
e1f636d40e
31 changed files with 749947 additions and 740245 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "40k9e",
|
||||
"revision": "0.2.0",
|
||||
"revision": "0.2.1",
|
||||
"game": "Warhammer 40,000",
|
||||
"genre": "sci-fi",
|
||||
"publisher": "Games Workshop",
|
||||
|
|
@ -1798,6 +1798,12 @@
|
|||
"aspects": {
|
||||
"Describe": true
|
||||
}
|
||||
},
|
||||
"Relic Weapon": {
|
||||
"templateClass": "Weapon"
|
||||
},
|
||||
"Relic": {
|
||||
"templateClass": "Weapon"
|
||||
}
|
||||
},
|
||||
"assetCatalog": {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
91494
aeldari/Aeldari.manifest
91494
aeldari/Aeldari.manifest
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
33702
necrons/Necrons.manifest
33702
necrons/Necrons.manifest
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
81965
orks/Orks.manifest
81965
orks/Orks.manifest
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -30,7 +30,7 @@ processInfo = (data,factionKey) => {
|
|||
publisher: 'Games Workshop',
|
||||
url: 'https://warhammer40000.com/',
|
||||
notes: 'This manifest is provided for the purposes of testing the features of *Rosterizer* and is not intended for distribution.',
|
||||
revision: '0.0.4',
|
||||
revision: '0.0.5',
|
||||
dependencies: [
|
||||
{
|
||||
slug: "123456",
|
||||
|
|
@ -47,6 +47,7 @@ processItems = (data) => {
|
|||
processModels(data,assetCatalog);
|
||||
processAbilities(data,assetCatalog);
|
||||
processWargear(data,assetCatalog);
|
||||
processRelics(data,assetCatalog);
|
||||
processPsychicPowers(data,assetCatalog);
|
||||
processWarlordTraits(data,assetCatalog);
|
||||
processUnits(data,assetCatalog);
|
||||
|
|
@ -56,6 +57,7 @@ processClasses = data => {
|
|||
let assetTaxonomy = {};
|
||||
processFactions(data,assetTaxonomy);
|
||||
processPsychicClasses(data,assetTaxonomy);
|
||||
processRelicClasses(data,assetTaxonomy);
|
||||
return assetTaxonomy
|
||||
}
|
||||
processModels = (data,assetCatalog) => {
|
||||
|
|
@ -246,10 +248,10 @@ processWargear = (data,assetCatalog) => {
|
|||
assetCatalog['Wargear§'+bareName].stats.Points = assetCatalog['Wargear§'+bareName].stats.Points || {};
|
||||
assetCatalog['Wargear§'+bareName].stats.Points.value = assetCatalog['Weapon§'+shooter.name].stats.Points.value;
|
||||
delete assetCatalog['Weapon§'+shooter.name].stats;
|
||||
delete assetCatalog['Weapon§'+bareName+' (melee)'].stats;
|
||||
delete assetCatalog['Weapon§'+bareName+' (melee)']?.stats;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
data.wargear.composed = [];
|
||||
data.wargear.datasheets_wargear.forEach((wargear) => {
|
||||
let wargearArr = data.wargear.wargear_list.filter(wargear_list => wargear_list.wargear_id == wargear.wargear_id);
|
||||
|
|
@ -292,6 +294,61 @@ createWargearStat = (i,wargearArr,modelLoadout,assetCatalog) => {
|
|||
});
|
||||
return tempStat
|
||||
}
|
||||
processRelics = (data,assetCatalog) => {
|
||||
console.log(data.relics.relic_list)
|
||||
data.relics.relic_list?.forEach(relic => {
|
||||
let weapName = relic.name.replace(/(1: |2: |3: )/,'').replace(/в/g,'d').replace(/^"*(.*[^"])"*$/g,'$1').replace(/^\s*(.*[^\s])\s*$/g,'$1');
|
||||
let tempWeapon = {stats:{
|
||||
AP: {value: relic.armor_piercing},
|
||||
D: {value: relic.damage},
|
||||
S: {value: relic.strength},
|
||||
Type: {value: relic.type},
|
||||
Range: {value: relic.weapon_range},
|
||||
}};
|
||||
if(relic.abilities) tempWeapon.text = formatText(relic.abilities);
|
||||
let relicsArr = data.relics.relic_list.filter(relic_list => relic_list.wargear_id == relic.wargear_id).map(relic => 'Relic Weapon§' + relic.name);
|
||||
let relicType = data.relics.relics.filter(gear => gear.wargear_id == relic.wargear_id)[0].type;
|
||||
let relicName = data.relics.relics.filter(gear => gear.wargear_id == relic.wargear_id)[0].name;
|
||||
let itemKey = relicType + '§' + relicName;
|
||||
if(relicsArr.length === 1){
|
||||
assetCatalog[itemKey] = tempWeapon;
|
||||
}else if(relicsArr.length > 1){
|
||||
assetCatalog['Relic Weapon§' + weapName] = tempWeapon;
|
||||
// console.log(relicsArr,weapName)
|
||||
assetCatalog[itemKey] = assetCatalog[itemKey] || {};
|
||||
assetCatalog[itemKey].assets = assetCatalog[itemKey].assets || {};
|
||||
assetCatalog[itemKey].assets.traits = assetCatalog[itemKey].assets.traits || [];
|
||||
assetCatalog[itemKey].assets.traits.push('Relic Weapon§' + weapName);
|
||||
}
|
||||
});
|
||||
let shootingMelee = data.relics.relic_list.filter(relics => relics.name.includes('(shooting)') || relics.name.includes('(melee)'));
|
||||
let shooting = shootingMelee.filter(relics => relics.name.includes('(shooting)'));
|
||||
let melee = shootingMelee.filter(relics => relics.name.includes('(melee)'));
|
||||
shooting.forEach(shooter => {
|
||||
let bareName = shooter.name.replace(' (shooting)','');
|
||||
if(melee.filter(meleer => meleer.name.includes(bareName))){
|
||||
let relicType = data.relics.relics.filter(gear => gear.wargear_id == shooter.wargear_id)[0].type;
|
||||
assetCatalog[relicType+'§'+bareName] = {
|
||||
assets: {traits:[
|
||||
'Relic Weapon§'+bareName+' (melee)',
|
||||
'Relic Weapon§'+bareName+' (shooting)',
|
||||
]}
|
||||
}
|
||||
if(assetCatalog['Relic Weapon§'+shooter.name].stats?.Points?.value){
|
||||
assetCatalog[relicType+'§'+bareName].stats = assetCatalog[relicType+'§'+bareName].stats || {};
|
||||
assetCatalog[relicType+'§'+bareName].stats.Points = assetCatalog[relicType+'§'+bareName].stats.Points || {};
|
||||
assetCatalog[relicType+'§'+bareName].stats.Points.value = assetCatalog['Relic Weapon§'+shooter.name].stats.Points.value;
|
||||
delete assetCatalog['Relic Weapon§'+shooter.name].stats;
|
||||
delete assetCatalog['Relic Weapon§'+bareName+' (melee)'].stats;
|
||||
}
|
||||
}
|
||||
});
|
||||
data.relics.relics.forEach(relic => {
|
||||
let itemKey = relic.type + '§' + relic.name;
|
||||
assetCatalog[itemKey] = assetCatalog[itemKey] || {};
|
||||
if(relic.description) assetCatalog[itemKey].text = formatText(relic.description);
|
||||
});
|
||||
}
|
||||
processPsychicPowers = (data,assetCatalog) => {
|
||||
data.psychicPowers.forEach(power => {
|
||||
if(power.type){
|
||||
|
|
@ -775,4 +832,13 @@ processPsychicClasses = (data,assetTaxonomy) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
processRelicClasses = (data,assetTaxonomy) => {
|
||||
data.relics.relics.forEach(relic => {
|
||||
if(relic.type){
|
||||
assetTaxonomy[relic.type] = assetTaxonomy[relic.type] || {
|
||||
templateClass: 'Relic'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
module.exports = { processItems };
|
||||
|
|
@ -35,11 +35,12 @@ router.get('/:faction', async function (req, res, next) {
|
|||
allResults.factions = await getFactions(req.params.faction);
|
||||
allResults.datasheets = await getDatasheets(req.params.faction);
|
||||
let datasheetList = Array.from(new Set(allResults.datasheets.map(datasheet => datasheet.datasheet_id)));
|
||||
console.log(datasheetList)
|
||||
// console.log(datasheetList)
|
||||
allResults.keywords = await getKeywords(datasheetList);
|
||||
allResults.models = await getModels(datasheetList);
|
||||
allResults.damage = await getDamage(datasheetList);
|
||||
allResults.wargear = await getWargear(datasheetList);
|
||||
allResults.relics = await getRelics(req.params.faction);
|
||||
allResults.abilities = await getAbilities(datasheetList);
|
||||
allResults.options = await getOptions(datasheetList);
|
||||
allResults.psychicPowers = await getPsychicPowers(req.params.faction);
|
||||
|
|
@ -135,6 +136,7 @@ let getDamage = async (datasheets) => {
|
|||
|
||||
let getWargear = async (datasheets) => {
|
||||
let sql = SqlString.format("SELECT * FROM datasheets_wargear WHERE datasheet_id in (?)",[datasheets]);
|
||||
console.log('query',sql)
|
||||
let datasheets_wargear = await new Promise((resolve, reject) => pool.query(sql, (error, results) => {
|
||||
if(error) {
|
||||
console.log(error);
|
||||
|
|
@ -173,6 +175,37 @@ let getWargear = async (datasheets) => {
|
|||
};
|
||||
}
|
||||
|
||||
let getRelics = async (fac) => {
|
||||
sql = SqlString.format("SELECT * FROM wargear WHERE faction_id = ? && is_relic = 1",fac);
|
||||
console.log('query',sql)
|
||||
let relics = await new Promise((resolve, reject) => pool.query(sql, (error, results) => {
|
||||
if(error) {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
return;
|
||||
}else{
|
||||
resolve(results);
|
||||
}
|
||||
}));
|
||||
let relicIDs = Array.from(new Set(relics?.map(relic => relic?.wargear_id)));
|
||||
sql = SqlString.format("SELECT * FROM wargear_list WHERE wargear_id in (?)",[relicIDs]);
|
||||
console.log('query',sql)
|
||||
let relic_list = relicIDs.length ? await new Promise((resolve, reject) => pool.query(sql, (error, results) => {
|
||||
if(error) {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
return;
|
||||
}else{
|
||||
resolve(results);
|
||||
}
|
||||
})) : [];
|
||||
// console.log('models',results)
|
||||
return {
|
||||
relic_list:relic_list,
|
||||
relics:relics,
|
||||
};
|
||||
}
|
||||
|
||||
let getAbilities = async (datasheets) => {
|
||||
let sql = SqlString.format("SELECT * FROM datasheets_abilities WHERE datasheet_id in (?)",[datasheets]);
|
||||
let datasheets_abilities = await new Promise((resolve, reject) => pool.query(sql, (error, results) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue