Search in sources :

Example 1 with BattleRecords

use of games.strategy.triplea.delegate.dataObjects.BattleRecords in project triplea by triplea-game.

the class RemoveBattleRecordsChange method perform.

@Override
protected void perform(final GameData data) {
    final Map<Integer, BattleRecords> currentRecords = data.getBattleRecordsList().getBattleRecordsMap();
    // make a copy else we will get a concurrent modification error
    BattleRecordsList.removeRecords(currentRecords, m_round, new BattleRecords(m_recordsToRemove));
}
Also used : BattleRecords(games.strategy.triplea.delegate.dataObjects.BattleRecords)

Example 2 with BattleRecords

use of games.strategy.triplea.delegate.dataObjects.BattleRecords in project triplea by triplea-game.

the class BattleRecordsList method addRecords.

public static void addRecords(final Map<Integer, BattleRecords> recordList, final int currentRound, final BattleRecords other) {
    final BattleRecords current = recordList.get(currentRound);
    if (current == null) {
        recordList.put(currentRound, other);
        return;
    }
    current.addRecord(other);
    recordList.put(currentRound, current);
}
Also used : BattleRecords(games.strategy.triplea.delegate.dataObjects.BattleRecords)

Example 3 with BattleRecords

use of games.strategy.triplea.delegate.dataObjects.BattleRecords in project triplea by triplea-game.

the class BattleRecordsList method removeRecords.

public static void removeRecords(final Map<Integer, BattleRecords> recordList, final int round, final BattleRecords other) {
    final BattleRecords current = recordList.get(round);
    if (current == null) {
        throw new IllegalStateException("Trying to remove records for round that does not exist");
    }
    current.removeRecord(other);
}
Also used : BattleRecords(games.strategy.triplea.delegate.dataObjects.BattleRecords)

Example 4 with BattleRecords

use of games.strategy.triplea.delegate.dataObjects.BattleRecords in project triplea by triplea-game.

the class AddBattleRecordsChange method perform.

@Override
protected void perform(final GameData data) {
    final Map<Integer, BattleRecords> currentRecords = data.getBattleRecordsList().getBattleRecordsMap();
    // make a copy because otherwise ours will be
    // cleared when we RemoveBattleRecordsChange
    BattleRecordsList.addRecords(currentRecords, m_round, new BattleRecords(m_recordsToAdd));
}
Also used : BattleRecords(games.strategy.triplea.delegate.dataObjects.BattleRecords)

Example 5 with BattleRecords

use of games.strategy.triplea.delegate.dataObjects.BattleRecords in project triplea by triplea-game.

the class BattleRecordsList method getTuvDamageCausedByPlayer.

// Interpretation stuff below
public static int getTuvDamageCausedByPlayer(final PlayerID attacker, final BattleRecordsList brl, final int beginningRound, final int endRound, final boolean currentRoundOnly, final boolean includeNullPlayer) {
    final Collection<BattleRecords> brs = new ArrayList<>();
    if (currentRoundOnly) {
        if (brl != null) {
            final BattleRecords current = brl.getCurrentRoundCopy();
            if (current != null) {
                brs.add(current);
            }
        }
    } else {
        if (brl != null) {
            final Map<Integer, BattleRecords> currentList = brl.getBattleRecordsMapCopy();
            if (currentList != null) {
                for (int i = beginningRound; i <= endRound; i++) {
                    final BattleRecords currentRecords = currentList.get(i);
                    if (currentRecords != null) {
                        brs.add(currentRecords);
                    }
                }
            }
        }
    }
    int damageCausedByAttacker = 0;
    for (final BattleRecords br : brs) {
        damageCausedByAttacker += BattleRecords.getLostTuvForBattleRecords(BattleRecords.getRecordsForPlayerId(attacker, br), false, includeNullPlayer);
    }
    return damageCausedByAttacker;
}
Also used : ArrayList(java.util.ArrayList) BattleRecords(games.strategy.triplea.delegate.dataObjects.BattleRecords)

Aggregations

BattleRecords (games.strategy.triplea.delegate.dataObjects.BattleRecords)5 ArrayList (java.util.ArrayList)1