290 public static WeightedRandomPicker<DropGroupRow>
getPicker(String group) {
291 WeightedRandomPicker<DropGroupRow> picker =
new WeightedRandomPicker<DropGroupRow>();
298 if (!spec.isMultiValued() && spec.isFighterWing() && spec.getFighterWingSpec().hasTag(Tags.WING_NO_DROP)) {
302 if (spec.getGroup().equals(group)) {
303 picker.add(spec, spec.getFreq());
308 if (curr.isNothing() && curr.percent) {
309 float totalOther = picker.getTotal() - curr.freq;
311 float fNothing = curr.freq / 100f;
312 if (fNothing < 0) fNothing = 0;
313 if (fNothing > 1) fNothing = 1;
315 float weightNothing = totalOther * fNothing / (1f - fNothing);
317 picker.setWeight(picker.getItems().indexOf(curr), weightNothing);
322 if (picker.isEmpty()) {
323 throw new RuntimeException(
"No drop data found for drop group [" + group +
"], probably an error in drop_groups.csv");
331 if (random ==
null) random =
new Random();
336 copy.multiValued =
false;
346 String test = commodity.replaceFirst(
ITEM_PREFIX,
"");
347 int index = test.indexOf(
':');
350 boolean getParamsFromP =
false;
351 String itemId = test.substring(0, index);
352 String params = test.substring(index + 1);
354 if (!itemId.isEmpty()) {
359 Iterator<SpecialItemSpecAPI> iter = specs.iterator();
365 if (!tags.isEmpty()) {
366 iter = specs.iterator();
367 while (iter.hasNext()) {
368 SpecialItemSpecAPI curr = iter.next();
369 for (String tag : tags) {
370 boolean not = tag.startsWith(
"!");
371 tag = not ? tag.substring(1) : tag;
372 boolean has = curr.hasTag(tag);
381 WeightedRandomPicker<SpecialItemSpecAPI> picker =
new WeightedRandomPicker<SpecialItemSpecAPI>(random);
382 for (SpecialItemSpecAPI spec : specs) {
383 picker.add(spec, 1f * spec.getRarity());
385 SpecialItemSpecAPI pick = picker.pick();
389 itemId = pick.getId();
390 getParamsFromP =
true;
395 if (!itemId.isEmpty()) {
398 if (getParamsFromP) {
399 JSONObject json =
new JSONObject(params);
401 params = json.getJSONObject(
"p").toString();
408 SpecialItemPlugin plugin = spec.getNewPluginInstance(
null);
409 String itemData = plugin.resolveDropParamsToSpecificItemData(params, random);
411 if (itemData ==
null) {
413 }
else if (itemData.isEmpty()) {
416 copy.commodity =
ITEM_PREFIX + itemId +
":" + itemData;
421 }
catch (JSONException e) {
422 throw new RuntimeException(
"Params: " + params, e);
478 Iterator<WeaponSpecAPI> iter = specs.iterator();
479 while (iter.hasNext()) {
480 WeaponSpecAPI curr = iter.next();
481 if (curr.getTier() != tier) iter.remove();
485 if (!tags.isEmpty()) {
486 Iterator<WeaponSpecAPI> iter = specs.iterator();
487 while (iter.hasNext()) {
488 WeaponSpecAPI curr = iter.next();
489 for (String tag : tags) {
490 boolean not = tag.startsWith(
"!");
491 tag = not ? tag.substring(1) : tag;
492 boolean has = curr.hasTag(tag);
501 if (weaponType !=
null || weaponSize !=
null) {
502 Iterator<WeaponSpecAPI> iter = specs.iterator();
503 while (iter.hasNext()) {
504 WeaponSpecAPI curr = iter.next();
505 if ((weaponType !=
null && curr.getType() != weaponType) ||
506 (weaponSize !=
null && curr.getSize() != weaponSize)) {
513 WeightedRandomPicker<WeaponSpecAPI> picker =
new WeightedRandomPicker<WeaponSpecAPI>(random);
515 for (WeaponSpecAPI spec : specs) {
516 picker.add(spec, 1f * spec.getRarity());
518 WeaponSpecAPI pick = picker.pick();
526 Iterator<FighterWingSpecAPI> iter = specs.iterator();
527 while (iter.hasNext()) {
528 FighterWingSpecAPI curr = iter.next();
529 if (curr.hasTag(Tags.WING_NO_DROP)) iter.remove();
532 iter = specs.iterator();
533 while (iter.hasNext()) {
534 FighterWingSpecAPI curr = iter.next();
535 if (curr.getTier() != tier) iter.remove();
539 if (!tags.isEmpty()) {
540 iter = specs.iterator();
541 while (iter.hasNext()) {
542 FighterWingSpecAPI curr = iter.next();
543 for (String tag : tags) {
544 boolean not = tag.startsWith(
"!");
545 tag = not ? tag.substring(1) : tag;
546 boolean has = curr.hasTag(tag);
554 WeightedRandomPicker<FighterWingSpecAPI> picker =
new WeightedRandomPicker<FighterWingSpecAPI>(random);
556 for (FighterWingSpecAPI spec : specs) {
557 picker.add(spec, 1f * spec.getRarity());
559 FighterWingSpecAPI pick = picker.pick();