}
}
class ConfirmAcceptOfferChatAction implements ChatAction {
public void fire (Player player, Sentence sentence, EventRaiser npc) {
Offer offer = getOffer();
Market m = TradeCenterZoneConfigurator.getShopFromZone(player.getZone());
String itemname = offer.getItemName();
if (m.acceptOffer(offer,player)) {
// Successful trade. Tell the offerer
StringBuilder earningToFetchMessage = new StringBuilder();
earningToFetchMessage.append("Your ");
earningToFetchMessage.append(itemname);
earningToFetchMessage.append(" was sold. You can now fetch your earnings from me.");
logger.debug("sending a notice to '" + offer.getOfferer() + "': " + earningToFetchMessage.toString());
DBCommandQueue.get().enqueue(new StoreMessageCommand("Harold", offer.getOfferer(), earningToFetchMessage.toString(), "N"));
npc.say("Thanks.");
// Obsolete the offers, since the list has changed
((MarketManagerNPC) npc.getEntity()).getOfferMap().clear();
} else {
// Trade failed for some reason. Check why, and inform the player
if (!m.contains(offer)) {
int quantity = getQuantity(offer.getItem());
npc.say("I'm sorry, but " + Grammar.thatthose(quantity) + " "
+ Grammar.quantityplnoun(quantity, offer.getItem().getName(), "the")
+ " " + Grammar.isare(quantity)
+ " no longer for sale.");
} else {
npc.say("Sorry, you don't have enough money!");
}