package com.openosrs.client.api.types;

public class InventoryChange {
    private final int slot;
    private final Item oldItem;
    private final Item newItem;

    public InventoryChange(int slot, Item oldItem, Item newItem) {
        this.slot = slot;
        this.oldItem = oldItem;
        this.newItem = newItem;
    }

    public int getSlot() { return slot; }
    public Item getOldItem() { return oldItem; }
    public Item getNewItem() { return newItem; }

    public boolean isItemAdded() {
        return oldItem.isEmpty() && !newItem.isEmpty();
    }

    public boolean isItemRemoved() {
        return !oldItem.isEmpty() && newItem.isEmpty();
    }

    public boolean isQuantityChanged() {
        return oldItem.getItemId() == newItem.getItemId() &&
               oldItem.getQuantity() != newItem.getQuantity();
    }

    @Override
    public String toString() {
        return String.format("InventoryChange[%d]: %s -> %s", slot, oldItem, newItem);
    }
}
