2020-09-23 17:19:28 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
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),
|
2021-12-29 19:13:07 +01:00
|
|
|
NEUTRAL(Formatting.LIGHT_PURPLE, 0),
|
2020-01-16 12:35:46 +01:00
|
|
|
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;
|
|
|
|
|
2021-03-02 14:40:37 +01:00
|
|
|
public static final Affinity[] VALUES = values();
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-03-02 14:40:37 +01:00
|
|
|
public Formatting getColor() {
|
2019-01-22 17:39:30 +01:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTranslationKey() {
|
|
|
|
return this == BAD ? "curse" : "spell";
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCorruption() {
|
|
|
|
return corruption;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isNeutral() {
|
|
|
|
return this == NEUTRAL;
|
|
|
|
}
|
2019-02-04 19:29:37 +01:00
|
|
|
|
2020-09-23 17:19:28 +02:00
|
|
|
public boolean alignsWith(Affinity other) {
|
|
|
|
return isNeutral() || other.isNeutral() || this == other;
|
|
|
|
}
|
|
|
|
|
2021-03-02 14:40:37 +01:00
|
|
|
public static Affinity of(int ordinal, Affinity fallback) {
|
|
|
|
return ordinal < 0 || ordinal >= VALUES.length ? fallback : VALUES[ordinal];
|
2019-02-08 16:56:28 +01:00
|
|
|
}
|
2019-01-22 17:39:30 +01:00
|
|
|
}
|