pokemon mostly localized, only strings which are constructed are left.

This commit is contained in:
Kwoth 2017-02-13 13:24:11 +01:00
parent a1e25f5149
commit eb17f0b5b7
4 changed files with 305 additions and 53 deletions

View File

@ -28,30 +28,48 @@ namespace NadekoBot.Modules
: NadekoBot.Localization.GetCultureInfo(Context.Guild));
}
public Task<IUserMessage> ConfirmLocalized(string titleKey, string textKey, string url = null, string footer = null)
//public Task<IUserMessage> ReplyConfirmLocalized(string titleKey, string textKey, string url = null, string footer = null)
//{
// var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo);
// var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
// return Context.Channel.SendConfirmAsync(title, text, url, footer);
//}
//public Task<IUserMessage> ReplyConfirmLocalized(string textKey)
//{
// var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
// return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + textKey);
//}
//public Task<IUserMessage> ReplyErrorLocalized(string titleKey, string textKey, string url = null, string footer = null)
//{
// var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo);
// var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
// return Context.Channel.SendErrorAsync(title, text, url, footer);
//}
public Task<IUserMessage> ErrorLocalized(string textKey, params object[] replacements)
{
var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo);
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendConfirmAsync(title, text, url, footer);
return Context.Channel.SendErrorAsync(string.Format(text, replacements));
}
public Task<IUserMessage> ConfirmLocalized(string textKey)
public Task<IUserMessage> ReplyErrorLocalized(string textKey, params object[] replacements)
{
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendConfirmAsync(textKey);
return Context.Channel.SendErrorAsync(Context.User.Mention + " " +string.Format(text, replacements));
}
public Task<IUserMessage> ErrorLocalized(string titleKey, string textKey, string url = null, string footer = null)
public Task<IUserMessage> ConfirmLocalized(string textKey, params object[] replacements)
{
var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo);
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendErrorAsync(title, text, url, footer);
return Context.Channel.SendConfirmAsync(string.Format(text, replacements));
}
public Task<IUserMessage> ErrorLocalized(string textKey)
public Task<IUserMessage> ReplyConfirmLocalized(string textKey, params object[] replacements)
{
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendErrorAsync(textKey);
return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + string.Format(text, replacements));
}
}

View File

