Skip to content

Commit

Permalink
[BE-FEAT] 바이옴 리스트를 불러오는 API (#231)
Browse files Browse the repository at this point in the history
* feat: 특성, 기술 머신, 날씨 정보 추출 기능

* feat: 바이옴 리스트 불러오는 API

* refactor: 절대 경로를 상대 경로로 수정

* refactor: txt파일을 파싱하는 로직 이동

* refactor: String으로 저장하던 것을 객체로 변환

* refactor: 필드 변수를 메서드 내부 변수로 이동

* refactor: 에러 처리 및 개행 추가

* test: 바이옴 데이터 세팅 테스트

* rename: 폴더명 수정

* refactor: try-with-resource문으로 예외처리

* chore: 바이옴 데이터 추가

* refactor: 파일 경로 수정
  • Loading branch information
unifolio0 authored Aug 16, 2024
1 parent ce9a128 commit f8c6802
Show file tree
Hide file tree
Showing 19 changed files with 1,065 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
// import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
//
// import { Abilities } from "#app/enums/abilities.js";
// import { ability } from "#app/locales/ko/ability"
// import { Moves } from "#app/enums/moves"
// import { Type } from "#app/data/type"
// import { allMoves } from "#app/data/move.js";
// import PokemonSpecies, { starterPassiveAbilities, initSpecies, allSpecies, PokemonSpeciesForm, PokemonForm } from "#app/data/pokemon-species.js";
// import * as fs from "fs";
// import * as path from 'path';
// import { speciesEggMoves } from "#app/data/egg-moves"
// import { Species } from "#app/enums/species.ts";
// import i18next, { init } from "i18next";
// import { pokemonSpeciesLevelMoves } from "#app/data/pokemon-level-moves.ts";
// import { biomePokemonPools, getBiomeName, initBiomes, pokemonBiomes } from "#app/data/biomes.ts";
// import { Biome } from "#app/enums/biome.ts";
// import { exit } from "process";
// import { Ability, allAbilities } from "#app/data/ability.ts";
// import GameManager from "#test/utils/gameManager";
// import { enConfig } from "#app/locales/en/config.js";
// import { koConfig } from "#app/locales/ko/config.js";
//
// const filePath = path.join(__dirname, 'ability.txt');
// const logStream = fs.createWriteStream(filePath, { flags: 'w' });
// console.log = (...args: any[]) => {
// const message = args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : arg).join(' ');
// logStream.write(message + '\n');
// };
//
// describe("Ability", () => {
// let phaserGame: Phaser.Game;
// let game: GameManager;
// const TIMEOUT = 1000 * 20;
//
// beforeAll(() => {
// });
//
// afterEach(() => {
// });
//
// beforeEach(() => {
// });
//
// // const print = (((x: PokemonForm, sp: PokemonSpecies, pokemonId: integer, passive: Abilities, eggMoves, moves, biomes) => {
// // var ret = []
// // // id
// // ret.push(pokemonId)
// // ret.push(x.speciesId)
// // //name
// // ret.push(sp.name +"-"+ x.formName)
// // // type
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type2]}`))
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type1]}`))
// // // ability (todo: passive)
// // ret.push(new Ability(x.ability1, x.generation).name)
// // ret.push(new Ability(x.ability2, x.generation).name)
// // ret.push(new Ability(x.abilityHidden, x.generation).name)
// // ret.push(new Ability(passive, x.generation).name)
// // // metadata
// // ret.push(x.generation)
// // ret.push(sp.legendary)
// // ret.push(sp.subLegendary)
// // ret.push(sp.mythical)
// // // evolution (speciesId, level)
// // ret.push(sp.getEvolutionLevels())
// // // stats (baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd)
// // ret.push(x.baseTotal)
// // ret.push(x.baseStats)
// // ret.push(x.height)
// // ret.push(x.weight)
// // // form
// // ret.push(sp.canChangeForm)
// // // eggMoves
// // var tmp = []
// // for(let i =0; i < eggMoves.length; i++){
// // tmp.push(eggMoves[i].name)
// // }
// // ret.push(tmp)
// // // moves
// // tmp = []
// // for(let i =0; i < moves.length; i++){
// // tmp.push(moves[i][1].name)
// // }
// // ret.push(tmp)
//
//
// // tmp = []
// // for(let i =0; i < biomes.length; i++){
// // tmp.push(getBiomeName(biomes[i]))
// // }
// // ret.push(tmp)
//
// // console.log(ret.join(" / "))
// // }));
//
//
//
// // const print2 = (((x: PokemonSpecies, pokemonId: integer, passive: Abilities, eggMoves, moves, biomes
// // ) => {
// // var ret = []
// // // id
// // ret.push(pokemonId)
// // ret.push(x.speciesId)
// // //name
// // ret.push(x.name)
// // // type
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type2]}`))
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type1]}`))
// // // ability (todo: passive)
// // ret.push(new Ability(x.ability1, x.generation).name)
// // ret.push(new Ability(x.ability2, x.generation).name)
// // ret.push(new Ability(x.abilityHidden, x.generation).name)
// // ret.push(new Ability(passive, x.generation).name)
// // // metadata
// // ret.push(x.generation)
// // ret.push(x.legendary)
// // ret.push(x.subLegendary)
// // ret.push(x.mythical)
// // // evolution (speciesId, level)
// // ret.push(x.getEvolutionLevels())
// // // stats (baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd)
// // ret.push(x.baseTotal)
// // ret.push(x.baseStats)
// // ret.push(x.height)
// // ret.push(x.weight)
// // // form
// // ret.push(x.canChangeForm)
// // // eggMoves
// // var tmp = []
// // for(let i =0; i < eggMoves.length; i++){
// // tmp.push(eggMoves[i].name)
// // }
// // ret.push(tmp)
// // // moves
// // tmp = []
// // for(let i =0; i < moves.length; i++){
// // tmp.push(moves[i][1].name)
// // }
// // ret.push(tmp)
//
//
// // tmp = []
// // for(let i =0; i < biomes.length; i++){
// // tmp.push(getBiomeName(biomes[i]))
// // }
// // ret.push(tmp)
//
// // console.log(ret.join(" / "))
// // }));
//
// it("특성 정보 추출 테스트", async () => {
// console.log("이름 / 효과 설명 / 세대 / 해당 특성을 가진 포켓몬")
// console.log()
//
// let p = allAbilities;
// var abilityId: integer = 1
// let q = allSpecies
//
// for (let i = 0; i < allAbilities.length; i++) {
// var ret = []
// let x = allAbilities[i]
// if (x.id === Abilities.NONE) {
// continue
// }
// var name = x.name
// ret.push(name)
// var description = x.description
// ret.push(description)
// var generation = x.generation
// ret.push(generation)
// var abret = []
// for (let i = 0; i < allSpecies.length; i++) {
// let y = allSpecies[i]
// var passive = starterPassiveAbilities[y.getRootSpeciesId()]
// if (y.ability1 === x.id || y.ability2 === x.id || y.abilityHidden === x.id || passive === x.id) {
// abret.push(y.name)
// }
// if (y.canChangeForm) {
// for (var form of y.forms) {
// if (form.ability1 === x.id || form.ability2 === x.id || form.abilityHidden === x.id) {
// if (form.formName === "Normal") {
// continue
// }
// abret.push(y.name + "-" + form.formName)
// }
// }
// }
// }
// ret.push(abret.join(" , "))
// console.log(ret.join(" / "))
// }
// });
// });
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
// import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
//
// import { Moves } from "#app/enums/moves"
// import { allMoves } from "#app/data/move.js";
// import PokemonSpecies, { starterPassiveAbilities, initSpecies, allSpecies, PokemonSpeciesForm, PokemonForm } from "#app/data/pokemon-species.js";
// import * as fs from "fs";
// import * as path from 'path';
// import { Species } from "#app/enums/species.js";
// import i18next, { init } from "i18next";
// import { exit } from "process";
// import { tmSpecies } from "#app/data/tms.js";
//
// const filePath = path.join(__dirname, 'tms.txt');
// const logStream = fs.createWriteStream(filePath, { flags: 'w' });
// console.log = (...args: any[]) => {
// const message = args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : arg).join(' ');
// logStream.write(message + '\n');
// };
//
// describe("Pokemon", () => {
// beforeAll(() => {
// });
//
// afterEach(() => {
// });
//
// beforeEach(() => {
// });
//
// // const print = (((x: PokemonForm, sp: PokemonSpecies, pokemonId: integer, passive: Abilities, eggMoves, moves, biomes) => {
// // var ret = []
// // // id
// // ret.push(pokemonId)
// // ret.push(x.speciesId)
// // //name
// // ret.push(sp.name +"-"+ x.formName)
// // // type
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type2]}`))
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type1]}`))
// // // ability (todo: passive)
// // ret.push(new Ability(x.ability1, x.generation).name)
// // ret.push(new Ability(x.ability2, x.generation).name)
// // ret.push(new Ability(x.abilityHidden, x.generation).name)
// // ret.push(new Ability(passive, x.generation).name)
// // // metadata
// // ret.push(x.generation)
// // ret.push(sp.legendary)
// // ret.push(sp.subLegendary)
// // ret.push(sp.mythical)
// // // evolution (speciesId, level)
// // ret.push(sp.getEvolutionLevels())
// // // stats (baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd)
// // ret.push(x.baseTotal)
// // ret.push(x.baseStats)
// // ret.push(x.height)
// // ret.push(x.weight)
// // // form
// // ret.push(sp.canChangeForm)
// // // eggMoves
// // var tmp = []
// // for(let i =0; i < eggMoves.length; i++){
// // tmp.push(eggMoves[i].name)
// // }
// // ret.push(tmp)
// // // moves
// // tmp = []
// // for(let i =0; i < moves.length; i++){
// // tmp.push(moves[i][1].name)
// // }
// // ret.push(tmp)
//
//
// // tmp = []
// // for(let i =0; i < biomes.length; i++){
// // tmp.push(getBiomeName(biomes[i]))
// // }
// // ret.push(tmp)
//
// // console.log(ret.join(" / "))
// // }));
//
//
//
// // const print2 = (((x: PokemonSpecies, pokemonId: integer, passive: Abilities, eggMoves, moves, biomes
// // ) => {
//
// // var ret = []
// // // id
// // ret.push(pokemonId)
// // ret.push(x.speciesId)
// // //name
// // ret.push(x.name)
// // // type
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type2]}`))
// // ret.push(i18next.t(`pokemonInfo:Type.${Type[x.type1]}`))
// // // ability (todo: passive)
// // ret.push(new Ability(x.ability1, x.generation).name)
// // ret.push(new Ability(x.ability2, x.generation).name)
// // ret.push(new Ability(x.abilityHidden, x.generation).name)
// // ret.push(new Ability(passive, x.generation).name)
// // // metadata
// // ret.push(x.generation)
// // ret.push(x.legendary)
// // ret.push(x.subLegendary)
// // ret.push(x.mythical)
// // // evolution (speciesId, level)
// // ret.push(x.getEvolutionLevels())
// // // stats (baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd)
// // ret.push(x.baseTotal)
// // ret.push(x.baseStats)
// // ret.push(x.height)
// // ret.push(x.weight)
// // // form
// // ret.push(x.canChangeForm)
// // // eggMoves
// // var tmp = []
// // for(let i =0; i < eggMoves.length; i++){
// // tmp.push(eggMoves[i].name)
// // }
// // ret.push(tmp)
// // // moves
// // tmp = []
// // for(let i =0; i < moves.length; i++){
// // tmp.push(moves[i][1].name)
// // }
// // ret.push(tmp)
//
//
// // tmp = []
// // for(let i =0; i < biomes.length; i++){
// // tmp.push(getBiomeName(biomes[i]))
// // }
// // ret.push(tmp)
//
// // console.log(ret.join(" / "))
// // }));
//
// function getEnumValues<T>(enumObj: T): T[keyof T][] {
// return Object.values(enumObj).filter(value => typeof value === 'number') as T[keyof T][];
// }
// function toCamelCase(str: string): string {
// return str
// .toLowerCase()
// .replace(/_./g, match => match.charAt(1).toUpperCase());
// }
//
// it("포켓몬이 배울 수 있는 기술 정보 추출 테스트", async () => {
//
// let p = allSpecies;
// var pokemonId: integer = 1
//
// // initBiomes();
// // const biomeMap = new Map<Species, Biome[]>();
// // for (let i = 0; i < pokemonBiomes.length; i++) {
// // var species = Species[pokemonBiomes[i][0]]
// // var biomeEntries = pokemonBiomes[i][3]
// // biomeMap.set(species, biomeEntries
// // .map((a, b, c) => a[0])
// // .filter((value, index, self) => self.indexOf(value) === index))
// // }
// const moves: Moves[] = getEnumValues(Moves);
// const species: Species[] = getEnumValues(Species);
// console.log("이름 / 배울 수 있는 기술 목록")
// console.log()
// for (let i = 0; i < allSpecies.length; i++) {
// var x = allSpecies[i]
// var ret = []
// ret.push(x.name)
// var ts = []
// for (let j = 0; j < allMoves.length; j++) {
// var y = tmSpecies[allMoves[j].id]
// if (Array.isArray(y)) {
// for (let k = 0; k < y.length; k++) {
// var speciesEntry = y[k];
//
// // speciesEntry가 배열인지 확인하고 처리
// if (Array.isArray(speciesEntry)) {
// // 배열의 첫 번째 항목이 x.speciesId와 일치하는지 확인
// if (speciesEntry[0] === x.speciesId) {
// ts.push(allMoves[j].name);
// }
// } else {
// // speciesEntry가 단일 Species인지 확인
// if (speciesEntry === x.speciesId) {
// ts.push(allMoves[j].name);
// }
// }
// }
// }
// }
// ret.push(ts.join(" , "))
// console.log(ret.join(" / "))
// }
// });
// });
Loading

0 comments on commit f8c6802

Please sign in to comment.