@PostConstruct private void initialize() { taskList.add(this); }
@PostConstruct private void initialize() { taskList.add(this); }
private void scheduleNextDayUpdate() { taskList.add(taskFactory.getDailyAIPlayerCheck()); } }
private void scheduleNextWeekUpdate() { taskList.add(taskFactory.getWeeklyLoanerCheck()); } }
private void scheduleNextWeekUpdate() { taskList.add(taskFactory.getWeeklyCityCheck()); } }
private void scheduleNextDayUpdate() { taskList.add(taskFactory.getPeriodicalDailyUpdateTask()); }
@PostConstruct private void init() { clientServerEventBus.register(this); taskList.add(taskFactory.getWeeklyLoanerCheck()); } @PreDestroy
@PostConstruct private void initialize() { setExecutionTime(date.getCurrentDate().plusDays(20)); timedUpdatableTaskList.add(this); }
@PostConstruct private void initializeEventBus() { setExecutionTime(date.getCurrentDate().plusDays(10)); clientServerEventBus.register(this); list.add(this); }
@PostConstruct public void initialize() { numberOfTicks = WARE_UPDATES_MINUTES/date.getTickUpdate(); clientServerEventBus.register(this); timerEventBus.register(this); taskList.add(taskFactory.getWeeklyCityCheck()); }
@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); } }; }
private void voteOnPetition(ICityHall cityHall) { LocalDateTime now = date.getCurrentDate(); ICityPetition petition = cityHall.getPetition().get(); Ballot result = new Ballot(petition); ((CityHall)cityHall).setBallotResult(Optional.of(result)); List<ICitizen> councilmen = cityHall.getCouncilmen(); int votingTimeFrame = 18*60; for (ICitizen citizen : councilmen) { if (citizen instanceof IHumanPlayer) { // Human player should vote themselves continue; } LocalDateTime executionTime = now.plusMinutes(rnd.nextInt(votingTimeFrame)); int random = rnd.nextInt(100); int limit = getLimit(cityHall, petition); boolean yes = random <= limit; VoteTask task = engineFactory.getVoteTask(yes, executionTime, result); timedTaskListener.add(task); } }
@Override public void handleMarriageEvent(IAIPlayer player, MarriageBrokerAnnouncementState state) { IAIEventDecisionStrategy strategy = player.getEventDecitionStrategyType().getStrategy(); if (!player.getSpouseData().isPresent() && strategy.acceptMarriagBrokereOffer(player)) { int delay = rnd.nextInt(50) + 24; LocalDateTime deadLine = state.getDate().plusDays(delay); MarriageOfferTask task = taskFactory.getMarriageOfferTask(player, state, deadLine); logger.debug("Add marriage offer task for {} {}", player.getName(), player.getLastName()); taskList.add(task); eventState.setMarriageState(player, EEventState.MARRIAGE_UNDER_CONSIDERATION); } }
private void voteOnViolation(ICityHall cityHall) { LocalDateTime now = date.getCurrentDate(); ICityViolation violation = cityHall.getAldermanOffice().get().getViolation().get(); Ballot result = new Ballot(violation); ((CityHall)cityHall).setBallotResult(Optional.of(result)); int votingTimeFrame = 18*60; for (ICity city : map.getCities()) { ICityHall ch = cityHallAccessor.getCityHall(city); ICitizen mayor = ch.getMayor(); if (mayor instanceof IHumanPlayer) { // Human player should vote themselves continue; } LocalDateTime executionTime = now.plusMinutes(rnd.nextInt(votingTimeFrame)); int random = rnd.nextInt(100); int limit = getLimit(city, violation); boolean yes = random <= limit; VoteTask task = engineFactory.getVoteTask(yes, executionTime, result); timedTaskListener.add(task); } }
@Subscribe public void handleWeeklyUpdate(PeriodicalTimeWeekEndUpdate event) { // check if an upgrade can be made for (ICity iCity : churchMap.keySet()) { IChurch church = churchProvider.getChurch(iCity); if (church.getExtensionLevel().getNextExtensionLevel().isPresent()) { EChurchExtension next = church.getExtensionLevel().getNextExtensionLevel().get(); final int collectedDonationsForExtension = church.getCollectedDonationsForExtension(); if (collectedDonationsForExtension >= next.getRequiredCash()) { // start upgrade int delay = rnd.nextInt(30); LocalDateTime executionTime = date.getCurrentDate().plusDays(delay); TimedTask task = taskFactory.getChurchUpgradeTask(church, executionTime); timedTaskListener.add(task); } } } } public void establishChurch(ICity city) {
/** * Order the repair of a single AI owned ship. * @param shipyard where it should be repaired * @param ship that should be repaired */ public void repairAIShip(IShipyard shipyard, IShip ship) { int repairTime = shipyard.calculateRepairTime(ship.getShipType()); ship.setAvailable(false); int damageInv = ship.getDamage(); repairTime = Math.max((int) (repairTime * Math.max(damageInv/100.0, 0.05)), 1); LocalDateTime startDate = findeLatestDate(shipyard.getShipRepairList()); ShipDueDate dueDate = new ShipDueDate(ship, startDate.plusDays(repairTime)); TimedTask task = taskFactory.getAIShipRepairTask(dueDate.getDueDate(), ship, shipyard); taskList.add(task); shipyard.addShipRepairOrder(dueDate, Optional.of(task)); }
/** * Order the repair of the ship. The costs for the repair not are deduced. * With each repair order the crew gets more expierianced. * @param ship to be repaired. * @param shipyard reference to the state */ private void repair(IShipyard shipyard, IShip ship, ICityPlayerProxyJFX proxy) { int repairTime = shipyard.calculateBuildTime(ship.getShipType()); int damageInv = ship.getDamage(); repairTime = Math.max((int) (repairTime * Math.max(damageInv/100.0, 0.05)), 1); LocalDateTime startDate = findeLatestDate(shipyard.getShipRepairList()); ShipDueDate dueDate = new ShipDueDate(ship, startDate.plusDays(repairTime)); TimedTask task = taskFactory.getRepairTask(dueDate.getDueDate(), ship, proxy, shipyard); taskList.add(task); ship.setAvailable(false); shipyard.addShipRepairOrder(dueDate, Optional.of(task)); }
/** * Order the repair of a single pirate ship. * @param shipyard where it should be repaired * @param ship that should be repaired */ public void repairPirateShip(IShipyard shipyard, IShip ship) { int repairTime = shipyard.calculateRepairTime(ship.getShipType()); ship.setAvailable(false); int damageInv = ship.getDamage(); repairTime = Math.max((int) (repairTime * Math.max(damageInv/100.0, 0.05)), 1); LocalDateTime startDate = findeLatestDate(shipyard.getShipRepairList()); ShipDueDate dueDate = new ShipDueDate(ship, startDate.plusDays(repairTime)); TimedTask task = taskFactory.getPirateRepairTask(dueDate.getDueDate(), ship, (ISeaPirate)ship.getOwner(), shipyard); taskList.add(task); shipyard.addShipRepairOrder(dueDate, Optional.of(task)); }
/** * Order the repair of a group of pirate ship. * @param shipyard where it should be repaired * @param shipGroup ships that should be repaired */ public void repair(IShipyard shipyard, IShipGroup shipGroup) { int repairTime = 0; for (IShip ship : shipGroup.getShips()) { repairTime += shipyard.calculateRepairTime(ship.getShipType()); ship.setAvailable(false); } int damageInv = shipGroup.getDamage(); repairTime = Math.max((int) (repairTime * Math.max(damageInv/100.0, 0.05)), 1); LocalDateTime startDate = findeLatestDate(shipyard.getShipRepairList()); ShipDueDate dueDate = new ShipDueDate(shipGroup.getShips().get(0), startDate.plusDays(repairTime)); TimedTask task = taskFactory.getPirateRepairTask(dueDate.getDueDate(), shipGroup, (ISeaPirate)shipGroup.getOwner(), shipyard); taskList.add(task); shipyard.addShipRepairOrder(dueDate, Optional.of(task)); }