Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@Schema(description = "인카운터 조회 요청에 대한 응답")
public record EncounterResponse(

@Schema(description = "인카운터 ID")
@Schema(description = "인카운터 ID(jwt token)")
Long encounterId,

@Schema(description = "인카운터 카테고리")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public record MatchingEncounterResponse(

@Schema(description = "인카운터 ID(jwt 토큰)")
String id,
String encounterId,

@Schema(description = "인카운터 카테고리")
EncounterCategory encounterCategory,
Expand All @@ -33,7 +33,7 @@ public static MatchingEncounterResponse from(RandomEncounter encounter, String e

return MatchingEncounterResponse.builder()
.encounterCategory(encounter.getEncounterCategory())
.id(encounterIdToken)
.encounterId(encounterIdToken)
.name(encounter.getName())
.encounterText(encounter.getEncounterText())
.choice1Text(encounter.getChoice1Text())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public String createGameToken(Long eventId) {

return Jwts.builder()
.setSubject(String.valueOf(eventId))
.setExpiration(new Date(date.getTime() + GAME_TOKEN_EXPIRATION_TIME * 1000L))
.setExpiration(new Date(date.getTime() + GAME_TOKEN_EXPIRATION_TIME * 2000L))
.setIssuedAt(date)
.signWith(key, signatureAlgorithm)
.compact();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class SecurityPath {
"/webjars/**",
"/searching",
"/css/**", //html 화면 구성 접근
"/images/**"
"/images/**",
"/gaming"
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public class CharacterRealStat {
private int ap = 3;

public CharacterRealStat(CharacterRealStat source) {
this.atk = source.atk;
this.def = source.def;
this.speed = source.speed;
this.crit = source.crit;
this.stun = source.stun;
this.evasion = source.evasion;
this.atk = source.atk;
this.def = source.def;
this.speed = source.speed;
this.crit = source.crit;
this.stun = source.stun;
this.evasion = source.evasion;
this.accuracy = source.accuracy;
this.hp = source.hp;
this.ap = source.ap;
this.hp = source.hp;
this.ap = source.ap;
}

public void applyItemRealStat(List<Item> equippedItems) {
Expand All @@ -47,17 +47,17 @@ public void applyItemRealStat(List<Item> equippedItems) {
}

equippedItems.forEach(item -> {
if(item instanceof Weapon weapon) {
if (item instanceof Weapon weapon) {
this.atk += weapon.getAtk();
this.speed += weapon.getSpeed();
this.crit += weapon.getCrit();
this.stun += weapon.getStun();
this.accuracy += weapon.getAccuracy();
} else if(item instanceof Defence defence) {
} else if (item instanceof Defence defence) {
this.def += defence.getDef();
this.speed += defence.getSpeed();
this.evasion += defence.getEvasion();
} else if(item instanceof Accessory accessory) {
} else if (item instanceof Accessory accessory) {
this.speed += accessory.getSpeed();
this.crit += accessory.getCrit();
this.stun += accessory.getStun();
Expand All @@ -78,25 +78,30 @@ public void applyIncreaseRealStats(Map<Stat, Double> increaseRates) {
}

public void increase(Stat stat, double rate) {
switch(stat) {
switch (stat) {
case PROBLEM_SOLVING:
this.atk += 2.0 + rate;
this.atk += rate / 10;
this.accuracy += rate / 10;
break;
case DATA_STRUCTURE:
this.def += 1.0 + rate;
this.atk += 0.5 + rate;
this.def += rate / 10;
this.atk += rate / 10;
this.accuracy += rate / 10;
break;
case SPEED:
this.speed += 1.0 + rate;
this.atk += rate;
this.speed += rate / 10;
this.atk += rate / 10;
this.accuracy += rate / 10;
break;
case DEBUGGING:
this.crit += rate;
this.stun += rate;
this.crit += rate / 5;
this.def += rate / 10;
this.stun += rate / 10;
break;
case OPTIMIZATION:
this.evasion += 1.0 + rate;
this.accuracy += 1.0 + rate;
this.evasion += rate / 5;
this.def += rate / 10;
this.accuracy += rate / 10;
break;
default:
break;
Expand All @@ -106,43 +111,50 @@ public void increase(Stat stat, double rate) {
public void applyAtkChange(double atk) {

this.atk += atk;
if(this.atk < 0.0) this.atk = 0.0;
if (this.atk < 0.0)
this.atk = 0.0;
}

public void applyDefChange(double def) {

this.def += def;
if(this.def < 0.0) this.def = 0.0;
if (this.def < 0.0)
this.def = 0.0;
}

public void applySpeedChange(double speed) {

this.speed += speed;
if(this.speed < 0.0) this.speed = 0.0;
if (this.speed < 0.0)
this.speed = 0.0;
}

public void applyCritChange(double crit) {

this.crit += crit;
if(this.crit < 0.0) this.crit = 0.0;
if (this.crit < 0.0)
this.crit = 0.0;
}

public void applyEvasionChange(double evasion) {

this.evasion += evasion;
if(this.evasion < 0.0) this.evasion = 0.0;
if (this.evasion < 0.0)
this.evasion = 0.0;
}

public void applyAccuracyChange(double accuracy) {

this.accuracy += accuracy;
if(this.accuracy < 0.0) this.accuracy = 0.0;
if (this.accuracy < 0.0)
this.accuracy = 0.0;
}

public void applyStunChange(double stun) {

this.stun += stun;
if(this.stun < 0.0) this.stun = 0.0;
if (this.stun < 0.0)
this.stun = 0.0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void gameCharacterLevelUp(Long userId, boolean isProblemSolved, String pr
GameCharacter character = characterRepository.findByUserId(userId)
.orElseThrow(() -> new GameException(GameExceptionCode.CHARACTER_NOT_FOUND));

character.earnGold(500L);
character.earnGold(300L);

character.applyIncreaseStats(increaseStatRate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public void eventHappen(
} else {
long lost = character.getGold() / 2;
character.loseGold(lost);
realStat.applyDefChange(-1.0);
realStat.applyDefChange(-0.2);
log.add("그러나 결심과는 무색하게 %s(은)는 첫 지팡이에 명치가 눌리고, 두 번째 롤링 핀에 시야가 돌아갑니다.", playerContext.getName());
log.add("누군가는 ‘치료용 허브차’를 권했지만, 사실 그건 다시 맞으라는 신호였습니다.");
log.add("정신을 차려보니 골드 %d이 사라지고, 무릎엔 ‘할머니파이맛’이라는 딱지가 붙어 있습니다.", lost);
log.add("%s(은)는 이번 싸움이 육체보다 자존심에 더 큰 데미지를 줬음을 느끼며, 방어력이 1 감소했습니다. (방어력 -1)", playerContext.getName());
log.add("%s(은)는 이번 싸움이 육체보다 자존심에 더 큰 데미지를 줬음을 느끼며, 방어력이 0.2 감소했습니다. (방어력 -0.2)", playerContext.getName());
log.setIsPositive(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -83,7 +82,7 @@ public ResponseEntity<CharacterStatusResponse> CharacterStatusOpen(
}
)
@ResponseMessage("정상적으로 캐릭터 보유 스킬이 조회되었습니다.")
@GetMapping("/skills/unequipped")
@GetMapping("/characters/skills/unequipped")
public ResponseEntity<List<SkillResponse>> CharacterSkillsOpen(
@AuthenticationPrincipal AuthUser authUser
) {
Expand All @@ -98,7 +97,7 @@ public ResponseEntity<List<SkillResponse>> CharacterSkillsOpen(
}
)
@ResponseMessage("정상적으로 아이템 뽑기에 성공하였습니다.")
@PostMapping("/items/gambling")
@PostMapping("/characters/items/gamble")
public ResponseEntity<ItemGamblingResponse> gamblingForItem(
@AuthenticationPrincipal AuthUser authUser,
@RequestBody @Valid ItemGamblingRequest request
Expand All @@ -115,7 +114,7 @@ public ResponseEntity<ItemGamblingResponse> gamblingForItem(
}
)
@ResponseMessage("정상적으로 스킬 뽑기에 성공하였습니다.")
@PostMapping("/skills/gambling")
@PostMapping("/characters/skills/gamble")
public ResponseEntity<SkillGamblingResponse> gamblingForSkill(
@AuthenticationPrincipal AuthUser authUser
) {
Expand All @@ -131,7 +130,7 @@ public ResponseEntity<SkillGamblingResponse> gamblingForSkill(
}
)
@ResponseMessage("정상적으로 인벤토리가 조회되었습니다.")
@GetMapping("/inventories")
@GetMapping("/characters/inventories")
public ResponseEntity<List<ItemResponse>> inventoryOpen(
@AuthenticationPrincipal AuthUser authUser
) {
Expand All @@ -147,7 +146,7 @@ public ResponseEntity<List<ItemResponse>> inventoryOpen(
}
)
@ResponseMessage("정상적으로 아이템이 장착되었습니다.")
@PatchMapping("/items/equip")
@PatchMapping("/characters/items/equip")
public ResponseEntity<Void> equipItem(
@AuthenticationPrincipal AuthUser authUser,
@RequestBody @Valid ItemEquipRequest request
Expand All @@ -165,7 +164,7 @@ public ResponseEntity<Void> equipItem(
}
)
@ResponseMessage("정상적으로 스킬이 장착되었습니다.")
@PatchMapping("/skills/equip")
@PatchMapping("/characters/skills/equip")
public ResponseEntity<Void> equipSkill(
@AuthenticationPrincipal AuthUser authUser,
@RequestBody @Valid SkillEquipRequest request
Expand All @@ -183,7 +182,7 @@ public ResponseEntity<Void> equipSkill(
}
)
@ResponseMessage("정상적으로 스킬 장착이 해제되었습니다.")
@PatchMapping("/skills/unequip")
@PatchMapping("/characters/skills/unequip")
public ResponseEntity<Void> unEquipSkill(
@AuthenticationPrincipal AuthUser authUser,
@RequestBody @Valid SkillUnEquipRequest request
Expand All @@ -201,7 +200,7 @@ public ResponseEntity<Void> unEquipSkill(
}
)
@ResponseMessage("정상적으로 배틀이 완료되었습니다.")
@PostMapping("/battles")
@PostMapping("/characters/battles")
public ResponseEntity<BattleHistoryResponse> battle(
@AuthenticationPrincipal AuthUser authUser,
@RequestBody @Valid BattleRequest request
Expand All @@ -218,7 +217,7 @@ public ResponseEntity<BattleHistoryResponse> battle(
}
)
@ResponseMessage("정상적으로 배틀 매칭에 성공하였습니다.")
@GetMapping("/battles/matching")
@GetMapping("/characters/battles/matching")
public ResponseEntity<MatchingBattleResponse> randomBattleMatching(
@AuthenticationPrincipal AuthUser authUser
) {
Expand All @@ -234,7 +233,7 @@ public ResponseEntity<MatchingBattleResponse> randomBattleMatching(
}
)
@ResponseMessage("정상적으로 인카운터 매칭에 성공하였습니다.")
@GetMapping("/encounters/matching")
@GetMapping("/characters/encounters/matching")
public ResponseEntity<MatchingEncounterResponse> randomEncounterMatching(
@AuthenticationPrincipal AuthUser authUser
) {
Expand All @@ -250,7 +249,7 @@ public ResponseEntity<MatchingEncounterResponse> randomEncounterMatching(
}
)
@ResponseMessage("정상적으로 인카운터 선택지가 결정되었습니다.")
@PostMapping("/encounters/choice")
@PostMapping("/characters/encounters/choice")
public ResponseEntity<EncounterResultResponse> encounterChoice(
@AuthenticationPrincipal AuthUser authUser,
@RequestBody @Valid EncounterChoiceRequest request
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.ezcode.codetest.presentation.game.play;

import org.ezcode.codetest.domain.game.service.CharacterStatusDomainService;
import org.ezcode.codetest.domain.problem.model.enums.Category;
import org.ezcode.codetest.domain.user.model.entity.AuthUser;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/games/levels")
public class TestGamePlayController {

private final CharacterStatusDomainService statusDomainService;

@GetMapping("/characters")
@Transactional
public ResponseEntity<Void> CharacterLevelUpTest(
@AuthenticationPrincipal AuthUser authUser
) {

Category randomCat = Category.values()[java.util.concurrent.ThreadLocalRandom.current().nextInt(Category.values().length)];

statusDomainService.gameCharacterLevelUp(authUser.getId(), true, randomCat.getDescription());

System.out.println(randomCat.getDescription() + "레벨업");
Copy link

@coderabbitai coderabbitai bot Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

System.out.println을 적절한 로깅으로 대체하세요.

테스트 환경이더라도 System.out.println 대신 로깅 프레임워크를 사용하는 것이 좋습니다.

+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/api/games/levels")
 public class TestGamePlayController {
 
-		System.out.println(randomCat.getDescription() + "레벨업");
+		log.info("테스트 레벨업 실행: {} 카테고리", randomCat.getDescription());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
System.out.println(randomCat.getDescription() + "레벨업");
import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/games/levels")
public class TestGamePlayController {
// … other fields and methods …
// 기존 System.out.println을 로깅으로 대체
log.info("테스트 레벨업 실행: {} 카테고리", randomCat.getDescription());
// … 나머지 코드 …
}
🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/presentation/game/play/TestGamePlayController.java
at line 33, replace the System.out.println statement with a proper logging call
using the project's logging framework. Initialize a logger instance for the
class if not already present, and use it to log the message instead of printing
directly to the console.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 곧지울거임

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chat26666 네, 이해했습니다! 테스트 코드라서 곧 삭제될 예정이라면 굳이 로깅으로 리팩토링할 필요가 없겠네요. 👍


return ResponseEntity.status(HttpStatus.OK).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.ezcode.codetest.presentation.game.view;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Controller
public class GameViewController {

@GetMapping("/gaming")
public String getChattingPage() {

return "game-page";
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading