Exemplo 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();
    }
  }
Exemplo 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));
  }
Exemplo n.º 3
0
  /** Construct the list of spells the character knows, has prepared or has in a spell book. */
  private void buildKnownPreparedNodes() {
    allKnownSpellNodes.clearContents();
    knownSpellNodes.clearContents();
    bookSpellNodes.clearContents();
    preparedSpellNodes.clearContents();

    // Ensure spell information is up to date
    pc.getSpellList();

    // Scan character classes for spell classes
    List<PCClass> classList = getCharactersSpellcastingClasses();
    List<PObject> pobjList = new ArrayList<>(classList);

    // Include spells from race etc
    pobjList.add(charDisplay.getRace());

    // Look at each spell on each spellcasting class
    for (PObject pcClass : pobjList) {
      buildKnownPreparedSpellsForCDOMObject(pcClass);
    }

    spellBooks.clear();
    spellBookNames.clearContents();
    for (SpellBook spellBook : charDisplay.getSpellBooks()) {
      if (spellBook.getType() == SpellBook.TYPE_PREPARED_LIST) {
        DummySpellNodeImpl spellListNode = new DummySpellNodeImpl(getRootNode(spellBook.getName()));
        preparedSpellLists.add(spellListNode);
        addDummyNodeIfSpellListEmpty(spellBook.getName());
      } else if (spellBook.getType() == SpellBook.TYPE_SPELL_BOOK) {
        DummySpellNodeImpl spellListNode = new DummySpellNodeImpl(getRootNode(spellBook.getName()));
        spellBooks.add(spellListNode);
        addDummyNodeIfSpellBookEmpty(spellBook.getName());
        spellBookNames.addElement(spellBook.getName());
      }
    }
  }