Ejemplo n.º 1
0
  @Override
  public void removeChoice(
      PlayerCharacter pc, CDOMObject owner, CategorizedAbilitySelection choice) {
    if (!pc.isImporting()) {
      pc.getSpellList();
    }

    // See if our choice is not auto or virtual
    Ability anAbility =
        pc.getMatchingAbility(AbilityCategory.FEAT, choice.getAbility(), Nature.NORMAL);

    if (anAbility != null) {
      pc.removeRealAbility(AbilityCategory.FEAT, anAbility);
      CDOMObjectUtilities.removeAdds(anAbility, pc);
      CDOMObjectUtilities.restoreRemovals(anAbility, pc);
      pc.adjustMoveRates();
    }
  }
Ejemplo n.º 2
0
  @Override
  public void applyChoice(
      CDOMObject owner, CategorizedAbilitySelection choice, PlayerCharacter pc) {
    if (!pc.isImporting()) {
      pc.getSpellList();
    }

    // See if our choice is not auto or virtual
    Ability anAbility =
        pc.getMatchingAbility(AbilityCategory.FEAT, choice.getAbility(), Nature.NORMAL);

    if (anAbility != null) {
      // how many sub-choices to make
      double abilityCount =
          (pc.getSelectCorrectedAssociationCount(anAbility)
              * anAbility.getSafe(ObjectKey.SELECTION_COST).doubleValue());

      boolean result = false;
      // adjust the associated List
      if (anAbility.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
        pc.removeAssociation(anAbility, choice.getSelection());
        result = pc.hasAssociations(anAbility);
      }

      boolean removed = false;

      // if no sub choices made (i.e. all of them removed in Chooser box),
      // then remove the Feat
      if (!result) {
        removed = pc.removeRealAbility(AbilityCategory.FEAT, anAbility);
        CDOMObjectUtilities.removeAdds(anAbility, pc);
        CDOMObjectUtilities.restoreRemovals(anAbility, pc);
      }

      AbilityUtilities.adjustPool(anAbility, pc, false, abilityCount, removed);
      pc.adjustMoveRates();
    }
    double cost = choice.getAbility().getSafe(ObjectKey.SELECTION_COST).doubleValue();
    pc.adjustAbilities(AbilityCategory.FEAT, BigDecimal.valueOf(-cost));
  }
Ejemplo n.º 3
0
  /**
   * Test to ensure that a number of feat test will correctly require a number of separate feats in
   * any combination of two types.
   *
   * @throws Exception
   */
  public void testMultiFeats() throws Exception {
    final Ability metamagic1 = new Ability();
    metamagic1.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic1.setName("MM1");
    metamagic1.put(StringKey.KEY_NAME, "MM1");
    metamagic1.setCDOMCategory(AbilityCategory.FEAT);

    final Ability metamagic2 = new Ability();
    metamagic2.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic2.setName("MM2");
    metamagic2.put(StringKey.KEY_NAME, "MM2");
    metamagic2.setCDOMCategory(AbilityCategory.FEAT);

    final Ability metamagic3 = new Ability();
    metamagic3.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic3.setName("MM3");
    metamagic3.put(StringKey.KEY_NAME, "MM3");
    metamagic3.setCDOMCategory(AbilityCategory.FEAT);

    final Ability item1 = new Ability();
    item1.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item1.setName("IC1");
    item1.put(StringKey.KEY_NAME, "IC1");
    item1.setCDOMCategory(AbilityCategory.FEAT);

    final Ability item2 = new Ability();
    item2.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item2.setName("IC2");
    item2.put(StringKey.KEY_NAME, "IC2");
    item2.setCDOMCategory(AbilityCategory.FEAT);

    final Ability item3 = new Ability();
    item3.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item3.setName("IC3");
    item3.put(StringKey.KEY_NAME, "IC3");
    item3.setCDOMCategory(AbilityCategory.FEAT);

    final PlayerCharacter character = getCharacter();

    final PreFeatParser producer = new PreFeatParser();

    final Prerequisite prereq =
        producer.parse("FEAT", "3,TYPE=Metamagic,TYPE=ItemCreation", false, false);

    final PreMult test = new PreMult();
    int passes = test.passes(prereq, character, null);
    assertEquals("No feats should not pass", 0, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic1);
    passes = test.passes(prereq, character, null);
    assertEquals("One feat should not pass", 0, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic2);
    passes = test.passes(prereq, character, null);
    assertEquals("Two feats should not pass", 0, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic3);
    passes = test.passes(prereq, character, null);
    assertEquals("Three feats should pass", 1, passes);

    character.removeRealAbility(AbilityCategory.FEAT, metamagic3);
    character.addAbilityNeedCheck(AbilityCategory.FEAT, item1);
    passes = test.passes(prereq, character, null);
    assertEquals("Three feats should pass", 1, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, item2);
    character.addAbilityNeedCheck(AbilityCategory.FEAT, item3);
    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic3);
    passes = test.passes(prereq, character, null);
    assertEquals("Six feats should pass", 1, passes);

    character.removeRealAbility(AbilityCategory.FEAT, metamagic3);
    character.removeRealAbility(AbilityCategory.FEAT, item3);
    character.removeRealAbility(AbilityCategory.FEAT, item2);
    character.removeRealAbility(AbilityCategory.FEAT, item1);
    character.removeRealAbility(AbilityCategory.FEAT, metamagic2);
    character.removeRealAbility(AbilityCategory.FEAT, metamagic1);
  }