Esempio n. 1
1
  @Override
  public void useMineDetectorToGivenDirection(Direction direction) {
    final Point result = getCellPossiblePosition(direction);
    if (cells.contains(result)) {
      if (sapper.isEmptyCharge()) {
        return;
      }

      if (isFlag.contains(result)) {
        return;
      }

      sapper.tryToUseDetector(
          new DetectorAction() {
            @Override
            public void used() {
              isFlag.add(result);
              if (getMines().contains(result)) {
                removeMine(result);
              } else {
                fire(MinesweeperEvents.FORGET_CHARGE);
              }
            }
          });

      if (isEmptyDetectorButPresentMines()) {
        openAllBoard();
        fire(MinesweeperEvents.NO_MORE_CHARGE);
      }
    }
  }
Esempio n. 2
0
 @Override
 public boolean isEmptyDetectorButPresentMines() {
   return getMines().size() != 0 && sapper.isEmptyCharge();
 }