Translate the ship command

This commit is contained in:
runebaas 2020-04-04 23:05:18 +02:00
parent 3bd7274d68
commit f12bdcf4cd
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
2 changed files with 40 additions and 15 deletions

View file

@ -7,6 +7,7 @@ using Geekbot.net.Database;
using Geekbot.net.Database.Models; using Geekbot.net.Database.Models;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions; using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.Localization;
using Geekbot.net.Lib.RandomNumberGenerator; using Geekbot.net.Lib.RandomNumberGenerator;
namespace Geekbot.net.Commands.Randomness namespace Geekbot.net.Commands.Randomness
@ -15,13 +16,15 @@ namespace Geekbot.net.Commands.Randomness
{ {
private readonly IErrorHandler _errorHandler; private readonly IErrorHandler _errorHandler;
private readonly IRandomNumberGenerator _randomNumberGenerator; private readonly IRandomNumberGenerator _randomNumberGenerator;
private readonly ITranslationHandler _translation;
private readonly DatabaseContext _database; private readonly DatabaseContext _database;
public Ship(DatabaseContext database, IErrorHandler errorHandler, IRandomNumberGenerator randomNumberGenerator) public Ship(DatabaseContext database, IErrorHandler errorHandler, IRandomNumberGenerator randomNumberGenerator, ITranslationHandler translation)
{ {
_database = database; _database = database;
_errorHandler = errorHandler; _errorHandler = errorHandler;
_randomNumberGenerator = randomNumberGenerator; _randomNumberGenerator = randomNumberGenerator;
_translation = translation;
} }
[Command("Ship", RunMode = RunMode.Async)] [Command("Ship", RunMode = RunMode.Async)]
@ -55,9 +58,11 @@ namespace Geekbot.net.Commands.Randomness
shippingRate = dbval.Strength; shippingRate = dbval.Strength;
} }
var reply = ":heartpulse: **Matchmaking** :heartpulse:\r\n"; var transContext = await _translation.GetGuildContext(Context);
var reply = $":heartpulse: **{transContext.GetString("Matchmaking")}** :heartpulse:\r\n";
reply += $":two_hearts: {user1.Mention} :heart: {user2.Mention} :two_hearts:\r\n"; reply += $":two_hearts: {user1.Mention} :heart: {user2.Mention} :two_hearts:\r\n";
reply += $"0% [{BlockCounter(shippingRate)}] 100% - {DeterminateSuccess(shippingRate)}"; reply += $"0% [{BlockCounter(shippingRate)}] 100% - {DeterminateSuccess(shippingRate, transContext)}";
await ReplyAsync(reply); await ReplyAsync(reply);
} }
catch (Exception e) catch (Exception e)
@ -66,22 +71,22 @@ namespace Geekbot.net.Commands.Randomness
} }
} }
private string DeterminateSuccess(int rate) private string DeterminateSuccess(int rate, TranslationGuildContext transContext)
{ {
if (rate < 20) return (rate / 20) switch
return "Not gonna happen"; {
if (rate >= 20 && rate < 40) 0 => transContext.GetString("NotGonnaToHappen"),
return "Not such a good idea"; 1 => transContext.GetString("NotSuchAGoodIdea"),
if (rate >= 40 && rate < 60) 2 => transContext.GetString("ThereMightBeAChance"),
return "There might be a chance"; 3 => transContext.GetString("CouldWork"),
if (rate >= 60 && rate < 80) 4 => transContext.GetString("ItsAMatch"),
return "Almost a match, but could work"; _ => "nope"
return rate >= 80 ? "It's a match" : "a"; };
} }
private string BlockCounter(int rate) private string BlockCounter(int rate)
{ {
var amount = Math.Floor(decimal.Floor(rate / 10)); var amount = rate / 10;
Console.WriteLine(amount); Console.WriteLine(amount);
var blocks = ""; var blocks = "";
for (var i = 1; i <= 10; i++) for (var i = 1; i <= 10; i++)

View file

@ -176,3 +176,23 @@ rank:
HighscoresFor: HighscoresFor:
EN: ":bar_chart: **{0} Highscore for {1}**" EN: ":bar_chart: **{0} Highscore for {1}**"
CHDE: ":bar_chart: **{0} Highscore für {1}**" CHDE: ":bar_chart: **{0} Highscore für {1}**"
ship:
Matchmaking:
EN: "Matchmaking"
CHDE: "Verkupple"
NotGonnaToHappen:
EN: "Not gonna happen"
CHDE: "Wird nöd klappe"
NotSuchAGoodIdea:
EN: "Not such a good idea"
CHDE: "Nöd so ä gueti idee"
ThereMightBeAChance:
EN: "There might be a chance"
CHDE: "Es gid eventuel ä chance"
CouldWork:
EN: "Almost a match"
CHDE: "Fasch en match"
ItsAMatch:
EN: "It's a match"
CHDE: "Es isch es traumpaar"