Java

冗長なコードの改善方法を教えていただきたいです!

public class Battle {
static Hero player1;
static Hero player2;
static Skill Skill11;
static Skill Skill12;
static Skill Skill13;
static Skill Skill14;
static Skill Skill21;
static Skill Skill22;
static Skill Skill23;
static Skill Skill24;

public static void main(String[] args) {
    Hero[] players = {null,player1,player2};
    MakePlayers.chooseHero(players);

    Skill[] skills1 = {null,Skill11,Skill12,Skill13,Skill14};
    Skill[] skills2 = {null,Skill21,Skill22,Skill23,Skill24};
    MakePlayers.chooseSkill(players,skills1,skills2);

    for (;;) {
        //技発動部
        PlaySkill.playSkill(players,skills1,skills2);

        //先攻後攻決定部
        int ranSpd1 = new java.util.Random().nextInt(players[1].getSpd());
        int conSpd1 = players[1].getSpd() / 2;
        int realSpd1 = ranSpd1 + conSpd1;
        int ranSpd2 = new java.util.Random().nextInt(players[2].getSpd());
        int conSpd2 = players[2].getSpd() / 2;
        int realSpd2 = ranSpd2 + conSpd2;

        if (realSpd1 >= realSpd2) {

            //第1計算部
            //技タイプ判断課
            if (players[1].skill.getType() == 1) {
                //通常攻撃
                CalcDam.calcDam1(players,skills1,skills2);

            } else if (players[1].skill.getType() == 2 && players[1].getMp() >= players[1].skill.getmCost()) {
                CalcMdam.calcMdam1(players,skills1,skills2);
            }
        }
        //第2計算部
        if (players[2].skill.getType() == 1) {
            CalcDam.calcDam2(players,skills1,skills2);

        } else if (players[2].skill.getType() == 2) {
            CalcMdam.calcMdam2(players,skills1,skills2);

        }

        if (realSpd1 < realSpd2) {

            //第1計算部
            if (players[1].skill.getType() == 1) {
                //通常攻撃
                CalcDam.calcDam1(players,skills1,skills2);

            } else if (players[1].skill.getType() == 2 && players[1].getMp() >= players[1].skill.getmCost()) {
                CalcMdam.calcMdam1(players,skills1,skills2);
            }
        }
        //判断部

        if (players[2].getHp() <= 0 && players[1].getHp() > 0) {
            System.out.println(players[2].getName() + "を倒した!");
            break;
        } else if (players[2].getHp() > 0 && players[1].getHp() <= 0) {
            System.out.println(players[1].getName() + "は倒されてしまった…");
            break;
        } else if (players[2].getHp() <= 0 && players[1].getHp() <= 0) {
            System.out.println(players[2].getName() + players[1].getName() + "は倒れた…");
            break;
        }
    }
}

}
////////////////////////////////////////////

