From: <nu...@us...> - 2008-10-05 17:35:21
|
Revision: 7948 http://pcgen.svn.sourceforge.net/pcgen/?rev=7948&view=rev Author: nuance Date: 2008-10-05 17:35:18 +0000 (Sun, 05 Oct 2008) Log Message: ----------- Add in the basis of the term evaluators Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/base/term/BaseEQTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesNatureTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTypeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/BasePCTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/ConstantZeroTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQACCheckTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQBaseCostTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQCritMultTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDiceTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDieTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQEquipSizeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQHandsTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQRaceReachTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQRangeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQReachMultTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQReachTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQSizeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQSpellFailureTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EQWeightTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/EvaluatorFactory.java Trunk/pcgen/code/src/java/pcgen/base/term/PCACcheckTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCArmourACcheckTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCBABTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCBLTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCBaseSpellStatTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCLBeforeLevelTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCLTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCarriedWeightTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCasterLevelClassTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCasterLevelRaceTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCasterLevelTotalTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilitiesNatureAllTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilitiesNatureAutoTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilitiesNatureNormalTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilitiesNatureVirtualTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilitiesTypeNatureAllTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilitiesTypeNatureAutoTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilitiesTypeNatureVirtualTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAbilityNameTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountAttacksTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountChecksTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountClassesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountContainersTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountDomainsTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountEquipmentTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountFollowerTypeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountFollowerTypeTransitiveTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountFollowersTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountLanguagesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountMiscCompanionsTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountMiscFundsTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountMiscMagicTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountMoveTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountNotesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountRaceSubTypesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSABTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSkillsTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSpellClassesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSpellRaceTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSpellTimesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSpellbookTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSpellsInbookTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSpellsKnownTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountSpellsLevelsInBookTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountStatsTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountTempBonusNamesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountTemplatesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountVisibleTemplatesTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCCountVisionTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCEncumberanceTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCEqTypeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCHDTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCHasClassTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCHasDeityTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCHasFeatTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCHeightTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCMaxCastableAnyTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCMaxCastableClassTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCMaxCastableDomainTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCMaxCastableSpellTypeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCModEquipTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCMoveBaseTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCMovementTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCProfACCheckTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCRaceSizeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSPellBaseStatScoreEvaluatorTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSPellBaseStatTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCScoreTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCShieldACcheckTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSizeModEvaluatorTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSizeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSkillRankTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSkillTotalTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSkillTypeTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCSpellLevelTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCStatBaseTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCStatModTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCStatTotalTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCTLTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCTotalWeightTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCVarDefinedTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCVerbatimTextTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/PCWeightTermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/TermEvaluator.java Trunk/pcgen/code/src/java/pcgen/base/term/TermEvaluatorBuilder.java Trunk/pcgen/code/src/java/pcgen/base/term/TermEvaluatorBuilderEQVar.java Trunk/pcgen/code/src/java/pcgen/base/term/TermEvaluatorBuilderPCStat.java Trunk/pcgen/code/src/java/pcgen/base/term/TermEvaluatorBuilderPCVar.java Trunk/pcgen/code/src/test/pcgen/base/ Trunk/pcgen/code/src/test/pcgen/base/term/ Trunk/pcgen/code/src/test/pcgen/base/term/EvaluatorFactoryTest.java Added: Trunk/pcgen/code/src/java/pcgen/base/term/BaseEQTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/BaseEQTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/BaseEQTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,65 @@ +/** + * pcgen.base.term.BaseEQTermEvaluator.java + * Copyright 2008 Andrew Wilson <nu...@us...>. + * + * 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 03 October 2008 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.PlayerCharacter; +import pcgen.core.Equipment; +import pcgen.core.spell.Spell; + +public abstract class BaseEQTermEvaluator +{ + protected String originalText; + + public String evaluate(PlayerCharacter pc) { + return Float.toString(resolve(pc)); + } + + public Float resolve(PlayerCharacter pc) + { + return 0f; + } + + public Float resolve(PlayerCharacter pc, final Spell aSpell) { + return resolve(pc); + } + + public Float getDefault () + { + return 1f; + } + + public String getOriginal () + { + return originalText; + } + + public int getLength () + { + return originalText.length(); + } +} + Added: Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesNatureTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesNatureTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesNatureTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,51 @@ +/** + * pcgen.base.term.PCCountAbilitiesNatureBaseEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 09-Aug-2008 19:06:01 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import java.util.List; + +import pcgen.core.PlayerCharacter; +import pcgen.core.Ability; +import pcgen.core.spell.Spell; + +public abstract class BasePCCountAbilitiesNatureTermEvaluator + extends BasePCCountAbilitiesTermEvaluator +{ + protected boolean visible; + protected boolean hidden; + + public BasePCCountAbilitiesNatureTermEvaluator() + { + } + + public Float resolve(PlayerCharacter pc) + { + List<Ability> lAb = getAbilities(pc); + + return countVisibleAbilities(pc, lAb, visible, hidden); + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,118 @@ +/** + * pcgen.base.term.PCCountFeatsBaseEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 09-Aug-2008 16:08:40 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import java.util.List; + +import pcgen.core.Ability; +import pcgen.core.PlayerCharacter; +import pcgen.core.AbilityCategory; +import pcgen.core.AssociationStore; +import pcgen.cdom.enumeration.ObjectKey; +import pcgen.util.enumeration.Visibility; + +public abstract class BasePCCountAbilitiesTermEvaluator extends BasePCTermEvaluator +{ + protected AbilityCategory abCat; + protected boolean visible; + protected boolean hidden; + + abstract List<Ability> getAbilities(PlayerCharacter pc); + + /** + * This function takes a list of feats and returns the number of visible, + * or hidden feats that are in the list The visible flag determines if + * the result should be the number of hidden feats, or the number of + * visible feats + * + * @param pc the Character with the abilities + * @param aList a list of the feats to look through. + * @param visible Count visible abilities + * @param hidden Count hidden abilities @return An int containing the number of feats in the list + * @return the number of matching abilities + */ + protected Float countVisibleAbilities( + AssociationStore pc, + final Iterable<Ability> aList, + final boolean visible, + final boolean hidden) + { + Float count = 0f; + + for (Ability ability : aList) + { + count += countVisibleAbility(pc, ability, visible, hidden, true); + } + + return count; + } + + /** + * Count the number of times the character has the ability. This can be + * limited to either hidden or visible Abilities, and can be limited to only + * counting once per ability rather than once per time taken (e.g. + * Weapon Specialisation in two weapons would count as 2 unless the onceOnly + * flag was true). + * + * @param pc the Character with the abilities + * @param ability The feat to be counted. + * @param visible Should it be counted if it is visible? + * @param hidden Should it be counted if it is hidden? + * @param onceOnly Should it be counted as one if was taken multiple times? + * @return The number of occurrences of the ability. + */ + protected Float countVisibleAbility( + AssociationStore pc, + final Ability ability, + final boolean visible, + final boolean hidden, + final boolean onceOnly) + { + Visibility v = ability.getSafe(ObjectKey.VISIBILITY); + + boolean abilityInvisibile = (v == Visibility.DISPLAY_ONLY) || + (v == Visibility.HIDDEN); + int count = 0; + + if (abilityInvisibile) + { + if (hidden) + { + count += (onceOnly) ? 1 : Math.max(1, pc.getSelectCorrectedAssociationCount(ability)); + } + } + else + { + if (visible) + { + count += (onceOnly) ? 1 : Math.max(1, pc.getSelectCorrectedAssociationCount(ability)); + } + } + + return (float) count; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTypeTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTypeTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/BasePCCountAbilitiesTypeTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,61 @@ +/** + * pcgen.base.term.PCCountAbilitiesTypeBaseEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 09-Aug-2008 19:37:53 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import java.util.List; + +import pcgen.core.PlayerCharacter; +import pcgen.core.Ability; + +public abstract class BasePCCountAbilitiesTypeTermEvaluator extends BasePCCountAbilitiesTermEvaluator +{ + protected String[] types; + + public Float resolve(PlayerCharacter pc) + { + Float count = 0f; + + List<Ability> abilityList = getAbilities(pc); + + for ( Ability anAbility : abilityList ) + { + // for each feat, look to see if it has any of the required types. + for ( String type : types) + { + if (anAbility.isType(type)) + { + count += countVisibleAbility( + pc, anAbility, visible, hidden, false); + + break; + } + } + } + + return count; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/BasePCTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/BasePCTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/BasePCTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,68 @@ +/** + * pcgen.base.term.BasePCTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 07-Aug-2008 20:49:05 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.PlayerCharacter; +import pcgen.core.Equipment; +import pcgen.core.spell.Spell; + +public abstract class BasePCTermEvaluator +{ + protected String originalText; + + public String evaluate(PlayerCharacter pc) { + return Float.toString(resolve(pc)); + } + + public abstract Float resolve(PlayerCharacter pc); + + public Float resolve(PlayerCharacter pc, final Spell aSpell) { + return resolve(pc); + } + + public Float resolve( + Equipment equipment, + boolean primary, + PlayerCharacter pc) { + return resolve(pc); + } + + public Float getDefault () + { + return 1.0f; + } + + public String getOriginal () + { + return originalText; + } + + public int getLength () + { + return originalText.length(); + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/ConstantZeroTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/ConstantZeroTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/ConstantZeroTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,51 @@ +/** + * pcgen.base.term.ConstantZeroTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 22-Sep-2008 01:31:27 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.PlayerCharacter; + +public class ConstantZeroTermEvaluator + extends BasePCTermEvaluator implements TermEvaluator { + + public ConstantZeroTermEvaluator(String originalText) + { + this.originalText = originalText; + } + + public Float resolve(PlayerCharacter pc) { + return 0f; + } + + public boolean isSourceDependant() { + return false; + } + + public boolean isStatic() + { + return true; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQACCheckTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQACCheckTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQACCheckTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,58 @@ +/** + * pcgen.base.term.EQACCheckTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:38:19 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQACCheckTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQACCheckTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) eq.getSafe(IntegerKey.AC_CHECK); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} + Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQBaseCostTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQBaseCostTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQBaseCostTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,58 @@ +/** + * pcgen.base.term.EQBaseCostTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 01:55:27 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.cdom.enumeration.ObjectKey; +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; + +public class EQBaseCostTermEvaluator + extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQBaseCostTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return eq.getSafe(ObjectKey.COST).floatValue(); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQCritMultTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQCritMultTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQCritMultTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,61 @@ +/** + * pcgen.base.term.EQCritMultTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:14:17 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; + +public class EQCritMultTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQCritMultTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + if (primary) + { + return (float) eq.getCritMultiplier(); + } + + return (float) eq.getAltCritMultiplier(); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDiceTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDiceTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDiceTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,57 @@ +/** + * pcgen.base.term.EQDamageDiceTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:23:47 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.core.RollInfo; + +public class EQDamageDiceTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQDamageDiceTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) new RollInfo(eq.getDamage(pc)).getTimes(); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDieTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDieTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQDamageDieTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,57 @@ +/** + * pcgen.base.term.EQDamageDieTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:36:29 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.core.RollInfo; + +public class EQDamageDieTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQDamageDieTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) new RollInfo(eq.getDamage(pc)).getSides(); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQEquipSizeTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQEquipSizeTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQEquipSizeTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,56 @@ +/** + * pcgen.base.term.EQEquipSizeTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:45:23 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; + +public class EQEquipSizeTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQEquipSizeTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return Float.valueOf(eq.getSize()); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQHandsTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQHandsTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQHandsTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,58 @@ +/** + * pcgen.base.term.EQHandsTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:40:23 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQHandsTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQHandsTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) eq.getSafe(IntegerKey.SLOTS); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } + +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQRaceReachTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQRaceReachTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQRaceReachTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,59 @@ +/** + * pcgen.base.term.EQRaceReachTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:51:58 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; + +public class EQRaceReachTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + private final String source; + + public EQRaceReachTermEvaluator(String expressionString, String src) + { + this.originalText = expressionString; + this.source = src; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return pc.getVariableValue("REACH.VAL", source); + } + + public boolean isSourceDependant() + { + return true; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQRangeTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQRangeTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQRangeTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,57 @@ +/** + * pcgen.base.term.EQRangeTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:57:13 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQRangeTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQRangeTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) eq.getSafe(IntegerKey.RANGE); + } + + public boolean isSourceDependant() + { + return true; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQReachMultTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQReachMultTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQReachMultTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,57 @@ +/** + * pcgen.base.term.EQReachMultTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 03:01:55 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQReachMultTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQReachMultTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) eq.getSafe(IntegerKey.REACH_MULT); + } + + public boolean isSourceDependant() + { + return true; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQReachTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQReachTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQReachTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,56 @@ +/** + * pcgen.base.term.EQReachTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:59:53 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQReachTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQReachTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) eq.getSafe(IntegerKey.REACH); + } + + public boolean isSourceDependant() + { + return true; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQSizeTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQSizeTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQSizeTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,57 @@ +/** + * pcgen.base.term.EQSizeTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 03:03:04 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQSizeTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQSizeTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) eq.sizeInt(); + } + + public boolean isSourceDependant() + { + return true; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQSpellFailureTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQSpellFailureTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQSpellFailureTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,57 @@ +/** + * pcgen.base.term.EQSpellFailureTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 02:42:03 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQSpellFailureTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQSpellFailureTermEvaluator(String expressionString) + { + this.originalText =expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + return (float) eq.getSafe(IntegerKey.SPELL_FAILURE); + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EQWeightTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EQWeightTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EQWeightTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,75 @@ +/** + * pcgen.base.term.EQWeightTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 03:10:04 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import java.math.BigDecimal; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.cdom.enumeration.IntegerKey; + +public class EQWeightTermEvaluator extends BaseEQTermEvaluator implements TermEvaluator +{ + public EQWeightTermEvaluator(String expressionString) + { + this.originalText = expressionString; + } + + public Float resolve( + Equipment eq, + boolean primary, + PlayerCharacter pc) + { + if (eq.isCalculatingCost() && eq.isWeightAlreadyUsed()) + { + return 0f; + } + + BigDecimal weightInPounds = eq.getWeightInPounds(); + + if (eq.isCalculatingCost() && eq.isAmmunition()) + { + Float unitWeight = weightInPounds.floatValue(); + unitWeight /= eq.getSafe(IntegerKey.BASE_QUANTITY); + eq.setWeightAlreadyUsed(true); + return unitWeight; + } + + eq.setWeightAlreadyUsed(true); + return weightInPounds.floatValue(); + } + + public boolean isSourceDependant() + { + return true; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/EvaluatorFactory.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/EvaluatorFactory.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/EvaluatorFactory.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,198 @@ +/** + * pcgen.base.term.EvaluatorFactory.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Oct-2008 17:46:37 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import java.util.Map; +import java.util.TreeMap; +import java.util.HashMap; + +import pcgen.core.GameMode; +import pcgen.core.SettingsHandler; + +public class EvaluatorFactory { + + Pattern internalVarPattern; + Map<String, TermEvaluatorBuilder> BuilderStore; + + private Map<String, TermEvaluator> SrcNeutralEvaluatorStore = + new HashMap<String, TermEvaluator>(); + private Map<String, Map<String, TermEvaluator>> SrcDependantEvaluatorStore = + new HashMap<String, Map<String, TermEvaluator>>(); + + + public static EvaluatorFactory PC = + new EvaluatorFactory(true, TermEvaluatorBuilderPCVar.values()); + + public static EvaluatorFactory EQ = + new EvaluatorFactory(false, TermEvaluatorBuilderEQVar.values()); + + private EvaluatorFactory ( + boolean addStats, + final TermEvaluatorBuilder[] termEvaluatorBuilders) + { + TermEvaluatorBuilder[] evals = (addStats) ? + addStatBuilder(termEvaluatorBuilders) : + termEvaluatorBuilders; + + BuilderStore = new TreeMap<String, TermEvaluatorBuilder>(); + StringBuilder sb = new StringBuilder("^("); + + boolean add = false; + + for (TermEvaluatorBuilder e : evals) { + if (add) { + sb.append("|"); + } else { + add = true; + } + sb.append(e.getTermConstructorPattern()); + + String[] keys = e.getTermConstructorKeys(); + for (String k : keys) { + BuilderStore.put(k, e); + } + } + + sb.append(")"); + internalVarPattern = Pattern.compile(sb.toString()); + } + + private static TermEvaluatorBuilder[] addStatBuilder( + TermEvaluatorBuilder[] builderArray) + { + int end = builderArray.length; + + TermEvaluatorBuilder[] tempArray = new TermEvaluatorBuilder[end + 1]; + + System.arraycopy(builderArray, 0, tempArray, 0, end); + + tempArray[end] = makeStatBuilder(); + + return tempArray; + } + + private static TermEvaluatorBuilder makeStatBuilder() + { + GameMode game = SettingsHandler.getGame(); + int num = game.s_ATTRIBSHORT.length; + String[] s = new String[num]; + + StringBuffer pSt = new StringBuffer(num * 4 + 6); + + pSt.append("(?:"); + boolean add1 = false; + for (int x = 0; x < num; ++x) + { + if (add1) { + pSt.append("|"); + } else { + add1 = true; + } + pSt.append(game.s_ATTRIBSHORT[x]); + s[x] = game.s_ATTRIBSHORT[x]; + } + pSt.append(")"); + + return new TermEvaluatorBuilderPCStat(pSt.toString(), s, false); + } + + private TermEvaluator makeTermEvaluator( + String term, + String source) { + + Matcher mat = internalVarPattern.matcher(term); + + if (mat.find()) { + String matchedPortion = mat.group(1); + TermEvaluatorBuilder f = BuilderStore.get(matchedPortion); + + try + { + if (f.isEntireTerm() && + (term.length() != matchedPortion.length())) + { + return null; + } + else + { + return f.getTermEvaluator(term, source, matchedPortion); + } + } + catch (TermEvaulatorException e) + { + e.printStackTrace(); + } + } + + return null; + } + + public TermEvaluator getTermEvaluator ( + String term, + String source) { + + Map<String, TermEvaluator> inner = SrcDependantEvaluatorStore.get(term); + + if (inner == null) + { + TermEvaluator evaluator = SrcNeutralEvaluatorStore.get(term); + if (evaluator != null) { + return evaluator; + } + } + else + { + TermEvaluator evaluator = inner.get(source); + if (evaluator != null) { + return evaluator; + } + } + + TermEvaluator evaluator = makeTermEvaluator(term, source); + + if (evaluator == null) + { + return null; + } + + if (evaluator.isSourceDependant()) + { + Map<String, TermEvaluator> i = SrcDependantEvaluatorStore.get(term); + Map<String, TermEvaluator> j = (i == null) ? new HashMap<String, TermEvaluator>() : i; + j.put(source, evaluator); + SrcDependantEvaluatorStore.put(term, j); + } + else + { + SrcNeutralEvaluatorStore.put(term, evaluator); + } + + return evaluator; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/PCACcheckTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/PCACcheckTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/PCACcheckTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,67 @@ +/** + * pcgen.base.term.PCACcheckTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Aug-2008 21:30:46 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; + +public class PCACcheckTermEvaluator + extends BasePCTermEvaluator implements TermEvaluator { + + PCACcheckTermEvaluator( + final String originalText) + { + this.originalText = originalText; + } + + public Float resolve(PlayerCharacter pc) + { + int maxCheck = 0; + + for ( Equipment eq : pc.getEquipmentOfType("Armor", 1) ) + { + maxCheck += eq.acCheck(pc); + } + + for ( Equipment eq : pc.getEquipmentOfType("Shield", 1) ) + { + maxCheck += eq.acCheck(pc); + } + + return (float) maxCheck; + } + + public boolean isSourceDependant() + { + return false; + } + + public boolean isStatic() + { + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/base/term/PCArmourACcheckTermEvaluator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/term/PCArmourACcheckTermEvaluator.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/base/term/PCArmourACcheckTermEvaluator.java 2008-10-05 17:35:18 UTC (rev 7948) @@ -0,0 +1,61 @@ +/** + * pcgen.base.term.PCArmourACcheckTermEvaluator.java + * Copyright \xA9 2008 Andrew Wilson <nu...@us...>. + * + * 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 03-Aug-2008 22:25:54 + * + * Current Ver: $Revision:$ + * Last Editor: $Author:$ + * Last Edited: $Date:$ + * + */ + +package pcgen.base.term; + +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; + +public class PCArmourACcheck... [truncated message content] |