Account for corruption when computing a unicorn's job title

This commit is contained in:
Sollace 2022-09-04 14:17:15 +02:00
parent edad4678ca
commit 518c418072
3 changed files with 33 additions and 24 deletions

View file

@ -40,7 +40,7 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell
int currentLevel = pony.getLevel().get();
DrawableUtil.drawScaledText(matrices, pony.getEntity().getName(), SpellbookScreen.TITLE_X, y, 1.3F, SpellbookScreen.TITLE_COLOR);
DrawableUtil.drawScaledText(matrices, ExperienceGroup.forLevel(currentLevel).getLabel(), SpellbookScreen.TITLE_X, y + 13, 0.8F, 0xAA0040FF);
DrawableUtil.drawScaledText(matrices, ExperienceGroup.forLevel(currentLevel, pony.getCorruption().get()), SpellbookScreen.TITLE_X, y + 13, 0.8F, 0xAA0040FF);
MagicReserves reserves = pony.getMagicalReserves();

View file

@ -180,6 +180,7 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
@Override
protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) {
this.clearAndInit();
chapters.getCurrentChapter().content().ifPresent(content -> content.draw(matrices, mouseX, mouseY, (IViewRoot)this));
}

View file

@ -3,31 +3,39 @@ package com.minelittlepony.unicopia.entity.player;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
public enum ExperienceGroup {
MAGICAL_KINDERGARTENER,
FRIENDSHIP_STUDENT,
SENIOR_FRIENDSHIP_STUDENT,
JUNIOR_MAGE,
MAGE,
ARCHMAGE,
ARCHMAGUS,
SENIOR_ARCHMAGUS,
ASCENDED_SENIOR_ARCHMAGUS,
DEMI_GOD,
ARCH_DEMI_GOD,
ALICORN_PRINCESS,
POLYCORN_PRINCESS,
FAUSTIAN_LEGEND;
public record ExperienceGroup (String experience, String corruption) {
public static final LinearSelector<String> EXPERIENCES = new LinearSelector<>(new String[] {
"MAGICAL_KINDERGARTENER",
"FRIENDSHIP_STUDENT",
"SENIOR_FRIENDSHIP_STUDENT",
"JUNIOR_MAGE",
"MAGE",
"ARCHMAGE",
"ARCHMAGUS",
"SENIOR_ARCHMAGUS",
"ASCENDED_SENIOR_ARCHMAGUS",
"DEMI_GOD",
"ARCH_DEMI_GOD",
"ALICORN_PRINCESS",
"POLYCORN_PRINCESS",
"FAUSTIAN_LEGEND"
}, 2);
public static final LinearSelector<String> CORRUPTIONS = new LinearSelector<>(new String[] {
"PURE",
"IMPURE",
"TAINTED",
"TWISTED",
"CORRUPT",
"MONSTROUS"
}, 1F/8F);
private final Text label = Text.literal(name().toLowerCase());
public Text getLabel() {
return label;
public static Text forLevel(int level, int corruption) {
return Text.of(CORRUPTIONS.get(corruption).toLowerCase() + " " + EXPERIENCES.get(level).toLowerCase());
}
public static ExperienceGroup forLevel(int level) {
level /= 20;
level = MathHelper.clamp(level, 0, values().length - 1);
return values()[level];
public record LinearSelector<T> (T[] values, float ratio) {
public T get(int level) {
return values()[MathHelper.clamp(MathHelper.floor(MathHelper.sqrt(level * ratio())), 0, values().length - 1)];
}
}
}