protected int getValueCount(ITurn turn, int value) { int count = 0; for (IDice dice : turn.getDiceList()) { if (dice.hasValue()) { if (dice.getValue() == value) { count++; } } } return count; }
protected int[] getValueCount(ITurn turn, int... values) { int[] counts = new int[values.length]; for (IDice dice : turn.getDiceList()) { if (dice.hasValue()) { for (int i = 0; i < values.length; i++) { int value = values[i]; if (dice.getValue() == value) { counts[i]++; } } } } return counts; }
/** Get values sorted byt natural order so smallest is first and largest is last */ protected List<Integer> getValues(ITurn turn) { List<Integer> values = new ArrayList<Integer>(); for (IDice dice : turn.getDiceList()) { if (dice.hasValue()) { int value = dice.getValue(); if (values.contains(value) == false) { values.add(value); } } } Collections.sort(values); return values; }