Example #1
0
  private void finishWithCard() {
    if ((state != RULES)
        && (currentCard != null)
        && (currentCard.getTypeLine() != null)
        && (currentCard.getTypeLine().indexOf("Land") < 0))
      throw new IllegalStateException(
          "Can't finish with card ("
              + currentCard.getName()
              + ") if there's no rule text or P/T. (state="
              + state
              + ")");
    if (flipLines != null) {
      String name = currentCard.getName();

      List tempHoldFlipLines = flipLines;
      flipLines = null;
      splitLines = null;

      Iterator itrLines = tempHoldFlipLines.iterator();
      String otherName = null;
      if (name.equals("Curse of the Fire Penguin")) otherName = "Fire Penguin";
      else otherName = (String) itrLines.next();

      String cost = currentCard.getCost();
      currentCard.clearName();
      currentCard.setName(name);
      //            currentCard.setName(name + " ["+name+"]");
      currentCard.setRules("[Flips to: " + otherName + "]");
      storeCurrentCard();
      currentCard = null;

      handleAttributeLine(otherName);
      //            handleAttributeLine(name + " ["+otherName+"]");
      currentCard.setCost(cost);
      while (itrLines.hasNext()) handleAttributeLine((String) itrLines.next());
      currentCard.setRules("[Flips from: " + name + "]");
    } else if (splitLines != null) {
      String bigName = currentCard.getName();
      String[] littleNames = bigName.split("\\s*/+\\s*");
      String bigCost = currentCard.getCost();
      String bigType = currentCard.getTypeLine();
      String bigRules = currentCard.getRules().toString("; ");

      // this is totally stupid.  Oh well.
      currentCard = new OracleCardInfo();
      currentCard.setName(littleNames[0]);
      currentCard.setCost(bigCost);
      currentCard.setType(bigType);
      currentCard.setRules(bigRules);
      storeCurrentCard();

      for (int i = 1; i < littleNames.length; i++) {
        List tempList = splitLines;
        currentCard = null;
        splitLines = null;
        flipLines = null;
        handleAttributeLine(littleNames[i]);
        //                handleAttributeLine(bigName + " ("+littleNames[i]+")");
        Iterator itrLines = tempList.iterator();
        while (itrLines.hasNext()) {
          String line = (String) itrLines.next();
          handleAttributeLine(line);
        }
        bigCost = bigCost + " // " + currentCard.getCost();
        bigRules = bigRules + " // " + currentCard.getRules().toString("; ");
        storeCurrentCard();
      }
      /*
      for (int i = 1; i < littleNames.length; i++) {
          storeCurrentCard();
          currentCard = null;
          List tempList = splitLines;
          splitLines = null;
          flipLines = null;
          handleAttributeLine(bigName + " ("+littleNames[i]+")");
          Iterator itrLines = tempList.iterator();
          while (itrLines.hasNext()) {
              String line = (String)itrLines.next();
              handleAttributeLine(line);
          }
      }
      */
      currentCard = null;
      splitLines = null;
      flipLines = null;

      currentCard = new OracleCardInfo();
      currentCard.setName(bigName);
      currentCard.setCost(bigCost);
      currentCard.setType(bigType);
      currentCard.setRules(bigRules);
    }

    storeCurrentCard();
    currentCard = null;
    splitLines = null;
    flipLines = null;
  }