/** * Add a new pirate activity with the current date. * @param pirateActivity to be added with the present date. */ public void add(PirateActivityEntry pirateActivity) { map.put(date.getCurrentDate(), pirateActivity); }
int dayBefore = clock.getCurrentDate().getDayOfMonth(); clock.updateTime(clock.getCurrentDate().plusMinutes(clock.getTickUpdate())); if (dayBefore!=clock.getCurrentDate().getDayOfMonth()){ Platform.runLater(() -> clock.dayDateBinding().invalidate()); final ClockTickDayChange event = new ClockTickDayChange(); timerEventBus.post(event); logger.info("Day change"); DayOfWeek dayOfWeek = clock.getCurrentDate().getDayOfWeek(); if (dayOfWeek == DayOfWeek.SUNDAY) { timerEventBus.post(new PeriodicalTimeWeekEndUpdate()); int monthOfYear = clock.getCurrentDate().getMonthValue(); int dayOfMonth = clock.getCurrentDate().getDayOfMonth(); if (monthOfYear == 12 && dayOfMonth == 31) { timerEventBus.post(new PeriodicalTimeYearEndUpdate()); LocalDateTime last = clock.getCurrentDate().with(TemporalAdjusters.lastDayOfMonth()); if (dayOfMonth == last.getDayOfMonth()) { PeriodicalTimeMonthEndUpdate event1 = new PeriodicalTimeMonthEndUpdate();
private LocalDateTime computeRandomBirthDate(int age){ int year = date.getStartYear()-age; int month = rnd.nextInt(12)+1; int day; switch (month) { case 2: day = rnd.nextInt(28) + 1; break; case 4: case 6: case 9: case 11: day = rnd.nextInt(30) + 1; break; default: day = rnd.nextInt(31) + 1; break; } return LocalDateTime.of(year, month, day, 0, 0); } /**
gameDate.setStartYear(Date.DEFAULT_INVALID_START_YEAR); // will be changed final double width = getRoot().getWidth(); final double height = getRoot().getHeight(); while (gameDate.getStartYear() == null) { try { Thread.sleep(1);
date.resetStartYear(Date.DEFAULT_INVALID_START_YEAR); // will be changed while (date.getStartYear() == null) { try { Thread.sleep(1);
@Override public long calculateDuration(INavigableVessel vessel, PathInterpolator interpolator, double fraction) { double speedKmPerH = vessel.getCurrentSpeed(); double distanceInPixels = interpolator.getTotalLength() * fraction; double distanceInKm = mapService.convertToDistenceInKm(distanceInPixels); double tickUpdateInHours = date.getTickUpdate()/60.0; // tick update is in minutes double inGameAnimationDurationInHours = distanceInKm/speedKmPerH; long nbTicks = Math.round(Math.ceil(inGameAnimationDurationInHours / tickUpdateInHours)); logger.debug("Distance of {}km can be traveled in {}h at {}km/h, which results in {} clock ticks or {}ms, fraction to travel={}",distanceInKm, inGameAnimationDurationInHours, speedKmPerH, nbTicks, EngineConfiguration.CLOCK_TICK_INTERVALL_MS * nbTicks, fraction); return EngineConfiguration.CLOCK_TICK_INTERVALL_MS * nbTicks; }
private void bindDate(SimpleStringProperty date) { date.bind(gameDate.dayDateBinding()); gameDate.dayDateBinding().addListener((observable, oldValue, newValue) -> { date.unbind(); date.bind(gameDate.dayDateBinding()); }); }
private IHumanPlayer startupGameEnvironment(NewGame newGameDTO) { date.setStartYear(newGameDTO.getStartYear()); GameFactory gameFactory = serverContext.getBean(GameFactory.class); CityFactory cityFactory = serverContext.getBean(CityFactory.class); ShipFactory shipFactory = serverContext.getBean(ShipFactory.class); gameFactory.createMap(newGameDTO.getMapName()); LocationTracker locationTracker = serverContext.getBean(LocationTracker.class); serverContext.getBean(StartNewGameBean.class); IGame game = gameFactory.createGame(newGameDTO.getObjective(), newGameDTO.getDifficulty(), newGameDTO.getSpeed(), newGameDTO.isSingleplayer()); ICity homeCity = cityFactory.createCityByName(newGameDTO.getHometown()); IHumanPlayer player = gameFactory.createPlayer(newGameDTO.getFirstName(), newGameDTO.getLastName(), homeCity, newGameDTO.isMale(), newGameDTO.getDifficulty().getStartingCapital(), EPlayerColor.BLUE); IShip ship = shipFactory.createCrayer(shipNameLoader.getRandomName(), EShipUpgrade.LEVEL1, 350); ship.setOwner(player); player.addShip(ship); player.addSelectableVessel(ship); ship.setLocation(homeCity.getCoordinates()); locationTracker.add(ship); // Start the game server.startGame(game, 1); server.startStandaloneGame(player); serverContext.getBean("startNewGameHandler"); // Force creation of this lazy bean return player; }
@Override public void rebind() { cashTxt.textProperty().removeListener(cashChangeListener); cashTxt.textProperty().unbind(); cashTxt.textProperty().addListener(cashChangeListener); gameDate.invalidate(); dateTxt.textProperty().removeListener(dateChangeListener); dateTxt.textProperty().unbind(); StringProperty date = createDateProperty(); dateTxt.textProperty().bind(date); dateTxt.textProperty().addListener(dateChangeListener); } }
@PostConstruct public void initialize() { numberOfTicks = WARE_UPDATES_MINUTES/date.getTickUpdate(); clientServerEventBus.register(this); timerEventBus.register(this); taskList.add(taskFactory.getWeeklyCityCheck()); }
private EWeapon getSmallWeaponType() { int year = date.getCurrentDate().getYear(); if (year <= 1333) { return EWeapon.BALLISTA_SMALL; } else if (year <= 1367) { return EWeapon.TREBUCHET_SMALL; } else { return EWeapon.CANNON; } }
while (gameDate.getStartYear() == null) { try { Thread.sleep(1);
/** * If the deadline has passed, the passenger will leave the ship in the next port not the destination city. * @return true if the the current date is after the <code>deadline</code> */ @Override protected boolean ignoreEventCity() { return date.getCurrentDate().isAfter(deadline); }
@Override public String get() { return translations.toDisplayString(date.getCurrentDate()); } }
@Override protected String computeValue() { // FIXME: 5/15/16 this must go to the text.properties return modelTranslator.getStartOfWeek(date.getCurrentDate())+" to "+modelTranslator.getEndOfWeek(date.getCurrentDate()); } };
private EWeapon getBigWeaponType() { int year = date.getCurrentDate().getYear(); if (year <= 1333) { return EWeapon.BALLISTA_BIG; } else if (year <= 1367) { return EWeapon.TREBUCHET_BIG; } else { return EWeapon.BOMBARD; } } private EWeapon getSmallWeaponType() {
private LocalDateTime getScheduledDateWeeklyUpdate() { return date.getCurrentDate().plusWeeks(1); }
private LocalDateTime getScheduledDateWeeklyUpdate() { return date.getCurrentDate().plusWeeks(1); }
private LocalDateTime getScheduledDateDailyUpdate() { return date.getCurrentDate().plusDays(1); }
private LocalDateTime getScheduledDateDailyUpdate() { return date.getCurrentDate().plusDays(1); }