Beispiel #1
0
  private void inicializacaoJogo(Jogador jogador1, Jogador jogador2, Tabuleiro tabuleiro)
      throws InterruptedException {
    tabuleiro.instanciaTodasAsPecas();
    Set<Peca> todasAsPecas = tabuleiro.getTodasAsPecas();
    DominoUtil.misturaPecas(todasAsPecas);
    Thread.sleep(1000);

    DominoUtil.distribuiPecas(jogador1, jogador2, todasAsPecas);
    Thread.sleep(1000);
  }
  @Override
  public Peca joga(Tabuleiro tabuleiro) {

    Peca retorno = null;

    int i = 0;
    boolean achouJogada = false;
    while (i < getQuantPecas() && !achouJogada) {

      Peca peca = getPeca(i);
      if (tabuleiro.adicionaPecaEsquerdaTabuleiro(peca)
          || tabuleiro.adicionaPecaDireitaTabuleiro(peca)) {
        achouJogada = true;
        retorno = peca;
        removePeca(i);
      }

      i++;
    }

    return retorno;
  }
Beispiel #3
0
 private void impimeTabuleiro(Tabuleiro tabuleiro, Graphics g) {
   int x = 20;
   int y = 340;
   int i = 0;
   for (Peca peca : tabuleiro.getPecasJogadas()) {
     i++;
     if (i == 15) {
       ImageIcon image = new ImageIcon(peca.getImagemTabuleiroDeitado());
       image.paintIcon(this, g, x, y);
       y += 80;
       x -= 40;
     } else if (i < 15) {
       ImageIcon image = new ImageIcon(peca.getImagemTabuleiro());
       image.paintIcon(this, g, x, y);
       x += 80;
     } else {
       ImageIcon image = new ImageIcon(peca.getImagemTabuleiroInvertido());
       image.paintIcon(this, g, x, y);
       x -= 80;
     }
   }
 }