@ -107,12 +107,12 @@ namespace NadekoBot.Modules.Pokemon
if (targetUser == null)
{
await ErrorLocalized(nameof(ResponseStrings.Culture)).ConfigureAwait(false);
await ReplyErrorLocalized("user_not_found").ConfigureAwait(false);
return;
}
else if (targetUser == user)
if (targetUser == user)
{
await ErrorLocalized("You can't attack yourself.").ConfigureAwait(false);
await ReplyErrorLocalized("cant_attack_yourself").ConfigureAwait(false);
return;
}
@ -126,17 +126,17 @@ namespace NadekoBot.Modules.Pokemon
//User not able if HP < 0, has made more than 4 attacks
if (userStats.Hp < 0)
{
await Context.Channel.SendMessageAsync($"{user.Mention} has fainted and was not able to move!").ConfigureAwait(false);
await ReplyErrorLocalized("you_fainted").ConfigureAwait(false);
return;
}
if (userStats.MovesMade >= 5)
{
await Context.Channel.SendMessageAsync($"{user.Mention} has used too many moves in a row and was not able to move!").ConfigureAwait(false);
await ReplyErrorLocalized("too_many_moves").ConfigureAwait(false);
return;
}
if (userStats.LastAttacked.Contains(targetUser.Id))
{
await Context.Channel.SendMessageAsync($"{user.Mention} can't attack again without retaliation!").ConfigureAwait(false);
await ReplyErrorLocalized("cant_attack_again").ConfigureAwait(false);
return;
}
//get target stats
@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Pokemon
//If target's HP is below 0, no use attacking
if (targetStats.Hp <= 0)
{
await Context.Channel.SendMessageAsync($"{targetUser.Mention} has already fainted!").ConfigureAwait(false);
await ReplyErrorLocalized("too_many_moves", targetUser).ConfigureAwait(false);
return;
}
@ -156,7 +156,7 @@ namespace NadekoBot.Modules.Pokemon
var enabledMoves = userType.Moves;
if (!enabledMoves.Contains(move.ToLowerInvariant()))
{
await Context.Channel.SendMessageAsync($"{user.Mention} is not able to use **{move}**. Type {NadekoBot.ModulePrefixes[typeof(Pokemon).Name]}ml to see moves").ConfigureAwait(false);
await ReplyErrorLocalized("invalid_move", move, _prefix).ConfigureAwait(false);
return;
}
@ -172,7 +172,7 @@ namespace NadekoBot.Modules.Pokemon
//Damage type
if (damage < 40)
{
response += "\nIt's not effective..";
response += "\nIt's not effective.";
}
else if (damage > 60)
{
@ -235,7 +235,7 @@ namespace NadekoBot.Modules.Pokemon
IGuildUser user = (IGuildUser)Context.User;
if (targetUser == null) {
await Context.Channel.SendMessageAsync("No such person.").ConfigureAwait(false);
await ReplyErrorLocalized("user_not_found").ConfigureAwait(false);
return;
}
@ -244,7 +244,7 @@ namespace NadekoBot.Modules.Pokemon
var targetStats = Stats[targetUser.Id];
if (targetStats.Hp == targetStats.MaxHp)
{
await Context.Channel.SendMessageAsync($"{targetUser.Mention} already has full HP!").ConfigureAwait(false);
await ReplyErrorLocalized("already_full", targetUser).ConfigureAwait(false);
return;
}
//Payment~
@ -253,11 +253,11 @@ namespace NadekoBot.Modules.Pokemon
var target = (targetUser.Id == user.Id) ? "yourself" : targetUser.Mention;
if (amount > 0)
{
if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false))
{
try { await Context.Channel.SendMessageAsync($"{user.Mention} You don't have enough {NadekoBot.BotConfig.CurrencyName}s.").ConfigureAwait(false); } catch { }
return;
}
if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false))
{
await ReplyErrorLocalized("no_currency", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false);
return;
}
}
//healing
@ -268,20 +268,18 @@ namespace NadekoBot.Modules.Pokemon
Stats[targetUser.Id].Hp = (targetStats.MaxHp / 2);
if (target == "yourself")
{
await Context.Channel.SendMessageAsync($"You revived yourself with one {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
await ReplyErrorLocalized("revive_yourself", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false);
return;
}
else
{
await Context.Channel.SendMessageAsync($"{user.Mention} revived {targetUser.Mention} with one {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
}
return;
await ReplyErrorLocalized("revive_other", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false);
}
await Context.Channel.SendMessageAsync($"{user.Mention} healed {targetUser.Mention} with one {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
await ReplyErrorLocalized("healed", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false);
return;
}
else
{
await Context.Channel.SendMessageAsync($"{targetUser.Mention} already has full HP!").ConfigureAwait(false);
await ErrorLocalized("already_full", targetUser);
}
}
@ -290,15 +288,9 @@ namespace NadekoBot.Modules.Pokemon
[RequireContext(ContextType.Guild)]
public async Task Type(IGuildUser targetUser = null)
{
IGuildUser user = (IGuildUser)Context.User;
if (targetUser == null)
{
return;
}
targetUser = targetUser ?? (IGuildUser)Context.User;
var pType = GetPokeType(targetUser.Id);
await Context.Channel.SendMessageAsync($"Type of {targetUser.Mention} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false);
await ReplyConfirmLocalized("type_of_user", targetUser.Mention, pType.Name.ToLowerInvariant() + pType.Icon).ConfigureAwait(false);
}
@ -320,7 +312,7 @@ namespace NadekoBot.Modules.Pokemon
}
if (targetType == GetPokeType(user.Id))
{
await Context.Channel.SendMessageAsync($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Icon}").ConfigureAwait(false);
await ReplyErrorLocalized("already_that_type", targetType.Name.ToLowerInvariant() + targetType.Icon).ConfigureAwait(false);
return;
}
@ -328,9 +320,9 @@ namespace NadekoBot.Modules.Pokemon
var amount = 1;
if (amount > 0)
{
if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"{user.Mention} change type to {typeTargeted}", amount, true).ConfigureAwait(false))
if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"{user} change type to {typeTargeted}", amount, true).ConfigureAwait(false))
{
try { await Context.Channel.SendMessageAsync($"{user.Mention} You don't have enough {NadekoBot.BotConfig.CurrencyName}s.").ConfigureAwait(false); } catch { }
await ReplyErrorLocalized("no_currency", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false);
return;
}
}
@ -363,9 +355,10 @@ namespace NadekoBot.Modules.Pokemon
}
//Now for the response
await Context.Channel.SendMessageAsync($"Set type of {user.Mention} to {typeTargeted}{targetType.Icon} for a {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
await ReplyConfirmLocalized("settype_success",
typeTargeted + targetType.Icon,
NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false);
}
}
}

