congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ch.sahits.game.openpatrician.model.people
Code IndexAdd Tabnine to your IDE (free)

How to use ch.sahits.game.openpatrician.model.people

Best Java code snippets using ch.sahits.game.openpatrician.model.people (Showing top 20 results out of 315)

origin: ch.sahits.game/OpenPatricianClientServerInterface

/**
 * A non free pirate becomes free.
 * @param pirate non free pirate instance that is to be freed.
 */
public void free(INonFreeSeaPirate pirate) {
  ISeaPirate freePirate = createNewPirate(pirate.getName(), pirate.getShip());
  ((DependentAnnotationConfigApplicationContext)context).removePrototypeBean(pirate);
  piratesState.replace(pirate, freePirate);
}
origin: ch.sahits.game/OpenPatricianDisplay

  @Override
  protected String computeValue() {
    if (sailorState.getNumberOfSailors() > 1) {
      return messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernSailorDialog.dialog1", new Object[]{ sailorState.getNumberOfSailors()}, locale.getCurrentLocal());
    } else if (sailorState.getNumberOfSailors() == 1) {
      return messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernSailorDialog.dialog2", new Object[]{}, locale.getCurrentLocal());
    } else {
      return messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernSailorDialog.dialog3", new Object[]{}, locale.getCurrentLocal());
    }
  }
};
origin: ch.sahits.game/OpenPatricianDisplay

public BuyWares(ICityPlayerProxyJFX cityPlayerProxy, IBuyer buyer) {
  super();
  setExecutionTime(buyer.getTimeFrame());
  player = cityPlayerProxy.getPlayer();
  city = cityPlayerProxy.getCity();
  amountable = buyer.getAmountablePrice();
  ware = buyer.getWare();
}
origin: ch.sahits.game/OpenPatricianGameEvent

  public ShipEntersPortEvent(INavigableVessel ship, ICity city) {
    this.ship = ship;
    this.city = city;
    Preconditions.checkArgument(ship.getLocation().equals(city.getCoordinates()), "The ship "+ship.getName()+" of "+ship.getOwner().getName() +" "+ship.getOwner().getLastName()+" is not in city "+city.getName());
  }
}
origin: ch.sahits.game/OpenPatricianEngine

@VisibleForTesting
double calculateAccuracy(List<IShip> shipsOnTurn) {
  double accuracy = 0.7;
  double captainAccuracy = 0;
  int nbCaptains = 0;
  for (IShip ship : shipsOnTurn) {
    if (ship.getCaptian().isPresent()) {
      nbCaptains++;
      captainAccuracy += ship.getCaptian().get().getFightSkillLevel();
    }
  }
  if (nbCaptains > 0) {
    captainAccuracy = captainAccuracy / (nbCaptains*10.0);
  }
  return accuracy + captainAccuracy;
}
origin: ch.sahits.game/OpenPatricianEngine

@Subscribe
public void handleDayChange(ClockTickDayChange event) {
  for (Entry<ICity, TavernState> entry : cities.entrySet()) {
    ICity city = entry.getKey();
    TavernState state = entry.getValue();
    int nbSailors = computeNumbersOfSailors(city);
    state.getSailors().setNumberOfSailors(nbSailors);
    handlePersonsBecomingAbsent(state);
    handlePersonsBecomingPresent(city, state);
  }
}
/**
origin: ch.sahits.game/OpenPatricianEngine

}    /**
 * Select a new destination for the pirate.
 * @param pirate free sea pirate
 */
private void selectDestination(ISeaPirate pirate) {
  Point2D destination;
  if (pirate instanceof INonFreeSeaPirate && ((INonFreeSeaPirate) pirate).roamingNearCity().isPresent()) {
    ICity city = ((INonFreeSeaPirate) pirate).roamingNearCity().get();
    destination = mapService.getRandomPointAtSeaNear(city.getCoordinates());
  } else {
    destination = mapService.getLocationAtOtherEndOfMap(pirate.getShip().getLocation());
  }
  // make sure that the source of the pirate location is in the graph
  Point2D adjustedDestination = aStarHeuristicProvider.findClosest(destination);
  aStarHeuristicProvider.addTargetNodeToHeuristic(adjustedDestination);
  logger.debug("Source point of pirate is {}", pirate.getShip().getLocation());
  seafaringService.travelNotBetweenCities(pirate.getShip(), adjustedDestination);
}
origin: ch.sahits.game/OpenPatricianEngine

@VisibleForTesting
int calculateAgility(IShip ship) {
  int agility = shipFactory.getShipSpeed(ship.getShipType());
  if (ship.getCaptian().isPresent()) {
    ICaptain captain = ship.getCaptian().get();
    agility += (int)Math.rint(captain.getNavigationSkillLevel() * 0.7);
  }
  return agility;
}
origin: ch.sahits.game/OpenPatricianDisplay

  @Override
  protected boolean computeValue() {
    Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity());
    IShip ship = null;
    if (city.getActiveShip() instanceof IShip) {
      ship = (IShip) city.getActiveShip();
    }
    int barrelAmountFactor = 1;
    if (!trader.getWare().isBarrelSizedWare()) {
      barrelAmountFactor = 10;
    }
    return optOffice.isPresent() && ship == null && ship.getCapacity() < trader.getAmount() * barrelAmountFactor;
  }
};
origin: ch.sahits.game/OpenPatricianDisplay

