package de.siphalor.was.content.product;

import org.jetbrains.annotations.NotNull;

import java.util.ResourceBundle;

public interface Product {
	@NotNull
	String getPropertySpecifier();
	String[] getProperties();

	int getDepth();
	boolean testY(int y);

	@NotNull
	ProductType<?> getType();

	boolean equals(Product product);

	@NotNull
	default String getTranslationKey() {
		return "products." + getType().getId();
	}

	@NotNull
	default String getName(@NotNull ResourceBundle i18n) {
		return i18n.getString(getTranslationKey());
	}

	@NotNull
	default String getDescription(@NotNull ResourceBundle i18n) {
		String[] props = getType().getProperties();
		String[] values = getProperties();

		String base = getTranslationKey();

		StringBuilder res = new StringBuilder();
		for (int i = 0; i < props.length; i++) {
			res.append(i18n.getString(base + "." + props[i]));
			res.append(": ");
			res.append(i18n.getString(base + "." + props[i] + "." + values[i]));
			res.append(", ");
		}
		res.delete(res.length() - 2, res.length());

		return res.toString();
	}

	@NotNull
	default String getTextureLocation() {
		return "textures/products/" + getType().getId() + "/" + getPropertySpecifier() + ".png";
	}

	@NotNull
	static String getPlaceholderTextureLocation() {
		return "textures/products/package.png";
	}
}
