Anonymous

Module:GameData/doc: Difference between revisions

From Melvor Idle
Update for v1.1.2
m (Reference second data page)
(Update for v1.1.2)
Line 207: Line 207:
dataNode.data.masteryCheckpoints = [];
dataNode.data.masteryCheckpoints = [];
masteryCheckpoints.forEach((pct, idx) => {
masteryCheckpoints.forEach((pct, idx) => {
dataNode.data.masteryCheckpoints[idx] = getLangString('MASTERY_CHECKPOINT', `${ localID }_${ idx }`);
dataNode.data.masteryCheckpoints[idx] = this.getLangString('MASTERY_CHECKPOINT', `${ localID }_${ idx }`);
});
});
}
}
Line 279: Line 279:
// Remap a number of keys from their in-game names
// Remap a number of keys from their in-game names
const townKeys = [
const townKeys = [
{'from': 'TICK_LENGTH', 'to': 'tickLength'},
{from: 'BASE_STORAGE', to: 'baseStorage'},
{'from': 'MAX_TOWN_SIZE', 'to': 'maxTownSize'},
{from: 'BASE_TAX_RATE', to: 'baseTaxRate'},
{'from': 'SECTION_SIZE', 'to': 'sectionSize'},
{from: 'DECREASED_BUILDING_COST_CAP', to: 'decreasedBuildingCostCap' },
{'from': 'INITIAL_CITIZEN_COUNT', 'to': 'initialCitizenCount'},
{from: 'GP_PER_CITIZEN', to: 'gpPerCitizen'},
{'from': 'MIN_WORKER_AGE', 'to': 'minWorkerAge'},
{from: 'MAX_WORSHIP', to: 'maxWorship'},
{'from': 'MAX_WORKER_AGE', 'to': 'maxWorkerAge'},
{from: 'MINIMUM_HEALTH', to: 'minimumHealth'},
{'from': 'AGE_OF_DEATH', 'to': 'ageOfDeath'},
{from: 'TICK_LENGTH', to: 'tickLength'},
{'from': 'MIN_MIGRATION_AGE', 'to': 'minMigrationAge'},
{from: 'RARE_SEASON_CHANCE', to: 'rareSeasonChance'},
{'from': 'MAX_MIGRATION_AGE', 'to': 'maxMigrationAge'},
{from: 'WORSHIP_CHANGE_COST', to: 'worshipChangeCost'},
{'from': 'BASE_TAX_RATE', 'to': 'baseTaxRate'},
{from: 'WORSHIP_CHECKPOINTS', to: 'worshipCheckpoints'},
{'from': 'EDUCATION_PER_CITIZEN', 'to': 'educationPerCitizen'},
{'from': 'HAPPINESS_PER_CITIZEN', 'to': 'happinessPerCitizen'},
{'from': 'CITIZEN_FOOD_USAGE', 'to': 'citizenFoodUsage'},
{'from': 'POPULATION_REQUIRED_FOR_BIRTH', 'to': 'populationRequiredForBirth'},
{'from': 'BASE_STORAGE', 'to': 'baseStorage'},
{'from': 'WORSHIP_CHECKPOINTS', 'to': 'worshipCheckpoints'},
{'from': 'MAX_WORSHIP', 'to': 'maxWorship'},
{'from': 'populationForTier', 'to': 'populationForTier'},
{'from': 'MAX_TRADER_STOCK_INCREASE', 'to': 'maxTraderStockIncrease'},
];
];
townKeys.forEach((k) => dataNode.data[k.to] = gameSkill[k.from]);
townKeys.forEach((k) => dataNode.data[k.to] = gameSkill[k.from]);
Line 442: Line 433:
const skillObj = this.gameData[categoryName][skillIdx].data;
const skillObj = this.gameData[categoryName][skillIdx].data;
Object.keys(skillData.data).forEach((dataKey) => {
Object.keys(skillData.data).forEach((dataKey) => {
if (Array.isArray(skillData.data[dataKey]) && skillData.data[dataKey].length > 0 && skillData.data[dataKey][0].insertAt !== undefined) {
// Special case for Township item conversions
//Data is ordered, special handling applies
if ((skillObj[dataKey] !== undefined) && (skillData.skillID === 'melvorD:Township') && (dataKey === 'itemConversions')) {
Object.keys(skillData.data[dataKey]).forEach((convKey) => {
skillData.data[dataKey][convKey].forEach((resource) => {
// Find the resource if it already exists within the combined data
const resourceIdx = skillObj[dataKey][convKey].findIndex((res) => res.resourceID === resource.resourceID);
if (resourceIdx === -1) {
skillObj[dataKey][convKey].push(resource);
}
else {
skillObj[dataKey][convKey][resourceIdx].items.push(...resource.items);
}
})
});
}
else if (Array.isArray(skillData.data[dataKey]) && skillData.data[dataKey].length > 0 && skillData.data[dataKey][0].insertAt !== undefined) {
// Data is ordered, special handling applies
skillObj[dataKey] = this.combineOrderedData(skillObj[dataKey], skillData.data[dataKey]);
skillObj[dataKey] = this.combineOrderedData(skillObj[dataKey], skillData.data[dataKey]);
}
}
Line 597: Line 603:
if (this.gameData.equipmentSlots === undefined) {
if (this.gameData.equipmentSlots === undefined) {
const slotIDs = Object.keys(EquipmentSlots).filter((slotID) => !isNaN(parseInt(slotID)));
const slotIDs = Object.keys(EquipmentSlots).filter((slotID) => !isNaN(parseInt(slotID)));
this.gameData.equipmentSlots = slotIDs.map((slotID) => ({id: EquipmentSlots[slotID], name: getLangString('EQUIP_SLOT', slotID)}));
this.gameData.equipmentSlots = slotIDs.map((slotID) => ({id: EquipmentSlots[slotID], name: this.getLangString('EQUIP_SLOT', slotID)}));
}
}
if (this.gameData.attackTypes === undefined) {
if (this.gameData.attackTypes === undefined) {
Line 715: Line 721:
case 'langHint':
case 'langHint':
case 'langCustomDescription':
case 'langCustomDescription':
return getLangString(entity.category, this.getLocalID(entity.id));
return this.getLangString(entity.category, this.getLocalID(entity.id));
case 'equipmentStats':
case 'equipmentStats':
const newStats = {};
const newStats = {};
Line 765: Line 771:
return 'ALTMAGIC_DESC_{ID}';
return 'ALTMAGIC_DESC_{ID}';
};
};
const shopChainPropKey = function(data, dataKey, propName) {
const shopChainPropKey = (data, dataKey, propName) => {
// Accepts an upgrade chain data object & key of the property being localized
// Accepts an upgrade chain data object & key of the property being localized
const propToLang = {
const propToLang = {
Line 780: Line 786:
}
}
}
}
const itemDesc = function(data) {
const itemDesc = (data) => {
// Items have varying logic based on the type of item, and the lang data contains
// Items have varying logic based on the type of item, and the lang data contains
// some incorrect stuff for items whose descriptions are generated entirely
// some incorrect stuff for items whose descriptions are generated entirely
Line 788: Line 794:
if (item !== undefined) {
if (item !== undefined) {
desc = item.description;
desc = item.description;
if (desc === getLangString('BANK_STRING', '38')) {
if (desc === this.getLangString('BANK_STRING', '38')) {
// Generic "no description" string
// Generic "no description" string
return undefined;
return undefined;
Line 794: Line 800:
// Temporary fix for issue with language data keys for FrostSpark 1H Sword
// Temporary fix for issue with language data keys for FrostSpark 1H Sword
else if (desc.includes('UNDEFINED TRANSLATION') && data.id === 'melvorTotH:FrostSpark_1H_Sword') {
else if (desc.includes('UNDEFINED TRANSLATION') && data.id === 'melvorTotH:FrostSpark_1H_Sword') {
return getLangString('ITEM_DESCRIPTION', 'Frostspark_1H_Sword')
return this.getLangString('ITEM_DESCRIPTION', 'Frostspark_1H_Sword')
}
}
else {
else {
Line 1,149: Line 1,155:
}
}
getLangString(key, identifier) {
getLangString(key, identifier) {
const langCat = loadedLangJson[key];
return loadedLangJson[key + '_' + identifier];
if (langCat !== undefined) {
return langCat[identifier];
}
}
}
getNamespacedID(namespace, ID) {
getNamespacedID(namespace, ID) {