/* 
 * Autor: Piotr Wyczesany
 *       AGH Informatyka rok II grupa 6  
 */
package edu.agh.pwyczesa.sokoban.pola;

import java.awt.Graphics;
import java.awt.Image;
import edu.agh.pwyczesa.sokoban.gra.Plansza;

/**
 * Klasa odpowiedzialna za reprezentacje diamentu.
 
 @author <a href="mailto:calvo2k1@op.pl">Piotr Wyczesany (Calvo)</a>
 @version 1.0 
 */
public class Diament extends Pole {
  private boolean jestNaCelu;
  
  /**
   * Konstruktor diamentu.
   
   @param i pozycja pozioma w tablicy pol
   @param j pozycja pionowa w tablicy pol
   @param xMMax maksymalna liczba pol w poziomie
   @param yMMax maksymalna liczba pol w pionie
   @param xPlansza rozmiar planszy w pixelach
   @param yPlansza rozmiar planszy w pixelach
   @param im obrazek z ktorego czytana jest grafika
   @param jNC flaga okreslajaca, czy diament jest na celu, czy nie
   */
  public Diament(int i, int j, int xMMax, int yMMax,
  int xPlansza, int yPlansza, Image im, boolean jNC) {
    this.xPos = i;
    this.yPos = j;
    this.xMapaMax = xMMax;
    this.yMapaMax = yMMax;
    this.xPlanszaMax = xPlansza;
    this.yPlanszaMax = yPlansza;
    this.image = im;
    this.jestNaCelu = jNC;
  }
  
  /**
   * Metoda sprawdzajaca, czy diament jest na celu.
   
   @return true lub false, w zaleznosci od tego, czy diament jest na celu,
   * czy nie
   @see Diament#setIsNaCelu
   */
  public boolean isNaCelu() {
    if (jestNaCelureturn true;
    else return false;
  }
  
  /**
   * Metoda ustalajaca, czy diament jest na celu.
   
   @param b flaga okreslajaca, czy diament jest na celu
   @see Diament#isNaCelu
   */
  public void setIsNaCelu(boolean b) {
    this.jestNaCelu = b;
  }
  
  /**
   * Metoda rysujaca diament.
   
   @param g kontekst graficzny
   */
  public void draw(Graphics g) {
    this.xDraw = (int)(((20 - xMapaMax)/+ xPos)*30 ((xPlanszaMax - (30 * Plansza.MAX_X)) 2));
    this.yDraw = (int)(((15 - yMapaMax)/+ yPos)*30 ((yPlanszaMax - (30 * Plansza.MAX_Y)) 2));
    if (this.jestNaCelu
      g.drawImage(image,xDraw,yDraw,xDraw+30,yDraw+30,
      0,60,30,90,null);
    else 
      g.drawImage(image,xDraw,yDraw,xDraw+30,yDraw+30,
      30,60,60,90,null);
  };
  
  /**
   * Metoda poruszajaca diamentem w dol.
   @see Diament#ruchWGore
   @see Diament#ruchWLewo
   @see Diament#ruchWPrawo
   */
  public void ruchWDol() { this.yPos++; };
  
  /**
   * Metoda poruszajaca diamentem w gore.
   @see Diament#ruchWDol
   @see Diament#ruchWLewo
   @see Diament#ruchWPrawo
   */
  public void ruchWGore() { this.yPos--; };
  
  /**
   * Metoda poruszajaca diamentem w lewo.
   @see Diament#ruchWDol
   @see Diament#ruchWGore
   @see Diament#ruchWPrawo
   */
  public void ruchWLewo() { this.xPos--; };
  
  /**
   * Metoda poruszajaca diamentem w prawo.
   @see Diament#ruchWDol
   @see Diament#ruchWGore
   @see Diament#ruchWLewo
   */
  public void ruchWPrawo() { this.xPos++; };
}
Java2html