Search in sources :

Example 1 with DelegateHistoryWriter

use of games.strategy.engine.history.DelegateHistoryWriter 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();
        }
    }
}
Also used : IPersistentDelegate(games.strategy.engine.delegate.IPersistentDelegate) DelegateHistoryWriter(games.strategy.engine.history.DelegateHistoryWriter) DefaultDelegateBridge(games.strategy.engine.delegate.DefaultDelegateBridge) IDelegate(games.strategy.engine.delegate.IDelegate)

Example 2 with DelegateHistoryWriter

use of games.strategy.engine.history.DelegateHistoryWriter in project triplea by triplea-game.

the class ServerGame method startStep.

private void startStep(final boolean stepIsRestoredFromSavedGame) {
    // dont save if we just loaded
    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);
    // node is created.
    if (needToInitialize) {
        addPlayerTypesToGameData(gamePlayers.values(), playerManager, bridge);
    }
    notifyGameStepChanged(stepIsRestoredFromSavedGame);
    delegateExecutionManager.enterDelegateExecution();
    try {
        final IDelegate delegate = getCurrentStep().getDelegate();
        delegate.setDelegateBridgeAndPlayer(bridge);
        delegate.start();
    } finally {
        delegateExecutionManager.leaveDelegateExecution();
    }
}
Also used : DelegateHistoryWriter(games.strategy.engine.history.DelegateHistoryWriter) DefaultDelegateBridge(games.strategy.engine.delegate.DefaultDelegateBridge) IDelegate(games.strategy.engine.delegate.IDelegate)

Aggregations

DefaultDelegateBridge (games.strategy.engine.delegate.DefaultDelegateBridge)2 IDelegate (games.strategy.engine.delegate.IDelegate)2 DelegateHistoryWriter (games.strategy.engine.history.DelegateHistoryWriter)2 IPersistentDelegate (games.strategy.engine.delegate.IPersistentDelegate)1