public void writeImpl(GameClient client, WritableBuffer buffer) {
writeId(ServerPacketId.EX_BUY_SELL_LIST, buffer);
buffer.writeInt(0x01); // Type SELL
buffer.writeInt(_inventorySlots);
if ((_sellList != null)) {
buffer.writeShort(_sellList.size());
for (ItemInstance item : _sellList) {
writeItem(item, buffer);
int price = item.getItem().getReferencePrice() / 4;
final int crystalLevel = item.getItem().getCrystalType().getLevel();
if ((item.isWeapon() || item.isArmor()) && ((crystalLevel >= CrystalType.D.getLevel()) && (crystalLevel <= CrystalType.B.getLevel()))) {
price /= 3;
}
buffer.writeLong(Config.MERCHANT_ZERO_SELL_PRICE ? 0 : price);
}
} else {
buffer.writeShort(0x00);
}
if ((_refundList != null) && !_refundList.isEmpty()) {
buffer.writeShort(_refundList.size());
int i = 0;
for (ItemInstance item : _refundList) {
writeItem(item, buffer);
buffer.writeInt(i++);
int price = item.getItem().getReferencePrice() / 4;
final int crystalLevel = item.getItem().getCrystalType().getLevel();
if ((item.isWeapon() || item.isArmor()) && ((crystalLevel >= CrystalType.D.getLevel()) && (crystalLevel <= CrystalType.B.getLevel()))) {
price /= 3;
}
buffer.writeLong(Config.MERCHANT_ZERO_SELL_PRICE ? 0 : (price) * item.getCount());
}
} else {
buffer.writeShort(0x00);
}
buffer.writeByte(_done ? 0x01 : 0x00);
}