use of games.strategy.triplea.attachments.UserActionAttachment in project triplea by triplea-game.
the class TripleAPlayer method userActions.
private void userActions(final boolean firstRun) {
if (getPlayerBridge().isGameOver()) {
return;
}
final IUserActionDelegate userActionDelegate;
try {
userActionDelegate = (IUserActionDelegate) 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);
}
final UserActionAttachment actionChoice = ui.getUserActionChoice(getPlayerId(), firstRun, userActionDelegate);
if (actionChoice != null) {
userActionDelegate.attemptAction(actionChoice);
userActions(false);
}
}
use of games.strategy.triplea.attachments.UserActionAttachment in project triplea by triplea-game.
the class UserActionPanelTest method testCanPlayerAffordUserAction_ShouldReturnFalseWhenUserActionCostGreaterThanPlayerPUs.
@Test
public void testCanPlayerAffordUserAction_ShouldReturnFalseWhenUserActionCostGreaterThanPlayerPUs() {
givenGameHasPuResource();
final PlayerID player = createPlayer();
final UserActionAttachment userAction = createUserActionWithCost(player.getResources().getQuantity(pus) + 1);
final boolean canAffordUserAction = UserActionPanel.canPlayerAffordUserAction(player, userAction);
assertThat(canAffordUserAction, is(false));
}
use of games.strategy.triplea.attachments.UserActionAttachment in project triplea by triplea-game.
the class UserActionPanelTest method testCanPlayerAffordUserAction_ShouldReturnTrueWhenUserActionCostIsZeroAndPlayerPUsIsZero.
@Test
public void testCanPlayerAffordUserAction_ShouldReturnTrueWhenUserActionCostIsZeroAndPlayerPUsIsZero() {
givenGameHasPuResource();
final PlayerID player = createPlayer();
final UserActionAttachment userAction = createUserActionWithCost(0);
final boolean canAffordUserAction = UserActionPanel.canPlayerAffordUserAction(player, userAction);
assertThat(canAffordUserAction, is(true));
}
use of games.strategy.triplea.attachments.UserActionAttachment in project triplea by triplea-game.
the class UserActionPanelTest method testCanPlayerAffordUserAction_ShouldReturnTrueWhenUserActionCostEqualToPlayerPUs.
@Test
public void testCanPlayerAffordUserAction_ShouldReturnTrueWhenUserActionCostEqualToPlayerPUs() {
givenGameHasPuResource();
final PlayerID player = createPlayer();
final UserActionAttachment userAction = createUserActionWithCost(player.getResources().getQuantity(pus));
final boolean canAffordUserAction = UserActionPanel.canPlayerAffordUserAction(player, userAction);
assertThat(canAffordUserAction, is(true));
}
use of games.strategy.triplea.attachments.UserActionAttachment in project triplea by triplea-game.
the class UserActionPanelTest method createUserActionWithCost.
private UserActionAttachment createUserActionWithCost(final int costInPUs) {
final UserActionAttachment userAction = new UserActionAttachment("userAction", mock(Attachable.class), data);
userAction.setCostPu(costInPUs);
return userAction;
}
Aggregations