public class CalcDam {
static void calcDam1(Hero[] players, Skill[] skills1, Skill[] skills2) {
//atk計算課
double dAtk1 = -players[1].getAtk();
double aExp1 = Math.exp(dAtk1 / 1200);
double atkVal1 = 1 - aExp1;
double realAtkVal1 = players[1].skill.getDamage() * (1 + atkVal1);

    //def計算課
    double ddef1 = -players[2].getDef();
    double dExp1 = Math.exp(ddef1 / 1200);
    double defVal1 = 1 - dExp1;
    double realdefVal1 = realAtkVal1 * (1 - defVal1);

    //ダメージ計算課
    int realDamage1 = (int) Math.floor(realdefVal1);
    players[2].setHp(players[2].getHp() - realDamage1); //敵のダメージ計算
    System.out.print(players[1].getName() + "の" + players[1].skill.getName() + "!");
    System.out.println(players[2].getName() + "に" + realDamage1 + "ダメージを与えた!");
    System.out.print(players[2].getName() + "の残り体力は" + players[2].getHp() + "だ!");

    //MP計算課
    int ranAddMp1 = new java.util.Random().nextInt(players[1].getMgc());
    int conAddMp1 = players[1].getMgc() / 2;
    int addMp1 = (int) Math.floor((ranAddMp1 + conAddMp1) / 4);
    players[1].setMp(players[1].getMp() + addMp1);
    System.out.println(players[1].getName() + "のMPは" + addMp1 + "上昇した!");
}

static void calcDam2(Hero[] players, Skill[] skills1, Skill[] skills2) {
    //atk計算課
    double dAtk2 = -players[2].getAtk();
    double aExp2 = Math.exp(dAtk2 / 1200);
    double atkVal2 = 1 - aExp2;
    double realAtkVal2 = players[2].skill.getDamage() * (1 + atkVal2);

    //def計算課
    double ddef2 = -players[1].getDef();
    double dExp2 = Math.exp(ddef2 / 1200);
    double defVal2 = 1 - dExp2;
    double realDefVal2 = realAtkVal2 * (1 - defVal2);

    //ダメージ計算課
    int realDamage2 = (int) Math.floor(realDefVal2);
    players[1].setHp(players[1].getHp() - realDamage2); //敵のダメージ計算
    System.out.print(players[2].getName() + "の" + players[2].skill.getName() + "!");
    System.out.println(players[1].getName() + "に" + realDamage2 + "ダメージを与えた!");
    System.out.print(players[1].getName() + "の残り体力は" + players[1].getHp() + "だ!");

    //MP計算課
    int ranAddMp2 = new java.util.Random().nextInt(players[2].getMgc());
    int conAddMp2 = players[2].getMgc() / 2;
    int addMp2 = (int) ((ranAddMp2 + conAddMp2) / 4);
    players[2].setMp(players[2].getMp() + addMp2);
    System.out.println(players[2].getName() + "のMPは" + addMp2 + "上昇した!");
}

}
/////////////////////////////////////////

public class CalcMdam {
static void calcMdam1(Hero[] players, Skill[] skills1, Skill[] skills2) {
//魔術攻撃
//mp減少課
players[1].setMp(players[1].getMp() - players[1].skill.getmCost());
//matk計算課
double mAtk1 = -players[1].getMgc();
double mExp1 = Math.exp(mAtk1 / 1200);
double matkVal1 = 1 - mExp1;
double realmAtkVal1 = players[1].skill.getmDamage() * (1 + matkVal1);

    //mdef計算課

    double mddef1 = -players[2].getMgc();
    double mdExp1 = Math.exp(mddef1 / 1200);
    double mdefVal1 = 1 - mdExp1;
    double realmdefVal1 = realmAtkVal1 * (1 - mdefVal1);

    //ダメージ計算課
    int realmDamage1 = (int) Math.floor(realmdefVal1);
    players[2].setHp(players[2].getHp() - realmDamage1); //敵のダメージ計算
    System.out.print(players[1].getName() + "の" + players[1].skill.getName() + "!");
    System.out.println(players[2].getName() + "に" + realmDamage1 + "ダメージを与えた!");
    System.out.print(players[2].getName() + "の残り体力は" + players[2].getHp() + "だ!");

    //MP計算課
    int ranAddMp1 = new java.util.Random().nextInt(players[1].getMgc());
    int conAddMp1 = players[1].getMgc() / 2;
    int addMp1 = (int) Math.floor((ranAddMp1 + conAddMp1) / 4);
    players[1].setMp(players[1].getMp() + addMp1);
    System.out.println(players[1].getName() + "のMPは" + addMp1 + "上昇した!");
}

static void calcMdam2(Hero[] players, Skill[] skills1, Skill[] skills2) {
    //魔術攻撃
    //mp減少課
    players[2].setMp(players[2].getMp() - players[2].skill.getmCost());
    //matk計算課
    double mAtk2 = -players[2].getMgc();
    double mExp2 = Math.exp(mAtk2 / 1200);
    double matkVal2 = 1 - mExp2;
    double realmAtkVal2 = players[2].skill.getmDamage() * (1 + matkVal2);

    //mdef計算課

    double mddef2 = -players[1].getMgc();
    double mdExp2 = Math.exp(mddef2 / 1200);
    double mdefVal2 = 1 - mdExp2;
    double realmdefVal2 = realmAtkVal2 * (1 - mdefVal2);

    //ダメージ計算課
    int realmDamage2 = (int) Math.floor(realmdefVal2);
    players[1].setHp(players[1].getHp() - realmDamage2); //敵のダメージ計算
    System.out.print(players[2].getName() + "の" + players[2].skill.getName() + "!");
    System.out.println(players[1].getName() + "に" + realmDamage2 + "ダメージを与えた!");
    System.out.print(players[1].getName() + "の残り体力は" + players[1].getHp() + "だ!");

    //MP計算課
    int ranAddMp2 = new java.util.Random().nextInt(players[2].getMgc());
    int conAddMp2 = players[2].getMgc() / 2;
    int addMp2 = (int) Math.floor((ranAddMp2 + conAddMp2) / 4);
    players[2].setMp(players[2].getMp() + addMp2);
    System.out.println(players[2].getName() + "のMPは" + addMp2 + "上昇した!");
}

}
///////////////////////////////////////////

public class Hero {
private int id;
private String name;
private int hp;
private int mp=0;
private int atk;
private int def;
private int spd;
private int mgc;
Skill skill;

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public int getHp() {
    return hp;
}

public void setHp(int hp) {
    this.hp = hp;
}

public int getMp() {
    return mp;
}

public void setMp(int mp) {
    this.mp = mp;
}

public int getAtk() {
    return atk;
}

public void setAtk(int atk) {
    this.atk = atk;
}

public int getDef() {
    return def;
}

public void setDef(int def) {
    this.def = def;
}

public int getSpd() {
    return spd;
}

public void setSpd(int spd) {
    this.spd = spd;
}

public int getMgc() {
    return mgc;
}

public void setMgc(int mgc) {
    this.mgc = mgc;
}

}

//////////////////////////////////////////////////

public class LichKing extends Hero{

LichKing(){
    setId(6);
    setName("リッチキング");
    setHp(1200);
    setAtk(600);
    setDef(600);
    setSpd(600);
    setMgc(600);
}

}
////////////////////////////////////////

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class MakePlayers {
static void chooseHero(Hero[] players) {
//ヒーローリスト表示
Hero[] HeroList = new Hero[2];
HeroList[0] = new Paladin();
HeroList[1] = new LichKing();
for (int i = 0; i < HeroList.length; i++) {
System.out.print(i + 1 + ":" + HeroList[i].getName());
}
System.out.println();

    //ヒーロー選択
    System.out.println("\n赤の冒険者よ、ヒーローを選んでくれ");
    int c1;
    do {
        c1 = new Scanner(System.in).nextInt();
        if (c1 < 0 || c1 >= 7) {
            System.out.println("その番号は選べないぞ");
        }
    } while (c1 < 0 || c1 >= 7);
    switch (c1) {
    case 1: {
        players[1] = new Paladin();
        System.out.println(players[1].getName() + "が選択されたぞ!\n");
        break;
    }
    case 2: {
        players[1] = new LichKing();
        System.out.println(players[1].getName() + "が選択されたぞ!\n");
        break;
    }
    }
    System.out.println("\n青の冒険者よ、ヒーローを選んでくれ");
    int c2;
    do {
        c2 = new Scanner(System.in).nextInt();
        if (c2 < 0 || c2 >= 7) {
            System.out.println("その番号は選べないぞ");
        }
    } while (c2 < 0 || c2 >= 7);
    switch (c2) {
    case 1: {
        players[2] = new Paladin();
        System.out.println(players[2].getName() + "が選択されたぞ!\n");
        break;
    }
    case 2: {
        players[2] = new LichKing();
        System.out.println(players[2].getName() + "が選択されたぞ!\n");
        break;
    }
    }
}

//技選択

static void chooseSkill(Hero[] players, Skill[] skills1, Skill[] skills2) {

    ArrayList<Integer> list = new ArrayList<Integer>();

    // listに値を入れる。この段階では昇順
    for(int i = 0 ; i < 3 ; i++) {
        list.add(i);
    }
    // シャッフルして、順番を変える
    Collections.shuffle(list);

    Skill skillBox = new Skill();
    System.out.println("\n赤の冒険者よ、" + players[1].getName() + "の技が決まるぞ!");

    System.out.println();

    System.out.println("1つ目の技は");
    if (players[1].getName().equals("パラディン")) {
        switch (list.get(0)) {
        case 0: {
            skills1[1] = skillBox.new silverSlash();
            System.out.println("シルバースラッシュだ!");
            break;
        }
        case 1: {
            skills1[1] = skillBox.new ikari();
            System.out.println("怒りの鉄槌だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new goldSlash();
            System.out.println("ゴールドスラッシュだ!");
            break;
        }
        }

    } else if (players[1].getName().equals("リッチキング")) {
        switch (list.get(0)) {
        case 0: {
            skills1[1] = skillBox.new frostMourne();
            System.out.println("フロストモーンだ!");
            break;
        }
        case 1: {
            skills1[1] = skillBox.new huhai();
            System.out.println("死と腐敗だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new deathcoil();
            System.out.println("死の螺旋だ!");
            break;
        }
        }
    }

    System.out.println("2つ目の技は");
    if (players[1].getName().equals("パラディン")) {
        switch (list.get(1)) {
        case 0: {
            skills1[2] = skillBox.new silverSlash();
            System.out.println("シルバースラッシュだ!");
            break;
        }
        case 1:{
            skills1[2] = skillBox.new ikari();
            System.out.println("怒りの鉄槌だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new goldSlash();
            System.out.println("ゴールドスラッシュだ!");
            break;
        }
        }
    } else if (players[1].getName().equals("リッチキング")) {
        switch (list.get(1)) {
        case 0: {
            skills1[2] = skillBox.new frostMourne();
            System.out.println("フロストモーンだ!");
            break;
        }
        case 1: {
            skills1[2] = skillBox.new huhai();
            System.out.println("死と腐敗だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new deathcoil();
            System.out.println("死の螺旋だ!");
            break;
        }
        }
    }


    Collections.shuffle(list);

    System.out.println("\n青の冒険者よ、" + players[2].getName() + "の技が決まるぞ!");

    System.out.println();

    System.out.println("1つ目の技は");
    if (players[2].getName().equals("パラディン")) {
        switch (list.get(0)) {
        case 0: {
            skills2[1] = skillBox.new silverSlash();
            System.out.println("シルバースラッシュだ!");
            break;
        }
        case 1:{
            skills2[1] = skillBox.new ikari();
            System.out.println("怒りの鉄槌だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new goldSlash();
            System.out.println("ゴールドスラッシュだ!");
            break;
        }
        }
    } else if (players[2].getName().equals("リッチキング")) {
        switch (list.get(0)) {
        case 0: {
            skills2[1] = skillBox.new frostMourne();
            System.out.println("フロストモーンだ!");
            break;
        }
        case 1: {
            skills2[1] = skillBox.new huhai();
            System.out.println("死と腐敗だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new deathcoil();
            System.out.println("死の螺旋だ!");
            break;
        }
        }
    }
    System.out.println("2つ目の技は");
    if (players[2].getName().equals("パラディン")) {
        switch (list.get(1)) {
        case 0: {
            skills2[2] = skillBox.new silverSlash();
            System.out.println("シルバースラッシュだ!");
            break;
        }
        case 1:{
            skills2[2] = skillBox.new ikari();
            System.out.println("怒りの鉄槌だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new goldSlash();
            System.out.println("ゴールドスラッシュだ!");
            break;
        }
        }
    } else if (players[2].getName().equals("リッチキング")) {
        switch (list.get(1)) {
        case 0: {
            skills2[2] = skillBox.new frostMourne();
            System.out.println("フロストモーンだ!");
            break;
        }
        case 1: {
            skills2[2] = skillBox.new huhai();
            System.out.println("死と腐敗だ!");
            break;
        }
        case 2: {
            skills1[1] = skillBox.new deathcoil();
            System.out.println("死の螺旋だ!");
            break;
        }
        }
    }
}

}
//////////////////////////////////////////

public class Paladin extends Hero{

Paladin(){
    setId(1);
    setName("パラディン");
    setHp(800);
    setAtk(300);
    setDef(300);
    setSpd(300);
    setMgc(300);
}

}
/////////////////////////////////////////

import java.util.Scanner;

public class PlaySkill {

public static void playSkill(Hero[] players, Skill[] skills1, Skill[] skills2) {
    System.out.println("\n赤の冒険者よ、技を発動してくれ");
    System.out.println("1:"+skills1[1].getName()+" 2:"+skills1[2].getName());
    int c1;
    do {
        c1 = new Scanner(System.in).nextInt();
        switch (c1) {
        case 1: {
            players[1].skill = skills1[1];
            break;
        }
        case 2: {
            players[1].skill = skills1[2];
            break;
        }
        }
        if (skills1[c1].getType() == 2 && players[1].getMp() < skills1[c1].getmCost()) {
            System.out.println("MPが足りない!");
        }
    } while (skills1[c1].getType() == 0 || (skills1[c1].getType() == 2 && players[1].getMp() < skills1[c1].getmCost()));

    System.out.println("\n青の冒険者よ、技を発動してくれ");
    System.out.println("1:"+skills2[1].getName()+" 2:"+skills2[2].getName());
    int c2;
    do {
        c2 = new Scanner(System.in).nextInt();
        switch (c2) {
        case 1: {
            players[2].skill = skills2[1];
            break;
        }
        case 2: {
            players[2].skill = skills2[2];
            break;
        }
        }
        if (skills2[c2].getType() == 2 && players[2].getMp() < skills2[c2].getmCost()) {
            System.out.println("MPが足りない!");
        }
    } while (skills2[c2].getType() == 0 || (skills2[c2].getType() == 2 && players[2].getMp() < skills2[c2].getmCost()));
}

}
////////////////////////////////////////////////

public class Skill {

private String name;
private int damage;
private int mDamage;
private int mCost;
private int type;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public int getDamage() {
    return damage;
}

public void setDamage(int damage) {
    this.damage = damage;
}

public int getmDamage() {
    return mDamage;
}

public void setmDamage(int mDamage) {
    this.mDamage = mDamage;
}

public int getmCost() {
    return mCost;
}

public void setmCost(int mCost) {
    this.mCost = mCost;
}

public int getType() {
    return type;
}

public void setType(int type) {
    this.type = type;
}


public class silverSlash extends Skill {
    silverSlash() {
        setName("シルバースラッシュ");
        setDamage(50);
        setType(1);
    }
}

public class ikari extends Skill {
    ikari() {
        setName("怒りの鉄槌");
        setmDamage(100);
        setmCost(300);
        setType(2);
    }
}

public class goldSlash extends Skill {
    goldSlash() {
        setName("ゴールドスラッシュ");
        setDamage(100);
        setType(1);
    }
}

public class frostMourne extends Skill {
    frostMourne() {
        setName("フロストモーン");
        setDamage(100);
        setType(1);
    }
}
public class huhai extends Skill {
    huhai() {
        setName("死と腐敗");
        setmDamage(500);
        setmCost(200);
        setType(2);
    }
}

public class deathcoil extends Skill {
    deathcoil() {
        setName("死の螺旋");
        setDamage(150);
        setType(1);
    }
}

}