Search in sources :

Example 1 with InternalDiceServer

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

the class PbemSetupPanel method loadDiceServer.

/**
 * 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());
        }
    }
    diceServerEditor.setBeans(diceRollers);
    if (gameSelectorModel.isSavedGame()) {
        // get the dice roller from the save game, if any
        final IRemoteDiceServer roller = (IRemoteDiceServer) data.getProperties().get(DICE_ROLLER);
        if (roller != null) {
            diceServerEditor.setSelectedBean(roller);
        }
    }
}
Also used : InternalDiceServer(games.strategy.engine.random.InternalDiceServer) ArrayList(java.util.ArrayList) IRemoteDiceServer(games.strategy.engine.random.IRemoteDiceServer)

Aggregations

IRemoteDiceServer (games.strategy.engine.random.IRemoteDiceServer)1 InternalDiceServer (games.strategy.engine.random.InternalDiceServer)1 ArrayList (java.util.ArrayList)1