diff --git a/src/NadekoBot/Modules/NadekoModule.cs b/src/NadekoBot/Modules/NadekoModule.cs index 5ce45fb4..9c574cde 100644 --- a/src/NadekoBot/Modules/NadekoModule.cs +++ b/src/NadekoBot/Modules/NadekoModule.cs @@ -14,12 +14,16 @@ namespace NadekoBot.Modules protected readonly Logger _log; public readonly string _prefix; public readonly CultureInfo cultureInfo; + public readonly string ModuleTypeName; + public readonly string LowerModuleTypeName; public NadekoModule(bool isTopLevelModule = true) { //if it's top level module - var typeName = isTopLevelModule ? this.GetType().Name : this.GetType().DeclaringType.Name; - if (!NadekoBot.ModulePrefixes.TryGetValue(typeName, out _prefix)) + ModuleTypeName = isTopLevelModule ? this.GetType().Name : this.GetType().DeclaringType.Name; + LowerModuleTypeName = ModuleTypeName.ToLowerInvariant(); + + if (!NadekoBot.ModulePrefixes.TryGetValue(ModuleTypeName, out _prefix)) _prefix = "?err?"; _log = LogManager.GetCurrentClassLogger(); @@ -48,27 +52,37 @@ namespace NadekoBot.Modules // return Context.Channel.SendErrorAsync(title, text, url, footer); //} + protected string GetText(string key) + { + return NadekoBot.ResponsesResourceManager.GetString(LowerModuleTypeName + "_" + key, cultureInfo); + } + + protected string GetText(string key, params object[] replacements) + { + return string.Format(GetText(key), replacements); + } + public Task ErrorLocalized(string textKey, params object[] replacements) { - var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); + var text = GetText(textKey); return Context.Channel.SendErrorAsync(string.Format(text, replacements)); } public Task ReplyErrorLocalized(string textKey, params object[] replacements) { - var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); + var text = GetText(textKey); return Context.Channel.SendErrorAsync(Context.User.Mention + " " +string.Format(text, replacements)); } public Task ConfirmLocalized(string textKey, params object[] replacements) { - var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); + var text = GetText(textKey); return Context.Channel.SendConfirmAsync(string.Format(text, replacements)); } public Task ReplyConfirmLocalized(string textKey, params object[] replacements) { - var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); + var text = GetText(textKey); return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + string.Format(text, replacements)); } } diff --git a/src/NadekoBot/Modules/Pokemon/Pokemon.cs b/src/NadekoBot/Modules/Pokemon/Pokemon.cs index 997f3570..dab998ff 100644 --- a/src/NadekoBot/Modules/Pokemon/Pokemon.cs +++ b/src/NadekoBot/Modules/Pokemon/Pokemon.cs @@ -166,32 +166,32 @@ namespace NadekoBot.Modules.Pokemon int damage = GetDamage(userType, targetType); //apply damage to target targetStats.Hp -= damage; - - var response = $"{user.Mention} used **{move}**{userType.Icon} on {targetUser.Mention}{targetType.Icon} for **{damage}** damage"; + + var response = GetText("attack", move, userType.Icon, targetUser.Mention, targetType.Icon, damage); //Damage type if (damage < 40) { - response += "\nIt's not effective."; + response += "\n" + GetText("not_effective"); } else if (damage > 60) { - response += "\nIt's super effective!"; + response += "\n" + GetText("super_effective"); } else { - response += "\nIt's somewhat effective"; + response += "\n" + GetText("somewhat_effective"); } //check fainted if (targetStats.Hp <= 0) { - response += $"\n**{targetUser.Mention}** has fainted!"; + response += $"\n" + GetText("fainted", targetUser); } else { - response += $"\n**{targetUser.Mention}** has {targetStats.Hp} HP remaining"; + response += $"\n" + GetText("hp_remaining", targetUser, targetStats.Hp); } //update other stats @@ -208,7 +208,7 @@ namespace NadekoBot.Modules.Pokemon Stats[user.Id] = userStats; Stats[targetUser.Id] = targetStats; - await Context.Channel.SendMessageAsync(response).ConfigureAwait(false); + await Context.Channel.SendConfirmAsync(Context.User.Mention + " " + response).ConfigureAwait(false); } @@ -220,12 +220,10 @@ namespace NadekoBot.Modules.Pokemon var userType = GetPokeType(user.Id); var movesList = userType.Moves; - var str = $"**Moves for `{userType.Name}` type.**"; - foreach (string m in movesList) - { - str += $"\n{userType.Icon}{m}"; - } - await Context.Channel.SendMessageAsync(str).ConfigureAwait(false); + var embed = new EmbedBuilder().WithOkColor() + .WithTitle(GetText("moves", userType)) + .WithDescription(string.Join("\n", movesList.Select(m => userType.Icon + " " + m))); + await Context.Channel.EmbedAsync(embed).ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -268,13 +266,13 @@ namespace NadekoBot.Modules.Pokemon Stats[targetUser.Id].Hp = (targetStats.MaxHp / 2); if (target == "yourself") { - await ReplyErrorLocalized("revive_yourself", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); + await ReplyConfirmLocalized("revive_yourself", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); return; } - await ReplyErrorLocalized("revive_other", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); + await ReplyConfirmLocalized("revive_other", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); } - await ReplyErrorLocalized("healed", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); + await ReplyConfirmLocalized("healed", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); return; } else diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index aab0ef1f..1e0c5ff4 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -141,34 +141,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to It's not effective.. - /// - public static string pokemon_its_not_effective { - get { - return ResourceManager.GetString("pokemon_its_not_effective", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to It's somewhat effective.. - /// - public static string pokemon_its_somewhat_effective { - get { - return ResourceManager.GetString("pokemon_its_somewhat_effective", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to It's super effective!. - /// - public static string pokemon_its_super_effective { - get { - return ResourceManager.GetString("pokemon_its_super_effective", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Moves for {0} type. + /// Looks up a localized string similar to Movelist for "{0}" type. /// public static string pokemon_moves { get { @@ -185,6 +158,15 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to It's not effective.. + /// + public static string pokemon_not_effective { + get { + return ResourceManager.GetString("pokemon_not_effective", resourceCulture); + } + } + /// /// Looks up a localized string similar to revived {0} with one {1}. /// @@ -212,6 +194,24 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to It's somewhat effective.. + /// + public static string pokemon_somewhat_effective { + get { + return ResourceManager.GetString("pokemon_somewhat_effective", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to It's super effective!. + /// + public static string pokemon_super_effective { + get { + return ResourceManager.GetString("pokemon_super_effective", resourceCulture); + } + } + /// /// Looks up a localized string similar to You used too many moves in a row, so you can't move!. /// diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index 69503270..1a349d0f 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -145,17 +145,11 @@ You are not able to use **{0}**. Type {1}ml to see a list of moves you can use. - - It's not effective. - - - It's somewhat effective. - - - It's super effective! - - Moves for {0} type + Movelist for "{0}" type + + + It's not effective. You don't have enough {0} @@ -169,6 +163,12 @@ Your type has been changed to {0} for a {1} + + It's somewhat effective. + + + It's super effective! + You used too many moves in a row, so you can't move!