public Object getValueAt(int row, int col) { BattleResults statistics = results[row]; switch (col) { case 0: { int place = row + 1; while (place < getRowCount() && statistics.getScore() == results[place].getScore()) { place++; } return StringUtil.getPlacementString(place); } case 1: return statistics.getTeamLeaderName(); case 2: String percent = ""; if (totalScore != 0) { percent = " (" + NumberFormat.getPercentInstance().format(statistics.getScore() / totalScore) + ")"; } return "" + (int) (statistics.getScore() + 0.5) + percent; case 3: return "" + (int) (statistics.getSurvival() + 0.5); case 4: return "" + (int) (statistics.getLastSurvivorBonus() + 0.5); case 5: return "" + (int) (statistics.getBulletDamage() + 0.5); case 6: return "" + (int) (statistics.getBulletDamageBonus() + 0.5); case 7: return "" + (int) (statistics.getRamDamage() + 0.5); case 8: return "" + (int) (statistics.getRamDamageBonus() + 0.5); case 9: return "" + statistics.getFirsts(); case 10: return "" + statistics.getSeconds(); case 11: return "" + statistics.getThirds(); default: return ""; } }
/** * The actual test, which asserts that ToyBot has won every round against SittingDuck. * * @param event Details about the completed battle. */ @Override public void onBattleCompleted(BattleCompletedEvent event) { // Return the results in order of getRobotNames. BattleResults[] battleResults = event.getIndexedResults(); // Sanity check that results[1] is ToyBot (not strictly necessary, but illustrative). BattleResults ToyBotResults = battleResults[1]; String robotName = ToyBotResults.getTeamLeaderName(); assertEquals("Check that results[1] is ToyBot", robotName, "lto.ToyBot*"); // Check to make sure ToyBot won every round. assertEquals("Check ToyBot winner", ToyBotResults.getFirsts(), getNumRounds()); }
private BattleResultsWrapper(BattleResults results) { super( results.getTeamLeaderName(), results.getRank(), results.getScore(), results.getSurvival(), results.getLastSurvivorBonus(), results.getBulletDamage(), results.getBulletDamageBonus(), results.getRamDamage(), results.getRamDamageBonus(), results.getFirsts(), results.getSeconds(), results.getThirds()); }