-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE-FEAT] 포켓몬의 기술 리스트 불러오는 API (#237)
* refactor: WeatherRepository 컴포넌트 애너테이션 변경 * feat: 기술 데이터 세팅 * refactor: 기술 id 저장 데이터 변경 * feat: 포켓몬의 기술 데이터 세팅 * feat: 포켓몬의 기술 리스트 불러오는 api * chore: 기술 데이터 추가 * feat: 기술 리스트에서 타입, 카테고리 로고 함께 반환 * fix: 빈 문자열 저장하는 오류 * refactor: 포켓몬 타입 enum 생성 * test: 모든 도감 번호에 대해서 기술 리스트 조회 테스트 * refactor: 포켓몬 타입 레포지토리 생성 * refactor: 기술 카테고리 enum 생성 * style: 개행 추가 * style: enum 개행 추가 * chore: 데이터 추가 히스토리 맞추기 * fix: 중복되는 bean 이름 변경
- Loading branch information
Showing
22 changed files
with
476 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
backend/pokerogue/src/main/java/com/pokerogue/helper/battle/BattleMove.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.pokerogue.helper.battle; | ||
|
||
public record BattleMove( | ||
String id, | ||
String name, | ||
String nameAppend, | ||
String effect, | ||
String type, | ||
String defaultTypeId, | ||
String category, | ||
String moveTarget, | ||
Integer power, | ||
Integer accuracy, | ||
Integer pp, | ||
Integer chance, | ||
Integer priority, | ||
Integer generation, | ||
String flags | ||
) { | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/pokerogue/src/main/java/com/pokerogue/helper/battle/BattleMoveRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.pokerogue.helper.battle; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class BattleMoveRepository { | ||
|
||
private final Map<String, BattleMove> moves = new HashMap<>(); | ||
|
||
public void save(BattleMove battleMove) { | ||
moves.put(battleMove.id(), battleMove); | ||
} | ||
|
||
public List<BattleMove> findAll() { | ||
return moves.values() | ||
.stream() | ||
.toList(); | ||
} | ||
|
||
public Optional<BattleMove> findById(String id) { | ||
return Optional.ofNullable(moves.get(id)); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/pokerogue/src/main/java/com/pokerogue/helper/battle/BattlePokemonTypeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.pokerogue.helper.battle; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class BattlePokemonTypeRepository { | ||
|
||
private final Map<String, PokemonType> pokemonTypes = new HashMap<>(); | ||
|
||
public void save(PokemonType pokemonType) { | ||
pokemonTypes.put(pokemonType.name(), pokemonType); | ||
} | ||
|
||
public List<PokemonType> findAll() { | ||
return pokemonTypes.values() | ||
.stream() | ||
.toList(); | ||
} | ||
|
||
public Optional<PokemonType> findByName(String name) { | ||
return Optional.ofNullable(pokemonTypes.get(name)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
backend/pokerogue/src/main/java/com/pokerogue/helper/battle/MoveCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.pokerogue.helper.battle; | ||
|
||
import com.pokerogue.helper.global.exception.ErrorMessage; | ||
import com.pokerogue.helper.global.exception.GlobalCustomException; | ||
import java.util.Arrays; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum MoveCategory { | ||
|
||
STATUS("status", "https://dl70s9ccojnge.cloudfront.net/pokerogue-helper/pokerogue/move-category/status.png"), | ||
SPECIAL("special", "https://dl70s9ccojnge.cloudfront.net/pokerogue-helper/pokerogue/move-category/special.png"), | ||
PHYSICAL("physical", "https://dl70s9ccojnge.cloudfront.net/pokerogue-helper/pokerogue/move-category/physical.png"), | ||
; | ||
|
||
private final String name; | ||
private final String image; | ||
|
||
MoveCategory(String name, String image) { | ||
this.name = name; | ||
this.image = image; | ||
} | ||
|
||
public static MoveCategory findByName(String name) { | ||
return Arrays.stream(values()) | ||
.filter(category -> category.hasSameName(name)) | ||
.findAny() | ||
.orElseThrow(() -> new GlobalCustomException(ErrorMessage.MOVE_CATEGORY_NOT_FOUND)); | ||
} | ||
|
||
private boolean hasSameName(String name) { | ||
return this.name.equals(name); | ||
} | ||
} |
Oops, something went wrong.