Search in sources :

Example 1 with PbemDiceRoller

use of games.strategy.engine.random.PbemDiceRoller in project triplea by triplea-game.

the class DiceServerEditor method setupListeners.

/**
 * Configures the listeners for the gui components.
 */
private void setupListeners() {
    testDiceyButton.addActionListener(e -> {
        final PbemDiceRoller random = new PbemDiceRoller(getDiceServer(), null);
        random.test();
    });
    final DocumentListener docListener = new EditorChangedFiringDocumentListener();
    toAddress.getDocument().addDocumentListener(docListener);
    ccAddress.getDocument().addDocumentListener(docListener);
}
Also used : DocumentListener(javax.swing.event.DocumentListener) PbemDiceRoller(games.strategy.engine.random.PbemDiceRoller)

Example 2 with PbemDiceRoller

use of games.strategy.engine.random.PbemDiceRoller in project triplea by triplea-game.

the class PbemSetupPanel method getLauncher.

/**
 * Called when the user hits play.
 */
@Override
public Optional<ILauncher> getLauncher() {
    // update local cache and write to disk before game starts
    final IForumPoster poster = (IForumPoster) forumPosterEditor.getBean();
    if (poster != null) {
        LocalBeanCache.INSTANCE.storeSerializable(poster.getClass().getCanonicalName(), poster);
    }
    final IEmailSender sender = (IEmailSender) emailSenderEditor.getBean();
    if (sender != null) {
        LocalBeanCache.INSTANCE.storeSerializable(sender.getClass().getCanonicalName(), sender);
    }
    final IRemoteDiceServer server = (IRemoteDiceServer) diceServerEditor.getBean();
    LocalBeanCache.INSTANCE.storeSerializable(server.getDisplayName(), server);
    LocalBeanCache.INSTANCE.writeToDisk();
    // create local launcher
    final String gameUuid = (String) gameSelectorModel.getGameData().getProperties().get(GameData.GAME_UUID);
    final PbemDiceRoller randomSource = new PbemDiceRoller((IRemoteDiceServer) diceServerEditor.getBean(), gameUuid);
    final Map<String, String> playerTypes = new HashMap<>();
    final Map<String, Boolean> playersEnabled = new HashMap<>();
    for (final PlayerSelectorRow player : this.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, gameSelectorModel.getGameData().getGameVersion(), gameSelectorModel.getGameName(), gameSelectorModel.getGameRound(), null, null);
    return Optional.of(new LocalLauncher(gameSelectorModel, randomSource, pl));
}
Also used : LocalLauncher(games.strategy.engine.framework.startup.launcher.LocalLauncher) HashMap(java.util.HashMap) IEmailSender(games.strategy.engine.pbem.IEmailSender) PlayerListing(games.strategy.engine.framework.message.PlayerListing) IForumPoster(games.strategy.engine.pbem.IForumPoster) PbemDiceRoller(games.strategy.engine.random.PbemDiceRoller) IRemoteDiceServer(games.strategy.engine.random.IRemoteDiceServer)

Aggregations

PbemDiceRoller (games.strategy.engine.random.PbemDiceRoller)2 PlayerListing (games.strategy.engine.framework.message.PlayerListing)1 LocalLauncher (games.strategy.engine.framework.startup.launcher.LocalLauncher)1 IEmailSender (games.strategy.engine.pbem.IEmailSender)1 IForumPoster (games.strategy.engine.pbem.IForumPoster)1 IRemoteDiceServer (games.strategy.engine.random.IRemoteDiceServer)1 HashMap (java.util.HashMap)1 DocumentListener (javax.swing.event.DocumentListener)1