refactor: remove if-else forests from rating commands using RatingLevel pattern
This commit is contained in:
parent
376d1a2c3b
commit
27dc060bf4
8 changed files with 155 additions and 129 deletions
|
|
@ -76,36 +76,16 @@ public class BoykisserCommand implements Command {
|
|||
bar.append("⬜");
|
||||
}
|
||||
|
||||
// Комментарий
|
||||
String comment;
|
||||
Color color;
|
||||
if (boykisserLevel >= 90) {
|
||||
comment = "😳 ЛЕГЕНДАРНЫЙ BOYKISSER!";
|
||||
color = new Color(255, 105, 180);
|
||||
} else if (boykisserLevel >= 70) {
|
||||
comment = "💕 Настоящий boykisser";
|
||||
color = new Color(255, 182, 193);
|
||||
} else if (boykisserLevel >= 50) {
|
||||
comment = "😊 Любит целовать мальчиков";
|
||||
color = new Color(255, 192, 203);
|
||||
} else if (boykisserLevel >= 30) {
|
||||
comment = "🙂 Иногда целует";
|
||||
color = new Color(176, 224, 230);
|
||||
} else if (boykisserLevel >= 10) {
|
||||
comment = "😐 Редко целует";
|
||||
color = new Color(135, 206, 235);
|
||||
} else {
|
||||
comment = "😶 Не boykisser";
|
||||
color = new Color(128, 128, 128);
|
||||
}
|
||||
// Определяем уровень
|
||||
RatingLevel level = RatingLevel.findLevel(boykisserLevel, RatingConfig.getBoykisserLevels());
|
||||
|
||||
context.getChannel().sendMessageEmbeds(
|
||||
EmbedFactory.create()
|
||||
.setTitle("💋 Boykisser Метр")
|
||||
.setDescription(target.getAsMention())
|
||||
.addField("Уровень", bar.toString() + "\n**" + boykisserLevel + "%** - " + comment, false)
|
||||
.addField("Уровень", bar.toString() + "\n**" + boykisserLevel + "%** - " + level.getComment(), false)
|
||||
.setThumbnail(target.getUser().getAvatarUrl())
|
||||
.setColor(color)
|
||||
.setColor(level.getColor())
|
||||
.setFooter("💡 Детерминировано вашим Discord ID")
|
||||
.build()
|
||||
).queue();
|
||||
|
|
|
|||
|
|
@ -71,36 +71,16 @@ public class FatCommand implements Command {
|
|||
bar.append("⬜");
|
||||
}
|
||||
|
||||
// Комментарий
|
||||
String comment;
|
||||
Color color;
|
||||
if (fatLevel >= 90) {
|
||||
comment = "🐷 СВИНОТА!";
|
||||
color = new Color(255, 0, 0);
|
||||
} else if (fatLevel >= 70) {
|
||||
comment = "🍔 Очень жирный";
|
||||
color = new Color(255, 100, 0);
|
||||
} else if (fatLevel >= 50) {
|
||||
comment = "🍕 Жирноват";
|
||||
color = new Color(255, 165, 0);
|
||||
} else if (fatLevel >= 30) {
|
||||
comment = "👍 Нормальный вес";
|
||||
color = new Color(0, 200, 0);
|
||||
} else if (fatLevel >= 10) {
|
||||
comment = "🥗 Худой";
|
||||
color = new Color(100, 200, 255);
|
||||
} else {
|
||||
comment = "💀 Очень худой";
|
||||
color = new Color(150, 150, 150);
|
||||
}
|
||||
// Определяем уровень
|
||||
RatingLevel level = RatingLevel.findLevel(fatLevel, RatingConfig.getFatLevels());
|
||||
|
||||
context.getChannel().sendMessageEmbeds(
|
||||
EmbedFactory.create()
|
||||
.setTitle("🐷 Fat Метр")
|
||||
.setDescription(target.getAsMention())
|
||||
.addField("Жирность", bar.toString() + "\n**" + fatLevel + "%** - " + comment, false)
|
||||
.addField("Жирность", bar.toString() + "\n**" + fatLevel + "%** - " + level.getComment(), false)
|
||||
.setThumbnail(target.getUser().getAvatarUrl())
|
||||
.setColor(color)
|
||||
.setColor(level.getColor())
|
||||
.setFooter("💡 Детерминировано вашим Discord ID")
|
||||
.build()
|
||||
).queue();
|
||||
|
|
|
|||
|
|
@ -68,32 +68,16 @@ public class IqCommand implements Command {
|
|||
iq = getDeterministicValue(target.getId(), 123, 0, 140);
|
||||
}
|
||||
|
||||
String level;
|
||||
Color color;
|
||||
if (iq >= 140) {
|
||||
level = "🧠 Гений!";
|
||||
color = new Color(255, 215, 0);
|
||||
} else if (iq >= 120) {
|
||||
level = "🎓 Очень умный";
|
||||
color = new Color(100, 255, 150);
|
||||
} else if (iq >= 100) {
|
||||
level = "📚 Средний";
|
||||
color = new Color(52, 152, 219);
|
||||
} else if (iq >= 80) {
|
||||
level = "📖 Ниже среднего";
|
||||
color = new Color(255, 165, 0);
|
||||
} else {
|
||||
level = "🤔 Низкий";
|
||||
color = new Color(231, 76, 60);
|
||||
}
|
||||
// Определяем уровень
|
||||
RatingLevel level = RatingLevel.findLevel(iq, RatingConfig.getIqLevels());
|
||||
|
||||
context.getChannel().sendMessageEmbeds(
|
||||
EmbedFactory.create()
|
||||
.setTitle("🧠 Тест IQ")
|
||||
.setDescription("Результат для " + target.getAsMention())
|
||||
.addField("IQ Уровень", "**" + iq + "** - " + level, false)
|
||||
.addField("IQ Уровень", "**" + iq + "** - " + level.getComment(), false)
|
||||
.setThumbnail(target.getUser().getAvatarUrl())
|
||||
.setColor(color)
|
||||
.setColor(level.getColor())
|
||||
.setFooter("💡 Научно доказано вашим ID")
|
||||
.build()
|
||||
).queue();
|
||||
|
|
|
|||
|
|
@ -80,39 +80,16 @@ public class MustacheCommand implements Command {
|
|||
bar.append("⬜");
|
||||
}
|
||||
|
||||
// Комментарий
|
||||
String comment;
|
||||
Color color;
|
||||
if (mustacheLevel >= 1000) {
|
||||
comment = "🎩 ЛЕГЕНДАРНЫЕ УСИЩИ!";
|
||||
color = new Color(255, 215, 0);
|
||||
} else if (mustacheLevel >= 80) {
|
||||
comment = "🧔 Роскошные усы!";
|
||||
color = new Color(139, 69, 19);
|
||||
} else if (mustacheLevel >= 60) {
|
||||
comment = "👨 Хорошие усы";
|
||||
color = new Color(160, 82, 45);
|
||||
} else if (mustacheLevel >= 40) {
|
||||
comment = "😊 Усики растут";
|
||||
color = new Color(205, 133, 63);
|
||||
} else if (mustacheLevel >= 20) {
|
||||
comment = "🙂 Лёгкая щетина";
|
||||
color = new Color(210, 180, 140);
|
||||
} else if (mustacheLevel > 0) {
|
||||
comment = "😐 Почти нет усов";
|
||||
color = new Color(128, 128, 128);
|
||||
} else {
|
||||
comment = "🪒 Гладко выбрит";
|
||||
color = new Color(200, 200, 200);
|
||||
}
|
||||
// Определяем уровень
|
||||
RatingLevel level = RatingLevel.findLevel(mustacheLevel, RatingConfig.getMustacheLevels());
|
||||
|
||||
context.getChannel().sendMessageEmbeds(
|
||||
EmbedFactory.create()
|
||||
.setTitle("🧔 Mustache Метр")
|
||||
.setDescription(target.getAsMention())
|
||||
.addField("Усатость", bar.toString() + "\n**" + mustacheLevel + "%** - " + comment, false)
|
||||
.addField("Усатость", bar.toString() + "\n**" + mustacheLevel + "%** - " + level.getComment(), false)
|
||||
.setThumbnail(target.getUser().getAvatarUrl())
|
||||
.setColor(color)
|
||||
.setColor(level.getColor())
|
||||
.setFooter("💡 Детерминировано вашим Discord ID")
|
||||
.build()
|
||||
).queue();
|
||||
|
|
|
|||
|
|
@ -80,35 +80,15 @@ public class PpCommand implements Command {
|
|||
ppVisual.append("D");
|
||||
|
||||
// Определяем уровень
|
||||
String comment;
|
||||
Color color;
|
||||
if (size >= 25) {
|
||||
comment = "😳 НЕВЕРОЯТНО!";
|
||||
color = new Color(255, 215, 0);
|
||||
} else if (size >= 20) {
|
||||
comment = "😮 Впечатляет";
|
||||
color = new Color(100, 255, 150);
|
||||
} else if (size >= 15) {
|
||||
comment = "👍 Выше среднего";
|
||||
color = new Color(52, 152, 219);
|
||||
} else if (size >= 10) {
|
||||
comment = "🙂 Средний";
|
||||
color = new Color(128, 128, 128);
|
||||
} else if (size >= 5) {
|
||||
comment = "😐 Ниже среднего";
|
||||
color = new Color(255, 165, 0);
|
||||
} else {
|
||||
comment = "💀 Микро";
|
||||
color = new Color(231, 76, 60);
|
||||
}
|
||||
RatingLevel level = RatingLevel.findLevel(size, RatingConfig.getPpLevels());
|
||||
|
||||
context.getChannel().sendMessageEmbeds(
|
||||
EmbedFactory.create()
|
||||
.setTitle("🍆 PP Размер")
|
||||
.setDescription(target.getAsMention())
|
||||
.addField("Размер", "```" + ppVisual.toString() + "```\n**" + size + " см** - " + comment, false)
|
||||
.addField("Размер", "```" + ppVisual.toString() + "```\n**" + size + " см** - " + level.getComment(), false)
|
||||
.setThumbnail(target.getUser().getAvatarUrl())
|
||||
.setColor(color)
|
||||
.setColor(level.getColor())
|
||||
.setFooter("💡 Детерминировано вашим Discord ID")
|
||||
.build()
|
||||
).queue();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
package creator.loki.command.impl.entertainment.games.rating;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Конфигурации уровней для различных rating команд
|
||||
*/
|
||||
public class RatingConfig {
|
||||
|
||||
/**
|
||||
* Уровни для Mustache команды
|
||||
*/
|
||||
public static List<RatingLevel> getMustacheLevels() {
|
||||
return Arrays.asList(
|
||||
new RatingLevel(1000, "🎩 ЛЕГЕНДАРНЫЕ УСИЩИ!", new Color(255, 215, 0)),
|
||||
new RatingLevel(80, "🧔 Роскошные усы!", new Color(139, 69, 19)),
|
||||
new RatingLevel(60, "👨 Хорошие усы", new Color(160, 82, 45)),
|
||||
new RatingLevel(40, "😊 Усики растут", new Color(205, 133, 63)),
|
||||
new RatingLevel(20, "🙂 Лёгкая щетина", new Color(210, 180, 140)),
|
||||
new RatingLevel(1, "😐 Почти нет усов", new Color(128, 128, 128)),
|
||||
new RatingLevel(0, "🪒 Гладко выбрит", new Color(200, 200, 200))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Уровни для IQ команды
|
||||
*/
|
||||
public static List<RatingLevel> getIqLevels() {
|
||||
return Arrays.asList(
|
||||
new RatingLevel(140, "🧠 Гений!", new Color(255, 215, 0)),
|
||||
new RatingLevel(120, "🎓 Очень умный", new Color(100, 255, 150)),
|
||||
new RatingLevel(100, "📚 Средний", new Color(52, 152, 219)),
|
||||
new RatingLevel(80, "📖 Ниже среднего", new Color(255, 165, 0)),
|
||||
new RatingLevel(0, "🤔 Низкий", new Color(231, 76, 60))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Уровни для Fat команды
|
||||
*/
|
||||
public static List<RatingLevel> getFatLevels() {
|
||||
return Arrays.asList(
|
||||
new RatingLevel(90, "🐷 СВИНОТА!", new Color(255, 0, 0)),
|
||||
new RatingLevel(70, "🍔 Очень жирный", new Color(255, 100, 0)),
|
||||
new RatingLevel(50, "🍕 Жирноват", new Color(255, 165, 0)),
|
||||
new RatingLevel(30, "👍 Нормальный вес", new Color(0, 200, 0)),
|
||||
new RatingLevel(10, "🥗 Худой", new Color(100, 200, 255)),
|
||||
new RatingLevel(0, "💀 Очень худой", new Color(150, 150, 150))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Уровни для PP команды (размер в см)
|
||||
*/
|
||||
public static List<RatingLevel> getPpLevels() {
|
||||
return Arrays.asList(
|
||||
new RatingLevel(25, "😳 НЕВЕРОЯТНО!", new Color(255, 215, 0)),
|
||||
new RatingLevel(20, "😮 Впечатляет", new Color(100, 255, 150)),
|
||||
new RatingLevel(15, "👍 Выше среднего", new Color(52, 152, 219)),
|
||||
new RatingLevel(10, "🙂 Средний", new Color(128, 128, 128)),
|
||||
new RatingLevel(5, "😐 Ниже среднего", new Color(255, 165, 0)),
|
||||
new RatingLevel(0, "💀 Микро", new Color(231, 76, 60))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Уровни для Boykisser команды
|
||||
*/
|
||||
public static List<RatingLevel> getBoykisserLevels() {
|
||||
return Arrays.asList(
|
||||
new RatingLevel(90, "💋 ЛЕГЕНДАРНЫЙ BOYKISSER!", new Color(255, 105, 180)),
|
||||
new RatingLevel(70, "😘 Активный boykisser", new Color(255, 182, 193)),
|
||||
new RatingLevel(50, "😊 Любит целоваться", new Color(255, 192, 203)),
|
||||
new RatingLevel(30, "🙂 Иногда целуется", new Color(255, 218, 185)),
|
||||
new RatingLevel(10, "😐 Редко целуется", new Color(176, 196, 222)),
|
||||
new RatingLevel(0, "😶 Не целуется", new Color(128, 128, 128))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package creator.loki.command.impl.entertainment.games.rating;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Уровень рейтинга с порогом, комментарием и цветом
|
||||
*/
|
||||
public class RatingLevel {
|
||||
private final int threshold;
|
||||
private final String comment;
|
||||
private final Color color;
|
||||
|
||||
public RatingLevel(int threshold, String comment, Color color) {
|
||||
this.threshold = threshold;
|
||||
this.comment = comment;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Находит подходящий уровень для значения
|
||||
* @param value значение для проверки
|
||||
* @param levels список уровней (должен быть отсортирован по убыванию threshold)
|
||||
* @return подходящий уровень
|
||||
*/
|
||||
public static RatingLevel findLevel(int value, List<RatingLevel> levels) {
|
||||
return levels.stream()
|
||||
.filter(level -> value >= level.threshold)
|
||||
.findFirst()
|
||||
.orElse(levels.get(levels.size() - 1));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue