Display the amount of corruption you would gain from casting a spell

This commit is contained in:
Sollace 2024-05-18 14:55:41 +01:00
parent 95ffe5b0b5
commit 8a3abf5622
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
5 changed files with 13 additions and 6 deletions

View file

@ -45,7 +45,7 @@ public enum Affinity implements StringIdentifiable {
} }
public Text getDisplayName() { public Text getDisplayName() {
return Text.translatable(getTranslationKey()); return Text.translatable(getTranslationKey()).formatted(getColor());
} }
public int getCorruption() { public int getCorruption() {

View file

@ -194,7 +194,7 @@ public class DismissSpellScreen extends GameGui {
tooltip.add(Text.translatable("gui.unicopia.dispell_screen.spell_type", name)); tooltip.add(Text.translatable("gui.unicopia.dispell_screen.spell_type", name));
type.traits().appendTooltip(tooltip); type.traits().appendTooltip(tooltip);
tooltip.add(ScreenTexts.EMPTY); tooltip.add(ScreenTexts.EMPTY);
tooltip.add(Text.translatable("gui.unicopia.dispell_screen.affinity", affinity.getDisplayName()).formatted(affinity.getColor())); tooltip.add(Text.translatable("gui.unicopia.dispell_screen.affinity", affinity.getDisplayName()));
tooltip.add(ScreenTexts.EMPTY); tooltip.add(ScreenTexts.EMPTY);
tooltip.addAll(TextHelper.wrap(Text.translatable(type.type().getTranslationKey() + ".lore").formatted(affinity.getColor()), 180).toList()); tooltip.addAll(TextHelper.wrap(Text.translatable(type.type().getTranslationKey() + ".lore").formatted(affinity.getColor()), 180).toList());
if (spell instanceof TimedSpell timed) { if (spell instanceof TimedSpell timed) {

View file

@ -955,7 +955,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
if (spell.getAffinity() == Affinity.BAD && entity.getWorld().random.nextInt(20) == 0) { if (spell.getAffinity() == Affinity.BAD && entity.getWorld().random.nextInt(20) == 0) {
getCorruption().add(entity.getRandom().nextBetween(1, 10)); getCorruption().add(entity.getRandom().nextBetween(1, 10));
} }
getCorruption().add((int)spell.getTypeAndTraits().traits().getCorruption() * 10); getCorruption().add(((int)spell.getTypeAndTraits().traits().getCorruption() * 10) + spell.getTypeAndTraits().type().getAffinity().getCorruption());
setDirty(); setDirty();
} }
} }

View file

@ -80,15 +80,20 @@ public class GemstoneItem extends Item implements MultiItem, EnchantableItem {
super.appendTooltip(stack, world, lines, tooltipContext); super.appendTooltip(stack, world, lines, tooltipContext);
if (EnchantableItem.isEnchanted(stack)) { if (EnchantableItem.isEnchanted(stack)) {
SpellType<?> key = EnchantableItem.getSpellKey(stack); CustomisedSpellType<?> type = getSpellEffect(stack);
MutableText line = Text.translatable(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor()); MutableText line = Text.translatable(type.type().getTranslationKey() + ".lore").formatted(type.type().getAffinity().getColor());
if (!InteractionManager.getInstance().getClientSpecies().canCast()) { if (!InteractionManager.getInstance().getClientSpecies().canCast()) {
line = line.formatted(Formatting.OBFUSCATED); line = line.formatted(Formatting.OBFUSCATED);
} }
lines.addAll(TextHelper.wrap(line, 180).toList()); lines.addAll(TextHelper.wrap(line, 180).toList());
lines.add(Text.empty());
float corruption = ((int)type.traits().getCorruption() * 10) + type.type().getAffinity().getCorruption();
if (corruption != 0) {
lines.add(Text.translatable("affinity.unicopia.when_cast").formatted(Formatting.GRAY));
lines.add(Text.translatable("affinity.unicopia.corruption", corruption > 0 ? "+" : "-", ItemStack.MODIFIER_FORMAT.format(Math.abs(corruption))).formatted(corruption < 0 ? Formatting.DARK_GREEN : Formatting.RED));
}
} }
} }

View file

@ -729,6 +729,8 @@
"affinity.unicopia.good": "Good", "affinity.unicopia.good": "Good",
"affinity.unicopia.bad": "Bad", "affinity.unicopia.bad": "Bad",
"affinity.unicopia.neutral": "Neutral", "affinity.unicopia.neutral": "Neutral",
"affinity.unicopia.when_cast": "When Cast:",
"affinity.unicopia.corruption": " %s%.2f Corruption",
"gui.unicopia.trait.label": "Element of %s", "gui.unicopia.trait.label": "Element of %s",
"gui.unicopia.trait.group": "\n %s", "gui.unicopia.trait.group": "\n %s",