コード例 #1
0
  /**
   * Remove a domain from the character.
   *
   * @param pc The character
   * @param domain The domain.
   */
  public static void removeDomain(PlayerCharacter pc, Domain domain) {
    ClassSource source = pc.getDomainSource(domain);
    PCClass aClass = pc.getClassKeyed(source.getPcclass().getKeyName());

    if (aClass != null) {
      int maxLevel;

      for (maxLevel = 0; maxLevel < 10; maxLevel++) {
        if (pc.getSpellSupport(aClass).getCastForLevel(maxLevel, pc) == 0) {
          break;
        }
      }

      if (maxLevel > 0) {
        removeSpellsFromClassForLevels(pc, domain, aClass);
      }

      if ((maxLevel > 1) && (aClass.getSafe(IntegerKey.KNOWN_SPELLS_FROM_SPECIALTY) == 0)) {
        DomainSpellList domainSpellList = domain.get(ObjectKey.DOMAIN_SPELLLIST);
        final List<Spell> aList =
            pc.getAllSpellsInLists(Collections.singletonList(domainSpellList));

        for (Spell gcs : aList) {
          if (SpellLevel.getFirstLvlForKey(gcs, domainSpellList, pc) < maxLevel) {
            pc.removeDomainSpellCount(aClass);
            break;
          }
        }
      }
    }

    if (!pc.isImporting()) {
      BonusActivation.deactivateBonuses(domain, pc);
    }
  }
コード例 #2
0
  /**
   * Sets the locked flag on a PC
   *
   * @param pc
   */
  public static void applyDomain(PlayerCharacter pc, Domain d) {
    ClassSource source = pc.getDomainSource(d);
    PCClass aClass = pc.getClassKeyed(source.getPcclass().getKeyName());
    if (aClass != null) {
      int maxLevel;

      for (maxLevel = 0; maxLevel < 10; maxLevel++) {
        if (pc.getSpellSupport(aClass).getCastForLevel(maxLevel, pc) == 0) {
          break;
        }
      }

      if (maxLevel > 0) {
        addSpellsToClassForLevels(pc, d, aClass, 0, maxLevel - 1);
      }

      if ((maxLevel > 1) && (aClass.getSafe(IntegerKey.KNOWN_SPELLS_FROM_SPECIALTY) == 0)) {
        DomainSpellList domainSpellList = d.get(ObjectKey.DOMAIN_SPELLLIST);
        final List<Spell> aList =
            pc.getAllSpellsInLists(Collections.singletonList(domainSpellList));

        for (Spell gcs : aList) {
          if (SpellLevel.getFirstLvlForKey(gcs, domainSpellList, pc) < maxLevel) {
            pc.setDomainSpellCount(aClass, 1);
            break;
          }
        }
      }
    }

    Collection<CDOMReference<Spell>> mods = d.getSafeListMods(Spell.SPELLS);
    for (CDOMReference<Spell> ref : mods) {
      Collection<Spell> spells = ref.getContainedObjects();
      Collection<AssociatedPrereqObject> assoc = d.getListAssociations(Spell.SPELLS, ref);
      for (AssociatedPrereqObject apo : assoc) {
        if (!PrereqHandler.passesAll(apo.getPrerequisiteList(), pc, d)) {
          continue;
        }
        for (Spell s : spells) {
          String book = apo.getAssociation(AssociationKey.SPELLBOOK);
          List<CharacterSpell> aList = pc.getCharacterSpells(aClass, s, book, -1);

          if (aList.isEmpty()) {
            Formula times = apo.getAssociation(AssociationKey.TIMES_PER_UNIT);
            CharacterSpell cs = new CharacterSpell(d, s);
            int resolvedTimes = times.resolve(pc, d.getQualifiedKey()).intValue();
            cs.addInfo(1, resolvedTimes, book);
            pc.addCharacterSpell(aClass, cs);
          }
        }
      }
    }
  }
コード例 #3
0
  /**
   * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter,
   *     pcgen.io.ExportHandler)
   */
  @Override
  public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
    StringBuffer retValue = new StringBuffer();

    SpellListTokenParams params =
        new SpellListTokenParams(tokenSource, SpellListToken.SPELLTAG_MEMORIZE);

    final CDOMObject aObject = pc.getSpellClassAtIndex(params.getClassNum());

    if (aObject != null) {
      PCClass aClass = null;

      if (aObject instanceof PCClass) {
        aClass = (PCClass) aObject;
      }

      if (aClass != null) {
        retValue.append((boolean) aClass.getSafe(ObjectKey.MEMORIZE_SPELLS));
      }
    }

    return retValue.toString();
  }
コード例 #4
0
 private boolean isSpellCaster(PCClass pcc) {
   return pcc.getSafe(ObjectKey.USE_SPELL_SPELL_STAT)
       || pcc.getSafe(ObjectKey.CASTER_WITHOUT_SPELL_STAT)
       || (pcc.get(ObjectKey.SPELL_STAT) != null);
 }