<commit_before>/**
 * This file is a part of FrogCraftRebirth, 
 * created by 3TUSK at 1:41:04 PM, Jul 25, 2016, 
 * FrogCraftRebirth, is open-source under MIT license,
 * check https://github.com/FrogCraft-Rebirth/
 * FrogCraft-Rebirth/LICENSE_FrogCraft_Rebirth for 
 * more information.
 */
package frogcraftrebirth.api.mps;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

import frogcraftrebirth.api.FrogAPI;
import net.minecraft.item.ItemStack;

public enum MPSUpgradeManager {
	
	INSTANCE;
	
	private Set<ItemStack> validSolarUpgrades = new LinkedHashSet<ItemStack>();
	
	private Map<ItemStack, Integer> validStorageUpgrades = new LinkedHashMap<ItemStack, Integer>();
	
	private Map<ItemStack, Integer> validVoltageUpgrades = new LinkedHashMap<ItemStack, Integer>();
	
	public boolean isSolarUpgradeValid(ItemStack stack) { 
		if (stack == null || stack.stackSize == 0)
			return false;
		for (ItemStack aStack : validSolarUpgrades) {
			if (aStack.isItemEqual(stack))
				return true;
		}
		return false;
	}
	
	public int getEnergyStoreIncreasementFrom(ItemStack stack) {
		if (stack == null || stack.stackSize == 0)
			return 0;
		for (Map.Entry<ItemStack, Integer> entry : validStorageUpgrades.entrySet()) {
			if (entry.getKey().isItemEqual(stack))
				return entry.getValue();
		}
		return 0;
	}
	
	public int getVoltageIncreasementFrom(ItemStack stack) {
		if (stack == null || stack.stackSize == 0)
			return 0;
		for (Map.Entry<ItemStack, Integer> entry : validVoltageUpgrades.entrySet()) {
			if (entry.getKey().isItemEqual(stack))
				return entry.getValue();
		}
		return 0;
	}
	
	/**
	 * @param stack The upgrade item being registered
	 * @return true if succeed, false if fail<commit_msg>API internal change: quantity of upgrade item now does matter<commit_after>/**
 * This file is a part of FrogCraftRebirth, 
 * created by 3TUSK at 1:41:04 PM, Jul 25, 2016, 
 * FrogCraftRebirth, is open-source under MIT license,
 * check https://github.com/FrogCraft-Rebirth/
 * FrogCraft-Rebirth/LICENSE_FrogCraft_Rebirth for 
 * more information.
 */
package frogcraftrebirth.api.mps;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

import frogcraftrebirth.api.FrogAPI;
import net.minecraft.item.ItemStack;

public enum MPSUpgradeManager {
	
	INSTANCE;
	
	private Set<ItemStack> validSolarUpgrades = new LinkedHashSet<ItemStack>();
	
	private Map<ItemStack, Integer> validStorageUpgrades = new LinkedHashMap<ItemStack, Integer>();
	
	private Map<ItemStack, Integer> validVoltageUpgrades = new LinkedHashMap<ItemStack, Integer>();
	
	public boolean isSolarUpgradeValid(ItemStack stack) { 
		if (stack == null || stack.stackSize == 0)
			return false;
		for (ItemStack aStack : validSolarUpgrades) {
			if (aStack.isItemEqual(stack))
				return true;
		}
		return false;
	}
	
	public int getEnergyStoreIncreasementFrom(ItemStack stack) {
		if (stack == null || stack.stackSize == 0)
			return 0;
		for (Map.Entry<ItemStack, Integer> entry : validStorageUpgrades.entrySet()) {
			if (entry.getKey().isItemEqual(stack)) {
				int increasement = stack.stackSize / entry.getKey().stackSize * entry.getValue();
				return increasement;
			}
		}
		return 0;
	}
	
	public int getVoltageIncreasementFrom(ItemStack stack) {
		if (stack == null || stack.stackSize == 0)
			return 0;
		for (Map.Entry<ItemStack, Integer> entry : validVoltageUpgrades.entrySet()) {
			if (entry.getKey().isItemEqual(stack)) {
				int increasement = stack.stackSize / entry.getKey().stackSize * entry.getValue();
				return increasement;
			}
		}
		return 0;
	}
	
	/**
	 * @param stack The upgrade item being registered
	 * @return true if succeed, false if fail
{'fraction_non_alphanumeric': 0.11084529505582137, 'fraction_numerical': 0.010101010101010102, 'mean_word_length': 4.391117478510028, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '373073', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1198, 'n_words': 308}