@Override public void run() { DisplayMessage msg = new DisplayMessage(messageKey, messageArgs); clientEventBus.post(msg); }
@Override public void run() { clientEventBus.post(new DisplayMessage("ch.sahits.game.graphic.event.task.ConcurrentReconciliation.message")); } }
@Override public void run() { DisplayMessage msg = new DisplayMessage(template.getTitleKey(), template, template.getMessageArgs()); clientEventBus.post(msg); } }
/** * The Hanseatic council decided not to punish a city for its violation, notify. * @param violation that is to be handled. */ private void handleDeniedCityViolation(ICityViolation violation) { DisplayMessage msg = null; if (violation instanceof ICustomsViolation) { msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.land.city.CityHallEngine.noSanctionsCustomViolation", new Object[]{violation.getCity().getName()}); } if (violation instanceof IPirateSupportViolation) { msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.land.city.CityHallEngine.noSanctionsPirateSupport", new Object[]{violation.getCity().getName()}); } if (violation instanceof IPlunderTradingOfficesViolation) { msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.land.city.CityHallEngine.noSanctionsPlunder", new Object[]{violation.getCity().getName()}); } if (violation instanceof ISpecialTaxViolation) { msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.land.city.CityHallEngine.noSanctionsSpecialTaxViolation", new Object[]{violation.getCity().getName()}); } postMayoralElectionMessage(msg); }
@Override public void run() { clientEventBus.post(new DisplayMessage("ch.sahits.game.openpatrician.display.dialog.TavernWarehouseTenantDialog.acceptMessage")); office.setOccupiedSpace(office.getOccupiedSpace() - tenant.getAmount()); } }
@Subscribe public void handleShipAuctionFinished(ShipAuctionFinished event) { IPlayer owner = event.getNewOwner(); if (owner instanceof IHumanPlayer) { IShip ship = event.getShip(); ship.setOwner(owner); owner.addShip(ship); // Post targeted message Optional<ICity> city = shipService.findCity(ship); DisplayMessage msg; msg = city.map(iCity -> new DisplayMessage("ch.sahits.game.openpatrician.engine.player.HumanPlayerEngine.shipAuctioned", ship.getName(), iCity.getName())) .orElseGet(() -> new DisplayMessage("ch.sahits.game.openpatrician.engine.player.HumanPlayerEngine.shipAuctionedOnSea", ship.getName())); TargetedEvent targetMsg = new TargetedEvent((IHumanPlayer) owner, msg); clientServerEventBus.post(targetMsg); } } @Subscribe
@Override public void run() { int bounty = (int)(Math.abs(opponent.getCompany().getCash()/2000*rnd.nextDouble())); if (opponent instanceof IHumanPlayer) { opponent.getCompany().updateCash(-bounty); } else { opponent.getCompany().updateCashDirectly(-bounty); } DisplayMessage msg = new DisplayMessage("ch.sahits.game.graphic.event.task.BreakInAction.message", bounty, opponent.getLastName()); clientEventBus.post(msg); }
@Override public void run() { clientEventBus.post(new DisplayMessage("ch.sahits.game.graphic.event.task.OpponentsOrder.message1", client.getName(), client.getLastName(),premium)); order = eventHandlerFactory.getSinkConcurrentsShipOrder(client, opponent, 10, premium, null); clientServerEventBus.unregister(order); }
@Subscribe public void handleBuildingNotAuction(BuildingNotAuctioned event) { if (event.getNewOwner() instanceof IHumanPlayer) { // Post targeted message ICity city = event.getBuilding().getCity(); DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.player.HumanPlayerEngine.buildingNotAuctioned", city.getName()); TargetedEvent targetMsg = new TargetedEvent((IHumanPlayer) event.getNewOwner(), msg); clientServerEventBus.post(targetMsg); } } }
@Override public void run() { DisplayMessage msg = new DisplayMessage(messageKey, fine); clientEventBus.post(msg); if (player instanceof IHumanPlayer) { player.getCompany().updateCash(-fine); } else { player.getCompany().updateCashDirectly(-fine); } } }
@Subscribe public void handleBuildingAuctionFinished(BuildingAuctionFinished event) { IPlayer owner = event.getNewOwner(); if (owner instanceof IHumanPlayer) { // Post targeted message IBuilding building = event.getBuilding(); building.setOwner(owner); ICity city = building.getCity(); DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.player.HumanPlayerEngine.buildingAuctioned", city.getName()); TargetedEvent targetMsg = new TargetedEvent((IHumanPlayer) owner, msg); clientServerEventBus.post(targetMsg); } } @Subscribe
@Override public void handleShipEntersPort(ShipEntersPortEvent event) { super.handleShipEntersPort(event); LocalDateTime now = date.getCurrentDate(); if (now.isAfter(deadline)) { clientEventBus.post(new DisplayMessage("ch.sahits.game.event.handler.impl.NextCourierPatrolStation.unreliable")); clientServerEventBus.unregister(this); clientServerEventBus.unregister(atackListener); } }
@Subscribe public void handleShipNotAuction(ShipNotAuctioned event) { IShipOwner owner = event.getShip().getOwner(); if (owner instanceof IHumanPlayer) { // Post targeted message IShip ship = event.getShip(); ((IHumanPlayer) owner).addShip(ship); Optional<ICity> city = shipService.findCity(ship); DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.player.HumanPlayerEngine.shipNotAuctioned", ship.getName(), city.get().getName()); TargetedEvent targetMsg = new TargetedEvent((IHumanPlayer) event.getNewOwner(), msg); clientServerEventBus.post(targetMsg); } } @Subscribe
@Override public boolean execute() { clientEventBus.post(new DisplayMessage("ch.sahits.game.event.handler.impl.SinkConcurrentShipOrder.thankyou")); if (player instanceof IHumanPlayer) { player.getCompany().updateCash(premium); } else { player.getCompany().updateCashDirectly(premium); } if (reconciliation != null) { list.remove(reconciliation); } return true; }}
@Override public void run() { ship.setLocation(location); locationTracker.add(ship); shipyard.removeCompletedConstruction(ship); if (owner instanceof IHumanPlayer) { DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.event.task.ShipBuildTask.message", new Object[]{type, ship.getName()}); TargetedEvent displayMessage = new TargetedEvent((IHumanPlayer) owner, msg); clientServerEventBus.post(displayMessage); } else { aiPlayerEngine.handleShipConstructionFinished(ship, (IAIPlayer) owner); } } /**
@VisibleForTesting Runnable createPawnRunnable(final IDebt debt, final ICity city) { return () -> { if (debt.getDebitor() instanceof IHumanPlayer) { pawnFromHumanDebitor(debt, city); // Add task for the following day to collect the money } else if (debt.getCreditor() instanceof IHumanPlayer){ int value = rnd.nextInt(debt.getAmount()/2) + debt.getAmount(); value = (int) Math.min(value, debt.getAmount()*debt.getInterest()); ((IPlayer)debt.getCreditor()).getCompany().updateCash(value); ICitizen debitor = debt.getDebitor(); DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.land.city.LoanerEngine.pawnMsg1", new Object[]{debitor.getName(), debitor.getLastName(), value}); TargetedEvent message = new TargetedEvent((IHumanPlayer) debt.getCreditor(), msg); clientServerEventBus.post(message); } }; } @VisibleForTesting
@Override public void run() { int penalty = (int)(Math.abs(player.getCompany().getCash()/(200*rnd.nextDouble()))); DisplayMessage msg = new DisplayMessage("ch.sahits.game.graphic.event.task.DelayedCaughtAction.message", penalty); clientEventBus.post(msg); ILoaner loaner = loaners.getLoaner(city); IDebt debt = Debt.builder() .amount(penalty) .dueDate(date.getCurrentDate().plusMonths(1)) .interest(0) .loanTakeOut(date.getCurrentDate()) .debitor(player) .creditor(new CityCreditor()) .build(); loaner.addDebt(debt); } }
@Override public void run() { ship.repair(); shipyard.removeCompletedRepair(ship); ship.setAvailable(true); city.getPlayersShips().add(ship); if (city.getPlayersShips().size() == 1) { city.activateShip(ship); } final IShipOwner owner = ship.getOwner(); if (owner instanceof IHumanPlayer) { DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.event.task.RepairTask.message", new Object[]{ship.getName()}); TargetedEvent displayMessage = new TargetedEvent((IHumanPlayer) owner, msg); clientServerEventBus.post(displayMessage); } else { clientServerEventBus.post(new RepairFinishedEvent(ship)); } } }
@Override public void run() { IHumanPlayer debitor = (IHumanPlayer) debt.getDebitor(); ICompany company = debitor.getCompany(); int requiredAmount = debt.getAmount(); int amount = (int) Math.min(requiredAmount, company.getCash()); company.updateCash(-amount); if (debt.getCreditor() instanceof IPlayer) { if (debt.getCreditor() instanceof IHumanPlayer) { ((IPlayer) debt.getCreditor()).getCompany().updateCash(amount); } else { ((IPlayer) debt.getCreditor()).getCompany().updateCashDirectly(amount); } if (debt.getCreditor() instanceof IHumanPlayer) { DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.land.city.LoanerEngine.paybackAfterShipAuction", new Object[]{debitor.getName(), debitor.getLastName(), amount}); TargetedEvent message = new TargetedEvent((IHumanPlayer) debt.getCreditor(), msg); clientServerEventBus.post(message); } } } }
void dissolveConvoy(IBlockade blockade, ICity city, ICity blockadedCity) { IConvoy convoy = blockade.getBlockadeConvoy(); for (IShip ship : convoy.getShips()) { ship.setAvailable(true); IShipOwner owner = ship.getOwner(); convoy.removeShip(ship); ship.parentShipProperty().setValue(null); if (owner instanceof IHumanPlayer) { DisplayMessage msg = new DisplayMessage("ch.sahits.game.openpatrician.engine.sea.BlockadeEngine.blockadesissolve", new Object[]{blockadedCity.getName(), ship.getName(), city.getName()}); TargetedEvent targetMsg = new TargetedEvent((IHumanPlayer) owner, msg); clientServerEventBus.post(targetMsg); } if (owner instanceof IPlayer) { IPlayer player = (IPlayer) owner; player.addSelectableVessel(ship); } clientServerEventBus.post(new ShipEntersPortEvent(ship, city)); } }