View File

@ -59,21 +59,201 @@ namespace NadekoBot.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to {0} has already fainted..
/// </summary>
public static string pokemon_already_fainted {
get {
return ResourceManager.GetString("pokemon_already_fainted", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {1} already has full HP..
/// </summary>
public static string pokemon_already_full {
get {
return ResourceManager.GetString("pokemon_already_full", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Your type is already {0}.
/// </summary>
public static string pokemon_already_that_type {
get {
return ResourceManager.GetString("pokemon_already_that_type", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to used **{0}**{1} on {2}{3} for **{4}** damage..
/// </summary>
public static string pokemon_attack {
get {
return ResourceManager.GetString("pokemon_attack", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You can&apos;t attack again without retaliation!.
/// </summary>
public static string pokemon_cant_attack_again {
get {
return ResourceManager.GetString("pokemon_cant_attack_again", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You can&apos;t attack yourself..
/// </summary>
public static string cant_attack_yourself {
public static string pokemon_cant_attack_yourself {
get {
return ResourceManager.GetString("cant_attack_yourself", resourceCulture);
return ResourceManager.GetString("pokemon_cant_attack_yourself", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} has fainted!.
/// </summary>
public static string pokemon_fainted {
get {
return ResourceManager.GetString("pokemon_fainted", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} has {1} HP remaining..
/// </summary>
public static string pokemon_hp_remaining {
get {
return ResourceManager.GetString("pokemon_hp_remaining", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are not able to use **{0}**. Type {1}ml to see a list of moves you can use..
/// </summary>
public static string pokemon_invalid_move {
get {
return ResourceManager.GetString("pokemon_invalid_move", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to It&apos;s not effective..
/// </summary>
public static string pokemon_its_not_effective {
get {
return ResourceManager.GetString("pokemon_its_not_effective", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to It&apos;s somewhat effective..
/// </summary>
public static string pokemon_its_somewhat_effective {
get {
return ResourceManager.GetString("pokemon_its_somewhat_effective", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to It&apos;s super effective!.
/// </summary>
public static string pokemon_its_super_effective {
get {
return ResourceManager.GetString("pokemon_its_super_effective", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Moves for {0} type.
/// </summary>
public static string pokemon_moves {
get {
return ResourceManager.GetString("pokemon_moves", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You don&apos;t have enough {0}.
/// </summary>
public static string pokemon_no_currency {
get {
return ResourceManager.GetString("pokemon_no_currency", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to revived {0} with one {1}.
/// </summary>
public static string pokemon_revive_other {
get {
return ResourceManager.GetString("pokemon_revive_other", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You revived yourself with one {0}.
/// </summary>
public static string pokemon_revive_yourself {
get {
return ResourceManager.GetString("pokemon_revive_yourself", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Your type has been changed to {0} for a {1}.
/// </summary>
public static string pokemon_settype_success {
get {
return ResourceManager.GetString("pokemon_settype_success", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You used too many moves in a row, so you can&apos;t move!.
/// </summary>
public static string pokemon_too_many_moves {
get {
return ResourceManager.GetString("pokemon_too_many_moves", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Type of {0} is **{1}**.
/// </summary>
public static string pokemon_type_of_user {
get {
return ResourceManager.GetString("pokemon_type_of_user", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to User not found..
/// </summary>
public static string no_user_found {
public static string pokemon_user_not_found {
get {
return ResourceManager.GetString("no_user_found", resourceCulture);
return ResourceManager.GetString("pokemon_user_not_found", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You fainted, so you are not able to move!.
/// </summary>
public static string pokemon_you_fainted {
get {
return ResourceManager.GetString("pokemon_you_fainted", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to healed {0} with one {1}.
/// </summary>
public static string pokmeon_healed {
get {
return ResourceManager.GetString("pokmeon_healed", resourceCulture);
}
}
}

View File

@ -117,10 +117,71 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="cant_attack_yourself" xml:space="preserve">
<data name="pokemon_already_fainted" xml:space="preserve">
<value>{0} has already fainted.</value>
</data>
<data name="pokemon_already_full" xml:space="preserve">
<value>{1} already has full HP.</value>
</data>
<data name="pokemon_already_that_type" xml:space="preserve">
<value>Your type is already {0}</value>
</data>
<data name="pokemon_attack" xml:space="preserve">
<value>used **{0}**{1} on {2}{3} for **{4}** damage.</value>
<comment>Kwoth used punch:type_icon: on Sanity:type_icon: for 50 damage.</comment>
</data>
<data name="pokemon_cant_attack_again" xml:space="preserve">
<value>You can't attack again without retaliation!</value>
</data>
<data name="pokemon_cant_attack_yourself" xml:space="preserve">
<value>You can't attack yourself.</value>
</data>
<data name="no_user_found" xml:space="preserve">
<data name="pokemon_fainted" xml:space="preserve">
<value>{0} has fainted!</value>
</data>
<data name="pokemon_hp_remaining" xml:space="preserve">
<value>{0} has {1} HP remaining.</value>
</data>
<data name="pokemon_invalid_move" xml:space="preserve">
<value>You are not able to use **{0}**. Type {1}ml to see a list of moves you can use.</value>
</data>
<data name="pokemon_its_not_effective" xml:space="preserve">
<value>It's not effective.</value>
</data>
<data name="pokemon_its_somewhat_effective" xml:space="preserve">
<value>It's somewhat effective.</value>
</data>
<data name="pokemon_its_super_effective" xml:space="preserve">
<value>It's super effective!</value>
</data>
<data name="pokemon_moves" xml:space="preserve">
<value>Moves for {0} type</value>
</data>
<data name="pokemon_no_currency" xml:space="preserve">
<value>You don't have enough {0}</value>
</data>
<data name="pokemon_revive_other" xml:space="preserve">
<value>revived {0} with one {1}</value>
</data>
<data name="pokemon_revive_yourself" xml:space="preserve">
<value>You revived yourself with one {0}</value>
</data>
<data name="pokemon_settype_success" xml:space="preserve">
<value>Your type has been changed to {0} for a {1}</value>
</data>
<data name="pokemon_too_many_moves" xml:space="preserve">
<value>You used too many moves in a row, so you can't move!</value>
</data>
<data name="pokemon_type_of_user" xml:space="preserve">
<value>Type of {0} is **{1}**</value>
</data>
<data name="pokemon_user_not_found" xml:space="preserve">
<value>User not found.</value>
</data>
<data name="pokemon_you_fainted" xml:space="preserve">
<value>You fainted, so you are not able to move!</value>
</data>
<data name="pokmeon_healed" xml:space="preserve">
<value>healed {0} with one {1}</value>
</data>
</root>