PieceFactory.java :  » Game » pathboardgame » gameLogic » board » Java Open Source

Java Open Source » Game » pathboardgame 
pathboardgame » gameLogic » board » PieceFactory.java
package gameLogic.board;

import gameLogic.board.piece.Piece;

public class PieceFactory {
  
  private static int idGen = 0;
  
  public static Piece getTopStrongPiece(final Board board){
    int id = 1;
    final boolean isTopPiece = true;
    while(!board.getStrongPiece(id, isTopPiece).isEmpty()){
      id ++;
    }
    return Piece.getTopStrongPiece(id);
  }
  
  public static Piece getTopStrongPiece(final int forceId){
    return Piece.getTopStrongPiece(forceId);
  }
  
  public static Piece getTopWeakPiece(){
    return Piece.getTopWeakPiece(genId());
  }
  
  private static int genId() {
    return idGen++;
  }

  public static Piece getBottomStrongPiece(final Board board){
    int id = 1;
    final boolean isTopPiece = false;
    while(!board.getStrongPiece(id, isTopPiece).isEmpty()){
      id ++;
    }
    return Piece.getBottomStrongPiece(id);
  }
  
  public static Piece getBottomStrongPiece(final int forceId){
    return Piece.getBottomStrongPiece(forceId);
  }
  
  public static Piece getBottomWeakPiece(){
    return Piece.getBottomWeakPiece(genId());
  }
  
  public static Piece getEmptyPiece(){
    return Piece.getEmptyPiece();
  }
  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.