package org.Controllers;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import org.Models.Direction;
import org.Models.Jeu;

public class IO implements KeyListener {

    private Jeu jeu;

    public IO(Jeu jeu) {
        this.jeu = jeu;
    }

    @Override
    public void keyPressed(KeyEvent e) {
        if (jeu.getGrille().estEnPause()){
            System.err.println("Grille est en pause");
            return;
        }
        switch (e.getKeyCode()) {
            case KeyEvent.VK_DOWN:
                jeu.getGrille().deplacerPiece(Direction.BAS);
                break;

            case KeyEvent.VK_LEFT:
                jeu.getGrille().deplacerPiece(Direction.GAUCHE);
                break;

            case KeyEvent.VK_RIGHT:
                jeu.getGrille().deplacerPiece(Direction.DROITE);
                break;

            case KeyEvent.VK_SPACE:
                jeu.getGrille().deplacerPiece(Direction.TOUTENBAS);

            default:
                break;
        }
    }

    @Override
    public void keyTyped(KeyEvent e) {
    }

    @Override
    public void keyReleased(KeyEvent e) {
    }
}
