Fixes, everything localized?
This commit is contained in:
@@ -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<IUserMessage> 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<IUserMessage> 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<IUserMessage> 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<IUserMessage> 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));
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user