Skip to content

Commit

Permalink
Merge pull request #74 from WatWowMap/add-hindi-indonesian
Browse files Browse the repository at this point in the history
add hindi & indonesian locales
  • Loading branch information
TurtIeSocks committed Dec 4, 2022
2 parents 4370cae + ae6cba5 commit 9b7cb64
Show file tree
Hide file tree
Showing 22 changed files with 1,046 additions and 494 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Generates templated data for Pokemon GO related projects, including:
- Quest Reward Types
- Future Pokemon via PokeAPI

## Current Status
- Internally the typing is strong, however, the return results are typed pretty horribly due to this being my first TypeScript project. Going to work on this in the 2.0 release.


## Installing/Usage

### Package
Expand Down
41 changes: 35 additions & 6 deletions devWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,51 @@ const main = async () => {
const data = await generate({
raw: process.argv.includes('--raw'),
test: process.argv.includes('--test'),
pokeApi: process.argv.includes('--pokeapi') || { baseStats, tempEvos, types },
pokeApi: process.argv.includes('--pokeapi') || {
baseStats,
tempEvos,
types,
},
})

if (process.argv.includes('--test')) {
if (process.argv.includes('--invasions')) {
fs.writeFile('./invasions.json', JSON.stringify(await invasions(), null, 2), 'utf8', () => {})
fs.writeFile(
'./invasions.json',
JSON.stringify(await invasions(), null, 2),
'utf8',
() => {},
)
}
if (data?.AllPokeApi) {
const { baseStats, tempEvos, types } = data.AllPokeApi
fs.writeFile('./static/baseStats.json', JSON.stringify(baseStats, null, 2), 'utf8', () => {})
fs.writeFile('./static/tempEvos.json', JSON.stringify(tempEvos, null, 2), 'utf8', () => {})
fs.writeFile('./static/types.json', JSON.stringify(types, null, 2), 'utf8', () => {})
fs.writeFile(
'./static/baseStats.json',
JSON.stringify(baseStats, null, 2),
'utf8',
() => {},
)
fs.writeFile(
'./static/tempEvos.json',
JSON.stringify(tempEvos, null, 2),
'utf8',
() => {},
)
fs.writeFile(
'./static/types.json',
JSON.stringify(types, null, 2),
'utf8',
() => {},
)
delete data.AllPokeApi
}
if (data) {
fs.writeFile('./masterfile.json', JSON.stringify(data, null, 2), 'utf8', () => {})
fs.writeFile(
'./masterfile.json',
JSON.stringify(data, null, 2),
'utf8',
() => {},
)
}
}
console.timeEnd('Generated in')
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pogo-data-generator",
"version": "1.8.5",
"version": "1.9.0",
"description": "Pokemon GO project data generator",
"author": "TurtIeSocks",
"license": "Apache-2.0",
Expand All @@ -18,13 +18,15 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"start": "node .",
"generate": "ts-node devWrapper.ts --test",
"pokeapi": "ts-node devWrapper.ts --test --pokeapi",
"raw": "ts-node devWrapper.ts --test --raw",
"invasions": "ts-node devWrapper.ts --test --invasions",
"test": "tsc && ./node_modules/.bin/jest",
"format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"publishBuild": "rm -r dist && tsc"
"publishBuild": "rm -r dist && tsc",
"prettier": "prettier --write \"**/*.ts\""
},
"repository": {
"type": "git",
Expand All @@ -35,7 +37,7 @@
},
"dependencies": {
"node-fetch": "2.6.7",
"pogo-protos": "github:Furtif/pogo-protos#06a4d37"
"pogo-protos": "github:Furtif/pogo-protos"
},
"engines": {
"node": ">=16.0.0"
Expand Down
13 changes: 12 additions & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,16 @@ const baseTemplate: FullTemplate = {
prefix: '{{',
suffix: '}}',
},
questTitleTermsToSkip: ['gofest', 'gotour', 'dialog', 'title', 'summer_return', '_complete_', 'location', 'vote'],
questTitleTermsToSkip: [
'gofest',
'gotour',
'dialog',
'title',
'summer_return',
'_complete_',
'location',
'vote',
],
masterfileLocale: false,
manualTranslations: true,
mergeCategories: true,
Expand All @@ -339,6 +348,8 @@ const baseTemplate: FullTemplate = {
en: true,
es: false,
fr: true,
hi: true,
id: true,
it: false,
ja: false,
ko: false,
Expand Down
51 changes: 39 additions & 12 deletions src/classes/Invasion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export default class Invasion extends Masterfile {

async customInvasions(override: boolean = false): Promise<InvasionInfo> {
try {
if (this.options.customInvasions === true || (this.options.customInvasions === undefined && override)) {
if (
this.options.customInvasions === true ||
(this.options.customInvasions === undefined && override)
) {
return this.fetch(
'https://raw.githubusercontent.com/WatWowMap/Masterfile-Generator/master/custom-invasions.json',
)
Expand Down Expand Up @@ -47,10 +50,20 @@ export default class Invasion extends Masterfile {
}

formatGrunts(character: string) {
const base = character.replace('CHARACTER_', '').replace('_MALE', '').replace('_FEMALE', '')
const type = base.replace('EXECUTIVE_', '').replace('_GRUNT', '').replace('EVENT_', '')
const grunt = base.split('_').length > 1 ? base.replace(`${type}`, '').replace('_', '') : base
let gender = character.includes('MALE') || character.includes('FEMALE') ? 1 : 0
const base = character
.replace('CHARACTER_', '')
.replace('_MALE', '')
.replace('_FEMALE', '')
const type = base
.replace('EXECUTIVE_', '')
.replace('_GRUNT', '')
.replace('EVENT_', '')
const grunt =
base.split('_').length > 1
? base.replace(`${type}`, '').replace('_', '')
: base
let gender =
character.includes('MALE') || character.includes('FEMALE') ? 1 : 0
if (character.includes('FEMALE')) {
gender = 2
}
Expand All @@ -70,7 +83,10 @@ export default class Invasion extends Masterfile {
Object.entries(Rpc.EnumWrapper.InvasionCharacter).forEach((proto) => {
try {
const [name, id] = proto
if ((this.options.includeBalloons && name.includes('BALLOON')) || !name.includes('BALLOON_')) {
if (
(this.options.includeBalloons && name.includes('BALLOON')) ||
!name.includes('BALLOON_')
) {
const pogoInfo = invasionData[id]
this.parsedInvasions[id] = {
id: +id,
Expand All @@ -82,20 +98,31 @@ export default class Invasion extends Masterfile {
thirdReward: false,
}
if (pogoInfo && pogoInfo.active) {
this.parsedInvasions[id].firstReward = pogoInfo.lineup.rewards.includes(0)
this.parsedInvasions[id].secondReward = pogoInfo.lineup.rewards.includes(1)
this.parsedInvasions[id].thirdReward = pogoInfo.lineup.rewards.includes(2)
this.parsedInvasions[id].firstReward =
pogoInfo.lineup.rewards.includes(0)
this.parsedInvasions[id].secondReward =
pogoInfo.lineup.rewards.includes(1)
this.parsedInvasions[id].thirdReward =
pogoInfo.lineup.rewards.includes(2)
this.parsedInvasions[id].encounters = []

positions.forEach((position, i) => {
pogoInfo.lineup.team[i].forEach((pkmn) => {
this.parsedInvasions[id].encounters.push({ id: pkmn.id, formId: pkmn.form, position })
this.parsedInvasions[id].encounters.push({
id: pkmn.id,
formId: pkmn.form,
position,
})
})
this.parsedInvasions[id].encounters.sort((a, b) => a.id - b.id)
this.parsedInvasions[id].encounters.sort((a, b) => a.position.localeCompare(b.position))
this.parsedInvasions[id].encounters.sort((a, b) =>
a.position.localeCompare(b.position),
)
})
} else if (this.options.placeholderData) {
this.parsedInvasions[id].encounters = positions.map((position) => ({ position }))
this.parsedInvasions[id].encounters = positions.map((position) => ({
position,
}))
}
}
} catch (e) {
Expand Down
9 changes: 7 additions & 2 deletions src/classes/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ export default class Item extends Masterfile {
},
templateId,
} = object
if (!this.options.minTrainerLevel || !dropTrainerLevel || dropTrainerLevel <= this.options.minTrainerLevel) {
const id = typeof itemId === 'string' ? Rpc.Item[itemId as ItemProto] : itemId
if (
!this.options.minTrainerLevel ||
!dropTrainerLevel ||
dropTrainerLevel <= this.options.minTrainerLevel
) {
const id =
typeof itemId === 'string' ? Rpc.Item[itemId as ItemProto] : itemId
this.parsedItems[id] = {
itemId: id,
itemName: this.capitalize(templateId.replace('ITEM_', '')),
Expand Down
Loading

0 comments on commit 9b7cb64

Please sign in to comment.