use of games.strategy.engine.delegate.IPersistentDelegate in project triplea by triplea-game.
the class ServerGame method startPersistentDelegates.
private void startPersistentDelegates() {
for (final IDelegate delegate : gameData.getDelegateList()) {
if (!(delegate instanceof IPersistentDelegate)) {
continue;
}
final DefaultDelegateBridge bridge = new DefaultDelegateBridge(gameData, this, new DelegateHistoryWriter(channelMessenger), randomStats, delegateExecutionManager);
if (delegateRandomSource == null) {
delegateRandomSource = (IRandomSource) delegateExecutionManager.createOutboundImplementation(randomSource, new Class<?>[] { IRandomSource.class });
}
bridge.setRandomSource(delegateRandomSource);
delegateExecutionManager.enterDelegateExecution();
try {
delegate.setDelegateBridgeAndPlayer(bridge);
delegate.start();
} finally {
delegateExecutionManager.leaveDelegateExecution();
}
}
}
use of games.strategy.engine.delegate.IPersistentDelegate in project triplea by triplea-game.
the class DefaultPlayerBridge method getRemotePersistentDelegate.
@Override
public IRemote getRemotePersistentDelegate(final String name) {
if (game.isGameOver()) {
throw new GameOverException("Game Over");
}
try {
game.getData().acquireReadLock();
try {
final IDelegate delegate = game.getData().getDelegateList().getDelegate(name);
if (delegate == null) {
final String errorMessage = "IDelegate in DefaultPlayerBridge.getRemote() cannot be null. Looking for delegate named: " + name;
// for some reason, client isn't getting or seeing the errors, so make sure we print it to err
System.err.println(errorMessage);
// too
throw new IllegalStateException(errorMessage);
}
if (!(delegate instanceof IPersistentDelegate)) {
return null;
}
return getRemoteThatChecksForGameOver(game.getRemoteMessenger().getRemote(ServerGame.getRemoteName(delegate)));
} finally {
game.getData().releaseReadLock();
}
} catch (final MessengerException me) {
throw new GameOverException("Game Over!");
}
}
Aggregations