@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
@Subscribe public void handleShipNotAuction(ShipNotAuctioned event) { IShip ship = event.getShip(); IPlayer owner = (IPlayer) ship.getOwner(); if (owner instanceof IAIPlayer) { owner.addShip(ship); initializeRandomTradeStrategy(ship, (IAIPlayer) owner); initializeStrategyForVessel((IAIPlayer) owner, ship); startTradeStrategySteps((IAIPlayer) owner, ship); } } @Subscribe
@Override public void run() { if (run) { if (auction instanceof IShipAuction) { if (auction.getOwner().isPresent()) { IShipAuction shipAuction = (IShipAuction) auction; clientServerEventBus.post(new ShipNotAuctioned(shipAuction.getAuctionedShip(), shipAuction.getOwner().get())); } } else { IBuildingAuction buildingAuction = (IBuildingAuction) auction; clientServerEventBus.post(new BuildingNotAuctioned(buildingAuction.getAuctionedBuilding(), buildingAuction.getOwner().get())); } } } };