2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia.magic;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2020-01-27 11:05:22 +01:00
|
|
|
import net.minecraft.text.Text;
|
|
|
|
import net.minecraft.text.TranslatableText;
|
2020-01-16 12:35:46 +01:00
|
|
|
import net.minecraft.util.Formatting;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
public enum Affinity {
|
|
|
|
GOOD(Formatting.BLUE, -1),
|
|
|
|
NEUTRAL(Formatting.WHITE, 0),
|
|
|
|
BAD(Formatting.RED, 1);
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
private final Formatting color;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
|
|
|
private final int corruption;
|
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
private Affinity[] implications;
|
2019-02-04 19:29:37 +01:00
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
Affinity(Formatting color, int corruption) {
|
2019-01-22 17:39:30 +01:00
|
|
|
this.color = color;
|
|
|
|
this.corruption = corruption;
|
|
|
|
}
|
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
public Formatting getColourCode() {
|
2019-01-22 17:39:30 +01:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTranslationKey() {
|
|
|
|
return this == BAD ? "curse" : "spell";
|
|
|
|
}
|
|
|
|
|
2020-01-27 11:05:22 +01:00
|
|
|
public Text getName() {
|
2020-04-25 22:03:36 +02:00
|
|
|
Text text = new TranslatableText("affinity." + getTranslationKey());
|
2020-01-27 11:05:22 +01:00
|
|
|
text.getStyle().setColor(getColourCode());
|
|
|
|
return text;
|
2019-03-11 19:50:06 +01:00
|
|
|
}
|
|
|
|
|
2019-01-22 17:39:30 +01:00
|
|
|
public int getCorruption() {
|
|
|
|
return corruption;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isNeutral() {
|
|
|
|
return this == NEUTRAL;
|
|
|
|
}
|
2019-02-04 19:29:37 +01:00
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
public Affinity[] getImplicators() {
|
2019-02-04 19:29:37 +01:00
|
|
|
if (implications != null) {
|
|
|
|
return implications;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this == NEUTRAL) {
|
|
|
|
implications = values();
|
|
|
|
} else {
|
2020-01-16 12:35:46 +01:00
|
|
|
implications = new Affinity[] { this };
|
2019-02-04 19:29:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return implications;
|
|
|
|
}
|
2019-02-08 16:56:28 +01:00
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
public static Affinity of(String s) {
|
2019-02-08 16:56:28 +01:00
|
|
|
try {
|
|
|
|
if (s != null)
|
|
|
|
return valueOf(s.toUpperCase());
|
|
|
|
} catch (Throwable e) {}
|
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
return Affinity.NEUTRAL;
|
2019-02-08 16:56:28 +01:00
|
|
|
}
|
2019-01-22 17:39:30 +01:00
|
|
|
}
|