From: <th...@us...> - 2008-01-13 19:38:33
|
Revision: 4872 http://pcgen.svn.sourceforge.net/pcgen/?rev=4872&view=rev Author: thpr Date: 2008-01-13 11:38:37 -0800 (Sun, 13 Jan 2008) Log Message: ----------- [ 1856120 ] Please Implement - Equipment Prof Token Issue#: 1856120 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/ArmorProf.java Trunk/pcgen/code/src/java/pcgen/core/Campaign.java Trunk/pcgen/code/src/java/pcgen/core/Globals.java Trunk/pcgen/code/src/java/pcgen/core/PObject.java Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/ProficiencyToken.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreShieldProfTester.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/core/ShieldProf.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLstToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ArmorprofToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ShieldprofToken.java Modified: Trunk/pcgen/code/src/java/pcgen/core/ArmorProf.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/ArmorProf.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/pcgen/core/ArmorProf.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -28,13 +28,8 @@ * @version $Revision$ * DO NOT DELETE (waiting for use) */ -final class ArmorProf extends PObject implements Comparable<Object> +public final class ArmorProf extends PObject implements Comparable<Object> { - ArmorProf(final String aString) - { - setName(aString); - } - /** * Compares keyName only * Modified: Trunk/pcgen/code/src/java/pcgen/core/Campaign.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -79,6 +79,8 @@ listChar.initializeListFor(ListKey.FILE_SPELL); listChar.initializeListFor(ListKey.FILE_TEMPLATE); listChar.initializeListFor(ListKey.FILE_WEAPON_PROF); + listChar.initializeListFor(ListKey.FILE_ARMOR_PROF); + listChar.initializeListFor(ListKey.FILE_SHIELD_PROF); } /** @@ -556,6 +558,24 @@ * * @param file */ + public void addArmorProfFile(final CampaignSourceEntry file) + { + listChar.addToListFor(ListKey.FILE_ARMOR_PROF, file); + } + + /** + * + * @param file + */ + public void addShieldProfFile(final CampaignSourceEntry file) + { + listChar.addToListFor(ListKey.FILE_SHIELD_PROF, file); + } + + /** + * + * @param file + */ public void addWeaponProfFile(final CampaignSourceEntry file) { listChar.addToListFor(ListKey.FILE_WEAPON_PROF, file); @@ -958,6 +978,24 @@ } /** + * Returns the armorProfFileList. + * @return List + */ + public List<CampaignSourceEntry> getArmorProfFiles() + { + return getListFor(ListKey.FILE_ARMOR_PROF); + } + + /** + * Returns the shieldProfFileList. + * @return List + */ + public List<CampaignSourceEntry> getShieldProfFiles() + { + return getListFor(ListKey.FILE_SHIELD_PROF); + } + + /** * Returns the weaponProfFileList. * @return List */ Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -127,6 +127,8 @@ /** Weapon proficiency Data storage */ private static final PObjectDataStore<WeaponProf> weaponProfs = new PObjectDataStore<WeaponProf>("WeaponProf"); + private static final PObjectDataStore<ArmorProf> armorProfs = new PObjectDataStore<ArmorProf>("ArmorProf"); + private static final PObjectDataStore<ShieldProf> shieldProfs = new PObjectDataStore<ShieldProf>("ShieldProf"); /** this is used by the random selection tools */ private static final Random random = new Random(System.currentTimeMillis()); @@ -2028,6 +2030,28 @@ } /** + * Searches for an exact key match. + * + * @param aKey + * @return an exact match or null + */ + public static ArmorProf getArmorProfKeyed(final String aKey) + { + return armorProfs.getKeyed(aKey); + } + + /** + * Searches for an exact key match. + * + * @param aKey + * @return an exact match or null + */ + public static ShieldProf getShieldProfKeyed(final String aKey) + { + return shieldProfs.getKeyed(aKey); + } + + /** * Get weapon prof names * @param delim * @param addArrayMarkers @@ -2199,6 +2223,24 @@ } /** + * Add a armor proficiency + * @param wp + */ + public static void addArmorProf(final ArmorProf wp) + { + armorProfs.add(wp); + } + + /** + * Add a shield proficiency + * @param wp + */ + public static void addShieldProf(final ShieldProf wp) + { + shieldProfs.add(wp); + } + + /** * Adjust damage * @param aDamage * @param baseSize @@ -2580,6 +2622,24 @@ } /** + * Remove a armor prof by key + * @param aKey + */ + public static void removeArmorProfKeyed(final String aKey) + { + armorProfs.removeNamed(aKey); + } + + /** + * Remove a shield prof by key + * @param aKey + */ + public static void removeShieldProfKeyed(final String aKey) + { + shieldProfs.removeNamed(aKey); + } + + /** * roll HP * @param min * @param max Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -3309,12 +3309,19 @@ String tok = aTok.nextToken(); if ((tok.startsWith("TYPE=") || tok.startsWith("TYPE.")) - && tag.startsWith("WEAPON") && expandWeaponTypes) - { - List<String> xList = processWeaponAutoTags(aPC, tok); + && tag.startsWith("WEAPON") && expandWeaponTypes) + { + List<String> xList = processWeaponAutoTags(aPC, tok.substring(5)); - aList.addAll(xList); - } + aList.addAll(xList); + } + else if ((tok.startsWith("WEAPONTYPE=") || tok.startsWith("WEAPONTYPE.")) + && tag.startsWith("WEAPON") && expandWeaponTypes) + { + List<String> xList = processWeaponAutoTags(aPC, tok.substring(11)); + + aList.addAll(xList); + } else if ((tok.startsWith("TYPE=") || tok.startsWith("TYPE.")) && tag.startsWith("ARMOR")) { @@ -3384,7 +3391,7 @@ */ private List<String> processWeaponAutoTags(final PlayerCharacter aPC, String tok) { - final StringTokenizer bTok = new StringTokenizer(tok.substring(5), "."); + final StringTokenizer bTok = new StringTokenizer(tok, "."); List<String> xList = null; while (bTok.hasMoreTokens()) Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -7683,8 +7683,12 @@ // // Insert all types at the head of the list // - if (aProf.startsWith("TYPE=") || aProf.startsWith("TYPE.")) + if (aProf.startsWith("SHIELDTYPE=") || aProf.startsWith("SHIELDTYPE.")) { + armorProfList.add(0, aProf); + } + else if (aProf.startsWith("TYPE=") || aProf.startsWith("TYPE.")) + { shieldProfList.add(0, aProf); } else @@ -11940,6 +11944,10 @@ { tok = new StringTokenizer(aString.substring(10), "."); } + else if (aString.startsWith("SHIELDTYPE=") || aString.startsWith("SHIELDTYPE.")) + { + tok = new StringTokenizer(aString.substring(11), "."); + } else { // All TYPE profs are at the beginning of the list Added: Trunk/pcgen/code/src/java/pcgen/core/ShieldProf.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/ShieldProf.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/core/ShieldProf.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -0,0 +1,68 @@ +/* + * ArmorProf.java + * Copyright 2001 (C) Bryan McRoberts <mer...@ya...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on April 21, 2001, 2:15 PM + */ +package pcgen.core; + + +/** + * <code>ArmorProf</code>. + * + * @author Thomas Clegg <ark...@sw...> + * @version $Revision: 1957 $ + * DO NOT DELETE (waiting for use) + */ +public final class ShieldProf extends PObject implements Comparable<Object> +{ + /** + * Compares keyName only + * + * @param o1 Object + * @return int + * @see Comparable#compareTo(Object) + */ + @Override + public int compareTo(final Object o1) + { + return keyName.compareToIgnoreCase(((ShieldProf) o1).keyName); + } + + /** + * Compares keyName only + * + * @param o1 Object + * @return boolean + */ + @Override + public boolean equals(final Object o1) + { + return o1 instanceof ShieldProf && keyName.equals(((ShieldProf) o1).keyName); + } + + /** + * Hashcode of the keyName + * + * @return int + */ + @Override + public int hashCode() + { + return keyName.hashCode(); + } +} Modified: Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -139,6 +139,8 @@ public static final ListKey<Ability> VIRTUAL_FEATS = new ListKey<Ability>(); // /** Key for a list of weapon proficiencies */ // public static final ListKey<String> WEAPON_PROF = new ListKey<String>(); + public static final ListKey<CampaignSourceEntry> FILE_ARMOR_PROF = new ListKey<CampaignSourceEntry>(); + public static final ListKey<CampaignSourceEntry> FILE_SHIELD_PROF = new ListKey<CampaignSourceEntry>(); /** Private constructor to prevent instantiation of this class */ private ListKey() { Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLoader.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -0,0 +1,149 @@ +/* + * WeaponProfLoader.java + * Copyright 2001 (C) Bryan McRoberts <mer...@ya...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on February 22, 2002, 10:29 PM + * + * $Id: WeaponProfLoader.java 3827 2007-08-20 21:42:58Z thpr $ + */ +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.ArmorProf; +import pcgen.core.Globals; +import pcgen.core.PObject; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public final class ArmorProfLoader extends LstObjectFileLoader<ArmorProf> +{ + /** Creates a new instance of ArmorProfLoader */ + public ArmorProfLoader() + { + super(); + } + + /** + * @see pcgen.persistence.lst.LstObjectFileLoader#parseLine(pcgen.core.PObject, java.lang.String, pcgen.persistence.lst.CampaignSourceEntry) + */ + @Override + public ArmorProf parseLine(ArmorProf aWP, String lstLine, + CampaignSourceEntry source) throws PersistenceLayerException + { + ArmorProf prof = aWP; + + // Make sure we have a weapon prof to load + if (prof == null) + { + prof = new ArmorProf(); + } + + final StringTokenizer colToken = + new StringTokenizer(lstLine, SystemLoader.TAB_DELIM); + int col = 0; + + Map<String, LstToken> tokenMap = + TokenStore.inst().getTokenMap(ArmorProfLstToken.class); + while (colToken.hasMoreTokens()) + { + final String colString = colToken.nextToken().trim(); + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (Exception e) + { + // TODO Handle Exception + } + ArmorProfLstToken token = (ArmorProfLstToken) tokenMap.get(key); + + if (col == 0) // First column is name, without a tag + { + prof.setName(colString); + prof.setSourceCampaign(source.getCampaign()); + prof.setSourceURI(source.getURI()); + } + else if (token != null) + { + final String value = colString.substring(idxColon + 1).trim(); + LstUtils.deprecationCheck(token, prof, value); + if (!token.parse(prof, value)) + { + Logging.errorPrint("Error parsing skill " + + prof.getDisplayName() + ':' + source.getURI() + ':' + + colString + "\""); + } + } + else if (PObjectLoader.parseTag(prof, colString)) + { + continue; + } + else + { + Logging.errorPrint("Illegal armor proficiency info '" + + lstLine + "' in " + source.toString()); + } + + ++col; + } + + // WeaponProfs are one line each; + // finish the object and return null + completeObject(source, prof); + + return null; + } + + /** + * Get the weapon prof object with key aKey + * + * @param aKey + * @return PObject + * @see pcgen.persistence.lst.LstObjectFileLoader#getObjectKeyed(java.lang.String) + */ + @Override + protected ArmorProf getObjectKeyed(String aKey) + { + return Globals.getArmorProfKeyed(aKey); + } + + /** + * @see pcgen.persistence.lst.LstObjectFileLoader#performForget(pcgen.core.PObject) + */ + @Override + protected void performForget(final ArmorProf objToForget) + { + Globals.removeArmorProfKeyed(objToForget.getKeyName()); + } + + /** + * @see pcgen.persistence.lst.LstObjectFileLoader#addGlobalObject(pcgen.core.PObject) + */ + @Override + protected void addGlobalObject(final PObject pObj) + { + Globals.addArmorProf((ArmorProf) pObj); + // TODO - What exactly is this doing? Why would we set that it is not + // a new item when we just added it? + pObj.setNewItem(false); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/ArmorProfLstToken.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -0,0 +1,43 @@ +/* + * WeaponProfToken + * Copyright 2008 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on September 2, 2002, 8:16 AM + * + * Current Ver: $Revision: 197 $ + * Last Editor: $Author: nuance $ + * Last Edited: $Date: 2006-03-14 18:59:43 -0400 (Tue, 14 Mar 2006) $ + * + */ +package pcgen.persistence.lst; + +import pcgen.core.ArmorProf; + +/** + * <code>ArmorProfToken</code> + */ +public interface ArmorProfLstToken extends LstToken +{ + /** + * Parses an ArmorProf object + * + * @param prof + * @param value + * @return true if parse OK + */ + public abstract boolean parse(ArmorProf prof, String value); +} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -205,7 +205,11 @@ private final List<CampaignSourceEntry> templateFileList = new ArrayList<CampaignSourceEntry>(); private final List<CampaignSourceEntry> weaponProfFileList = - new ArrayList<CampaignSourceEntry>(); + new ArrayList<CampaignSourceEntry>(); + private final List<CampaignSourceEntry> armorProfFileList = + new ArrayList<CampaignSourceEntry>(); + private final List<CampaignSourceEntry> shieldProfFileList = + new ArrayList<CampaignSourceEntry>(); private LocationLoader locationLoader = new LocationLoader(); private final Set<URI> loadedFiles = new HashSet<URI>(); private PCClassLoader classLoader = new PCClassLoader(); @@ -232,6 +236,8 @@ private StringBuffer matureCampaigns = new StringBuffer(); private TraitLoader traitLoader = new TraitLoader(); private WeaponProfLoader wProfLoader = new WeaponProfLoader(); + private ArmorProfLoader aProfLoader = new ArmorProfLoader(); + private ShieldProfLoader sProfLoader = new ShieldProfLoader(); private boolean customItemsLoaded = false; private boolean showD20 = false; private boolean showLicensed = true; @@ -274,6 +280,8 @@ templateLoader.addObserver(this); traitLoader.addObserver(this); wProfLoader.addObserver(this); + aProfLoader.addObserver(this); + sProfLoader.addObserver(this); try { globalCampaign = new CampaignSourceEntry(new Campaign(), @@ -435,6 +443,8 @@ // load weapon profs first wProfLoader.loadLstFiles(weaponProfFileList); + aProfLoader.loadLstFiles(armorProfFileList); + sProfLoader.loadLstFiles(shieldProfFileList); // load skills before classes to handle class skills skillLoader.loadLstFiles(skillFileList); @@ -562,6 +572,8 @@ count += spellFileList.size(); count += templateFileList.size(); count += weaponProfFileList.size(); + count += armorProfFileList.size(); + count += shieldProfFileList.size(); return count; } @@ -1191,6 +1203,8 @@ deityFileList.addAll(aCamp.getDeityFiles()); domainFileList.addAll(aCamp.getDomainFiles()); weaponProfFileList.addAll(aCamp.getWeaponProfFiles()); + armorProfFileList.addAll(aCamp.getArmorProfFiles()); + shieldProfFileList.addAll(aCamp.getShieldProfFiles()); equipmentFileList.addAll(aCamp.getEquipFiles()); classSkillFileList.addAll(aCamp.getClassSkillFiles()); classSpellFileList.addAll(aCamp.getClassSpellFiles()); @@ -2000,6 +2014,8 @@ deityFileList.removeAll(lstExcludeFiles); domainFileList.removeAll(lstExcludeFiles); weaponProfFileList.removeAll(lstExcludeFiles); + armorProfFileList.removeAll(lstExcludeFiles); + shieldProfFileList.removeAll(lstExcludeFiles); equipmentFileList.removeAll(lstExcludeFiles); classSkillFileList.removeAll(lstExcludeFiles); classSpellFileList.removeAll(lstExcludeFiles); @@ -2030,6 +2046,8 @@ domainFileList.clear(); templateFileList.clear(); weaponProfFileList.clear(); + armorProfFileList.clear(); + shieldProfFileList.clear(); equipmentFileList.clear(); classSkillFileList.clear(); classSpellFileList.clear(); Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLoader.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -0,0 +1,149 @@ +/* + * WeaponProfLoader.java + * Copyright 2001 (C) Bryan McRoberts <mer...@ya...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on February 22, 2002, 10:29 PM + * + * $Id: WeaponProfLoader.java 3827 2007-08-20 21:42:58Z thpr $ + */ +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Globals; +import pcgen.core.PObject; +import pcgen.core.ShieldProf; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public final class ShieldProfLoader extends LstObjectFileLoader<ShieldProf> +{ + /** Creates a new instance of ShieldProfLoader */ + public ShieldProfLoader() + { + super(); + } + + /** + * @see pcgen.persistence.lst.LstObjectFileLoader#parseLine(pcgen.core.PObject, java.lang.String, pcgen.persistence.lst.CampaignSourceEntry) + */ + @Override + public ShieldProf parseLine(ShieldProf aWP, String lstLine, + CampaignSourceEntry source) throws PersistenceLayerException + { + ShieldProf prof = aWP; + + // Make sure we have a weapon prof to load + if (prof == null) + { + prof = new ShieldProf(); + } + + final StringTokenizer colToken = + new StringTokenizer(lstLine, SystemLoader.TAB_DELIM); + int col = 0; + + Map<String, LstToken> tokenMap = + TokenStore.inst().getTokenMap(ShieldProfLstToken.class); + while (colToken.hasMoreTokens()) + { + final String colString = colToken.nextToken().trim(); + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch (Exception e) + { + // TODO Handle Exception + } + ShieldProfLstToken token = (ShieldProfLstToken) tokenMap.get(key); + + if (col == 0) // First column is name, without a tag + { + prof.setName(colString); + prof.setSourceCampaign(source.getCampaign()); + prof.setSourceURI(source.getURI()); + } + else if (token != null) + { + final String value = colString.substring(idxColon + 1).trim(); + LstUtils.deprecationCheck(token, prof, value); + if (!token.parse(prof, value)) + { + Logging.errorPrint("Error parsing skill " + + prof.getDisplayName() + ':' + source.getURI() + ':' + + colString + "\""); + } + } + else if (PObjectLoader.parseTag(prof, colString)) + { + continue; + } + else + { + Logging.errorPrint("Illegal armor proficiency info '" + + lstLine + "' in " + source.toString()); + } + + ++col; + } + + // WeaponProfs are one line each; + // finish the object and return null + completeObject(source, prof); + + return null; + } + + /** + * Get the weapon prof object with key aKey + * + * @param aKey + * @return PObject + * @see pcgen.persistence.lst.LstObjectFileLoader#getObjectKeyed(java.lang.String) + */ + @Override + protected ShieldProf getObjectKeyed(String aKey) + { + return Globals.getShieldProfKeyed(aKey); + } + + /** + * @see pcgen.persistence.lst.LstObjectFileLoader#performForget(pcgen.core.PObject) + */ + @Override + protected void performForget(final ShieldProf objToForget) + { + Globals.removeShieldProfKeyed(objToForget.getKeyName()); + } + + /** + * @see pcgen.persistence.lst.LstObjectFileLoader#addGlobalObject(pcgen.core.PObject) + */ + @Override + protected void addGlobalObject(final PObject pObj) + { + Globals.addShieldProf((ShieldProf) pObj); + // TODO - What exactly is this doing? Why would we set that it is not + // a new item when we just added it? + pObj.setNewItem(false); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/ShieldProfLstToken.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -0,0 +1,43 @@ +/* + * WeaponProfToken + * Copyright 2008 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on September 2, 2002, 8:16 AM + * + * Current Ver: $Revision: 197 $ + * Last Editor: $Author: nuance $ + * Last Edited: $Date: 2006-03-14 18:59:43 -0400 (Tue, 14 Mar 2006) $ + * + */ +package pcgen.persistence.lst; + +import pcgen.core.ShieldProf; + +/** + * <code>ShieldProfToken</code> + */ +public interface ShieldProfLstToken extends LstToken +{ + /** + * Parses an ShieldProf object + * + * @param prof + * @param value + * @return true if parse OK + */ + public abstract boolean parse(ShieldProf prof, String value); +} Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -37,6 +37,11 @@ + " is not supported on class level lines"); return false; } + if (value.startsWith("TYPE")) + { + Logging.deprecationPrint("TYPE= in AUTO:" + getTokenName() + + " is deprecated. " + "Use SHIELDTYPE="); + } target.addAutoArray(getTokenName(), value); return true; } Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -37,6 +37,13 @@ + " is not supported on class level lines"); return false; } + if (value.startsWith("TYPE")) + { + Logging.deprecationPrint("TYPE= in AUTO:" + getTokenName() + + " Must refer to the Weapon Proficiency LST File. " + + "Consider WEAPONTYPE= " + + "if you are trying to match an Equipment TYPE"); + } target.addAutoArray(getTokenName(), value); return true; } Added: Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ArmorprofToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ArmorprofToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ArmorprofToken.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -0,0 +1,27 @@ +package plugin.lsttokens.campaign; + +import java.net.URI; + +import pcgen.core.Campaign; +import pcgen.persistence.lst.CampaignLstToken; +import pcgen.persistence.lst.CampaignSourceEntry; + +/** + * Class deals with WEAPONPROF Token + */ +public class ArmorprofToken implements CampaignLstToken +{ + + public String getTokenName() + { + return "ARMORPROF"; + } + + public boolean parse(Campaign campaign, String value, URI sourceUri) + { + campaign.addLine("ARMORPROF:" + value); + campaign.addArmorProfFile(CampaignSourceEntry.getNewCSE(campaign, + sourceUri, value)); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ShieldprofToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ShieldprofToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/ShieldprofToken.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -0,0 +1,27 @@ +package plugin.lsttokens.campaign; + +import java.net.URI; + +import pcgen.core.Campaign; +import pcgen.persistence.lst.CampaignLstToken; +import pcgen.persistence.lst.CampaignSourceEntry; + +/** + * Class deals with WEAPONPROF Token + */ +public class ShieldprofToken implements CampaignLstToken +{ + + public String getTokenName() + { + return "ArmorprofToken.java"; + } + + public boolean parse(Campaign campaign, String value, URI sourceUri) + { + campaign.addLine("SHIELDPROF:" + value); + campaign.addShieldProfFile(CampaignSourceEntry.getNewCSE(campaign, + sourceUri, value)); + return true; + } +} Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/ProficiencyToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/ProficiencyToken.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/ProficiencyToken.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -45,36 +45,15 @@ } if (subtoken.equals("WEAPON")) { - if (prof.startsWith("TYPE=")) - { - eq.setArmorProf("Weapon (" + prof.substring(5) + ")"); - } - else - { - eq.setWeaponProf(prof); - } + eq.setWeaponProf(prof); } else if (subtoken.equals("ARMOR")) { - if (prof.startsWith("TYPE=")) - { - eq.setArmorProf("Armor (" + prof.substring(5) + ")"); - } - else - { - eq.setArmorProf(prof); - } + eq.setArmorProf(prof); } else if (subtoken.equals("SHIELD")) { - if (prof.startsWith("TYPE=")) - { - eq.setShieldProf("Shield (" + prof.substring(5) + ")"); - } - else - { - eq.setShieldProf(prof); - } + eq.setShieldProf(prof); } else { Modified: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreShieldProfTester.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/test/PreShieldProfTester.java 2008-01-13 02:05:00 UTC (rev 4871) +++ Trunk/pcgen/code/src/java/plugin/pretokens/test/PreShieldProfTester.java 2008-01-13 19:38:37 UTC (rev 4872) @@ -60,6 +60,18 @@ { runningTotal++; } + else if (profName.startsWith("SHIELDTYPE")) + { + if (profName.substring(6).equalsIgnoreCase(prereq.getKey())) + { + runningTotal++; + } + else if (profName.substring(11).equalsIgnoreCase( + prereq.getKey())) + { + runningTotal++; + } + } } runningTotal = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |