mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 22:07:59 +01:00
60 lines
1.3 KiB
Java
60 lines
1.3 KiB
Java
package com.minelittlepony.unicopia;
|
|
|
|
import net.minecraft.util.Formatting;
|
|
|
|
public enum Affinity {
|
|
GOOD(Formatting.BLUE, -1),
|
|
NEUTRAL(Formatting.WHITE, 0),
|
|
BAD(Formatting.RED, 1);
|
|
|
|
private final Formatting color;
|
|
|
|
private final int corruption;
|
|
|
|
private Affinity[] implications;
|
|
|
|
public static final Affinity[] VALUES = values();
|
|
|
|
Affinity(Formatting color, int corruption) {
|
|
this.color = color;
|
|
this.corruption = corruption;
|
|
}
|
|
|
|
public Formatting getColor() {
|
|
return color;
|
|
}
|
|
|
|
public String getTranslationKey() {
|
|
return this == BAD ? "curse" : "spell";
|
|
}
|
|
|
|
public int getCorruption() {
|
|
return corruption;
|
|
}
|
|
|
|
public boolean isNeutral() {
|
|
return this == NEUTRAL;
|
|
}
|
|
|
|
public boolean alignsWith(Affinity other) {
|
|
return isNeutral() || other.isNeutral() || this == other;
|
|
}
|
|
|
|
public Affinity[] getImplicators() {
|
|
if (implications != null) {
|
|
return implications;
|
|
}
|
|
|
|
if (this == NEUTRAL) {
|
|
implications = new Affinity[] { GOOD, BAD };
|
|
} else {
|
|
implications = new Affinity[] { this };
|
|
}
|
|
|
|
return implications;
|
|
}
|
|
|
|
public static Affinity of(int ordinal, Affinity fallback) {
|
|
return ordinal < 0 || ordinal >= VALUES.length ? fallback : VALUES[ordinal];
|
|
}
|
|
}
|