@Subscribe public void handleShipNearingPort(ShipNearingPortEvent event) { ICity city = event.getCity(); INavigableVessel ship = event.getShip(); if (ship.getPirateFlag()) { Optional<ICityHall> optCityHall = cityHalls.findCityHall(city); if (optCityHall.isPresent()) { Optional<IOutriggerContract> optContract = optCityHall.get().getOutriggerContract(); //noinspection OptionalIsPresent if (optContract.isPresent()) { IShip outrigger = optContract.get().getOutrigger(); SeaFightContext context = new SeaFightContext(ESeaFightType.OUTRIGGER); IPlayer owner = (IPlayer) ship.getOwner(); owner.updateCrimialDrive(1); seaFightService.calculateOutcome(outrigger, ship, context); } } else { logger.warn("No CityHall found for city "+city.getName()); } } }
private void updateCapturedShipInternal(List<IShip> capturedDefendingShips, List<IShip> capturedAttackingShips, boolean attackShipTurn, IShip shipWithMaxSailors, IShip captureShip, SeaFightContext context) { final int numberOfSailors = captureShip.getNumberOfSailors(); int halfTheSailors = numberOfSailors /2; captureShip.setNumberOfSailors(numberOfSailors - halfTheSailors); IShipOwner previousOwner = shipWithMaxSailors.getOwner(); removeFromFleet(shipWithMaxSailors, previousOwner); shipWithMaxSailors.setNumberOfSailors(halfTheSailors); shipWithMaxSailors.setOwner(captureShip.getOwner()); if (context.getType() == ESeaFightType.BLOCKADE && attackShipTurn) { IBlockade blockade = ((BlockadeSeafightContext)context).getBlockade(); blockade.getShipsToAuction().add(captureShip); } else { addToFleet(shipWithMaxSailors, captureShip.getOwner()); } if (attackShipTurn) { // shipWithMaxSailors belongs to attacking fleet capturedAttackingShips.add(shipWithMaxSailors); } else { capturedDefendingShips.add(shipWithMaxSailors); } }
seaFightService.calculateOutcome(vessel, visibleVessel, new SeaFightContext(ESeaFightType.STANDARD)); if (vissibleOwner instanceof IPlayer) {