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

Method parseEquipmentLine

code/src/java/pcgen/io/PCGVer2Parser.java:4687–4888  ·  view source on GitHub ↗
(final String line)

Source from the content-addressed store, hash-verified

4685 }
4686
4687 private void parseEquipmentLine(final String line)
4688 {
4689 final PCGTokenizer tokens;
4690
4691 try
4692 {
4693 tokens = new PCGTokenizer(line);
4694 }
4695 catch (PCGParseException pcgpex)
4696 {
4697 final String message = "Illegal Equipment line ignored: " + line + Constants.LINE_SEPARATOR + "Error: "
4698 + pcgpex.getMessage();
4699 warnings.add(message);
4700
4701 return;
4702 }
4703
4704 String itemKey;
4705 Equipment aEquip;
4706
4707 PCGElement element;
4708
4709 // the first element defines the item key name
4710 element = tokens.getElements().get(0);
4711 itemKey = EntityEncoder.decode(element.getText());
4712 // Check for an equipment key that has been updated.
4713 itemKey = EquipmentMigration.getNewEquipmentKey(itemKey, pcgenVersion, SettingsHandler.getGameAsProperty().get().getName());
4714
4715 // might be dynamically created container
4716 aEquip = thePC.getEquipmentNamed(itemKey);
4717
4718 if (aEquip == null)
4719 {
4720 // Must load custom equipment from the .pcg file
4721 // before we check the Global list (which may get
4722 // loaded from customEquipment.lst) as equipment
4723 // in the PC's .pcg may contain additional info
4724 // such as Charges on a wand, etc
4725 //
4726 // Make sure that we are not picking up custom items!
4727 aEquip = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Equipment.class,
4728 itemKey);
4729 if (aEquip != null)
4730 {
4731 if (aEquip.isType(Constants.TYPE_CUSTOM))
4732 {
4733 aEquip = null;
4734 }
4735 else
4736 {
4737 // standard item
4738 aEquip = aEquip.clone();
4739 }
4740 }
4741 if (line.contains(IOConstants.TAG_CUSTOMIZATION))
4742 {
4743 // might be customized item
4744 for (PCGElement pcgElement : tokens.getElements())

Callers 1

parseCachedLinesMethod · 0.95

Calls 15

getElementsMethod · 0.95
decodeMethod · 0.95
getTextMethod · 0.95
getNewEquipmentKeyMethod · 0.95
getGameAsPropertyMethod · 0.95
getContextMethod · 0.95
isTypeMethod · 0.95
cloneMethod · 0.95
getNameMethod · 0.95
getChildrenMethod · 0.95
getBaseItemNameMethod · 0.95

Tested by

no test coverage detected