equivalent-exchange-3/ee3_common/com/pahimar/ee3/emc/EMCEntry.java

97 lines
2.1 KiB
Java
Raw Normal View History

package com.pahimar.ee3.emc;
2012-10-16 03:42:57 +02:00
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
2012-10-27 23:41:02 +02:00
/**
* EMCEntry
*
* Holds the breakdown of how much, and what kinds, of EMC an object has
*
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
2012-10-16 03:42:57 +02:00
public class EMCEntry {
private float cost, recoveryPercentage;
private boolean learnable, recoverable;
private Map<EMCType, Float> breakdown;
2012-10-16 03:42:57 +02:00
public EMCEntry(float cost) {
this.cost = cost;
recoveryPercentage = 1F;
learnable = true;
recoverable = true;
breakdown = Collections.synchronizedMap(new HashMap<EMCType, Float>());
}
2012-10-16 19:31:27 +02:00
public EMCEntry(float cost, float recoveryPercentage, boolean learnable, boolean recoverable) {
2012-10-16 03:42:57 +02:00
this.cost = cost;
this.recoveryPercentage = recoveryPercentage;
this.learnable = learnable;
this.recoverable = recoverable;
breakdown = Collections.synchronizedMap(new HashMap<EMCType, Float>());
}
2012-10-16 03:42:57 +02:00
public float getCost() {
return cost;
}
2012-10-16 03:42:57 +02:00
public float getRecoveryPercentage() {
return recoveryPercentage;
}
2012-10-16 03:42:57 +02:00
public boolean isLearnable() {
return learnable;
}
2012-10-16 03:42:57 +02:00
public boolean isRecoverable() {
return recoverable;
}
2012-10-16 03:42:57 +02:00
public Map<EMCType, Float> getEMCBreakDown() {
return breakdown;
}
2012-10-16 03:42:57 +02:00
public float getEMCBreakdownByType(EMCType emcType) {
if (breakdown.containsKey(emcType)) {
if (breakdown.get(emcType) != null) {
return breakdown.get(emcType).floatValue();
}
}
2012-10-16 03:42:57 +02:00
return -1F;
}
2012-10-16 03:42:57 +02:00
public void setCost(float cost) {
this.cost = cost;
}
2012-10-16 03:42:57 +02:00
public void setRecoveryPercentage(float recoveryPercentage) {
this.recoveryPercentage = recoveryPercentage;
}
2012-10-16 03:42:57 +02:00
public void setLearnable(boolean learnable) {
this.learnable = learnable;
}
2012-10-16 03:42:57 +02:00
public void setRecoverable(boolean recoverable) {
this.recoverable = recoverable;
}
2012-10-16 03:42:57 +02:00
public void addEMCBreakDown(EMCType emcType, Float breakdownPercentage) {
if (!(breakdown.containsKey(emcType))) {
2012-10-16 03:42:57 +02:00
breakdown.put(emcType, breakdownPercentage);
}
}
2012-10-16 03:42:57 +02:00
public void setEMCBreakDown(EMCType emcType, Float breakdownPercentage) {
if (breakdown.containsKey(emcType)) {
breakdown.put(emcType, breakdownPercentage);
}
}
}