package com.mycompany;

public class Main {
    public static void main(String[] args) {
        System.out.println("Let's get it started!");
        Turn t1;
        Turn t2;
        do {
            t1 = Turn.random();
            System.out.printf("Игрок 1 выбирает %s%n", t1.definition);
            t2 = Turn.random();
            System.out.printf("Игрок 2 выбирает %s%n", t2.definition);
            if (t1 == t2) {
                System.out.println("Ничья, повтор хода!");
            }
        } while (t1 == t2);
        if (Math.abs(t1.order - t2.order) == 2) {
            if (t1.order < t2.order) {
                t2.order -= 3;
            } else {
                t1.order -= 3;
            }
        }
        System.out.println(t1.order < t2.order ? "Игрок 1 побеждает!" : "Игрок 2 побеждает!");
    }

    private enum Turn {
        ROCK(0, "Камень"),
        SCISSORS(1, "Ножницы"),
        PAPER(2, "Бумага");
        int order;
        String definition;
        Turn(int order, String definition) {
            this.order = order;
            this.definition = definition;
        }
        public static Turn random() {
            switch ((int)(Math.random() * 3)) {
                case 0: return ROCK;
                case 1: return SCISSORS;
                default: return PAPER;
            }
        }
    }
}
