package h03;

import fopbot.World;
import h03.robots.DoublePowerRobot;
import h03.robots.HackingRobot;
import h03.robots.MovementType;
import h03.robots.VersatileRobot;

import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Main entry point in executing the program.
 */
public class Main {
    /**
     * Main entry point in executing the program.
     *
     * @param args program arguments, currently ignored
     */
    public static void main(String[] args) {
        // Create a 5x5 world and make it visible
        World.setSize(5, 5);
        World.setVisible(true);

        var haxxor = new HackingRobot(3, 2, true);
        var olaf = new HackingRobot(1, 4, false);

        var versi = new VersatileRobot(4, 3, true, false);
        while (versi.getType() != MovementType.DIAGONAL)  {
            versi = new VersatileRobot(4, 3, true, false);
        }

        var doubleTrouble1 = new DoublePowerRobot(2, 1, true);
        var doubleTrouble2 = new DoublePowerRobot(2, 1, false);
        var doubleTrouble3 = new DoublePowerRobot(2, 3, true);

        var set = Stream.of(doubleTrouble1, doubleTrouble2, doubleTrouble3)
            .flatMap(x -> Stream.of(x.getType(), x.getNextType()))
            .collect(Collectors.toSet());
        while (set.size() < 3) {
            doubleTrouble1 = new DoublePowerRobot(2, 1, true);
            doubleTrouble2 = new DoublePowerRobot(2, 1, false);
            doubleTrouble3 = new DoublePowerRobot(2, 3, true);

            set = Stream.of(doubleTrouble1, doubleTrouble2, doubleTrouble3)
                .flatMap(x -> Stream.of(x.getType(), x.getNextType()))
                .collect(Collectors.toSet());
        }

        var challenge = new RobotsChallenge(0, 4, doubleTrouble1, doubleTrouble2, doubleTrouble3);
        System.out.println(Arrays.deepToString(challenge.findWinners()));
    }
}
