절차 지향 TextRPG1(강의복습,기능추가)
using System; namespace TextRPG_ { enum GameOnOff { None = 0, On = 1, Off =2, } enum ClassType { None = 0, Knight = 1, Archer = 2, Mage = 3, } enum MonsterType { None = 0, Slime = 1, Orc = 2, Skeleton = 3, } struct Player { public int hp; public int attack; } struct Monster { public int hp; public int attack; } internal class Program { static ClassType ChooseClass() //클래스 선택 { Console.WriteLine("직업을 선택하세요"); Console.WriteLine("[1]기사"); Console.WriteLine("[2]궁수"); Console.WriteLine("[3]법사"); ClassType choice = ClassType.None; string input = Console.ReadLine(); switch (input) { case "1": choice = ClassType.Knight; break; case "2": choice = ClassType.Archer; break; case "3": choice = ClassType.Mage; break; } return choice; } static void CreatePlayer(ClassType choice,out Player player) //클래스 정보 { switch(choice) { case ClassType.Knight: player.hp = 100; player.attack = 20; break; case ClassType.Archer: player.hp = 80; player.attack = 30; break; case ClassType.Mage: player.hp = 60; player.attack = 40; break; default: player.hp = 0; player.attack = 0; break; } } static void EnterGame(ref Player player) //게임접속 { Console.WriteLine("게임에 접속하셧습니다."); Console.WriteLine("[1]필드로 간다"); Console.WriteLine("[2]로비로 돌아간다"); string input = Console.ReadLine(); switch(input) { case "1": EnterField(ref player); break; case "2": return; } } static void CreateMonster(out Monster monster) //몬스터 소환 { Random rand = new Random(); int randomMonster = rand.Next(1, 4); switch(randomMonster) { case (int)MonsterType.Slime: Console.WriteLine("슬라임이 소환되었습니다"); monster.hp = 50; monster.attack = 15; break; case (int)MonsterType.Orc: Console.WriteLine("오크가 소환되었습니다"); monster.hp = 100; monster.attack = 10; break; case (int)MonsterType.Skeleton: Console.WriteLine("스켈레톤이 소환되었습니다"); monster.hp = 80; monster.attack = 20; break; default: monster.hp = 0; monster.attack = 0; break; } } static void EnterField(ref Player player) //필드접속 { Console.WriteLine("필드에 접속하셨습니다"); //몬스터 생성 Monster monster; CreateMonster(out monster); Console.WriteLine("[1]전투 한다"); Console.WriteLine("[2]도망 친다"); string input = Console.ReadLine(); if(input == "1") { Fight(ref player,ref monster); } else if (input == "2") { Random rand = new Random(); int randRun = rand.Next(0, 101); if(randRun