docs: add task to refactor if-else forests in rating commands, fix GayCommand package
This commit is contained in:
parent
4329b988e2
commit
376d1a2c3b
3 changed files with 71 additions and 1 deletions
69
TODO.md
69
TODO.md
|
|
@ -402,6 +402,75 @@ src/main/java/creator/loki/
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Рефакторинг кода (Code Quality)
|
||||||
|
|
||||||
|
### Убрать if-else леса в rating командах
|
||||||
|
|
||||||
|
**Проблема:**
|
||||||
|
Все rating команды (MustacheCommand, IqCommand, FatCommand, GayCommand, PpCommand, BoykisserCommand) содержат огромные if-else цепочки для определения уровня/комментария/цвета.
|
||||||
|
|
||||||
|
**Пример плохого кода (MustacheCommand):**
|
||||||
|
```java
|
||||||
|
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` с конфигурацией уровней:
|
||||||
|
|
||||||
|
```java
|
||||||
|
public class RatingLevel {
|
||||||
|
private final int threshold;
|
||||||
|
private final String comment;
|
||||||
|
private final Color color;
|
||||||
|
|
||||||
|
public static RatingLevel findLevel(int value, List<RatingLevel> levels) {
|
||||||
|
return levels.stream()
|
||||||
|
.filter(level -> value >= level.threshold)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(levels.get(levels.size() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**План действий:**
|
||||||
|
- [ ] Создать `command/impl/entertainment/games/rating/RatingLevel.java`
|
||||||
|
- [ ] Создать `command/impl/entertainment/games/rating/RatingConfig.java` с предустановленными конфигурациями
|
||||||
|
- [ ] Рефакторить MustacheCommand - использовать RatingLevel
|
||||||
|
- [ ] Рефакторить IqCommand - использовать RatingLevel
|
||||||
|
- [ ] Рефакторить FatCommand - использовать RatingLevel
|
||||||
|
- [ ] Рефакторить GayCommand - использовать RatingLevel (без уровней, только прогресс-бар)
|
||||||
|
- [ ] Рефакторить PpCommand - использовать RatingLevel
|
||||||
|
- [ ] Рефакторить BoykisserCommand - использовать RatingLevel
|
||||||
|
- [ ] Проверить что все команды работают корректно
|
||||||
|
- [ ] Удалить дублирующийся код
|
||||||
|
|
||||||
|
**Приоритет:** Средний (улучшение качества кода)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Основные задачи
|
## Основные задачи
|
||||||
|
|
||||||
### 1. ⚡ Переделать систему опыта (XP System Rework)
|
### 1. ⚡ Переделать систему опыта (XP System Rework)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package creator.loki.command.impl.entertainment.games;
|
package creator.loki.command.impl.entertainment.games.rating;
|
||||||
|
|
||||||
import creator.loki.command.Command;
|
import creator.loki.command.Command;
|
||||||
import creator.loki.command.CommandContext;
|
import creator.loki.command.CommandContext;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import creator.loki.command.impl.entertainment.games.random.MemeCommand;
|
||||||
import creator.loki.command.impl.entertainment.games.random.RateCommand;
|
import creator.loki.command.impl.entertainment.games.random.RateCommand;
|
||||||
import creator.loki.command.impl.entertainment.games.rating.BoykisserCommand;
|
import creator.loki.command.impl.entertainment.games.rating.BoykisserCommand;
|
||||||
import creator.loki.command.impl.entertainment.games.rating.FatCommand;
|
import creator.loki.command.impl.entertainment.games.rating.FatCommand;
|
||||||
|
import creator.loki.command.impl.entertainment.games.rating.GayCommand;
|
||||||
import creator.loki.command.impl.entertainment.games.rating.IqCommand;
|
import creator.loki.command.impl.entertainment.games.rating.IqCommand;
|
||||||
import creator.loki.command.impl.entertainment.games.rating.MustacheCommand;
|
import creator.loki.command.impl.entertainment.games.rating.MustacheCommand;
|
||||||
import creator.loki.command.impl.entertainment.games.rating.PpCommand;
|
import creator.loki.command.impl.entertainment.games.rating.PpCommand;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue