package User;

import java.io.*;

public class Main
{
    static Person person = new Person();
    static Enemy enemy = new Enemy();

    public static void main(String[] args) throws IOException, InterruptedException {
        System.out.println("==========================");
        System.out.println("Введите имя Вашего киборга:");

        Person.setName();

        System.out.println();

        System.out.println("Выберите тип (введите цифру):");
        System.out.println("1. КРАБ. Сильная защита, слабая атака, средняя удача.");
        System.out.println("2. ПОЛИП. Средняя защита, сильная атака, слабая удача.");
        System.out.println("3. ДРОН. Слабая защита, средняя атака, большая удача.");

        Person.setType();
        person.setParametres();

        System.out.println();
        System.out.println("==========================");
        System.out.println();
        System.out.println("Вашего киборга зовут " + Person.name);

        if (Person.type == 1) System.out.println("Тип Вашего киборга: КРАБ.");
        else if (Person.type == 2) System.out.println("Тип Вашего киборга: ПОЛИП.");
        else if (Person.type == 3) System.out.println("Тип Вашего киборга: ДРОН.");

        System.out.println("Сила атаки: " + Person.strength);
        System.out.println("Защитное поле: " + Person.defense);
        System.out.println("Удачливость: " + Person.lucky);

        System.out.println();
        System.out.println("==========================");
        System.out.println();

        int i;

        System.out.println("Подбираем врага.");
        System.out.println();
        System.out.print("Инверсия гвоздей");
        for (i = 0; i < 3; i++)
        {
            Thread.sleep(1000);
            System.out.print(".");
        }
        Thread.sleep(1000);

        Enemy.setName();

        System.out.println();
        System.out.print("Реинкарнация будильника");
        for (i = 0; i < 3; i++)
        {
            Thread.sleep(1000);
            System.out.print(".");
        }
        Thread.sleep(1000);

        enemy.setType();

        System.out.println();
        System.out.print("Изменение узоров");
        for (i = 0; i < 3; i++)
        {
            Thread.sleep(1000);
            System.out.print(".");
        }
        Thread.sleep(1000);

        Enemy.setParametres();

        System.out.println();
        System.out.println();
        System.out.println("==========================");
        System.out.println();
        System.out.println("Вашего врага зовут " + Enemy.name);

        if (Enemy.type == 1) System.out.println("Тип Вашего врага: КРАБ.");
        else if (Enemy.type == 2) System.out.println("Тип Вашего врага: ПОЛИП.");
        else if (Enemy.type == 3) System.out.println("Тип Вашего врага: ДРОН.");

        System.out.println("Сила атаки: " + Enemy.strength);
        System.out.println("Защитное поле: " + Enemy.defense);
        System.out.println("Удачливость: " + Enemy.lucky);
        System.out.println("==========================");

        Fight.fighting();

        System.out.println();
        System.out.println("==========================");
        System.out.println("==========================");
        System.out.println();

        if (Person.defense > Enemy.defense)
            System.out.println("Победил " + Person.name);
        else System.out.println("Победил " + Enemy.name);

    }

}

 

package User;

import java.io.*;

public class Person
{


    public static String name;
    public static int type;
    public static int strength, defense, lucky;

    public static String setName() throws IOException
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Person.name = reader.readLine();
        return name;
    }


    public static int setType() throws IOException
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        while (true)
        {
            Person.type = Integer.parseInt(reader.readLine());
            if (Person.type == 1 || Person.type == 2 || Person.type == 3) break;
            else System.out.println("Попробуйте ещё раз. Введите цифру от 1 до 3.");
        }
        return type;
    }

    public void setParametres()
    {
        if (type == 1)
        {
            defense = 300 + (int)(Math.random() * (200) + 1);
            strength = 10 + (int)(Math.random() * (20) + 1);
            lucky = 2 + (int)(Math.random() * (2) + 1);
        }
        else if (type == 2)
        {
            defense = 200 + (int)(Math.random() * (200) + 1);
            strength = 30 + (int)(Math.random() * (20) + 1);
            lucky = 1 + (int)(Math.random() * (2) + 1);
        }
        else if (type == 3)
        {
            defense = 100 + (int)(Math.random() * (200) + 1);
            strength = 20 + (int)(Math.random() * (20) + 1);
            lucky = 3 + (int)(Math.random() * (2) + 1);
        }
    }
}

 

package User;

public class Enemy {

    public static String name;
    public static int type;
    public static int strength, defense, lucky;

    public static void setName()
    {
        String[] names = {"Робокоп", "Терминатор", "iCub", "Ибн Сина", "Генерал Гривус", "Люк Скайвокер", "Адептус Механикус", "Мегадред", "Убейбанк", "Борг",};

        int namesRandom = (int)(Math.random() * 10);
        name = names[namesRandom];
    }

    public void setType()
    {
        type = (int)(Math.random() * 3) + 1;
    }

    public static void setParametres()
    {
        if (type == 1)
        {
            defense = 300 + (int)(Math.random() * (200) + 1);
            strength = 10 + (int)(Math.random() * (20) + 1);
            lucky = 2 + (int)(Math.random() * (2) + 1);
        }
        else if (type == 2)
        {
            defense = 200 + (int)(Math.random() * (200) + 1);
            strength = 30 + (int)(Math.random() * (20) + 1);
            lucky = 1 + (int)(Math.random() * (2) + 1);
        }
        else {
            if (type == 3) {
                defense = 100 + (int) (Math.random() * (200) + 1);
                strength = 20 + (int) (Math.random() * (20) + 1);
                lucky = 3 + (int) (Math.random() * (2) + 1);
            }
        }
    }
}

 

package User;

import java.io.*;

public class Fight {

    static int i = 0;
    static int j;

    public static void fighting() throws IOException, InterruptedException {
        System.out.println("Если Вы готовы сразиться, нажмите ENTER");

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            if (reader.readLine().equals("")) break;
            System.out.println("Просто нажмите ENTER.");
        }

        while (true) {
            if (Person.defense > 0 && Enemy.defense > 0)
                fightingProcess();
            else break;
        }
    }

    private static void fightingProcess() throws InterruptedException {
        switch (i) {
            case 0:
                i = 1;
                j = Person.strength / 3 * (Person.lucky / 2) + (int) (Math.random() * (Person.lucky) + 1);
                Enemy.defense -= j;
                System.out.print(Person.name + " ударил " + Enemy.name + " и отнял у него " + j + " очков защиты. ");
                if (Enemy.defense < 0)
                System.out.println("У " + Enemy.name + ": 0");
                else System.out.println(Enemy.name + ": " + Enemy.defense);
                Thread.sleep(1000);
                break;
            case 1:
                i = 0;
                j = Enemy.strength / 3 * (Enemy.lucky / 2) + (int) (Math.random() * (Enemy.lucky) + 1);
                Person.defense -= j;
                System.out.print(Enemy.name + " ударил " + Person.name + " и отнял у него " + j + " очков защиты. ");
                if (Person.defense < 0) System.out.println("У " + Person.name + " осталось 0");
                else System.out.println(Person.name + ": " + Person.defense);
                Thread.sleep(1000);
        }
    }
}