package net.yyc12345.teyvatcraft.trading;

import java.util.List;

import net.minecraft.item.Item;
import net.minecraft.village.TradeOffers;
import net.minecraft.item.ItemStack;
import net.minecraft.village.TradeOffer;
import net.minecraft.item.Items;

public class VillagerTradingBuilder {
    public VillagerTradingBuilder() {}

    public static final int basicRewardedExp = 5;
    //public static final int basicMaxUses = 12;
    public static final float basicPriceMultiplier = 0.05f;

    public static int GetRewardedExpWithLevel(int level) {
        return 5 * level;
    }
    public static int GetMaxUsesWithLevel(int level) {
        if (level <= 3) return 12;
        else return 8;
    }

    public static void VillagerBuyVanilla(List<TradeOffers.Factory> factories, int level, Item item, int itemCount, int emeraldCount) {
        factories.add((entity, random) -> new TradeOffer(new ItemStack(item, itemCount), new ItemStack(Items.EMERALD, emeraldCount), GetMaxUsesWithLevel(level), GetRewardedExpWithLevel(level), basicPriceMultiplier));
    }

    public static void VillagerSellVanilla(List<TradeOffers.Factory> factories, int level, Item item, int itemCount, int emeraldCount) {
        factories.add((entity, random) -> new TradeOffer(new ItemStack(Items.EMERALD, emeraldCount), new ItemStack(item, itemCount), GetMaxUsesWithLevel(level), GetRewardedExpWithLevel(level), basicPriceMultiplier));
    }

    public static void VillagerProcessVanilla(List<TradeOffers.Factory> factories, int level, Item originalItem, Item resultItem, int emeraldCount) {
        factories.add((entity, random) -> new TradeOffer(new ItemStack(originalItem, 1), new ItemStack(Items.EMERALD, emeraldCount), new ItemStack(resultItem, 1), GetMaxUsesWithLevel(level), GetRewardedExpWithLevel(level), basicPriceMultiplier));
    }
}
