Search in sources :

Example 1 with PlaceData

use of games.strategy.triplea.ui.PlaceData in project triplea by triplea-game.

the class TripleAPlayer method place.

private void place() {
    final boolean bid = GameStepPropertiesHelper.isBid(getGameData());
    if (getPlayerBridge().isGameOver()) {
        return;
    }
    final PlayerID id = getPlayerId();
    final IAbstractPlaceDelegate placeDel;
    try {
        placeDel = (IAbstractPlaceDelegate) 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);
    }
    while (true) {
        if (!soundPlayedAlreadyPlacement) {
            ClipPlayer.play(SoundPath.CLIP_PHASE_PLACEMENT, id);
            soundPlayedAlreadyPlacement = true;
        }
        final PlaceData placeData = ui.waitForPlace(id, bid, getPlayerBridge());
        if (placeData == null) {
            // this only happens in lhtr rules
            if (!GameStepPropertiesHelper.isRemoveAirThatCanNotLand(getGameData()) || canAirLand(false, id) || getPlayerBridge().isGameOver()) {
                return;
            }
            continue;
        }
        final String error = placeDel.placeUnits(placeData.getUnits(), placeData.getAt(), bid ? IAbstractPlaceDelegate.BidMode.BID : IAbstractPlaceDelegate.BidMode.NOT_BID);
        if (error != null) {
            ui.notifyError(error);
        }
    }
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) IAbstractPlaceDelegate(games.strategy.triplea.delegate.remote.IAbstractPlaceDelegate) PlaceData(games.strategy.triplea.ui.PlaceData)

Aggregations

PlayerID (games.strategy.engine.data.PlayerID)1 IAbstractPlaceDelegate (games.strategy.triplea.delegate.remote.IAbstractPlaceDelegate)1 PlaceData (games.strategy.triplea.ui.PlaceData)1