Skip to content

Commit

Permalink
🔖 0.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaoz-Topsy committed Sep 26, 2023
1 parent 68013d0 commit f74d26e
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 241 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
dist
dist
public/assets/json/tempGameDetails.json
public/assets/json/tempAllPokemon.json
462 changes: 231 additions & 231 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "assistantapps-pokemon-living-dex",
"version": "0.0.7",
"version": "0.0.8",
"description": "",
"scripts": {
"start": "vite",
Expand Down
Binary file added public/assets/img/game/SV2TM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/assets/img/pokemon/0000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions public/assets/json/pokedexByGame.json
Original file line number Diff line number Diff line change
Expand Up @@ -4326,5 +4326,21 @@
"1007",
"1008"
]
},
{
"game": "Teal Mask",
"icon": "SV2TM",
"region": "Paldea",
"bulbaUrl": "https://bulbapedia.bulbagarden.net/wiki/List_of_Pokémon_by_Paldea_Pokédex_number",
"bulbaQuery": "",
"pokemon": [
"1011",
"1012",
"1013",
"1014",
"1015",
"1016",
"1017"
]
}
]
56 changes: 56 additions & 0 deletions public/assets/json/pokemonByGame.json
Original file line number Diff line number Diff line change
Expand Up @@ -9140,6 +9140,62 @@
"col": 18,
"boxCol": 3,
"boxRow": 3
},
{
"id": "1011",
"name": "Dipplin",
"row": 31,
"col": 19,
"boxCol": 4,
"boxRow": 3
},
{
"id": "1012",
"name": "Poltchageist",
"row": 31,
"col": 20,
"boxCol": 5,
"boxRow": 3
},
{
"id": "1013",
"name": "Sinistcha",
"row": 31,
"col": 21,
"boxCol": 6,
"boxRow": 3
},
{
"id": "1014",
"name": "Okidogi",
"row": 31,
"col": 22,
"boxCol": 1,
"boxRow": 4
},
{
"id": "1015",
"name": "Munkidori",
"row": 31,
"col": 23,
"boxCol": 2,
"boxRow": 4
},
{
"id": "1016",
"name": "Fezandipiti",
"row": 31,
"col": 24,
"boxCol": 3,
"boxRow": 4
},
{
"id": "1017",
"name": "Ogerpon",
"row": 31,
"col": 25,
"boxCol": 4,
"boxRow": 4
}
]
}
Expand Down
45 changes: 37 additions & 8 deletions scripts/compileJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const capitalizeFirstLetter = (orig) => {
}

const getAllPokemon = async () => {
const pokemonJson = path.join(__dirname, '../public/assets/json/tempAllPokemon.json');
if (fs.existsSync(pokemonJson)) {
console.log('loading details per Pokemon from file');
const rawdata = fs.readFileSync(pokemonJson);
const data = JSON.parse(rawdata);
return data;
}

const pokemonApiAllUrl = 'https://pokeapi.co/api/v2/pokemon?limit=100000&offset=0';
const pokemonApiResult = await fetch(pokemonApiAllUrl);
const pokemonApiData = await pokemonApiResult.json();
Expand Down Expand Up @@ -41,12 +49,24 @@ const getAllPokemon = async () => {
} else {
pokemonLookup[pokeId] = [dataToAdd];
}
process.stdout.write(Object.keys(pokemonLookup).length + ` items fetched of approx. ${pokemonApiData.results.length}\r`);
}

console.log('');
fs.writeFileSync(pokemonJson, JSON.stringify(pokemonLookup, null, 2));

return pokemonLookup;
}

const getAllGameDetails = async () => {
const gameDetailsJson = path.join(__dirname, '../public/assets/json/tempGameDetails.json');
if (fs.existsSync(gameDetailsJson)) {
console.log('loading details per Generation from file');
const rawdata = fs.readFileSync(gameDetailsJson);
const data = JSON.parse(rawdata);
return data;
}

const pokemonApiAllUrl = 'https://pokeapi.co/api/v2/generation?limit=100000&offset=0';
const pokemonApiResult = await fetch(pokemonApiAllUrl);
const pokemonApiData = await pokemonApiResult.json();
Expand All @@ -69,7 +89,11 @@ const getAllGameDetails = async () => {
generations.push(dataToAdd);
}

process.stdout.write(generations.length + " generations fetched\r");
console.log('');

const orderedGenerations = generations.sort((a, b) => (a.genId > b.genId) ? 1 : -1);
fs.writeFileSync(gameDetailsJson, JSON.stringify(orderedGenerations, null, 2));
return orderedGenerations;
}

Expand Down Expand Up @@ -126,8 +150,6 @@ const joinPokemonDataIntoOneFile = async () => {
})
}

console.log('data combined');

await combinePokemonImagesIntoSingleSprite(combined, numCol);

const orderedCombined = combined.sort((a, b) => (a.id > b.id) ? 1 : -1);
Expand Down Expand Up @@ -155,7 +177,7 @@ const combinePokemonImagesIntoSingleSprite = async (combined, numCol) => {
const pokemonImgPath = path.join(__dirname, '../public/assets/img/pokemon');
const outputImg = path.join(pokemonImgPath, '0000.png');

console.log('Comment this out to generate new image');
console.log('skipping the generation of a new single sprite');
return;

if (fs.existsSync(outputImg)) {
Expand All @@ -166,15 +188,19 @@ const combinePokemonImagesIntoSingleSprite = async (combined, numCol) => {
const canvas = createCanvas(widthInPx, widthInPx);
const ctx = canvas.getContext('2d');

console.log('number of games', combined.length);
for (const combo of combined) {
console.log(`\t${combo.name}`, combo.pokemon.length);
for (const pokemonDetail of combo.pokemon) {
// const response = await fetch(pokemonDetail.image);
// const blob = await response.blob();
// const arrayBuffer = await blob.arrayBuffer();
// const buffer = Buffer.from(arrayBuffer);
// await fs.writeFileSync(tempImg, buffer);

console.log(pokemonDetail.id)
if (pokemonDetail.image == null) {
pokemonDetail.image = path.join(__dirname, '../public/assets/img/pokeball-loader.png');
}
// await fs.writeFileSync(tempImg.replace('temp', pokemonDetail.id), buffer);

const image = await loadImage(pokemonDetail.image);
Expand All @@ -188,10 +214,13 @@ const combinePokemonImagesIntoSingleSprite = async (combined, numCol) => {
}
}

const buffer = canvas.toBuffer('image/png');
fs.writeFileSync(outputImg, buffer);

console.log('spritemap created');
try {
const buffer = canvas.toBuffer('image/png');
fs.writeFileSync(outputImg, buffer);
console.log('spritemap created');
} catch (e) {
console.error('Unable to write single aprite', e);
}
}

joinPokemonDataIntoOneFile();
2 changes: 2 additions & 0 deletions src/scss/_pkmBox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@

.content {
.box-item {
display: flex;
position: relative;
justify-content: center;
border-radius: 10px;
opacity: 0.3;
filter: grayscale(100%);
Expand Down

0 comments on commit f74d26e

Please sign in to comment.