Skip to content

Commit

Permalink
#1 Pulled through map data and replaced location objects with locatio…
Browse files Browse the repository at this point in the history
…n IDs.
  • Loading branch information
JamesDonnelly committed Jun 2, 2019
1 parent 8ae1956 commit 4dcaccd
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 18 deletions.
1 change: 1 addition & 0 deletions data/maps.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/methods/gathering.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{"minion":[{"contentId":38,"icon":60438,"iconPath":"/i/060000/060438.png","job":{"level":50,"name":{"de":"Minenarbeiter (Abbauen)","en":"Mining","fr":"Extraction de minerai","ja":"採掘"}},"location":145},{"contentId":48,"icon":60432,"iconPath":"/i/060000/060432.png","job":{"level":50,"name":{"de":"Gärtner (Abernten)","en":"Harvesting","fr":"Fauche","ja":"草刈"}},"location":152},{"contentId":24,"icon":60929,"iconPath":"/i/060000/060929.png","job":{"level":20,"name":{"de":"Angeln","en":"Fishing","fr":"Pêche","ja":"釣り"}},"location":135},{"contentId":30,"icon":60929,"iconPath":"/i/060000/060929.png","job":{"level":40,"name":{"de":"Angeln","en":"Fishing","fr":"Pêche","ja":"釣り"}},"location":145},{"contentId":188,"icon":60929,"iconPath":"/i/060000/060929.png","job":{"level":53,"name":{"de":"Angeln","en":"Fishing","fr":"Pêche","ja":"釣り"}},"location":397},{"contentId":237,"icon":60929,"iconPath":"/i/060000/060929.png","job":{"level":50,"name":{"de":"Angeln","en":"Fishing","fr":"Pêche","ja":"釣り"}},"location":137},{"contentId":244,"icon":60929,"iconPath":"/i/060000/060929.png","job":{"level":70,"name":{"de":"Speerfischen","en":"Spear fishing","fr":"Pêche au harpon","ja":"銛"},"stars":0},"location":613}]}
2 changes: 1 addition & 1 deletion data/methods/quests.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/npcs.json

Large diffs are not rendered by default.

