Exemplo n.º 1
0
  public static void addSpellsToClassForLevels(
      PlayerCharacter pc, Domain d, PCClass aClass, int minLevel, int maxLevel) {
    if (aClass == null) {
      return;
    }

    for (int aLevel = minLevel; aLevel <= maxLevel; aLevel++) {
      Collection<Spell> domainSpells = pc.getSpellsIn(d.get(ObjectKey.DOMAIN_SPELLLIST), aLevel);
      for (Spell spell : domainSpells) {
        List<CharacterSpell> slist =
            pc.getCharacterSpells(aClass, spell, Globals.getDefaultSpellBook(), aLevel);
        boolean flag = true;

        for (CharacterSpell cs1 : slist) {
          flag = !(cs1.getOwner().equals(d));

          if (!flag) {
            break;
          }
        }

        if (flag) {
          CharacterSpell cs = new CharacterSpell(d, spell);
          cs.addInfo(aLevel, 1, Globals.getDefaultSpellBook());
          pc.addCharacterSpell(aClass, cs);
        }
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Remove any spells granted by the domain to the class.
   *
   * @param pc The character.
   * @param domain The domain.
   * @param aClass The class which would have the spells allocated.
   */
  public static void removeSpellsFromClassForLevels(
      PlayerCharacter pc, Domain domain, PCClass aClass) {
    if (aClass == null) {
      return;
    }

    Collection<? extends CharacterSpell> characterSpells = pc.getCharacterSpells(aClass);
    for (CharacterSpell characterSpell : characterSpells) {
      if (characterSpell.getOwner() == domain) {
        pc.removeCharacterSpell(aClass, characterSpell);
      }
    }
  }