示例#1
0
  public void createTradeGood() throws CivException {

    if (!this.isActive()) {
      return;
    }

    /* Add custom item.
     * This function is called on reload. The constructor either loads
     * the good or creates a new one at the trade outpost if no good could
     * be found.
     * */
    try {
      this.goodie = new BonusGoodie(this);

      if (this.goodie.getFrame() == null) {
        // goodie not in a frame, skip it.
        return;
      }

      TownHall townhall = this.goodie.getFrame().getTown().getTownHall();
      if (townhall != null) {
        for (ItemFrameStorage ifs : townhall.getGoodieFrames()) {
          if (ifs.getFrameID() == this.goodie.getFrame().getFrameID()) {
            townhall.getTown().loadGoodiePlaceIntoFrame(townhall, goodie);
          }
        }
      }
    } catch (SQLException e) {
      e.printStackTrace();
      throw new CivException("Internal database error.");
    } catch (InvalidNameException e) {
      e.printStackTrace();
      throw new CivException("Invalid name exception.");
    }
  }