[Commands] Cleanup #stun Command. (#1749)

* [Commands] Cleanup #stun Command.
- Cleanup message.
- Add ConvertSecondsToTime() to string_util.h and convert Quest API Methods to use helper.

* Add days to ConvertSecondsToTime() and cleanup logic.

* Cleanup.

* Typo.

* Cleanup.

* Cleanup.
This commit is contained in:
Kinglykrab
2021-11-14 14:05:44 -05:00
committed by GitHub
parent 90bcc5f03c
commit ddcb184183
4 changed files with 201 additions and 40 deletions
+1 -26
View File
@@ -3353,32 +3353,7 @@ EQ::ItemInstance *QuestManager::CreateItem(uint32 item_id, int16 charges, uint32
}
std::string QuestManager::secondstotime(int duration) {
int timer_length = duration;
int hours = int(timer_length / 3600);
timer_length %= 3600;
int minutes = int(timer_length / 60);
timer_length %= 60;
int seconds = timer_length;
std::string time_string = "Unknown";
std::string hour_string = (hours == 1 ? "Hour" : "Hours");
std::string minute_string = (minutes == 1 ? "Minute" : "Minutes");
std::string second_string = (seconds == 1 ? "Second" : "Seconds");
if (hours > 0 && minutes > 0 && seconds > 0) {
time_string = fmt::format("{} {}, {} {}, and {} {}", hours, hour_string, minutes, minute_string, seconds, second_string);
} else if (hours > 0 && minutes > 0 && seconds == 0) {
time_string = fmt::format("{} {} and {} {}", hours, hour_string, minutes, minute_string);
} else if (hours > 0 && minutes == 0 && seconds > 0) {
time_string = fmt::format("{} {} and {} {}", hours, hour_string, seconds, second_string);
} else if (hours > 0 && minutes == 0 && seconds == 0) {
time_string = fmt::format("{} {}", hours, hour_string);
} else if (hours == 0 && minutes > 0 && seconds > 0) {
time_string = fmt::format("{} {} and {} {}", minutes, minute_string, seconds, second_string);
} else if (hours == 0 && minutes > 0 && seconds == 0) {
time_string = fmt::format("{} {}", minutes, minute_string);
} else if (hours == 0 && minutes == 0 && seconds > 0) {
time_string = fmt::format("{} {}", seconds, second_string);
}
return time_string;
return ConvertSecondsToTime(duration);
}
std::string QuestManager::gethexcolorcode(std::string color_name) {