예제 #1
0
 /**
  * @param location The location to search
  * @param needForCancel If true, excludes noCancel spells
  * @return A list of ALL breakable spells (currently Combat,Day,Permanent) that are in the
  *     clearing.
  */
 public ArrayList getAllSpellsInClearing(TileLocation location, boolean needForCancel) {
   ArrayList ret = new ArrayList();
   for (Iterator i = getSpells(null).iterator(); i.hasNext(); ) {
     SpellWrapper spell = (SpellWrapper) i.next();
     if (!needForCancel || !spell.isNoCancelSpell()) {
       TileLocation test = spell.getCurrentLocation();
       if (test
           != null) { // test might be null if the spell is targeting a treasure that hasn't yet
                      // been seen
         if (test.equals(location)) {
           ret.add(spell);
         } else if (test.isTileOnly()) {
           ret.add(spell);
         }
       }
     }
   }
   return ret;
 }
예제 #2
0
  private boolean spellCanEnergize(
      GameWrapper game, TileLocation loc, SpellWrapper spell, boolean includeCalendar) {
    RealmCalendar cal = RealmCalendar.getCalendar(game.getGameObject().getGameData());
    ArrayList infiniteSources = new ArrayList();
    if (loc.isInClearing()) {
      infiniteSources.addAll(loc.clearing.getAllSourcesOfColor(true));
    } else if (loc.isBetweenClearings()) {
      infiniteSources.addAll(loc.clearing.getAllSourcesOfColor(true));
      infiniteSources.addAll(loc.getOther().clearing.getAllSourcesOfColor(true));
    } else if (loc.isTileOnly()) {
      infiniteSources.addAll(loc.tile.getAllSourcesOfColor());
    } else if (loc.isBetweenTiles()) {
      infiniteSources.addAll(loc.tile.getAllSourcesOfColor());
      infiniteSources.addAll(loc.getOther().tile.getAllSourcesOfColor());
    }

    if (includeCalendar) {
      // 7th day color magic!
      infiniteSources.addAll(cal.getColorMagic(game.getMonth(), game.getDay()));
    }

    if (infiniteSources.size() > 0) {
      ColorMagic spellColor = spell.getRequiredColorMagic();
      if (spellColor == null || infiniteSources.contains(spellColor)) {
        // We got it!
        return true;
        //				spell.affectTargets(frame,game,false);
      }
    }
    return false;
  }