diff --git a/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/EncounterResponse.java b/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/EncounterResponse.java index 846e57a5..c6684940 100644 --- a/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/EncounterResponse.java +++ b/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/EncounterResponse.java @@ -7,7 +7,7 @@ @Schema(description = "인카운터 조회 요청에 대한 응답") public record EncounterResponse( - @Schema(description = "인카운터 ID") + @Schema(description = "인카운터 ID(jwt token)") Long encounterId, @Schema(description = "인카운터 카테고리") diff --git a/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/MatchingEncounterResponse.java b/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/MatchingEncounterResponse.java index cd8b7498..299428a3 100644 --- a/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/MatchingEncounterResponse.java +++ b/src/main/java/org/ezcode/codetest/application/game/dto/response/encounter/MatchingEncounterResponse.java @@ -11,7 +11,7 @@ public record MatchingEncounterResponse( @Schema(description = "인카운터 ID(jwt 토큰)") - String id, + String encounterId, @Schema(description = "인카운터 카테고리") EncounterCategory encounterCategory, @@ -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()) diff --git a/src/main/java/org/ezcode/codetest/common/security/util/JwtUtil.java b/src/main/java/org/ezcode/codetest/common/security/util/JwtUtil.java index 1856da9f..35890326 100644 --- a/src/main/java/org/ezcode/codetest/common/security/util/JwtUtil.java +++ b/src/main/java/org/ezcode/codetest/common/security/util/JwtUtil.java @@ -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(); diff --git a/src/main/java/org/ezcode/codetest/common/security/util/SecurityPath.java b/src/main/java/org/ezcode/codetest/common/security/util/SecurityPath.java index 46f27983..4698ee2b 100644 --- a/src/main/java/org/ezcode/codetest/common/security/util/SecurityPath.java +++ b/src/main/java/org/ezcode/codetest/common/security/util/SecurityPath.java @@ -24,6 +24,7 @@ public class SecurityPath { "/webjars/**", "/searching", "/css/**", //html 화면 구성 접근 - "/images/**" + "/images/**", + "/gaming" }; } diff --git a/src/main/java/org/ezcode/codetest/domain/game/model/character/CharacterRealStat.java b/src/main/java/org/ezcode/codetest/domain/game/model/character/CharacterRealStat.java index cd4ab322..7e0c4b41 100644 --- a/src/main/java/org/ezcode/codetest/domain/game/model/character/CharacterRealStat.java +++ b/src/main/java/org/ezcode/codetest/domain/game/model/character/CharacterRealStat.java @@ -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 equippedItems) { @@ -47,17 +47,17 @@ public void applyItemRealStat(List 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(); @@ -78,25 +78,30 @@ public void applyIncreaseRealStats(Map 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; @@ -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; } } diff --git a/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java b/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java index 7e5808bc..3304c83b 100644 --- a/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java +++ b/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java @@ -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); } diff --git a/src/main/java/org/ezcode/codetest/domain/game/strategy/encounter/encounterstrategyimpl/AmbushBanditsGood.java b/src/main/java/org/ezcode/codetest/domain/game/strategy/encounter/encounterstrategyimpl/AmbushBanditsGood.java index ddc681da..1173769e 100644 --- a/src/main/java/org/ezcode/codetest/domain/game/strategy/encounter/encounterstrategyimpl/AmbushBanditsGood.java +++ b/src/main/java/org/ezcode/codetest/domain/game/strategy/encounter/encounterstrategyimpl/AmbushBanditsGood.java @@ -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); } } diff --git a/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java b/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java index ae25abea..c49ad644 100644 --- a/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java +++ b/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java @@ -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; @@ -83,7 +82,7 @@ public ResponseEntity CharacterStatusOpen( } ) @ResponseMessage("정상적으로 캐릭터 보유 스킬이 조회되었습니다.") - @GetMapping("/skills/unequipped") + @GetMapping("/characters/skills/unequipped") public ResponseEntity> CharacterSkillsOpen( @AuthenticationPrincipal AuthUser authUser ) { @@ -98,7 +97,7 @@ public ResponseEntity> CharacterSkillsOpen( } ) @ResponseMessage("정상적으로 아이템 뽑기에 성공하였습니다.") - @PostMapping("/items/gambling") + @PostMapping("/characters/items/gamble") public ResponseEntity gamblingForItem( @AuthenticationPrincipal AuthUser authUser, @RequestBody @Valid ItemGamblingRequest request @@ -115,7 +114,7 @@ public ResponseEntity gamblingForItem( } ) @ResponseMessage("정상적으로 스킬 뽑기에 성공하였습니다.") - @PostMapping("/skills/gambling") + @PostMapping("/characters/skills/gamble") public ResponseEntity gamblingForSkill( @AuthenticationPrincipal AuthUser authUser ) { @@ -131,7 +130,7 @@ public ResponseEntity gamblingForSkill( } ) @ResponseMessage("정상적으로 인벤토리가 조회되었습니다.") - @GetMapping("/inventories") + @GetMapping("/characters/inventories") public ResponseEntity> inventoryOpen( @AuthenticationPrincipal AuthUser authUser ) { @@ -147,7 +146,7 @@ public ResponseEntity> inventoryOpen( } ) @ResponseMessage("정상적으로 아이템이 장착되었습니다.") - @PatchMapping("/items/equip") + @PatchMapping("/characters/items/equip") public ResponseEntity equipItem( @AuthenticationPrincipal AuthUser authUser, @RequestBody @Valid ItemEquipRequest request @@ -165,7 +164,7 @@ public ResponseEntity equipItem( } ) @ResponseMessage("정상적으로 스킬이 장착되었습니다.") - @PatchMapping("/skills/equip") + @PatchMapping("/characters/skills/equip") public ResponseEntity equipSkill( @AuthenticationPrincipal AuthUser authUser, @RequestBody @Valid SkillEquipRequest request @@ -183,7 +182,7 @@ public ResponseEntity equipSkill( } ) @ResponseMessage("정상적으로 스킬 장착이 해제되었습니다.") - @PatchMapping("/skills/unequip") + @PatchMapping("/characters/skills/unequip") public ResponseEntity unEquipSkill( @AuthenticationPrincipal AuthUser authUser, @RequestBody @Valid SkillUnEquipRequest request @@ -201,7 +200,7 @@ public ResponseEntity unEquipSkill( } ) @ResponseMessage("정상적으로 배틀이 완료되었습니다.") - @PostMapping("/battles") + @PostMapping("/characters/battles") public ResponseEntity battle( @AuthenticationPrincipal AuthUser authUser, @RequestBody @Valid BattleRequest request @@ -218,7 +217,7 @@ public ResponseEntity battle( } ) @ResponseMessage("정상적으로 배틀 매칭에 성공하였습니다.") - @GetMapping("/battles/matching") + @GetMapping("/characters/battles/matching") public ResponseEntity randomBattleMatching( @AuthenticationPrincipal AuthUser authUser ) { @@ -234,7 +233,7 @@ public ResponseEntity randomBattleMatching( } ) @ResponseMessage("정상적으로 인카운터 매칭에 성공하였습니다.") - @GetMapping("/encounters/matching") + @GetMapping("/characters/encounters/matching") public ResponseEntity randomEncounterMatching( @AuthenticationPrincipal AuthUser authUser ) { @@ -250,7 +249,7 @@ public ResponseEntity randomEncounterMatching( } ) @ResponseMessage("정상적으로 인카운터 선택지가 결정되었습니다.") - @PostMapping("/encounters/choice") + @PostMapping("/characters/encounters/choice") public ResponseEntity encounterChoice( @AuthenticationPrincipal AuthUser authUser, @RequestBody @Valid EncounterChoiceRequest request diff --git a/src/main/java/org/ezcode/codetest/presentation/game/play/TestGamePlayController.java b/src/main/java/org/ezcode/codetest/presentation/game/play/TestGamePlayController.java new file mode 100644 index 00000000..5bfe086f --- /dev/null +++ b/src/main/java/org/ezcode/codetest/presentation/game/play/TestGamePlayController.java @@ -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 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() + "레벨업"); + + return ResponseEntity.status(HttpStatus.OK).build(); + } +} diff --git a/src/main/java/org/ezcode/codetest/presentation/game/view/GameViewController.java b/src/main/java/org/ezcode/codetest/presentation/game/view/GameViewController.java new file mode 100644 index 00000000..0cc85fdd --- /dev/null +++ b/src/main/java/org/ezcode/codetest/presentation/game/view/GameViewController.java @@ -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"; + } +} diff --git a/src/main/resources/static/images/15328_green_noisy_nobg.gif b/src/main/resources/static/images/15328_green_noisy_nobg.gif new file mode 100644 index 00000000..61557e01 Binary files /dev/null and b/src/main/resources/static/images/15328_green_noisy_nobg.gif differ diff --git a/src/main/resources/static/images/vault_boy_transparent.gif b/src/main/resources/static/images/vault_boy_transparent.gif new file mode 100644 index 00000000..d8e713ea Binary files /dev/null and b/src/main/resources/static/images/vault_boy_transparent.gif differ diff --git a/src/main/resources/static/images/vaultboy_green_filtered.gif b/src/main/resources/static/images/vaultboy_green_filtered.gif new file mode 100644 index 00000000..ed0e5543 Binary files /dev/null and b/src/main/resources/static/images/vaultboy_green_filtered.gif differ diff --git a/src/main/resources/templates/game-page.html b/src/main/resources/templates/game-page.html new file mode 100644 index 00000000..f29e49cb --- /dev/null +++ b/src/main/resources/templates/game-page.html @@ -0,0 +1,1059 @@ + + + + + Vault Boy Walk + + + +
+ + +
+ +Vault Boy Walking + +
+ + + + + + +
+ + +
+ Vault Boy HUD +
+
+ Vault Boy HUD +
+
+ Vault Boy HUD +
+ + +
+ Vault Boy HUD +
+
+ Vault Boy HUD +
+
+ Vault Boy HUD +
+ + +
+ + + +