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

Method testApply

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

Source from the content-addressed store, hash-verified

165 }
166
167 @Override
168 public boolean testApply(Kit aKit, PlayerCharacter aPC, List<String> warnings)
169 {
170 actingQuantity = quantity;
171 actingCost = maxCost;
172 actingMods = mods == null ? null : new ArrayList<>(mods);
173 actingLocation = theLocationStr;
174 if (size != null)
175 {
176 actingSize = size.get();
177 }
178
179 theEquipment = null;
180 theQty = 0;
181 theLocation = "";
182 theCost = BigDecimal.ZERO;
183
184 processLookups(aKit, aPC);
185
186 int aBuyRate = aKit.getBuyRate(aPC);
187 BigDecimal pcGold = new BigDecimal(ChannelUtilities
188 .readControlledChannel(aPC.getCharID(), CControl.GOLDINPUT).toString());
189 final BigDecimal fixedTotalCost = aKit.getTotalCost(aPC);
190 if (fixedTotalCost != null)
191 {
192 // We are going to charge fr the kit once, rather than for every piece of gear
193 aBuyRate = 0;
194 }
195
196 List<Equipment> eqList = new ArrayList<>(equip.getContainedObjects());
197 if (actingCost != null)
198 {
199 final BigDecimal bdMaxCost = new BigDecimal(Integer.toString(actingCost));
200 eqList.removeIf(equipment -> equipment.getCost(aPC).compareTo(bdMaxCost) > 0);
201 }
202 if (eqList.size() == 1)
203 {
204 theEquipment = eqList.get(0);
205 }
206 else
207 {
208 List<Equipment> selected = new ArrayList<>(1);
209 selected = Globals.getChoiceFromList("Choose equipment", eqList, selected, 1, aPC);
210 if (selected.size() == 1)
211 {
212 theEquipment = selected.get(0);
213 }
214 }
215
216 //
217 // TODO: Check to see if the user has selected an item that
218 // requires modification (MOD:R)
219
220 theEquipment = theEquipment.clone();
221
222 //
223 // Resize item for character--never resize weapons or ammo, unless it's a
224 // natural (weapon)

Callers

nothing calls this directly

Calls 15

processLookupsMethod · 0.95
readControlledChannelMethod · 0.95
getChoiceFromListMethod · 0.95
canResizeHaveEffectMethod · 0.95
setControlledChannelMethod · 0.95
setQtyMethod · 0.95
getNameMethod · 0.95
getTotalCostMethod · 0.80
removeIfMethod · 0.80
isAmmunitionMethod · 0.80
typeListMethod · 0.80

Tested by

no test coverage detected