33 changes: 26 additions & 7 deletions src/config/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ module.exports = {
* `GatheringLevel` - The fishing node's level;
* `Item{0...n}TargetID` - Items attached to the fishing node;
* `TerritoryType` - The world map's...
* `PlaceName` - Region.
* `ID` - Territory ID used to link through to map data.
*/
columns: [
'GatheringLevel',
...fishingSpotItemIDFields,
'TerritoryType.PlaceName'
'TerritoryType.ID'
],
fishingSpotItemIDFields,
isPaginated: true,
Expand Down Expand Up @@ -140,14 +140,14 @@ module.exports = {
* `GatheringType` - Node details;
* `Item{0...n}` - Gathering item reference (gathering item =/= item).
* `TerritoryType` - The world map's...
* `PlaceName` - Region.
* `ID` - Territory ID used to link through to map data.
*/
columns: [
'GatheringPointBase.GatheringLevel',
'GatheringPointBase.GatheringType',
...gatheringItemIDFields.map(field => `GatheringPointBase.${field}`),
'TerritoryType.PlaceName',
'ID'
'ID',
'TerritoryType.ID'
],
gatheringItemIDFields,
isPaginated: true,
Expand All @@ -162,13 +162,13 @@ module.exports = {
* `IsVisible` - Whether the node is visible by default;
* `ItemTargetID` - The item's ID used to link the result to the items data set;
* `TerritoryType` - The world map's...
* `PlaceName` - Region.
* `ID` - Territory ID used to link through to map data.
*/
columns: [
'GatheringItemLevel',
'IsVisible',
'ItemTargetID',
'TerritoryType.PlaceName'
'TerritoryType.ID'
],
isPaginated: true,
log: 'Spear Fishing Items',
Expand Down Expand Up @@ -219,6 +219,25 @@ module.exports = {
method: 'search',
query: itemActionTypesQuery()
},
maps: {
/**
* For maps we need to extract the following fields:
* `ID` - To link other content to a given map;
* `PlaceName` - The name of the exact map area's...
* `Name_{lang}` - Localised name;
* `PlaceNameRegion` - The region the map area belongs to's...
* `Name_{lang}` - Localised name.
*/
columns: [
'ID',
...helper.localisedColumnProperty('PlaceName.Name'),
...helper.localisedColumnProperty('PlaceNameRegion.Name')
],
isPaginated: true,
log: 'Map Areas',
method: 'fetch',
name: 'territoryTypes'
},
quests: {
/**
* For quests we need to extract the following fields:
Expand Down
6 changes: 3 additions & 3 deletions src/parsers/gathering.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = (
level: GatheringPointBase.GatheringLevel,
name: helper.getLocalisedNamesObject(GatheringType)
},
location: helper.getLocalisedNamesObject(gatheringPoint.TerritoryType.PlaceName)
location: gatheringPoint.TerritoryType.ID
})
});
});
Expand Down Expand Up @@ -132,7 +132,7 @@ module.exports = (
ja: '釣り'
}
},
location: helper.getLocalisedNamesObject(fishingSpot.TerritoryType.PlaceName)
location: fishingSpot.TerritoryType.ID
});
})

Expand Down Expand Up @@ -186,7 +186,7 @@ module.exports = (
},
stars: GatheringItemLevel.Stars
},
location: helper.getLocalisedNamesObject(spearFishingItem.TerritoryType.PlaceName)
location: spearFishingItem.TerritoryType.ID
});
});

Expand Down
3 changes: 1 addition & 2 deletions src/parsers/mappy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ module.exports = async () => {
case 'ENPC':
parsed.npcs.push({
id: data.ENpcResidentID,
placeNameId: data.PlaceNameID,
territoryId: data.MapTerritoryID,
location: data.MapTerritoryID,
type: data.Type,
x: data.PosX,
y: data.PosY
Expand Down
22 changes: 22 additions & 0 deletions src/parsers/maps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');
const helper = require('../xivapi/helper');
const items = require('../../data/items.json');

/**
* Parse recipe data from XIVAPI.
*/
module.exports = (data) => {
const config = require('../config/data').maps;
const parsed = data.map(territoryType => ({
id: territoryType.id,
name: helper.getLocalisedNamesObject(territoryType.PlaceName),
region: helper.getLocalisedNamesObject(territoryType.PlaceNameRegion)
})).filter(map => map.name.en)

fs.writeFileSync(
'../data/maps.json',
JSON.stringify(parsed),
'utf8'
);
console.info(`${config.log} data parsed.`);
};
11 changes: 9 additions & 2 deletions src/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,21 @@ class API {
spearFishingItems
);

// // Shops.
// Shops.
const eNPCResidents = await this.crawl(config.shops.eNPCResident);
const gcScripShopItems = await this.crawl(config.shops.gcScripShopItem);
require ('./parsers/shops')(
eNPCResidents,
gcScripShopItems
[]
);

// Map data.
const maps = await this.crawl(config.maps);
await require('./parsers/maps')(maps);

// Mappy data (NPCs).
await require('./parsers/mappy')();

console.info('Finished parsing of misc required data.');
console.info('Starting parsing of obtain method data...');

Expand Down
3 changes: 2 additions & 1 deletion src/xivapi/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ module.exports = {
minion: (id) => `${xivapiBase}/companion/${id}`,
minions: () => `${xivapiBase}/companion`,
search: () => `${xivapiBase}/search`,
spearfishingItems: () => `${xivapiBase}/spearfishingitem`
spearfishingItems: () => `${xivapiBase}/spearfishingitem`,
territoryTypes: () => `${xivapiBase}/territorytype`
}

0 comments on commit 4dcaccd

Please sign in to comment.