Example #1
0
 private void loadWebPosters(final GameData data) {
   final List<IWebPoster> webPosters = new ArrayList<>();
   webPosters.add((IWebPoster) findCachedOrCreateNew(NullWebPoster.class));
   final TripleAWebPoster poster =
       (TripleAWebPoster) findCachedOrCreateNew(TripleAWebPoster.class);
   poster.setParties(data.getPlayerList().getNames());
   webPosters.add(poster);
   m_webPosterEditor.setBeans(webPosters);
   // now get the poster stored in the save game
   final IWebPoster webPoster =
       (IWebPoster) data.getProperties().get(PBEMMessagePoster.WEB_POSTER_PROP_NAME);
   if (webPoster != null) {
     poster.addToAllHosts(webPoster.getHost());
     webPoster.setAllHosts(poster.getAllHosts());
     m_webPosterEditor.setSelectedBean(webPoster);
   }
 }
Example #2
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);
 }
Example #3
0
 @Override
 public void postStartGame() {
   // // store the dice server
   final GameData data = m_gameSelectorModel.getGameData();
   data.getProperties().set(DICE_ROLLER, m_diceServerEditor.getBean());
   // store the Turn Summary Poster
   final IForumPoster poster = (IForumPoster) m_forumPosterEditor.getBean();
   if (poster != null) {
     IForumPoster summaryPoster = poster;
     // clone the poster, the remove sensitive info, and put the clone into the game data
     // this was the sensitive info is not stored in the save game, but the user cache still has
     // the password
     summaryPoster = summaryPoster.doClone();
     summaryPoster.clearSensitiveInfo();
     data.getProperties().set(PBEMMessagePoster.FORUM_POSTER_PROP_NAME, summaryPoster);
   }
   // store the email poster
   IEmailSender sender = (IEmailSender) m_emailSenderEditor.getBean();
   if (sender != null) {
     // create a clone, delete the sensitive information in the clone, and use it in the game
     // the locally cached version still has the password so the user doesn't have to enter it
     // every time
     sender = sender.doClone();
     sender.clearSensitiveInfo();
     data.getProperties().set(PBEMMessagePoster.EMAIL_SENDER_PROP_NAME, sender);
   }
   // store the web site poster
   IWebPoster webPoster = (IWebPoster) m_webPosterEditor.getBean();
   if (webPoster != null) {
     webPoster = webPoster.doClone();
     webPoster.clearSensitiveInfo();
     data.getProperties().set(PBEMMessagePoster.WEB_POSTER_PROP_NAME, webPoster);
   }
   // store whether we are a pbem game or not, whether we are capable of posting a game save
   if (poster != null || sender != null || webPoster != null) {
     data.getProperties().set(PBEMMessagePoster.PBEM_GAME_PROP_NAME, true);
   }
 }