public HanseaticHistoryScene getHanseaticHistoryScene() { if (!sceneMap.containsKey("hanseaticHistoryScene")) { sceneMap.put("hanseaticHistoryScene", (HanseaticHistoryScene) context.getBean("hanseaticHistoryScene")); } return (HanseaticHistoryScene) sceneMap.get("hanseaticHistoryScene"); }
@Override public void invalidate() { for (Iterator<Entry<String, OpenPatricianScene>> iterator = sceneMap.entrySet().iterator(); iterator.hasNext(); ) { iterator.next(); iterator.remove(); } }
@Override public void run() { int index = oprnd.nextSlidingRandomDecreasing(candidateMap.size() - 1, 0.5); // todo: andi 5/17/15: this should probably be dependent on the popularity of the top candidate List<ICitizen> citizens = candidateMap.getAtIndex(index); result.vote(citizens.get(0)); LOGGER.debug("Cast vote"); } }
/** * Create a sorted map of the candidates according to their reputation. As only {@link ch.sahits.game.openpatrician.model.IPlayer} * have a reputation any all {@link ch.sahits.game.openpatrician.model.ICitizen} have the same reputation of 0. * @param candidates List of the candidates * @param city for which the candidates are mapped * @return Sorted map by their reputation and the candidates */ public SortedMapRandomizedSameElements<Integer, ICitizen> getCandidateMap(List<ICitizen> candidates, ICity city) { List<ICitizen> citizens = new ArrayList<>(); Map<Integer, List<ICitizen>> initialMap = new HashMap<>(); initialMap.put(0,citizens); for (ICitizen citizen : candidates) { if (citizen instanceof IPlayer) { IReputation reputation = city.getReputation((IPlayer) citizen); int rep = reputation.getPopularity(); if (initialMap.containsKey(rep)) { List<ICitizen> list = initialMap.get(rep); list.add(citizen); initialMap.put(rep,list); } else { ArrayList<ICitizen> list = new ArrayList<>(); list.add(citizen); initialMap.put(rep,list); } } else { citizens.add(citizen); } } return new SortedMapRandomizedSameElements<>(initialMap); }
public CreditsScene getCreditsScene() { if (!sceneMap.containsKey("creditsScene")) { sceneMap.put("creditsScene", (CreditsScene) context.getBean("creditsScene")); } return (CreditsScene) sceneMap.get("creditsScene"); } public NewGameScene getNewGameScene() {
public InGameOptionsScene getInGameOptionsScene() { if (!sceneMap.containsKey("inGameOptionsScene")) { sceneMap.put("inGameOptionsScene", (InGameOptionsScene) context.getBean("inGameOptionsScene")); } return (InGameOptionsScene) sceneMap.get("inGameOptionsScene"); } public IJavaFXControlLoader getJavaFXControlLoader() {
public StartupScene getStartupScene() { if (!sceneMap.containsKey("startupScene")) { sceneMap.put("startupScene", (StartupScene) context.getBean("startupScene")); } return (StartupScene) sceneMap.get("startupScene"); } public HanseaticHistoryScene getHanseaticHistoryScene() {
public LoadGameScene getLoadGameScene() { if (!sceneMap.containsKey("loadGameScene")){ LoadGameScene loadGameScene = (LoadGameScene) context.getBean("loadGameScene"); loadGameScene.setSceneChangeable(applicationWindow); sceneMap.put("loadGameScene", loadGameScene); } return (LoadGameScene) sceneMap.get("loadGameScene"); }
public MainGameScene getMainGameScene(double width, double heigth) { if (!sceneMap.containsKey("mainGameScene")) { sceneMap.put("mainGameScene", (OpenPatricianScene) context.getBean("mainGameScene", width, heigth, getXMLImageLoader(), jfxControlLoader)); } return (MainGameScene) sceneMap.get("mainGameScene"); } public StartupScene getStartupScene() {
public NewGameScene getNewGameScene() { if (!sceneMap.containsKey("newGameScene")){ NewGameScene newGameScene = (NewGameScene) context.getBean("newGameScene"); newGameScene.setSceneChangeable(applicationWindow); sceneMap.put("newGameScene", newGameScene); } return (NewGameScene) sceneMap.get("newGameScene"); }