package cicaprojekt;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class Control {
    public static class KeyHandler extends KeyAdapter{
        @Override
        public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            c = Character.toUpperCase(c);
            switch(c) {
                case 'W' :
                    Game.instance.moveONeill(Direction.NORTH);
                    break;
                case 'A' :
                    Game.instance.moveONeill(Direction.WEST);
                    break;
                case 'S' :
                    Game.instance.moveONeill(Direction.SOUTH);
                    break;
                case 'D' :
                    Game.instance.moveONeill(Direction.EAST);
                    break;
                case 'Y' :
                    Game.instance.rotateOneillLeft();
                    break;
                case 'X' :
                    Game.instance.rotateOneillRight();
                    break;
                case 'I' :
                    Game.instance.moveJaffa(Direction.NORTH);
                    break;
                case 'J' :
                    Game.instance.moveJaffa(Direction.WEST);
                    break;
                case 'K' :
                    Game.instance.moveJaffa(Direction.SOUTH);
                    break;
                case 'L' :
                    Game.instance.moveJaffa(Direction.EAST);
                    break;
                case 'M' :
                    Game.instance.rotateJaffaLeft();
                    break;
                case ',' :
                    Game.instance.rotateJaffaRight();
                    break;
                case 'Q' :
                    Game.instance.boxONeill();
                    break;
                case 'U' :
                    Game.instance.boxJaffa();
                    break;
                case 'E' :
                    Game.instance.shootStargate(Color.YELLOW);
                    break;
                case 'R' :
                    Game.instance.shootStargate(Color.BLUE);
                    break;
                case 'O' :
                    Game.instance.shootStargate(Color.RED);
                    break;
                case 'P' :
                    Game.instance.shootStargate(Color.GREEN);
                    break;
            }
            Game.instance.updateDisplay();
        }
    }

    public static void ioErrorMessage(){
        JOptionPane.showMessageDialog(null, "Nem sikerült betölteni a dzidzás képeket :( ! Biztos a helyükön vannak?");
    }
}
