コード例 #1
0
  public void deenergizePermanentSpells() {
    // Make each permanent spell "inert", one at a time
    boolean didDeenergize = false;
    for (SpellWrapper spell : getSpells(PERMANENT_SPELLS)) {
      if (!spell.isInert()) { // If spell is already inert, then don't deenergize it!
        // Don't deenergize spells that have an automatic supply of color magic
        if (spellCanEnergize(
            GameWrapper.findGame(spell.getGameData()), spell.getCurrentLocation(), spell, false)) {
          continue;
        }

        if (!spell.isAlwaysActive()) {
          spell.unaffectTargets();
          spell.makeInert();
          didDeenergize = true;
        }
      }
    }
    if (didDeenergize) {
      // Yes, this is a dangerous recursion, but necessary I think.  If you Absorb Essence, and then
      // activate a Transform
      // spell, you end up two layers deep in spell wizardry, and this is the only way to guarantee
      // that both are deenergized.
      deenergizePermanentSpells();
    }
  }