Exemple #1
0
  /** Remove bids */
  private void removeBids() {
    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?");
      statement.setInt(1, getId());
      statement.execute();

      statement.close();
    } catch (Exception e) {
      _log.fatal("Exception: Auction.deleteFromDB(): " + e.getMessage(), e);
    } finally {
      L2DatabaseFactory.close(con);
    }

    for (Bidder b : _bidders.values()) {
      if (ClanTable.getInstance().getClanByName(b.getClanName()).getHasHideout() == 0)
        returnItem(b.getClanName(), PcInventory.ADENA_ID, b.getBid(), true); // 10 % tax
      else {
        L2Player bidder = L2World.getInstance().getPlayer(b.getName());
        if (bidder != null) bidder.sendMessage("Congratulations! You have won a ClanHall!");
      }
      ClanTable.getInstance().getClanByName(b.getClanName()).setAuctionBiddedAt(0, true);
    }
    _bidders.clear();
  }
Exemple #2
0
  /** Cancel bid */
  public synchronized void cancelBid(int bidder) {
    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?");
      statement.setInt(1, getId());
      statement.setInt(2, bidder);
      statement.execute();

      statement.close();
    } catch (Exception e) {
      _log.fatal("Exception: Auction.cancelBid(String bidder): " + e.getMessage(), e);
    } finally {
      L2DatabaseFactory.close(con);
    }

    returnItem(
        _bidders.get(bidder).getClanName(),
        PcInventory.ADENA_ID,
        _bidders.get(bidder).getBid(),
        true);
    ClanTable.getInstance()
        .getClanByName(_bidders.get(bidder).getClanName())
        .setAuctionBiddedAt(0, true);
    _bidders.clear();
    loadBid();
  }
Exemple #3
0
 /** End of auction */
 public void endAuction() {
   if (ClanHallManager.loaded()) {
     if (_highestBidderId == 0 && _sellerId == 0) {
       startAutoTask();
       return;
     }
     if (_highestBidderId == 0 && _sellerId > 0) {
       /** If seller haven't sell ClanHall, auction removed, THIS MUST BE CONFIRMED */
       int aucId = AuctionService.getInstance().getAuctionIndex(_id);
       AuctionService.getInstance().getAuctions().remove(aucId);
       return;
     }
     if (_sellerId > 0) {
       returnItem(_sellerClanName, PcInventory.ADENA_ID, _highestBidderMaxBid, true);
       returnItem(
           _sellerClanName,
           PcInventory.ADENA_ID,
           ClanHallManager.getInstance().getClanHallById(_itemId).getLease(),
           false);
     }
     deleteAuctionFromDB();
     L2Clan Clan =
         ClanTable.getInstance().getClanByName(_bidders.get(_highestBidderId).getClanName());
     _bidders.remove(_highestBidderId);
     Clan.setAuctionBiddedAt(0, true);
     removeBids();
     ClanHallManager.getInstance().setOwner(_itemId, Clan);
   } else {
     /** Task waiting ClanHallManager is loaded every 3s */
     ThreadPoolManager.getInstance().scheduleGeneral(new AutoEndTask(), 3000);
   }
 }
Exemple #4
0
 /**
  * Return Item in WHC
  *
  * @param Clan
  * @param itemId
  * @param quantity
  * @param penalty
  */
 private void returnItem(String Clan, int itemId, int quantity, boolean penalty) {
   if (penalty) quantity *= 0.9; // take 10% tax fee if needed
   ClanTable.getInstance()
       .getClanByName(Clan)
       .getWarehouse()
       .addItem("Outbidded", PcInventory.ADENA_ID, quantity, null, null);
 }