(Kit aKit, PlayerCharacter aPC, List<String> warnings)
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public boolean testApply(Kit aKit, PlayerCharacter aPC, List<String> warnings) |
| 112 | { |
| 113 | abilitiesToAdd = new ArrayList<>(); |
| 114 | double minCost = Double.MAX_VALUE; |
| 115 | List<AbilitySelection> available = new ArrayList<>(); |
| 116 | for (CDOMReference<Ability> ref : abilities) |
| 117 | { |
| 118 | String choice = ref.getChoice(); |
| 119 | for (Ability a : ref.getContainedObjects()) |
| 120 | { |
| 121 | if (a == null) |
| 122 | { |
| 123 | warnings.add("ABILITY: " + ref + " could not be found."); |
| 124 | minCost = 0; |
| 125 | continue; |
| 126 | } |
| 127 | |
| 128 | if (a.getCost() < minCost) |
| 129 | { |
| 130 | minCost = a.getCost(); |
| 131 | } |
| 132 | if ((choice == null) && a.getSafe(ObjectKey.MULTIPLE_ALLOWED)) |
| 133 | { |
| 134 | available.add(new AbilitySelection(a, "")); |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | available.add(new AbilitySelection(a, choice)); |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | int numberOfChoices = getSafeCount(); |
| 144 | // Can't choose more entries than there are... |
| 145 | // TODO this fails if SELECT != 1 |
| 146 | if (numberOfChoices > available.size()) |
| 147 | { |
| 148 | numberOfChoices = available.size(); |
| 149 | } |
| 150 | |
| 151 | /* |
| 152 | * this section needs to be rewritten once we determine how |
| 153 | * the new Ability Pools are going to work |
| 154 | */ |
| 155 | |
| 156 | AbilityCategory category = catRef.get(); |
| 157 | boolean tooManyAbilities = false; |
| 158 | // Don't allow choosing of more than allotted number of abilities |
| 159 | int maxChoices = minCost > 0.0d |
| 160 | ? aPC.getAvailableAbilityPool(category).divide(new BigDecimal(String.valueOf(minCost))).intValue() |
| 161 | : numberOfChoices; |
| 162 | if (!isFree() && numberOfChoices > maxChoices) |
| 163 | { |
| 164 | numberOfChoices = maxChoices; |
| 165 | tooManyAbilities = true; |
| 166 | } |
| 167 |
nothing calls this directly
no test coverage detected