MCPcopy Create free account
hub / github.com/PCGen/pcgen / testApply

Method testApply

code/src/java/pcgen/core/kit/KitAbilities.java:110–224  ·  view source on GitHub ↗
(Kit aKit, PlayerCharacter aPC, List<String> warnings)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

getSafeCountMethod · 0.95
isFreeMethod · 0.95
getPluralNameMethod · 0.95
getChoiceFromListMethod · 0.95
getCostMethod · 0.95
getCNAbilityMethod · 0.95
getInstanceMethod · 0.95
getSafeMethod · 0.80
intValueMethod · 0.80
divideMethod · 0.80
adjustAbilitiesMethod · 0.80

Tested by

no test coverage detected