mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-07-13 07:01:33 -05:00
Fix an issue where some gear displayed the wrong name
The "Annaki Blue Cuff" and "Moist Ghillie Helmet" both share the same ID (7010), but they are of different kinds. I didn't realize gear of different kinds could share the same ID, so the localization code didn't take this into account. This change also makes the localization code work with multi-part IDs.
This commit is contained in:
parent
da59394901
commit
479bf4cfba
|
|
@ -96,7 +96,7 @@ export default {
|
|||
},
|
||||
gearName() {
|
||||
let gear = this.merchandise.gear;
|
||||
return this.$t(`splatnet.gear.${gear.id}.name`, gear.name);
|
||||
return this.$t(`splatnet.gear.${gear.kind}.${gear.id}.name`, gear.name);
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,16 +37,27 @@ class LocalizationProcessor {
|
|||
writeJson(this.getFilename(), this.data);
|
||||
}
|
||||
|
||||
getExpression(id, valueKey) {
|
||||
return [this.ruleset.name, id, valueKey];
|
||||
getExpression(ids, valueKey) {
|
||||
return [this.ruleset.name, ...ids, valueKey];
|
||||
}
|
||||
|
||||
readValue(id, valueKey) {
|
||||
return _.get(this.data, this.getExpression(id, valueKey));
|
||||
readValue(ids, valueKey) {
|
||||
return _.get(this.data, this.getExpression(ids, valueKey));
|
||||
}
|
||||
|
||||
writeValue(id, valueKey, newValue) {
|
||||
return _.setWith(this.data, this.getExpression(id, valueKey), newValue, Object);
|
||||
writeValue(ids, valueKey, newValue) {
|
||||
return _.setWith(this.data, this.getExpression(ids, valueKey), newValue, Object);
|
||||
}
|
||||
|
||||
getIdValues(entity) {
|
||||
let idParts = this.ruleset.id;
|
||||
|
||||
// Support multi-part IDs
|
||||
if (!Array.isArray(idParts))
|
||||
idParts = [idParts];
|
||||
|
||||
// Get the ID part values
|
||||
return idParts.map(id => _.get(entity, id));
|
||||
}
|
||||
|
||||
eachEntity(data, callback) {
|
||||
|
|
@ -67,10 +78,10 @@ class LocalizationProcessor {
|
|||
|
||||
updateLocalizationsForEntity(entity) {
|
||||
for (let valueKey of this.valueExpressions) {
|
||||
let id = _.get(entity, this.ruleset.id);
|
||||
let ids = this.getIdValues(entity);
|
||||
let value = _.get(entity, valueKey);
|
||||
|
||||
this.writeValue(id, valueKey, value);
|
||||
this.writeValue(ids, valueKey, value);
|
||||
}
|
||||
|
||||
this.writeData();
|
||||
|
|
@ -83,9 +94,9 @@ class LocalizationProcessor {
|
|||
|
||||
hasLocalizationsForEntity(entity) {
|
||||
for (let valueKey of this.valueExpressions) {
|
||||
let id = _.get(entity, this.ruleset.id);
|
||||
let ids = this.getIdValues(entity);
|
||||
|
||||
if (this.readValue(id, valueKey) === undefined)
|
||||
if (this.readValue(ids, valueKey) === undefined)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ async function updateAll() {
|
|||
for (let updater of updaters) {
|
||||
try {
|
||||
await updater.update();
|
||||
} catch (e) { }
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return 'Done';
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class MerchandisesUpdater extends Updater {
|
|||
{
|
||||
name: 'gear',
|
||||
entities: '$..gear',
|
||||
id: 'id',
|
||||
id: ['kind', 'id'],
|
||||
values: 'name',
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class TimelineUpdater extends Updater {
|
|||
{
|
||||
name: 'gear',
|
||||
entities: '$.coop..gear',
|
||||
id: 'id',
|
||||
id: ['kind', 'id'],
|
||||
values: 'name',
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user