diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..87eca4e8 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,41 @@ +# 기능 요구사항 정리 +1. 보스 몬스터 +- hp + - 초기 : 100 이상 300 이하 + +2. 플레이어 +- 이름 + - 5자 이하 +- hp & mp + - hp + mp = 200 + +3. 게임 +- 종료 조건 + - 보스 몬스터 hp == 0 + - 플레이어 hp == 0 +- 결과 + - 보스 몬스터 죽으면 + - 몇 턴 만에 잡았는지 출력 + - 플레이어 죽으면 + - 실패 메시지 출력 +- 예외 처리 + - 잘못된 값 입력 + - IllegalArgumentException 발생 + - [ERROR]로 시작하는 에러 메시지 출력 + - 그 부분부터 다시 입력받음 + +4. 공격 +- 플레이어 -> 보스 몬스터 + - 물리 공격 + - 보스 몬스터 hp : 10 감소 + - 플레이어 mp : 10 회복 + - 최대치 이상의 mp 회복 불가 + - 마법 공격 + - 보스 몬스터 hp : 20 감소 + - 플레이어 mp : 30 감소 +- 보스 몬스터 -> 플레이어 + - 매 턴마다 공격 + - 0~20의 랜덤 데미지 +- 규칙 + - 플레이어가 먼저 시작 + - 공격시 보스 몬스터가 죽으면, 플레이어에게 피해 X diff --git a/src/main/java/bossmonster/Main.java b/src/main/java/bossmonster/Main.java index d9488c65..d0230f96 100644 --- a/src/main/java/bossmonster/Main.java +++ b/src/main/java/bossmonster/Main.java @@ -1,7 +1,10 @@ package bossmonster; +import bossmonster.controller.GameController; + public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); + GameController gameController = new GameController(); + gameController.run(); } } diff --git a/src/main/java/bossmonster/controller/BossMonsterController.java b/src/main/java/bossmonster/controller/BossMonsterController.java new file mode 100644 index 00000000..5799591c --- /dev/null +++ b/src/main/java/bossmonster/controller/BossMonsterController.java @@ -0,0 +1,17 @@ +package bossmonster.controller; + +import bossmonster.domain.BossMonster; + +public class BossMonsterController { + + public BossMonster hit(BossMonster bossMonster, int damage){ + if(bossMonster.getHp() <= damage){ + return new BossMonster(0, bossMonster.getInitHp()); + } + return new BossMonster(bossMonster.getHp()-damage, bossMonster.getInitHp()); + } + + public boolean die(BossMonster bossMonster){ + return bossMonster.getHp() == 0; + } +} diff --git a/src/main/java/bossmonster/controller/GameController.java b/src/main/java/bossmonster/controller/GameController.java new file mode 100644 index 00000000..3b92e15d --- /dev/null +++ b/src/main/java/bossmonster/controller/GameController.java @@ -0,0 +1,122 @@ +package bossmonster.controller; + +import bossmonster.domain.BossMonster; +import bossmonster.domain.Game; +import bossmonster.domain.Player; +import bossmonster.view.InputView; +import bossmonster.view.OutputView; + +public class GameController { + + private final InputView inputView = new InputView(); + private final OutputView outputView = new OutputView(); + private final BossMonsterController bossMonsterController = new BossMonsterController(); + private final PlayerController playerController = new PlayerController(); + + public void run() { + final Game game = initGame(); + outputView.printInit(game); + operate(game); + } + + private Game initGame() { + final BossMonster bossMonster = initBossMonsterHp(); + final Player player = initPlayer(); + return new Game(bossMonster, player); + } + + private BossMonster initBossMonsterHp() { + while(true){ + try{ + final int bossMonsterHp = inputView.readBossMonsterHp(); + return new BossMonster(bossMonsterHp); + }catch(IllegalArgumentException e){ + System.out.println(e.getMessage()); + } + } + } + + private Player initPlayer() { + final String name = initPlayerName(); + final int[] playerInfo = initPlayerInfo(); + return new Player(name, playerInfo[0], playerInfo[1]); + } + + private String initPlayerName() { + while(true){ + try{ + return inputView.readPlayerName(); + }catch(IllegalArgumentException e){ + System.out.println(e.getMessage()); + } + } + } + + private int[] initPlayerInfo() { + while(true){ + try{ + return inputView.readPlayerInfo(); + }catch(IllegalArgumentException e){ + System.out.println(e.getMessage()); + } + } + } + + private int inputAttackType(){ + while(true){ + try{ + return inputView.inputAttack(); + }catch(IllegalArgumentException e){ + System.out.println(e.getMessage()); + } + } + } + + private void operate(Game game){ + while(true){ + int type = inputAttackType(); + game = controlAttack(game, type); + + game.addNumberOfTimes(); + + boolean bossDie= bossMonsterController.die(game.getBossMonster()); + boolean playerDie = playerController.die(game.getPlayer()); + + boolean continueGame = outputView.controlPrintResult(game, bossDie, playerDie); + if(!continueGame){ + break; + } + } + } + + private Game controlAttack(Game game, int type){ + if(type==1){ + return startPhysicalAttack(game); + } + return startMagicAttack(game); + } + + private Game startPhysicalAttack(Game game){ + BossMonster newBossMonster = bossMonsterController.hit(game.getBossMonster(), 10); + Player player = playerController.recover(game.getPlayer()); + int random = getRandomNumber(); + Player newPlayer = playerController.hit(player, random); + game = new Game(newBossMonster, newPlayer); + outputView.printPhysicalAttack(random, bossMonsterController.die(game.getBossMonster())); + return game; + } + + private Game startMagicAttack(Game game) { + BossMonster newBossMonster = bossMonsterController.hit(game.getBossMonster(), 20); + Player newPlayer = playerController.consumeMp(game.getPlayer()); + int random = getRandomNumber(); + newPlayer = playerController.hit(newPlayer, 30 + random); + game = new Game(newBossMonster, newPlayer); + outputView.printMagicAttack(random, bossMonsterController.die(game.getBossMonster())); + return game; + } + + private int getRandomNumber(){ + return (int)(Math.random()*20); + } +} diff --git a/src/main/java/bossmonster/controller/PlayerController.java b/src/main/java/bossmonster/controller/PlayerController.java new file mode 100644 index 00000000..985fa13c --- /dev/null +++ b/src/main/java/bossmonster/controller/PlayerController.java @@ -0,0 +1,31 @@ +package bossmonster.controller; + +import bossmonster.domain.Player; + +public class PlayerController { + + private static final int MP_PLUS = 10; + + public Player hit(Player player, int damage){ + if(player.getHp() <= damage){ + return new Player(0, player.getMp(), player); + } + return new Player(player.getHp()-damage, player.getMp(), player); + } + + public Player consumeMp(Player player){ + return new Player(player.getHp(), player.getMp() - 30, player); + } + + public Player recover(Player player){ + int mp = player.getMp() + MP_PLUS; + if(mp > player.getInitMp()){ + mp = player.getInitMp(); + } + return new Player(player.getHp(), mp, player); + } + + public boolean die(Player player){ + return player.getHp() == 0; + } +} diff --git a/src/main/java/bossmonster/domain/BossMonster.java b/src/main/java/bossmonster/domain/BossMonster.java new file mode 100644 index 00000000..36a602df --- /dev/null +++ b/src/main/java/bossmonster/domain/BossMonster.java @@ -0,0 +1,25 @@ +package bossmonster.domain; + +public class BossMonster { + + private final int hp; + private final int initHp; + + public BossMonster(int hp){ + this.hp = hp; + this.initHp = hp; + } + + public BossMonster(int hp, int initHp){ + this.hp = hp; + this.initHp = initHp; + } + + public int getHp(){ + return this.hp; + } + + public int getInitHp(){ + return this.initHp; + } +} diff --git a/src/main/java/bossmonster/domain/Game.java b/src/main/java/bossmonster/domain/Game.java new file mode 100644 index 00000000..9ad231c4 --- /dev/null +++ b/src/main/java/bossmonster/domain/Game.java @@ -0,0 +1,29 @@ +package bossmonster.domain; + +public class Game { + + private final BossMonster bossMonster; + private final Player player; + private static int numberOfTimes = 0; + + public Game(final BossMonster bossMonster, final Player player){ + this.bossMonster = bossMonster; + this.player = player; + } + + public BossMonster getBossMonster(){ + return bossMonster; + } + + public Player getPlayer(){ + return player; + } + + public void addNumberOfTimes(){ + numberOfTimes++; + } + + public int getNumberOfTimes(){ + return numberOfTimes; + } +} diff --git a/src/main/java/bossmonster/domain/Player.java b/src/main/java/bossmonster/domain/Player.java new file mode 100644 index 00000000..86ae7823 --- /dev/null +++ b/src/main/java/bossmonster/domain/Player.java @@ -0,0 +1,46 @@ +package bossmonster.domain; + +public class Player { + + private final String name; + private final int hp; + private final int mp; + private final int initHp; + private final int initMp; + + public Player(String name, int hp, int mp){ + this.name = name; + this.hp = hp; + this.mp = mp; + this.initHp = hp; + this.initMp = mp; + } + + public Player(int hp, int mp, Player player){ + this.name = player.getName(); + this.hp = hp; + this.mp = mp; + this.initHp = player.getInitHp(); + this.initMp = player.getInitMp(); + } + + public String getName(){ + return this.name; + } + + public int getHp(){ + return this.hp; + } + + public int getMp(){ + return this.mp; + } + + public int getInitHp(){ + return this.initHp; + } + + public int getInitMp(){ + return this.initMp; + } +} diff --git a/src/main/java/bossmonster/view/InputView.java b/src/main/java/bossmonster/view/InputView.java new file mode 100644 index 00000000..6c6d8ccc --- /dev/null +++ b/src/main/java/bossmonster/view/InputView.java @@ -0,0 +1,80 @@ +package bossmonster.view; + +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; + +public class InputView { + + private static final Scanner scanner = new Scanner(System.in); + private static final String BOSS_HP_REQUEST_MESSAGE = "보스 몬스터의 HP를 입력해주세요."; + private static final String READ_BOSS_HP_RANGE_EXCEPTION_FORMAT = "[ERROR] Boss Monster의 HP 범위가 맞지 않습니다."; + private static final String PLAYER_NAME_REQUEST_MESSAGE = "\n플레이어의 이름을 입력해주세요"; + private static final String READ_PLAYER_NAME_EXCEPTION_MESSAGE = "[ERROR] Player의 이름 길이가 잘못되었습니다."; + private static final String PLAYER_INFO_REQUEST_MESSAGE = "\n플레이어의 HP와 MP를 입력해주세요.(,로 구분)"; + private static final String READ_PLAYER_INFO_EXCEPTION_MESSAGE = "플레이어의 HP와 MP의 정보 입력이 올바르지 않습니다."; + private static final String ATTACK_REQUEST_MESSAGE = "어떤 공격을 하시겠습니까?\n" + + "1. 물리 공격\n" + + "2. 마법 공격"; + + public int readBossMonsterHp() { + System.out.println(BOSS_HP_REQUEST_MESSAGE); + final int bossMonsterHp = scanner.nextInt(); + scanner.nextLine(); //줄바꿈 문자 제거 + if(bossMonsterHp <100 || bossMonsterHp > 300){ + throw new IllegalArgumentException(READ_BOSS_HP_RANGE_EXCEPTION_FORMAT); + } + return bossMonsterHp; + } + + public String readPlayerName() { + System.out.println(PLAYER_NAME_REQUEST_MESSAGE); + final String name = scanner.nextLine(); + if(name.isEmpty()||name.length()>5){ + throw new IllegalArgumentException(READ_PLAYER_NAME_EXCEPTION_MESSAGE); + } + return name; + } + + public int[] readPlayerInfo() { + System.out.println(PLAYER_INFO_REQUEST_MESSAGE); + final String info = scanner.nextLine(); + int[] newInfo = transformPlayerInfo(info); + if(!validatePlayerInfo(newInfo)){ + throw new IllegalArgumentException(READ_PLAYER_INFO_EXCEPTION_MESSAGE); + } + return newInfo; + } + + private boolean validatePlayerInfo(int[] info) { + return (0 <= info[0] && info[0] <= 200) && (0 <= info[1] && info[1] <= 200) && (info[0] + info[1] == 200); + } + + private int[] transformPlayerInfo(String info){ + String[] temp = splitPlayerInfo(info); + return Arrays.stream(temp) + .mapToInt(Integer::parseInt) + .toArray(); + } + + private String[] splitPlayerInfo(String info){ + return Arrays.stream(info.split(",")) + .map(String::trim) + .toArray(String[]::new); + } + + private boolean validAttackType(int type){ + return (type == 1 || type == 2); + } + + public int inputAttack() { + System.out.println(ATTACK_REQUEST_MESSAGE); + int type = scanner.nextInt(); + scanner.nextLine(); + + if(validAttackType(type)){ + return type; + } + throw new IllegalArgumentException("Copy to clipboard[ERROR] 공격하셔야 합니다. 1 또는 2를 입력해주세요."); + } +} diff --git a/src/main/java/bossmonster/view/OutputText.java b/src/main/java/bossmonster/view/OutputText.java new file mode 100644 index 00000000..5d2c3342 --- /dev/null +++ b/src/main/java/bossmonster/view/OutputText.java @@ -0,0 +1,75 @@ +package bossmonster.view; + +import bossmonster.domain.BossMonster; +import bossmonster.domain.Player; + +public class OutputText { + + public final String BOSS_INIT () { + return "____________________________\n" + + " ^-^\n" + + " / 0 0 \\\n" + + "( \" )\n" + + " \\ - /\n" + + " - ^ -\n" + + "____________________________"; + } + + public final String BOSS_WINNING () { + return "____________________________\n" + + " ^-^\n" + + " / ^ ^ \\\n" + + "( \" )\n" + + " \\ 3 /\n" + + " - ^ -\n" + + "____________________________"; + } + + public final String BOSS_LOSING () { + return "____________________________\n" + + " ^-^\n" + + " / x x \\\n" + + "( \"\\ )\n" + + " \\ ^ /\n" + + " - ^ -\n" + + "____________________________"; + } + + public final String printBossHp(BossMonster bossMonster){ + return "\n" + + "============================\n" + + "BOSS HP ["+bossMonster.getHp()+"/"+bossMonster.getInitHp()+"]"; + } + + public final String printPlayerInfo(Player player){ + return "\n"+player.getName()+" " + + "HP ["+player.getHp()+"/"+player.getInitHp()+"] " + + "MP ["+player.getMp()+"/"+player.getInitMp()+"]\n" + + "============================"; + } + + public final String printPhysicalAttack(int random, boolean bossDie){ + String sentence ="\n물리 공격을 했습니다. (입힌 데미지: 10)\n"; + if(!bossDie){ + return sentence+"보스가 공격 했습니다. (입힌 데미지: "+random+")"; + } + return sentence; + } + + public final String printMagicAttack(int random, boolean bossDie){ + String sentence = "\n마법 공격을 했습니다. (입힌 데미지: 20)\n"; + if(!bossDie) { + return sentence + "보스가 공격 했습니다. (입힌 데미지: " + random + ")"; + } + return sentence; + } + + public final String printFailMessage(){ + return "\ndori의 HP가 0이 되었습니다.\n" + + "보스 레이드에 실패했습니다."; + } + + public final String printWinMessage(Player player, int num){ + return player.getName() + " 님이 "+num+"번의 전투 끝에 보스 몬스터를 잡았습니다."; + } +} diff --git a/src/main/java/bossmonster/view/OutputView.java b/src/main/java/bossmonster/view/OutputView.java new file mode 100644 index 00000000..cd63c46a --- /dev/null +++ b/src/main/java/bossmonster/view/OutputView.java @@ -0,0 +1,61 @@ +package bossmonster.view; + +import bossmonster.domain.Game; + +public class OutputView { + + private final OutputText outputText = new OutputText(); + private final static String startSentence = "보스 레이드를 시작합니다!"; + public void printInit(Game game) { + System.out.println(); + System.out.println(startSentence); + System.out.println(outputText.printBossHp(game.getBossMonster())); + System.out.println(outputText.BOSS_INIT()); + System.out.println(outputText.printPlayerInfo(game.getPlayer())); + } + + public void printPhysicalAttack(int random, boolean bossDie) { + System.out.println(outputText.printPhysicalAttack(random, bossDie)); + } + + public void printResult(Game game, boolean playerDie){ + System.out.println(outputText.printBossHp(game.getBossMonster())); + printIcon(playerDie); + System.out.println(outputText.printPlayerInfo(game.getPlayer())); + } + + public void printIcon(boolean playerDie){ + if(playerDie){ + System.out.println(outputText.BOSS_WINNING()); + return; + } + System.out.println(outputText.BOSS_LOSING()); + } + + public void printMagicAttack(int random, boolean bossDie) { + System.out.println(outputText.printMagicAttack(random, bossDie)); + } + + public void printFailMessage(){ + System.out.println(outputText.printFailMessage()); + } + + public void printWinMessage(Game game){ + System.out.println(outputText.printWinMessage(game.getPlayer(), game.getNumberOfTimes())); + } + + public boolean controlPrintResult(Game game, boolean bossDie, boolean playerDie){ + if(!bossDie){ + printResult(game, playerDie); + } + if(bossDie){ + printWinMessage(game); + return false; + } + if(playerDie){ + printFailMessage(); + return false; + } + return true; + } +} diff --git a/src/test/java/bossmonster/controller/BossMonsterControllerTest.java b/src/test/java/bossmonster/controller/BossMonsterControllerTest.java new file mode 100644 index 00000000..7428af68 --- /dev/null +++ b/src/test/java/bossmonster/controller/BossMonsterControllerTest.java @@ -0,0 +1,38 @@ +package bossmonster.controller; + +import bossmonster.domain.BossMonster; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class BossMonsterControllerTest { + + private final static int HpInit = 100; + private final static int DAMAGE = 17; + private final static int deadDamage = 100; + private final BossMonster bossMonster = new BossMonster(HpInit); + private final BossMonster bossMonsterDead = new BossMonster(0); + private final BossMonster bossMonsterHit = new BossMonster(HpInit - DAMAGE); + private final BossMonsterController bossMonsterController = new BossMonsterController(); + + @Test + @DisplayName("보스 몬스터 공격당했을 때 Hp 테스트") + void hitTest(){ + BossMonster newBossMonster = bossMonsterController.hit(bossMonster, DAMAGE); + assertThat(newBossMonster.getHp()).isEqualTo(bossMonsterHit.getHp()); + } + + @Test + @DisplayName("보스 몬스터 공격당해서 죽었을 때 Hp 테스트") + void deadTest(){ + BossMonster newBossMonster = bossMonsterController.hit(bossMonster, deadDamage); + assertThat(newBossMonster.getHp()).isEqualTo(bossMonsterDead.getHp()); + } + + @Test + @DisplayName("보스 몬스터 죽었는지 확인 테스트") + void isDeadTest(){ + assertThat(bossMonsterController.die(bossMonsterDead)).isTrue(); + assertThat(bossMonsterController.die(bossMonster)).isFalse(); + } +} diff --git a/src/test/java/bossmonster/controller/PlayerControllerTest.java b/src/test/java/bossmonster/controller/PlayerControllerTest.java new file mode 100644 index 00000000..411723a8 --- /dev/null +++ b/src/test/java/bossmonster/controller/PlayerControllerTest.java @@ -0,0 +1,39 @@ +package bossmonster.controller; + +import bossmonster.domain.Player; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class PlayerControllerTest { + private final static String NAME = "dori"; + private final static int HP_INIT = 100; + private final static int MP_INIT = 100; + private final static int DAMAGE = 17; + private final static int deadDamage = 100; + private final Player player = new Player(NAME, HP_INIT, MP_INIT); + private final Player playerDead = new Player(NAME, 0, MP_INIT - DAMAGE); + private final Player playerHit = new Player(NAME, HP_INIT - DAMAGE, MP_INIT); + + private final PlayerController playerController = new PlayerController(); + + @Test + @DisplayName("플레이어 공격당했을 때 Hp 테스트") + void playerHitTest(){ + assertThat(playerController.hit(player, DAMAGE).getHp()).isEqualTo(playerHit.getHp()); + } + + @Test + @DisplayName("플레이어 회복 시 MP 테스트") + void recoverMpTest(){ + assertThat(playerDead.getMp()).isEqualTo(MP_INIT-DAMAGE); + assertThat(playerController.recover(playerDead).getMp()).isEqualTo(MP_INIT); + } + + @Test + @DisplayName("플레이어 죽었는지 확인 테스트") + void playerDeadTest(){ + assertThat(playerController.die(player)).isFalse(); + assertThat(playerController.die(playerDead)).isTrue(); + } +} diff --git a/src/test/java/bossmonster/domain/BossMonsterTest.java b/src/test/java/bossmonster/domain/BossMonsterTest.java new file mode 100644 index 00000000..25eef5bd --- /dev/null +++ b/src/test/java/bossmonster/domain/BossMonsterTest.java @@ -0,0 +1,18 @@ +package bossmonster.domain; + +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class BossMonsterTest { + + @Test + @DisplayName("보스 몬스터 hp 저장 테스트") + void storeBossMonsterHpTest(){ + final int hp = 200; + + BossMonster bossMonster = new BossMonster(hp); + + assertThat(bossMonster.getHp()).isEqualTo(hp); + } +} diff --git a/src/test/java/bossmonster/domain/GameTest.java b/src/test/java/bossmonster/domain/GameTest.java new file mode 100644 index 00000000..a016c4d7 --- /dev/null +++ b/src/test/java/bossmonster/domain/GameTest.java @@ -0,0 +1,31 @@ +package bossmonster.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class GameTest { + + private final int bossHp = 100; + private final String playerName = "dori"; + private final int playerHp = 100; + private final int playerMp = 100; + + @Test + @DisplayName("게임 초기화 테스트") + void initGame(){ + //given + final BossMonster bossMonster = new BossMonster(bossHp); + final Player player = new Player(playerName, playerHp, playerMp); + final Game game = new Game(bossMonster, player); + + //when + BossMonster newBossMonster = game.getBossMonster(); + Player newPlayer = game.getPlayer(); + + //then + assertThat(newBossMonster).isEqualTo(bossMonster); + assertThat(newPlayer).isEqualTo(player); + } +} diff --git a/src/test/java/bossmonster/domain/PlayerTest.java b/src/test/java/bossmonster/domain/PlayerTest.java new file mode 100644 index 00000000..24f5134d --- /dev/null +++ b/src/test/java/bossmonster/domain/PlayerTest.java @@ -0,0 +1,23 @@ +package bossmonster.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class PlayerTest { + private static final String PLAYER_NAME1 = "전영은"; + private static final String PlAYER_NAME2 = "안녕하세요반가워요"; + private static final int PLAYER_HP1 = 150; + private static final int PLAYER_MP1 = 50; + + @Test + @DisplayName("플레이어 정보 저장 테스트") + void storePlayerInfoTest(){ + Player player = new Player(PLAYER_NAME1, PLAYER_HP1, PLAYER_MP1); + + assertThat(player.getName()).isEqualTo(PLAYER_NAME1); + assertThat(player.getHp()).isEqualTo(PLAYER_HP1); + assertThat(player.getMp()).isEqualTo(PLAYER_MP1); + } +} diff --git a/src/test/java/bossmonster/view/OutputViewTest.java b/src/test/java/bossmonster/view/OutputViewTest.java new file mode 100644 index 00000000..604abd1f --- /dev/null +++ b/src/test/java/bossmonster/view/OutputViewTest.java @@ -0,0 +1,81 @@ +package bossmonster.view; + +import bossmonster.domain.BossMonster; +import bossmonster.domain.Game; +import bossmonster.domain.Player; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class OutputViewTest { + + private final BossMonster bossMonster1 = new BossMonster(100); + private final Player player1 = new Player("dori", 100, 100); + private final Player player2 = new Player("pobi", 10, 190); + private final Game game1 = new Game(bossMonster1, player1); + private final Game game2 = new Game(bossMonster1, player2); + private final static int RANDOM_NUMBER = 13; + private final OutputView outputView = new OutputView(); + + @Test + @DisplayName("초기 출력 테스트") + void printInitTest(){ + System.out.println("테스트1"); + outputView.printInit(game1); + System.out.println("\n테스트2"); + outputView.printInit(game2); + } + + @Test + @DisplayName("과정 결과 출력 테스트") + void printProcessResult(){ + outputView.printResult(game1, false); + } + + @Test + @DisplayName("플레이어 죽었을 때의 결과 출력 테스트") + void printResultPlayerDeadTest(){ + outputView.printResult(game1, true); + } + + @Test + @DisplayName("아이콘 출력 테스트") + void printIconTest(){ + System.out.println("플레이어 죽었을 때"); + outputView.printIcon(true); + + System.out.println("\n플레이어 살았을 때"); + outputView.printIcon(false); + } + + @Test + @DisplayName("마법 공격 출력 테스트") + void printMagicAttackTest(){ + System.out.println("보스 죽었을 때"); + outputView.printMagicAttack(RANDOM_NUMBER, true); + + System.out.println("\n보스 살았을 때"); + outputView.printMagicAttack(RANDOM_NUMBER, false); + } + + @Test + @DisplayName("물리 공격 출력 테스트") + void printPhysicalAttackTest(){ + System.out.println("보스 죽었을 때"); + outputView.printPhysicalAttack(RANDOM_NUMBER, true); + + System.out.println("\n보스 살았을 때"); + outputView.printPhysicalAttack(RANDOM_NUMBER, false); + } + + @Test + @DisplayName("실패 메시지 출력 테스트") + void printFailTest(){ + outputView.printFailMessage(); + } + + @Test + @DisplayName("성공 메시지 출력 테스트") + void printWinningTest(){ + outputView.printWinMessage(game1); + } +}