use of games.strategy.engine.data.GameSequence in project triplea by triplea-game.
the class ProUtils method getOtherPlayersInTurnOrder.
public static List<PlayerID> getOtherPlayersInTurnOrder(final PlayerID player) {
final GameData data = ProData.getData();
final List<PlayerID> players = new ArrayList<>();
final GameSequence sequence = data.getSequence();
final int startIndex = sequence.getStepIndex();
for (int i = 0; i < sequence.size(); i++) {
int currentIndex = startIndex + i;
if (currentIndex >= sequence.size()) {
currentIndex -= sequence.size();
}
final GameStep step = sequence.getStep(currentIndex);
final PlayerID stepPlayer = step.getPlayerId();
if (step.getName().endsWith("CombatMove") && stepPlayer != null && !stepPlayer.equals(player) && !players.contains(stepPlayer)) {
players.add(step.getPlayerId());
}
}
return players;
}
use of games.strategy.engine.data.GameSequence in project triplea by triplea-game.
the class PlayerOrderComparator method compare.
/**
* sort based on first step that isn't a bid related step.
*/
@Override
public int compare(final PlayerID p1, final PlayerID p2) {
if (p1.equals(p2)) {
return 0;
}
gameData.acquireReadLock();
final GameSequence sequence;
try {
sequence = gameData.getSequence();
} finally {
gameData.releaseReadLock();
}
for (final GameStep s : sequence) {
if (s.getPlayerId() == null) {
continue;
}
gameData.acquireReadLock();
final IDelegate delegate;
try {
delegate = s.getDelegate();
} finally {
gameData.releaseReadLock();
}
if (delegate != null && delegate.getClass() != null) {
final String delegateClassName = delegate.getClass().getName();
if (delegateClassName.equals("games.strategy.triplea.delegate.InitializationDelegate") || delegateClassName.equals("games.strategy.triplea.delegate.BidPurchaseDelegate") || delegateClassName.equals("games.strategy.triplea.delegate.BidPlaceDelegate") || delegateClassName.equals("games.strategy.triplea.delegate.EndRoundDelegate")) {
continue;
}
} else if (s.getName() != null && (s.getName().endsWith("Bid") || s.getName().endsWith("BidPlace"))) {
continue;
}
if (s.getPlayerId().equals(p1)) {
return -1;
} else if (s.getPlayerId().equals(p2)) {
return 1;
}
}
return 0;
}