Skip to content

Commit

Permalink
Merge pull request #42 from TurtIeSocks/update-protos
Browse files Browse the repository at this point in the history
Update Protos
  • Loading branch information
TurtIeSocks authored Nov 9, 2021
2 parents 2314c1a + 2b74a74 commit 46a228d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 6 additions & 6 deletions src/classes/Invasion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) => {
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/classes/Masterfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down
18 changes: 15 additions & 3 deletions tests/defaultValues.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 11 additions & 1 deletion tests/rawValues.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,17 @@
"gender": 1,
"grunt": "Grunt",
"secondReward": false,
"encounters": []
"encounters": [
{
"position": "first"
},
{
"position": "second"
},
{
"position": "third"
}
]
}
},
"weather": {
Expand Down

0 comments on commit 46a228d

Please sign in to comment.