7일차
public void ClassUp() throws IOException{
if(Integer.parseInt(List_P_M.Playerchoice.get(1)) >= 10 && List_P_M.Playerchoice.get(8).equals("Beginner")){ //직업 선택
ClassList ClassList = new ClassList();
ClassList.ClassList();
}else{
System.out.println("\nLack.");
return;
}
}
Choice 클래스에 새롭게 추가된 녀석입니다.
직업을 선택을 할 수 있게 해주는 기능을 가지고 있어요.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class ClassList {
ArrayList<String> Warrior;
ArrayList<String> Hunter;
ArrayList<String> Magician;
ArrayList<String> Assassin;
ArrayList<String> SkillName = new ArrayList<String>();
int Sk_1 = 20;
int Sk_2 = 30;
int Sk_3 = 40;
int Sk_4 = 50;
public ClassList(){
}
public void ClassList() throws IOException{ // 전직 시스템
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String F1 = "";
System.out.println("Claas Up");
while(true){
String result = "";
System.out.print("\n\n1.Warrior\n2.Hunter\n3.Magician\n4.Assassin\nCh : ");
String C_Ch = bf.readLine();
if(C_Ch.equals("1")){
Skill(C_Ch);
result = "Warrior";
F1 = Choice_Class();
}else if(C_Ch.equals("2")){
Skill(C_Ch);
result = "Hunter";
F1 = Choice_Class();
}else if(C_Ch.equals("3")){
Skill(C_Ch);
result = "Magician";
F1 = Choice_Class();
}else if(C_Ch.equals("4")){
Skill(C_Ch);
result = "Assassin";
F1 = Choice_Class();
}else{
System.out.println("RE");
}
if(F1.equals("1")){
List_P_M.Playerchoice.set(8, result);
return;
}
}
}
public String Choice_Class() throws IOException{ // 전직 여부
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
while(true){
System.out.print("Choice Class?\n1.Y\n2.N\nCh : ");
String RE_Ch = bf.readLine();
if(RE_Ch.equals("1") || RE_Ch.equals("2")){
return RE_Ch;
}else{
System.out.println("RE");
}
}
}
public void Skill(String C_Ch){ // 스킬 내용
if(C_Ch.equals("1")){
System.out.println("\nLv:10 [Rend] Atk : 20");
System.out.println("\nLv:12 [Charge] Atk : 30");
System.out.println("\nLv:14 [Execute] Atk : 40");
System.out.println("\nLv:16 [Heroic strike] Atk : 50");
}else if(C_Ch.equals("2")){
System.out.println("\nLv:10 [Piercing] Atk : 20");
System.out.println("\nLv:12 [Hamstring] Atk : 30");
System.out.println("\nLv:14 [Sniping] Atk : 40");
System.out.println("\nLv:16 [Dragon Pulse] Atk : 50");
}else if(C_Ch.equals("3")){
System.out.println("\nLv:10 [Mana Reflection] Atk : 20");
System.out.println("\nLv:12 [Chain Lightning] Atk : 30");
System.out.println("\nLv:14 [Blizzard] Atk : 40");
System.out.println("\nLv:16 [Big Bang] Atk : 50");
}else if(C_Ch.equals("4")){
System.out.println("\nLv:10 [Venom] Atk : 20");
System.out.println("\nLv:12 [Triple Throw] Atk : 30");
System.out.println("\nLv:14 [Spirit Javelin] Atk : 40");
System.out.println("\nLv:16 [Showdown] Atk : 50");
}
}
public void Warrior(){
Warrior = new ArrayList<String>();
String Warrior_1 = "Rend";
String Warrior_2 = "Charge";
String Warrior_3 = "Execute";
String Warrior_4 = "Heroic strike";
Warrior.add(Warrior_1);
Warrior.add(Warrior_2);
Warrior.add(Warrior_3);
Warrior.add(Warrior_4);
}
public String Warrior_ch(String Lv) throws IOException{ // 전사 레벨별 가능 스킬
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int LV = Integer.parseInt(Lv);
int count = 0;
if(LV >= 10 && LV < 12){
System.out.println("\n1. [Rend] Atk : 20");
count = 1;
}else if(LV >= 12 && LV < 14){
System.out.println("\n1. [Rend] Atk : 20");
System.out.println("\n2. [Charge] Atk : 30");
count = 2;
}else if(LV >= 14 && LV < 16){
System.out.println("\n1. [Rend] Atk : 20");
System.out.println("\n2. [Charge] Atk : 30");
System.out.println("\n3. [Execute] Atk : 40");
count = 3;
}else if(LV >= 16) {
System.out.println("\n1. [Rend] Atk : 20");
System.out.println("\n2. [Charge] Atk : 30");
System.out.println("\n3. [Execute] Atk : 40");
System.out.println("\n4. [Heroic strike] Atk : 50");
count = 4;
}
while(true){
System.out.print("Ch : ");
String Sk_Ch = bf.readLine();
if(count < Integer.parseInt(Sk_Ch) || Integer.parseInt(Sk_Ch) == 0){
System.out.println("RE");
}else{
// damage(Sk_Ch);
return Sk_Ch;
}
}
}
public int W_damage(String Sk_Ch){ // 데미지 측정
int Ch = Integer.parseInt(Sk_Ch);
Warrior();
for(int i = 0; i < SkillName.size(); i++){
if(SkillName.get(i).equals(Warrior.get(Ch-1))){
System.out.println("It's a skill I used once.");
return 0;
}
}
SkillName.add(Warrior.get(Ch-1));
if(Ch == 1){
System.out.println("\n"+Warrior.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_1);
return Sk_1;
}else if(Integer.parseInt(Sk_Ch) == 2){
System.out.println("\n"+Warrior.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_2);
return Sk_2;
}else if(Integer.parseInt(Sk_Ch) == 3){
System.out.println("\n"+Warrior.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_3);
return Sk_3;
}else if(Integer.parseInt(Sk_Ch) == 4){
System.out.println("\n"+Warrior.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_4);
return Sk_4;
}else{
return 0;
}
}
public void Hunter(){
Hunter = new ArrayList<String>();
String Hunter_1 = "Piercing";
String Hunter_2 = "Hamstring";
String Hunter_3 = "Sniping";
String Hunter_4 = "Dragon Pulse";
Hunter.add(Hunter_1);
Hunter.add(Hunter_2);
Hunter.add(Hunter_3);
Hunter.add(Hunter_4);
}
public String Hunter_ch(String Lv) throws IOException{ // 궁수 레벨별 가능 스킬
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int LV = Integer.parseInt(Lv);
int count = 0;
if(LV >= 10 && LV < 12){
System.out.println("\n1. [Piercing] Atk : 20");
count = 1;
}else if(LV >= 12 && LV < 14){
System.out.println("\n1. [Piercing] Atk : 20");
System.out.println("\n2. [Hamstring] Atk : 30");
count = 2;
}else if(LV >= 14 && LV < 16){
System.out.println("\n1. [Piercing] Atk : 20");
System.out.println("\n2. [Hamstring] Atk : 30");
System.out.println("\n3. [Sniping] Atk : 40");
count = 3;
}else if(LV >= 16) {
System.out.println("\n1. [Piercing] Atk : 20");
System.out.println("\n2. [Hamstring] Atk : 30");
System.out.println("\n3. [Sniping] Atk : 40");
System.out.println("\n4. [Dragon Pulse] Atk : 50");
count = 4;
}
while(true){
System.out.print("Ch : ");
String Sk_Ch = bf.readLine();
if(count < Integer.parseInt(Sk_Ch) || Integer.parseInt(Sk_Ch) == 0){
System.out.println("RE");
}else{
// damage(Sk_Ch);
return Sk_Ch;
}
}
}
public int H_damage(String Sk_Ch){ // 데미지 측정
int Ch = Integer.parseInt(Sk_Ch);
Hunter();
for(int i = 0; i < SkillName.size(); i++){
if(SkillName.get(i).equals(Hunter.get(Ch-1))){
System.out.println("It's a skill I used once.");
return 0;
}
}
SkillName.add(Hunter.get(Ch-1));
if(Ch == 1){
System.out.println("\n"+Hunter.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_1);
return Sk_1;
}else if(Integer.parseInt(Sk_Ch) == 2){
System.out.println("\n"+Hunter.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_2);
return Sk_2;
}else if(Integer.parseInt(Sk_Ch) == 3){
System.out.println("\n"+Hunter.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_3);
return Sk_3;
}else if(Integer.parseInt(Sk_Ch) == 4){
System.out.println("\n"+Hunter.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_4);
return Sk_4;
}else{
return 0;
}
}
public void Magician(){
Magician = new ArrayList<String>();
String Magician_1 = "Mana Reflection";
String Magician_2 = "Chain Lightning";
String Magician_3 = "Blizzard";
String Magician_4 = "Big Bang";
Magician.add(Magician_1);
Magician.add(Magician_2);
Magician.add(Magician_3);
Magician.add(Magician_4);
}
public String Magician_ch(String Lv) throws IOException{ // 궁수 레벨별 가능 스킬
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int LV = Integer.parseInt(Lv);
int count = 0;
if(LV >= 10 && LV < 12){
System.out.println("\n1. [Mana Reflection] Atk : 20");
count = 1;
}else if(LV >= 12 && LV < 14){
System.out.println("\n1. [Mana Reflection] Atk : 20");
System.out.println("\n2. [Chain Lightning] Atk : 30");
count = 2;
}else if(LV >= 14 && LV < 16){
System.out.println("\n1. [Mana Reflection] Atk : 20");
System.out.println("\n2. [Chain Lightning] Atk : 30");
System.out.println("\n3. [Blizzard] Atk : 40");
count = 3;
}else if(LV >= 16) {
System.out.println("\n1. [Mana Reflection] Atk : 20");
System.out.println("\n2. [Chain Lightning] Atk : 30");
System.out.println("\n3. [Blizzard] Atk : 40");
System.out.println("\n4. [Big Bang] Atk : 50");
count = 4;
}
while(true){
System.out.print("Ch : ");
String Sk_Ch = bf.readLine();
if(count < Integer.parseInt(Sk_Ch) || Integer.parseInt(Sk_Ch) == 0){
System.out.println("RE");
}else{
// damage(Sk_Ch);
return Sk_Ch;
}
}
}
public int M_damage(String Sk_Ch){ // 데미지 측정
int Ch = Integer.parseInt(Sk_Ch);
Magician();
for(int i = 0; i < SkillName.size(); i++){
if(SkillName.get(i).equals(Magician.get(Ch-1))){
System.out.println("It's a skill I used once.");
return 0;
}
}
SkillName.add(Magician.get(Ch-1));
if(Ch == 1){
System.out.println("\n"+Magician.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_1);
return Sk_1;
}else if(Integer.parseInt(Sk_Ch) == 2){
System.out.println("\n"+Magician.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_2);
return Sk_2;
}else if(Integer.parseInt(Sk_Ch) == 3){
System.out.println("\n"+Magician.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_3);
return Sk_3;
}else if(Integer.parseInt(Sk_Ch) == 4){
System.out.println("\n"+Magician.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_4);
return Sk_4;
}else{
return 0;
}
}
public void Assassin(){
Assassin = new ArrayList<String>();
String Assassin_1 = "Venom";
String Assassin_2 = "Triple Throw";
String Assassin_3 = "Spirit Javelin";
String Assassin_4 = "Showdown";
Assassin.add(Assassin_1);
Assassin.add(Assassin_2);
Assassin.add(Assassin_3);
Assassin.add(Assassin_4);
}
public String Assassin_ch(String Lv) throws IOException{ // 궁수 레벨별 가능 스킬
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int LV = Integer.parseInt(Lv);
int count = 0;
if(LV >= 10 && LV < 12){
System.out.println("\n1. [Venom] Atk : 20");
count = 1;
}else if(LV >= 12 && LV < 14){
System.out.println("\n1. [Venom] Atk : 20");
System.out.println("\n2. [Triple Throw] Atk : 30");
count = 2;
}else if(LV >= 14 && LV < 16){
System.out.println("\n1. [Venom] Atk : 20");
System.out.println("\n2. [Triple Throw] Atk : 30");
System.out.println("\n3. [Spirit Javelin] Atk : 40");
count = 3;
}else if(LV >= 16) {
System.out.println("\n1. [Venom] Atk : 20");
System.out.println("\n2. [Triple Throw] Atk : 30");
System.out.println("\n3. [Spirit Javelin] Atk : 40");
System.out.println("\n4. [Showdown] Atk : 50");
count = 4;
}
while(true){
System.out.print("Ch : ");
String Sk_Ch = bf.readLine();
if(count < Integer.parseInt(Sk_Ch) || Integer.parseInt(Sk_Ch) == 0){
System.out.println("RE");
}else{
// damage(Sk_Ch);
return Sk_Ch;
}
}
}
public int A_damage(String Sk_Ch){ // 데미지 측정
int Ch = Integer.parseInt(Sk_Ch);
Assassin();
for(int i = 0; i < SkillName.size(); i++){
if(SkillName.get(i).equals(Assassin.get(Ch-1))){
System.out.println("It's a skill I used once.");
return 0;
}
}
SkillName.add(Assassin.get(Ch-1));
if(Ch == 1){
System.out.println("\n"+Assassin.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_1);
return Sk_1;
}else if(Integer.parseInt(Sk_Ch) == 2){
System.out.println("\n"+Assassin.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_2);
return Sk_2;
}else if(Integer.parseInt(Sk_Ch) == 3){
System.out.println("\n"+Assassin.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_3);
return Sk_3;
}else if(Integer.parseInt(Sk_Ch) == 4){
System.out.println("\n"+Assassin.get(Ch-1)+"!");
System.out.println("Atk : "+Sk_4);
return Sk_4;
}else{
return 0;
}
}
}
직업을 4개만 적용했는데 코드가 엄청 늘어나버렸어요.. 아직 줄일 수 있는 수단이 많아서 점점 바꿔보려 합니다.
이 클래스에는 직업 선택 후 적용부터 전투 시 레벨에 따른 스킬 , 스킬 대미지 등 직업과 스킬에 관한 걸 넣어놨어요.
잘 보시면 중간에 한번 사용한 스킬은 같은 전투에서 다시는 사용 못하도록 해놨습니다. 그 이유는 바로 아래 코드에서!
else if(P_Ch.equals("3")){ // 스킬 선택시
if(List_P_M.Playerchoice.get(8).equals("Beginner")){ // 초보자면 다시 선택
System.out.println("No Skill!");
}else{
if(List_P_M.Playerchoice.get(8).equals("Warrior")){
String B_1 = C_ch.Warrior_ch(List_P_M.Playerchoice.get(1));
int Skill_Atk = C_ch.W_damage(B_1);
if(Skill_Atk == 0){
// 리턴 값이 잘못 넘어왔을 경우
}else if(M_Ch == 1){
System.out.println(MonsterState[0]+" Atk["+M_Atk_Rd+"]!!");
PlayerHp -= M_Atk_Rd ;
MonsterHp -= Skill_Atk;
}else{
System.out.println(MonsterState[0]+" Def["+M_Def_Rd+"]!!");
System.out.println("Skill Atk! Def Fall..");
MonsterHp -= Skill_Atk;
}
}else if(List_P_M.Playerchoice.get(8).equals("Hunter")){
String B_1 = C_ch.Hunter_ch(List_P_M.Playerchoice.get(1));
int Skill_Atk = C_ch.H_damage(B_1);
if(Skill_Atk == 0){
// 리턴 값이 잘못 넘어왔을 경우
}else if(M_Ch == 1){
System.out.println(MonsterState[0]+" Atk["+M_Atk_Rd+"]!!");
PlayerHp -= M_Atk_Rd ;
MonsterHp -= Skill_Atk;
}else{
System.out.println(MonsterState[0]+" Def["+M_Def_Rd+"]!!");
System.out.println("Skill Atk! Def Fall..");
MonsterHp -= Skill_Atk;
}
}else if(List_P_M.Playerchoice.get(8).equals("Magician")){
String B_1 = C_ch.Magician_ch(List_P_M.Playerchoice.get(1));
int Skill_Atk = C_ch.M_damage(B_1);
if(Skill_Atk == 0){
// 리턴 값이 잘못 넘어왔을 경우
}else if(M_Ch == 1){
System.out.println(MonsterState[0]+" Atk["+M_Atk_Rd+"]!!");
PlayerHp -= M_Atk_Rd ;
MonsterHp -= Skill_Atk;
}else{
System.out.println(MonsterState[0]+" Def["+M_Def_Rd+"]!!");
System.out.println("Skill Atk! Def Fall..");
MonsterHp -= Skill_Atk;
}
}else if(List_P_M.Playerchoice.get(8).equals("Assassin")){
String B_1 = C_ch.Assassin_ch(List_P_M.Playerchoice.get(1));
int Skill_Atk = C_ch.A_damage(B_1);
if(Skill_Atk == 0){
// 리턴 값이 잘못 넘어왔을 경우
}else if(M_Ch == 1){
System.out.println(MonsterState[0]+" Atk["+M_Atk_Rd+"]!!");
PlayerHp -= M_Atk_Rd ;
MonsterHp -= Skill_Atk;
}else{
System.out.println(MonsterState[0]+" Def["+M_Def_Rd+"]!!");
System.out.println("Skill Atk! Def Fall..");
MonsterHp -= Skill_Atk;
}
}
}
Adventure 클래스에 새롭게 추가된 부분입니다. 전투 부분에서 좀 많이 늘어났어요 ㅠㅠ
스킬을 한 번만 사용할 수 있게 한 이유는 스킬을 사용할 때 같이 공격하면 대미지를 주지만 방어를 하면 방어 실패가 떠버리게 했습니다.
50대 50이니 운 요소가 제대로 들어가 버렸어요.
스킬을 다 만들어갈 때쯤 뭔가 대미지만 있고 직업다운 스킬이 없어서 아차 싶었어요..
다 바꾸려면 매우 힘든 작업이 되겠지만 그래도 얼음은 공격 한턴 없애기 등 여러 기능들을 넣어볼까 합니다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Lv_m {
static ArrayList<String> MonsterLv = new ArrayList<String>();
String A = "1";
String B = "5";
String C = "10";
String D = "15";
String E = "20";
public Lv_m(){
}
public void Lv_m() throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("\n1. Lv1 ~ Lv5\n2. Lv5 ~ Lv10\n3. Lv10 ~ Lv15\n4. Lv15 ~ Lv20\nCh : ");
String Lv_ch = bf.readLine();
if(Lv_ch.equals("1")){
Lv_m_ch(A , B);
}else if(Lv_ch.equals("2")){
Lv_m_ch(B , C);
}else if(Lv_ch.equals("3")){
Lv_m_ch(C , D);
}else if(Lv_ch.equals("4")){
Lv_m_ch(D , E);
}else{
System.out.println("RE");
}
}
public void Lv_m_ch(String MinLv, String MaxLv) throws IOException{
Adventure Adventure = new Adventure();
MonsterLv = new ArrayList<String>();
for(int i = 0; i < List_P_M.Monsterlist.size(); i++){ //레벨에 맞게 입장
String Monster_s[] = List_P_M.Monsterlist.get(i).split(",");
if(Integer.parseInt(Monster_s[1]) <= Integer.parseInt(MaxLv) && Integer.parseInt(MinLv) <= Integer.parseInt(Monster_s[1])){
String result = Monster_s[0];
for(int j = 1; j < Monster_s.length; j++){
result = result+","+Monster_s[j];
}
MonsterLv.add(result);
}
}
System.out.println("\n\nLv"+MinLv+" ~ Lv"+MaxLv);
Adventure.Adventure();
}
}
이건 어제의 제가 하겠다고 적어놓은 부분! 바로 레벨별 몬스터 출현입니다.
스탯 분배를 잘해서 레벨이 높은 곳을 가고 싶을 수도 있겠다 싶어서 일단은 다 들어갈 수 있게 해 놨습니다.
하지만 많이 힘들다는 거..ㅎ
몬스터들을 제대로 추가해봤어요. A, B이건 너무 성의 없어서.. 나름 멋있게 지어주고 싶어서 찾아봤더니
이런 사이트가 있더군요. 다들 영어로 작명하기 힘들 때 여기를 사용해보는 것도 괜찮아 보입니다.
https://donjon.bin.sh/fantasy/name/#type=mon;mon=draconic_male
donjon; Fantasy Name Generator
English Male Names English Female Names English Town Names French Male Names French Female Names French Town Names German Male Names German Female Names German Town Names Italian Male Names Italian Female Names Italian Town Names Norse Male Names Norse Fem
donjon.bin.sh
오늘 생각보다 많은걸 고치고 추가했는데 고친 부분을 다 기억이 나질 않네요..ㅠㅠ
다음부터 고치면서 올리고 고치고 올리고 해야 될 거 같아요. 추가하고 버그를 찾아봤는데 생각보다 많이 있더라고요 허..
크게 기억나는 건 종료할 때랑 새로운 플레이어 만들 때? 꽤나 많았어요.. 뒤에 작성했던 코드들은 다 엉망이었구나 싶어요.
앞으로 주석도 좀 자세하게 달아놔야겠어요. 만들 때는 쑥쑥 만들었지만 다시 보면 기억이 안 갈 수도 있으니 그러는 게 좋을 거 같아요.
내일은 장비 시스템에 대해서 좀 생각해보려고 합니다.
'JAVA Console Game > JAVA Text RPG' 카테고리의 다른 글
JAVA 입문자 Text RPG 만들기 8일차 (0) | 2021.11.01 |
---|---|
JAVA 입문자 Text RPG 만들기 6일차 (1) | 2021.10.27 |
JAVA 입문자 Text RPG 만들기 5일차 (0) | 2021.10.25 |
JAVA 입문자 Text RPG 만들기 4일차 (0) | 2021.10.22 |
JAVA 입문자 Text RPG 만들기 3일차 (0) | 2021.10.21 |