コード例 #1
0
 /** Called when the user hits play */
 @Override
 public ILauncher getLauncher() {
   // update local cache and write to disk before game starts
   final IForumPoster poster = (IForumPoster) m_forumPosterEditor.getBean();
   if (poster != null) {
     LocalBeanCache.INSTANCE.storeSerializable(poster.getClass().getCanonicalName(), poster);
   }
   final IEmailSender sender = (IEmailSender) m_emailSenderEditor.getBean();
   if (sender != null) {
     LocalBeanCache.INSTANCE.storeSerializable(sender.getClass().getCanonicalName(), sender);
   }
   final IWebPoster web = (IWebPoster) m_webPosterEditor.getBean();
   if (web != null) {
     LocalBeanCache.INSTANCE.storeSerializable(web.getClass().getCanonicalName(), web);
   }
   final IRemoteDiceServer server = (IRemoteDiceServer) m_diceServerEditor.getBean();
   LocalBeanCache.INSTANCE.storeSerializable(server.getDisplayName(), server);
   LocalBeanCache.INSTANCE.writeToDisk();
   // create local launcher
   final String gameUUID =
       (String) m_gameSelectorModel.getGameData().getProperties().get(GameData.GAME_UUID);
   final PBEMDiceRoller randomSource =
       new PBEMDiceRoller((IRemoteDiceServer) m_diceServerEditor.getBean(), gameUUID);
   final Map<String, String> playerTypes = new HashMap<>();
   final Map<String, Boolean> playersEnabled = new HashMap<>();
   for (final PBEMLocalPlayerComboBoxSelector player : m_playerTypes) {
     playerTypes.put(player.getPlayerName(), player.getPlayerType());
     playersEnabled.put(player.getPlayerName(), player.isPlayerEnabled());
   }
   // we don't need the playerToNode list, the
   // disable-able players, or the alliances
   // list, for a local game
   final PlayerListing pl =
       new PlayerListing(
           null,
           playersEnabled,
           playerTypes,
           m_gameSelectorModel.getGameData().getGameVersion(),
           m_gameSelectorModel.getGameName(),
           m_gameSelectorModel.getGameRound(),
           null,
           null);
   return new LocalLauncher(m_gameSelectorModel, randomSource, pl);
 }
コード例 #2
0
 /**
  * Load the dice rollers from cache, if the game was a save game, the dice roller store is
  * selected
  *
  * @param data the game data
  */
 private void loadDiceServer(final GameData data) {
   final List<IRemoteDiceServer> diceRollers =
       new ArrayList<>(PropertiesDiceRoller.loadFromFile());
   diceRollers.add(new InternalDiceServer());
   for (final IRemoteDiceServer diceRoller : diceRollers) {
     final IRemoteDiceServer cached =
         (IRemoteDiceServer) LocalBeanCache.INSTANCE.getSerializable(diceRoller.getDisplayName());
     if (cached != null) {
       diceRoller.setCcAddress(cached.getCcAddress());
       diceRoller.setToAddress(cached.getToAddress());
       diceRoller.setGameId(cached.getGameId());
     }
   }
   m_diceServerEditor.setBeans(diceRollers);
   if (m_gameSelectorModel.isSavedGame()) {
     // get the dice roller from the save game, if any
     final IRemoteDiceServer roller = (IRemoteDiceServer) data.getProperties().get(DICE_ROLLER);
     if (roller != null) {
       m_diceServerEditor.setSelectedBean(roller);
     }
   }
 }