Search in sources :

Example 1 with IAbstractForumPosterDelegate

use of games.strategy.triplea.delegate.remote.IAbstractForumPosterDelegate in project triplea by triplea-game.

the class TripleAPlayer method endTurn.

private void endTurn() {
    if (getPlayerBridge().isGameOver()) {
        return;
    }
    final GameData data = getGameData();
    // play a sound for this phase
    final IAbstractForumPosterDelegate endTurnDelegate;
    try {
        endTurnDelegate = (IAbstractForumPosterDelegate) getPlayerBridge().getRemoteDelegate();
    } catch (final ClassCastException e) {
        final String errorContext = "PlayerBridge step name: " + getPlayerBridge().getStepName() + ", Remote class name: " + getPlayerBridge().getRemoteDelegate().getClass();
        // for some reason the client is not seeing or getting these errors, so print to err too
        System.err.println(errorContext);
        ClientLogger.logQuietly(errorContext, e);
        throw new IllegalStateException(errorContext, e);
    }
    if (!soundPlayedAlreadyEndTurn && TerritoryAttachment.doWeHaveEnoughCapitalsToProduce(getPlayerId(), data)) {
        // do not play if we are reloading a savegame from pbem (gets annoying)
        if (!endTurnDelegate.getHasPostedTurnSummary()) {
            ClipPlayer.play(SoundPath.CLIP_PHASE_END_TURN, getPlayerId());
        }
        soundPlayedAlreadyEndTurn = true;
    }
    ui.waitForEndTurn(getPlayerId(), getPlayerBridge());
}
Also used : GameData(games.strategy.engine.data.GameData) IAbstractForumPosterDelegate(games.strategy.triplea.delegate.remote.IAbstractForumPosterDelegate)

Example 2 with IAbstractForumPosterDelegate

use of games.strategy.triplea.delegate.remote.IAbstractForumPosterDelegate in project triplea by triplea-game.

the class AbstractAi method start.

@Override
public final void start(final String name) {
    super.start(name);
    final PlayerID id = getPlayerId();
    if (name.endsWith("Bid")) {
        final IPurchaseDelegate purchaseDelegate = (IPurchaseDelegate) getPlayerBridge().getRemoteDelegate();
        final String propertyName = id.getName() + " bid";
        final int bidAmount = getGameData().getProperties().get(propertyName, 0);
        purchase(true, bidAmount, purchaseDelegate, getGameData(), id);
    } else if (name.endsWith("Purchase")) {
        final IPurchaseDelegate purchaseDelegate = (IPurchaseDelegate) getPlayerBridge().getRemoteDelegate();
        final Resource pus = getGameData().getResourceList().getResource(Constants.PUS);
        final int leftToSpend = id.getResources().getQuantity(pus);
        purchase(false, leftToSpend, purchaseDelegate, getGameData(), id);
    } else if (name.endsWith("Tech")) {
        final ITechDelegate techDelegate = (ITechDelegate) getPlayerBridge().getRemoteDelegate();
        tech(techDelegate, getGameData(), id);
    } else if (name.endsWith("Move")) {
        final IMoveDelegate moveDel = (IMoveDelegate) getPlayerBridge().getRemoteDelegate();
        if (name.endsWith("AirborneCombatMove")) {
        // do nothing
        } else {
            move(name.endsWith("NonCombatMove"), moveDel, getGameData(), id);
        }
    } else if (name.endsWith("Battle")) {
        battle((IBattleDelegate) getPlayerBridge().getRemoteDelegate(), getGameData(), id);
    } else if (name.endsWith("Politics")) {
        politicalActions();
    } else if (name.endsWith("Place")) {
        final IAbstractPlaceDelegate placeDel = (IAbstractPlaceDelegate) getPlayerBridge().getRemoteDelegate();
        place(name.contains("Bid"), placeDel, getGameData(), id);
    } else if (name.endsWith("EndTurn")) {
        endTurn((IAbstractForumPosterDelegate) getPlayerBridge().getRemoteDelegate(), getGameData(), id);
    }
}
Also used : IMoveDelegate(games.strategy.triplea.delegate.remote.IMoveDelegate) PlayerID(games.strategy.engine.data.PlayerID) ITechDelegate(games.strategy.triplea.delegate.remote.ITechDelegate) IPurchaseDelegate(games.strategy.triplea.delegate.remote.IPurchaseDelegate) IAbstractForumPosterDelegate(games.strategy.triplea.delegate.remote.IAbstractForumPosterDelegate) IAbstractPlaceDelegate(games.strategy.triplea.delegate.remote.IAbstractPlaceDelegate) Resource(games.strategy.engine.data.Resource)

Aggregations

IAbstractForumPosterDelegate (games.strategy.triplea.delegate.remote.IAbstractForumPosterDelegate)2 GameData (games.strategy.engine.data.GameData)1 PlayerID (games.strategy.engine.data.PlayerID)1 Resource (games.strategy.engine.data.Resource)1 IAbstractPlaceDelegate (games.strategy.triplea.delegate.remote.IAbstractPlaceDelegate)1 IMoveDelegate (games.strategy.triplea.delegate.remote.IMoveDelegate)1 IPurchaseDelegate (games.strategy.triplea.delegate.remote.IPurchaseDelegate)1 ITechDelegate (games.strategy.triplea.delegate.remote.ITechDelegate)1