package com.openosrs.client.api.types;

public class GroundItem {
    private final int itemId;
    private final String name;
    private final int quantity;
    private final Position position;
    private final long spawnTime;
    private final boolean tradeable;

    public GroundItem(int itemId, String name, int quantity, Position position,
                     long spawnTime, boolean tradeable) {
        this.itemId = itemId;
        this.name = name;
        this.quantity = quantity;
        this.position = position;
        this.spawnTime = spawnTime;
        this.tradeable = tradeable;
    }

    public int getItemId() { return itemId; }
    public String getName() { return name; }
    public int getQuantity() { return quantity; }
    public Position getPosition() { return position; }
    public long getSpawnTime() { return spawnTime; }
    public boolean isTradeable() { return tradeable; }

    public long getAge() {
        return System.currentTimeMillis() - spawnTime;
    }

    public double distanceToPlayer(Position playerPos) {
        return position.distanceTo(playerPos);
    }

    @Override
    public String toString() {
        return String.format("GroundItem[%d] %s x%d at %s", itemId, name, quantity, position);
    }
}
