diff --git a/package-lock.json b/package-lock.json index dd44a34..161e813 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pogo-data-generator", - "version": "1.2.7", + "version": "1.2.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2596,7 +2596,7 @@ } }, "pogo-protos": { - "version": "github:Furtif/pogo-protos#d95f57ab27da3fda15cdf64a9209ee80e4624866", + "version": "github:Furtif/pogo-protos#3cc8815cc9076fba97aa788e9e0a5a18a227bf6a", "from": "github:Furtif/pogo-protos", "requires": { "protobufjs": "^6.10.2" diff --git a/package.json b/package.json index c1e7198..1e332b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pogo-data-generator", - "version": "1.2.7", + "version": "1.2.8", "description": "Pokemon GO project data generator", "author": "TurtIeSocks", "license": "Apache-2.0", diff --git a/src/classes/Invasion.ts b/src/classes/Invasion.ts index 504b0d5..0a101cf 100644 --- a/src/classes/Invasion.ts +++ b/src/classes/Invasion.ts @@ -62,6 +62,11 @@ export default class Invasion extends Masterfile { } invasions(invasionData: InvasionInfo) { + const positions = [ + this.customFieldNames.first || 'first', + this.customFieldNames.second || 'second', + this.customFieldNames.third || 'third', + ] Object.entries(Rpc.EnumWrapper.InvasionCharacter).forEach(proto => { try { const [name, id] = proto @@ -73,11 +78,6 @@ export default class Invasion extends Masterfile { } if (pogoInfo && pogoInfo.active) { this.parsedInvasions[id].secondReward = pogoInfo.lineup.rewards.length === 2 - const positions = [ - this.customFieldNames.first || 'first', - this.customFieldNames.second || 'second', - this.customFieldNames.third || 'third', - ] this.parsedInvasions[id].encounters = [] positions.forEach((position, i) => { @@ -87,7 +87,7 @@ export default class Invasion extends Masterfile { }) } else if (this.options.placeholderData) { this.parsedInvasions[id].secondReward = false - this.parsedInvasions[id].encounters = [] + this.parsedInvasions[id].encounters = positions.map(position => ({ position })) } } } catch (e) { diff --git a/src/classes/Masterfile.ts b/src/classes/Masterfile.ts index 4233b80..4d9d10c 100644 --- a/src/classes/Masterfile.ts +++ b/src/classes/Masterfile.ts @@ -139,6 +139,8 @@ export default class Masterfile { // edge case for encounters if (returnValue[customKey]) { returnValue[customKey].push(child) + } else if (typeof child === 'object') { + returnValue[customKey] = [] } else { returnValue[customKey] = [child] } diff --git a/tests/defaultValues.json b/tests/defaultValues.json index 9078892..d515a6c 100644 --- a/tests/defaultValues.json +++ b/tests/defaultValues.json @@ -576,21 +576,33 @@ "gender": 0, "grunt": "Unset", "second_reward": false, - "encounters": {} + "encounters": { + "first": [], + "second": [], + "third": [] + } }, "4": { "type": "Mixed", "gender": 1, "grunt": "Grunt", "second_reward": false, - "encounters": {} + "encounters": { + "first": [], + "second": [], + "third": [] + } }, "11": { "type": "Dark", "gender": 1, "grunt": "Grunt", "second_reward": false, - "encounters": {} + "encounters": { + "first": [], + "second": [], + "third": [] + } } }, "weather": { diff --git a/tests/rawValues.json b/tests/rawValues.json index c869668..cfad6c4 100644 --- a/tests/rawValues.json +++ b/tests/rawValues.json @@ -244,7 +244,17 @@ "gender": 1, "grunt": "Grunt", "secondReward": false, - "encounters": [] + "encounters": [ + { + "position": "first" + }, + { + "position": "second" + }, + { + "position": "third" + } + ] } }, "weather": {