public IntegerBinding sellPriceBinding(final EWeapon weapon, final IntegerBinding amountToSell) {
  return new IntegerBinding() {
    {
      super.bind(weaponsDealer.amountAvailableProperty(weapon), amountToSell);
    }
    @Override
    protected int computeValue() {
      if (amountToSell.get() > 0) {
        int availableAmount = weaponsDealer.amountAvailableProperty(weapon).getValue(); // that should be the amount of the dealer
        return computablePrice.sellPrice(weapon, new SimpleIntegerProperty(availableAmount), amountToSell);  // amountToSell is the amount stored on ship/office
      } else {
        return 0;
      }
    }
  };
}
origin: ch.sahits.game/OpenPatricianDisplay

  @Override
  public void run() {
    if (player instanceof IHumanPlayer) {
      player.getCompany().updateCash(tenant.getRentPerWeek());
    } else {
      player.getCompany().updateCashDirectly(tenant.getRentPerWeek());
    }

  }
}
origin: ch.sahits.game/OpenPatricianDisplay

  @Override
  protected boolean computeValue() {
    ITransportTrader trader = (ITransportTrader) currentPerson.get();
    return tavernDialogUtil.noShipWithEnoughCapacityAvailable(city, trader.getNeededCapacity());
  }
};
origin: ch.sahits.game/OpenPatricianDisplay

  @Override
  protected boolean computeValue() {
    ISmuggler smuggler = (ISmuggler) currentPerson.get();
    return tavernDialogUtil.noShipWithEnoughCapacityAvailable(city, smuggler.getAmount()/10);
  }
};
origin: ch.sahits.game/OpenPatricianDisplay

  @Override
  public void run() {
    clientEventBus.post(new DisplayMessage("ch.sahits.game.openpatrician.display.dialog.TavernWarehouseTenantDialog.acceptMessage"));
    office.setOccupiedSpace(office.getOccupiedSpace() - tenant.getAmount());

  }
}
origin: ch.sahits.game/OpenPatricianDisplay

@Override
protected EventHandler<MouseEvent> createAcceptHandler() {
  return mouseEvent -> {
    try {
      final IBuyer buyer = (IBuyer) currentPerson.get();
      timedTaskList.add(taskFactory.getBuyWares(city, buyer));
      buyer.leave();
      executeOnCloseButtonClicked();
    } catch (RuntimeException e) {
      logger.error("Failed to accept buyers offer", e);
    }
  };
}
origin: ch.sahits.game/OpenPatricianEngine

/**
 * Handle the even when a new pirate becomes available.
 * @param pirateEvent new pirate emerged
 */
@Subscribe
public void handleNewPirate(NewPirateEvent pirateEvent) {
  IShip ship = (IShip) pirateEvent.getPirate().getShip();
  Point2D adjustedSource = aStarHeuristicProvider.findClosest(ship.getLocation());
  ship.setLocation(adjustedSource);
  selectDestination(pirateEvent.getPirate());
}
origin: ch.sahits.game/OpenPatricianEngine

@VisibleForTesting
double calculatePropSurvivingAttack(IShip attackingShip, IShip defendingShip) {
  double captainCapabilities = 1;
  if (attackingShip.getCaptian().isPresent()) {
    captainCapabilities -= attackingShip.getCaptian().get().getFightSkillLevel() * 0.1;
  }
  if (defendingShip.getCaptian().isPresent()) {
    captainCapabilities += defendingShip.getCaptian().get().getFightSkillLevel() * 0.1;
  }
  return Math.min(Math.abs(rnd.nextGaussian()) * captainCapabilities, 1);
}
origin: ch.sahits.game/OpenPatricianEngine

public void addCity(TavernState state, ICity city) {
  cities.put(city, state);
  int nbSailors = computeNumbersOfSailors(city);
  final ISailorState sailors = state.getSailors();
  sailors.setNumberOfSailors(nbSailors);
  handlePersonsBecomingAbsent(state);
  handlePersonsBecomingPresent(city, state);
}
origin: ch.sahits.game/OpenPatricianDisplay

  @Override
  protected int computeValue() {
    if (amountToSell.get() > 0) {
      int availableAmount = weaponsDealer.amountAvailableProperty(weapon).getValue(); // that should be the amount of the dealer
      return computablePrice.sellPrice(weapon, new SimpleIntegerProperty(availableAmount), amountToSell);  // amountToSell is the amount stored on ship/office
    } else {
      return 0;
    }
  }
};
origin: ch.sahits.game/OpenPatricianEngine

@VisibleForTesting
int calculateShipStrength(IShip ship) {
  int strength = shipStrenghtService.calculateShipsWeaponsStrength(ship);
  if (ship.getCaptian().isPresent()) {
    ICaptain captain = ship.getCaptian().get();
    strength += captain.getFightSkillLevel()*2;
  }
  return strength;
}
ch.sahits.game.openpatrician.model.people

Most used classes

  • ICaptain
  • IShipOwner
  • CaptainsState
  • SeaPiratesState
  • IBuyer
  • ICourier,
  • IInformant,
  • INonFreeSeaPirate,
  • IPatrol,
  • IPirate,
  • IPirateHunter,
  • ISailorState,
  • ISeaPirate,
  • ISmuggler,
  • ITrader,
  • ITransportTrader,
  • ITreasureMapOwner,
  • IWarehouseTenant,
  • SeaPirate
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now