Beispiel #1
0
  protected boolean wet(int x, int y, Tools tools, World world) {
    return !tools
        .getDirVisitor()
        .visitWhile(
            x,
            y,
            (Element element, int nX, int nY) -> {
              if (element instanceof Water && !(element instanceof SaltWater)) {
                if (SALT_RATIO.nextBoolean()) {
                  // sůl mizí
                  world.setAndChange(x, y, saltWaterFactory.apply(this));
                  world.setAndChange(nX, nY, world.getBackground());
                  world.setTemperature(nX, nY, World.DEFAULT_TEMPERATURE);

                } else {
                  // sůl zůstává
                  world.setAndChange(nX, nY, saltWaterFactory.apply(this));
                }
                return false;
              }
              return true;
            },
            tools.randomDirection());
  }
Beispiel #2
0
  @Override
  public boolean testAction(int x, int y, Tools tools, World world) {
    return tools.testTemperature(x, y) || super.testAction(x, y, tools, world);

    // testovat přítomnost vody je zbytečné
  }
Beispiel #3
0
 @Override
 public boolean testAction(int x, int y, Tools tools, World world) {
   return tools.testTemperature(x, y) || super.testAction(x, y, tools, world);
 }