use of games.strategy.engine.random.IRemoteDiceServer 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);
}
}
}
use of games.strategy.engine.random.IRemoteDiceServer 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));
}
Aggregations