|
From: <boo...@us...> - 2006-04-18 23:37:48
|
Revision: 852 Author: boomer70 Date: 2006-04-18 16:37:08 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=852&view=rev Log Message: ----------- More PRExxx tests added. Minor bug fixes found by tests. Updated docs to reflect WIELDCATEGORY option supported for PREEQUIPTWOWEAPON. Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java Trunk/pcgen/code/src/java/pcgen/core/prereq/PreEquippedTester.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreEquipTester.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreDefaultMonsterTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTest.java Trunk/pcgen/docs/listfilepages/globalfilestagpages/globalfilesprexxx.html Added Paths: ----------- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipBothTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipPrimaryTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipSecondaryTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTwoWeaponTest.java Property Changed: ---------------- Trunk/pcgen/ Trunk/pcgen/docs/listfilepages/globalfilestagpages/ Property changes on: Trunk/pcgen ___________________________________________________________________ Name: svn:ignore - pcgen.jar *.ini pcgen-tests.jar pcgen.sh pcgen.bat pcgen_low_mem.bat target .pmd .settings + pcgen.jar *.ini pcgen-tests.jar pcgen.sh pcgen.bat pcgen_low_mem.bat target .pmd .settings bak Modified: Trunk/pcgen/code/src/java/pcgen/core/Equipment.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-04-18 22:41:33 UTC (rev 851) +++ Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-04-18 23:37:08 UTC (rev 852) @@ -7320,12 +7320,12 @@ { wCat = wCat.getWieldCategoryStep(1); } + + // See if there is a bonus associated with just this weapon + final String expProfName = wp.getName(); + aBump += (int) aPC.getTotalBonusTo("WEAPONPROF=" + expProfName, + "WIELDCATEGORY"); } - // See if there is a bonus associated with just this weapon - // Make sure this is profName(0) else you'll be sorry! - final String expProfName = wp.getName(); - aBump += (int) aPC.getTotalBonusTo("WEAPONPROF=" + expProfName, - "WIELDCATEGORY"); // or a bonus from the weapon itself aBump += (int) bonusTo(aPC, "WEAPON", "WIELDCATEGORY", true); Modified: Trunk/pcgen/code/src/java/pcgen/core/prereq/PreEquippedTester.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/prereq/PreEquippedTester.java 2006-04-18 22:41:33 UTC (rev 851) +++ Trunk/pcgen/code/src/java/pcgen/core/prereq/PreEquippedTester.java 2006-04-18 23:37:08 UTC (rev 852) @@ -51,6 +51,7 @@ */ public int passesPreEquipHandleTokens(final Prerequisite prereq, final PlayerCharacter character, final int equippedType) throws PrerequisiteException { + // TODO refactor this code with PreEquipTester boolean isEquipped = false; if (!character.getEquipmentList().isEmpty()) @@ -105,17 +106,20 @@ } else //not a TYPE string { + final String eqName = eq.getName().toUpperCase(); if (aString.indexOf('%') >= 0) { //handle wildcards (always assume they // end the line) - if (eq.getName().startsWith(aString.substring(0, aString.indexOf('%')))) + final int percentPos = aString.indexOf('%'); + final String substring = aString.substring(0, percentPos).toUpperCase(); + if ((eqName.startsWith(substring))) { isEquipped = true; break; } } - else if (eq.getName().equalsIgnoreCase(aString)) + else if (eqName.equalsIgnoreCase(aString)) { //just a straight String compare isEquipped = true; Modified: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreEquipTester.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/test/PreEquipTester.java 2006-04-18 22:41:33 UTC (rev 851) +++ Trunk/pcgen/code/src/java/plugin/pretokens/test/PreEquipTester.java 2006-04-18 23:37:08 UTC (rev 852) @@ -120,7 +120,7 @@ //handle wildcards (always assume // they end the line) final int percentPos = targetEquip.indexOf('%'); - final String substring = targetEquip.substring(0, percentPos); + final String substring = targetEquip.substring(0, percentPos).toUpperCase(); if ((eqName.startsWith(substring))) { ++runningTotal; Modified: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreDefaultMonsterTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreDefaultMonsterTest.java 2006-04-18 22:41:33 UTC (rev 851) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreDefaultMonsterTest.java 2006-04-18 23:37:08 UTC (rev 852) @@ -139,4 +139,10 @@ assertTrue("Should be case insensitive", PrereqHandler.passes(prereq, pc, null)); } + + protected void setUp() + throws Exception + { + super.setUp(); + } } Added: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipBothTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipBothTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipBothTest.java 2006-04-18 23:37:08 UTC (rev 852) @@ -0,0 +1,161 @@ +/* + * PreEquipBothTest.java + * Copyright 2006 (C) Aaron Divinsky <boo...@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 + * + */ +package pcgen.core.prereq; + +import pcgen.AbstractCharacterTestCase; +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.core.Race; + +/** + * <code>PreEquipBothTest</code> tests that the PREEQUIPBOTH tag is + * working correctly. + * + * Last Editor: $Author: $ + * Last Edited: $Date$ + * + * @author Aaron Divinsky <boo...@ya...> + * @version $Revision$ + */ +public class PreEquipBothTest extends AbstractCharacterTestCase +{ + + /* + * Class under test for int passes(Prerequisite, PlayerCharacter) + */ + public void testPassesPrerequisitePlayerCharacter() + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_BOTH); + + final Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipboth"); + prereq.setKey("LONGSWORD"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + final boolean passes = PrereqHandler.passes(prereq, character, null); + assertTrue(passes); + + longsword.setName("Longsword (Large/Masterwork)"); + + assertFalse("Should be an exact match only", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("LONGSWORD (LARGE%"); + + assertTrue("Should allow wildcard match", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test equipment type tests + * @throws Exception + */ + public void testType() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_BOTH); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipboth"); + prereq.setKey("TYPE=Weapon"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + assertFalse("Equipment has no type", + PrereqHandler.passes(prereq, character, null)); + + longsword.typeList().add("WEAPON"); + + assertTrue("Equipment is weapon", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("TYPE.Armor"); + + assertFalse("Equipment is not armor", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test wield category tests + * @throws Exception + */ + public void testWield() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Race race = new Race(); + race.setName("Test Race"); + race.setSize("M"); + + character.setRace(race); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_BOTH); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipboth"); + prereq.setKey("WIELDCATEGORY=OneHanded"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + // Test 3.0 Style + longsword.setSize("M", true); + + assertTrue("Weapon is M therefore OneHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setSize("L", true); + + assertFalse("Weapon is L therefore TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + // Test 3.5 style + longsword.setWield("TwoHanded"); + + assertFalse("Weapon is TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setWield("OneHanded"); + + assertTrue("Weapon is OneHanded", + PrereqHandler.passes(prereq, character, null)); + + } +} Property changes on: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipBothTest.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipPrimaryTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipPrimaryTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipPrimaryTest.java 2006-04-18 23:37:08 UTC (rev 852) @@ -0,0 +1,161 @@ +/* + * PreEquipPrimaryTest.java + * Copyright 2006 (C) Aaron Divinsky <boo...@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 + * + */ +package pcgen.core.prereq; + +import pcgen.AbstractCharacterTestCase; +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.core.Race; + +/** + * <code>PreEquipPrimaryTest</code> tests that the PREEQUIPPRIMARY tag is + * working correctly. + * + * Last Editor: $Author: $ + * Last Edited: $Date$ + * + * @author Aaron Divinsky <boo...@ya...> + * @version $Revision$ + */ +public class PreEquipPrimaryTest extends AbstractCharacterTestCase +{ + + /* + * Class under test for int passes(Prerequisite, PlayerCharacter) + */ + public void testPassesPrerequisitePlayerCharacter() + { + final PlayerCharacter character = getCharacter(); + + final Equipment dagger = new Equipment(); + dagger.setName("Dagger"); + + character.addEquipment(dagger); + dagger.setIsEquipped(true, character); + dagger.setLocation(Equipment.EQUIPPED_PRIMARY); + + final Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipprimary"); + prereq.setKey("DAGGER"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + final boolean passes = PrereqHandler.passes(prereq, character, null); + assertTrue(passes); + + dagger.setName("Dagger (Masterwork)"); + + assertFalse("Should be an exact match only", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("DAGGER%"); + + assertTrue("Should allow wildcard match", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test equipment type tests + * @throws Exception + */ + public void testType() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_PRIMARY); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipprimary"); + prereq.setKey("TYPE=Slashing"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + assertFalse("Equipment has no type", + PrereqHandler.passes(prereq, character, null)); + + longsword.typeList().add("SLASHING"); + + assertTrue("Equipment is slashing", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("TYPE.Armor"); + + assertFalse("Equipment is not armor", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test wield category tests + * @throws Exception + */ + public void testWield() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Race race = new Race(); + race.setName("Test Race"); + race.setSize("M"); + + character.setRace(race); + + final Equipment longsword = new Equipment(); + longsword.setName("Dagger"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_PRIMARY); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipprimary"); + prereq.setKey("WIELDCATEGORY=OneHanded"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + // Test 3.0 Style + longsword.setSize("M", true); + + assertTrue("Weapon is M therefore OneHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setSize("L", true); + + assertFalse("Weapon is L therefore TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + // Test 3.5 style + longsword.setWield("TwoHanded"); + + assertFalse("Weapon is TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setWield("OneHanded"); + + assertTrue("Weapon is OneHanded", + PrereqHandler.passes(prereq, character, null)); + + } +} Property changes on: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipPrimaryTest.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipSecondaryTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipSecondaryTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipSecondaryTest.java 2006-04-18 23:37:08 UTC (rev 852) @@ -0,0 +1,161 @@ +/* + * PreEquipSecondaryTest.java + * Copyright 2006 (C) Aaron Divinsky <boo...@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 + * + */ +package pcgen.core.prereq; + +import pcgen.AbstractCharacterTestCase; +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.core.Race; + +/** + * <code>PreEquipSecondaryTest</code> tests that the PREEQUIPSECONDARY tag is + * working correctly. + * + * Last Editor: $Author: $ + * Last Edited: $Date$ + * + * @author Aaron Divinsky <boo...@ya...> + * @version $Revision$ + */ +public class PreEquipSecondaryTest extends AbstractCharacterTestCase +{ + + /* + * Class under test for int passes(Prerequisite, PlayerCharacter) + */ + public void testPassesPrerequisitePlayerCharacter() + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_SECONDARY); + + final Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipsecondary"); + prereq.setKey("LONGSWORD"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + final boolean passes = PrereqHandler.passes(prereq, character, null); + assertTrue(passes); + + longsword.setName("Longsword (Masterwork)"); + + assertFalse("Should be an exact match only", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("LONGSWORD%"); + + assertTrue("Should allow wildcard match", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test equipment type tests + * @throws Exception + */ + public void testType() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_SECONDARY); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipsecondary"); + prereq.setKey("TYPE=Weapon"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + assertFalse("Equipment has no type", + PrereqHandler.passes(prereq, character, null)); + + longsword.typeList().add("WEAPON"); + + assertTrue("Equipment is weapon", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("TYPE.Armor"); + + assertFalse("Equipment is not armor", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test wield category tests + * @throws Exception + */ + public void testWield() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Race race = new Race(); + race.setName("Test Race"); + race.setSize("M"); + + character.setRace(race); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_SECONDARY); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equipsecondary"); + prereq.setKey("WIELDCATEGORY=Light"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + // Test 3.0 Style + longsword.setSize("S", true); + + assertTrue("Weapon is S therefore Light", + PrereqHandler.passes(prereq, character, null)); + + longsword.setSize("M", true); + + assertFalse("Weapon is M therefore OneHanded", + PrereqHandler.passes(prereq, character, null)); + + // Test 3.5 style + longsword.setWield("OneHanded"); + + assertFalse("Weapon is OneHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setWield("Light"); + + assertTrue("Weapon is Light", + PrereqHandler.passes(prereq, character, null)); + + } +} Property changes on: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipSecondaryTest.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTest.java 2006-04-18 22:41:33 UTC (rev 851) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTest.java 2006-04-18 23:37:08 UTC (rev 852) @@ -23,33 +23,146 @@ import pcgen.AbstractCharacterTestCase; import pcgen.core.Equipment; import pcgen.core.PlayerCharacter; +import pcgen.core.Race; +import pcgen.persistence.lst.prereq.PreParserFactory; /** */ -public class PreEquipTest extends AbstractCharacterTestCase { +public class PreEquipTest extends AbstractCharacterTestCase +{ - /* - * Class under test for int passes(Prerequisite, PlayerCharacter) - */ - public void testPassesPrerequisitePlayerCharacter() { + /* + * Class under test for int passes(Prerequisite, PlayerCharacter) + */ + public void testPassesPrerequisitePlayerCharacter() + { final PlayerCharacter character = getCharacter(); final Equipment longsword = new Equipment(); - longsword.setName("Longsword"); + longsword.setName("Longsword"); - character.addEquipment(longsword); - longsword.setIsEquipped(true, character); + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); - final Prerequisite prereq = new Prerequisite(); - prereq.setKind("equip"); - prereq.setKey("LONGSWORD%"); - prereq.setOperand("1"); - prereq.setOperator(PrerequisiteOperator.EQ); + final Prerequisite prereq = new Prerequisite(); + prereq.setKind("equip"); + prereq.setKey("LONGSWORD"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); - final boolean passes = PrereqHandler.passes(prereq, character, null); assertTrue(passes); - } + longsword.setName("Longsword (Masterwork)"); + assertFalse("Should be an exact match only", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("LONGSWORD%"); + + assertTrue("Should be allow wildcard match", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test equipment type tests + * @throws Exception + */ + public void testType() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equip"); + prereq.setKey("TYPE=Weapon"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + assertFalse("Equipment has no type", + PrereqHandler.passes(prereq, character, null)); + + longsword.typeList().add("WEAPON"); + + assertTrue("Equipment is weapon", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("TYPE.Armor"); + + assertFalse("Equipment is not armor", + PrereqHandler.passes(prereq, character, null)); + + final PreParserFactory factory = PreParserFactory.getInstance(); + prereq = factory.parse("PREEQUIP:2,TYPE=Armor,Longsword%"); + + assertFalse("Doesn't have armor equipped", + PrereqHandler.passes(prereq, character, null)); + + final Equipment leather = new Equipment(); + leather.setName("Leather"); + leather.typeList().add("ARMOR"); + + character.addEquipment(leather); + leather.setIsEquipped(true, character); + + assertTrue("Armor and sword equipped", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test wield category tests + * @throws Exception + */ + public void testWield() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Race race = new Race(); + race.setName("Test Race"); + race.setSize("M"); + + character.setRace(race); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equip"); + prereq.setKey("WIELDCATEGORY=OneHanded"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + // Test 3.0 Style + longsword.setSize("M", true); + + assertTrue("Weapon is M therefore OneHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setSize("L", true); + + assertFalse("Weapon is L therefore TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + // Test 3.5 style + longsword.setWield("TwoHanded"); + + assertFalse("Weapon is TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setWield("OneHanded"); + + assertTrue("Weapon is OneHanded", + PrereqHandler.passes(prereq, character, null)); + + } } Added: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTwoWeaponTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTwoWeaponTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTwoWeaponTest.java 2006-04-18 23:37:08 UTC (rev 852) @@ -0,0 +1,161 @@ +/* + * PreEquipTwoWeaponTest.java + * Copyright 2006 (C) Aaron Divinsky <boo...@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 + * + */ +package pcgen.core.prereq; + +import pcgen.AbstractCharacterTestCase; +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.core.Race; + +/** + * <code>PreEquipTwoWeaponTest</code> tests that the PREEQUIPTWOWEAPON tag is + * working correctly. + * + * Last Editor: $Author: $ + * Last Edited: $Date$ + * + * @author Aaron Divinsky <boo...@ya...> + * @version $Revision$ + */ +public class PreEquipTwoWeaponTest extends AbstractCharacterTestCase +{ + + /* + * Class under test for int passes(Prerequisite, PlayerCharacter) + */ + public void testPassesPrerequisitePlayerCharacter() + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_TWO_HANDS); + + final Prerequisite prereq = new Prerequisite(); + prereq.setKind("equiptwoweapon"); + prereq.setKey("LONGSWORD"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + final boolean passes = PrereqHandler.passes(prereq, character, null); + assertTrue(passes); + + longsword.setName("Longsword (Large/Masterwork)"); + + assertFalse("Should be an exact match only", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("LONGSWORD (LARGE%"); + + assertTrue("Should allow wildcard match", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test equipment type tests + * @throws Exception + */ + public void testType() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_TWO_HANDS); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equiptwoweapon"); + prereq.setKey("TYPE=Weapon"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + assertFalse("Equipment has no type", + PrereqHandler.passes(prereq, character, null)); + + longsword.typeList().add("WEAPON"); + + assertTrue("Equipment is weapon", + PrereqHandler.passes(prereq, character, null)); + + prereq.setKey("TYPE.Armor"); + + assertFalse("Equipment is not armor", + PrereqHandler.passes(prereq, character, null)); + } + + /** + * Test wield category tests + * @throws Exception + */ + public void testWield() + throws Exception + { + final PlayerCharacter character = getCharacter(); + + final Race race = new Race(); + race.setName("Test Race"); + race.setSize("M"); + + character.setRace(race); + + final Equipment longsword = new Equipment(); + longsword.setName("Longsword"); + + character.addEquipment(longsword); + longsword.setIsEquipped(true, character); + longsword.setLocation(Equipment.EQUIPPED_TWO_HANDS); + + Prerequisite prereq = new Prerequisite(); + prereq.setKind("equiptwoweapon"); + prereq.setKey("WIELDCATEGORY=OneHanded"); + prereq.setOperand("1"); + prereq.setOperator(PrerequisiteOperator.EQ); + + // Test 3.0 Style + longsword.setSize("M", true); + + assertTrue("Weapon is M therefore OneHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setSize("L", true); + + assertFalse("Weapon is L therefore TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + // Test 3.5 style + longsword.setWield("TwoHanded"); + + assertFalse("Weapon is TwoHanded", + PrereqHandler.passes(prereq, character, null)); + + longsword.setWield("OneHanded"); + + assertTrue("Weapon is OneHanded", + PrereqHandler.passes(prereq, character, null)); + + } +} Property changes on: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreEquipTwoWeaponTest.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Property changes on: Trunk/pcgen/docs/listfilepages/globalfilestagpages ___________________________________________________________________ Name: svn:ignore + *.bak Modified: Trunk/pcgen/docs/listfilepages/globalfilestagpages/globalfilesprexxx.html =================================================================== --- Trunk/pcgen/docs/listfilepages/globalfilestagpages/globalfilesprexxx.html 2006-04-18 22:41:33 UTC (rev 851) +++ Trunk/pcgen/docs/listfilepages/globalfilestagpages/globalfilesprexxx.html 2006-04-18 23:37:08 UTC (rev 852) @@ -438,6 +438,7 @@ (The name of a weapon - "%" may be used as a wildcard)</p> <p class="indent1"><strong>Variables Used (y):</strong> TYPE=Text (The type of a weapon that must be equipped in a two weapon fighting manner).</p> + <p class="indent1"><strong>Variables Used (y): </strong>WIELDCATEGORY=Text (The wield category of a weapon).</p> <p class="indent1"><strong>What it does:</strong></p> <p class="indent2">This is used to determine if a character has a particular item (usually a weapon) equipped and used two weapon style.</p> @@ -448,6 +449,8 @@ <p class="indent3">The "%" allows for items named Sword (Short/Masterwork) etc.</p> <p class="indent2"><code>PREEQUIPTWOWEAPON:1,TYPE=Slashing</code></p> <p class="indent3">Must have a Sword (Short) equipped as one of two weapons for two weapon fighting.</p> + <p class="indent2"><code>PREEQUIPTWOWEAPON:1,WIELDCATEGORY=Light</code></p> + <p class="indent3">Must have a light weapon equipped for two weapon fighting.</p> <p></p><a name="PREFEAT"></a><hr> <p class="new">*** Updated 5.4</p> @@ -460,7 +463,7 @@ <p class="indent1"><strong>Variables Used (z):</strong> [Text] (The name of a feat a character must NOT have).</p> <p class="indent1"><strong>Variables Used (z):</strong> TYPE=Text (The type of a feat the character must have).</p> <p class="indent1"><strong>Variables Used (z): </strong>[TYPE=Text] (The type of a feat the character must NOT have).</p> - <p class="indent1">What it does:</p> + <p class="indent1"><strong>What it does:</strong></p> <p class="indent2">Sets character feat requirements. For feats which can be taken multiple times you can specify the exact choices within that feat by using parentheses. The Fighter, Loremaster, Arcane Archer and Archmage are good examples of Prestige This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |