Search in sources :

Example 1 with CDOMSimpleSingleRef

use of pcgen.cdom.reference.CDOMSimpleSingleRef in project pcgen by PCGen.

the class PlayerCharacterTest method testGetAvailableFollowers.

/**
	 * Validate the getAvailableFollowers function.
	 */
public void testGetAvailableFollowers() {
    readyToRun();
    Ability ab = TestHelper.makeAbility("Tester1", AbilityCategory.FEAT, "Empty Container");
    Ability mab = TestHelper.makeAbility("Tester2", AbilityCategory.FEAT, "Mount Container");
    Ability fab = TestHelper.makeAbility("Tester3", AbilityCategory.FEAT, "Familiar Container");
    PlayerCharacter pc = getCharacter();
    CharacterDisplay display = pc.getDisplay();
    addAbility(AbilityCategory.FEAT, ab);
    CDOMSingleRef<CompanionList> ref = new CDOMSimpleSingleRef<>(CompanionList.class, "Mount");
    CDOMReference<Race> race = new CDOMDirectSingleRef<>(giantRace);
    FollowerOption option = new FollowerOption(race, ref);
    mab.addToListFor(ListKey.COMPANIONLIST, option);
    ref = new CDOMSimpleSingleRef<>(CompanionList.class, "Familiar");
    race = new CDOMDirectSingleRef<>(human);
    option = new FollowerOption(race, ref);
    fab.addToListFor(ListKey.COMPANIONLIST, option);
    Set<FollowerOption> fo = display.getAvailableFollowers("Familiar", null).keySet();
    assertTrue("Initially familiar list should be empty", fo.isEmpty());
    fo = display.getAvailableFollowers("MOUNT", null).keySet();
    assertTrue("Initially mount list should be empty", fo.isEmpty());
    addAbility(AbilityCategory.FEAT, mab);
    fo = display.getAvailableFollowers("Familiar", null).keySet();
    assertTrue("Familiar list should still be empty", fo.isEmpty());
    fo = display.getAvailableFollowers("MOUNT", null).keySet();
    assertFalse("Mount list should not be empty anymore", fo.isEmpty());
    assertEquals("Mount should be the giant race", giantRace.getKeyName(), fo.iterator().next().getRace().getKeyName());
    assertEquals("Mount list should only have one entry", 1, fo.size());
    addAbility(AbilityCategory.FEAT, fab);
    fo = display.getAvailableFollowers("Familiar", null).keySet();
    assertFalse("Familiar list should not be empty anymore", fo.isEmpty());
    assertEquals("Familiar should be the human race", human.getKeyName(), fo.iterator().next().getRace().getKeyName());
    assertEquals("Familiar list should only have one entry", 1, fo.size());
    fo = display.getAvailableFollowers("MOUNT", null).keySet();
    assertFalse("Mount list should not be empty anymore", fo.isEmpty());
    assertEquals("Mount should be the giant race", giantRace.getKeyName(), fo.iterator().next().getRace().getKeyName());
    assertEquals("Mount list should only have one entry", 1, fo.size());
}
Also used : CDOMDirectSingleRef(pcgen.cdom.reference.CDOMDirectSingleRef) CompanionList(pcgen.cdom.list.CompanionList) CharacterDisplay(pcgen.core.display.CharacterDisplay) CDOMSimpleSingleRef(pcgen.cdom.reference.CDOMSimpleSingleRef)

Example 2 with CDOMSimpleSingleRef

use of pcgen.cdom.reference.CDOMSimpleSingleRef in project pcgen by PCGen.

the class CompanionSupportFacadeImplTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    uiDelegate = new MockUIDelegate();
    todoManager = new TodoManager();
    ListFacade<CampaignFacade> campaigns = new DefaultListFacade<>();
    dataSetFacade = new DataSet(Globals.getContext(), SettingsHandler.getGame(), campaigns);
    masterRace = TestHelper.makeRace("Wood Elf");
    companionRace = TestHelper.makeRace("Weasel");
    CDOMReference<Race> race = new CDOMDirectSingleRef<>(companionRace);
    CDOMSingleRef<CompanionList> ref = new CDOMSimpleSingleRef<>(CompanionList.class, companionList.getKeyName());
    FollowerOption option = new FollowerOption(race, ref);
    masterRace.addToListFor(ListKey.COMPANIONLIST, option);
}
Also used : CDOMDirectSingleRef(pcgen.cdom.reference.CDOMDirectSingleRef) DataSet(pcgen.core.DataSet) FollowerOption(pcgen.core.FollowerOption) CompanionList(pcgen.cdom.list.CompanionList) CDOMSimpleSingleRef(pcgen.cdom.reference.CDOMSimpleSingleRef) CampaignFacade(pcgen.facade.core.CampaignFacade) Race(pcgen.core.Race) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

Aggregations

CompanionList (pcgen.cdom.list.CompanionList)2 CDOMDirectSingleRef (pcgen.cdom.reference.CDOMDirectSingleRef)2 CDOMSimpleSingleRef (pcgen.cdom.reference.CDOMSimpleSingleRef)2 DataSet (pcgen.core.DataSet)1 FollowerOption (pcgen.core.FollowerOption)1 Race (pcgen.core.Race)1 CharacterDisplay (pcgen.core.display.CharacterDisplay)1 CampaignFacade (pcgen.facade.core.CampaignFacade)1 DefaultListFacade (pcgen.facade.util.DefaultListFacade)1