Пример #1
0
 public EmbedFieldBuilder Localise(ITextResourceCollection textResource)
 => new EmbedFieldBuilder
 {
     Name     = Name?.Localise(textResource),
     Value    = Value?.Localise(textResource),
     IsInline = IsInline
 };
Пример #2
0
 public EmbedAuthorBuilder Localise(ITextResourceCollection textResource)
 => new EmbedAuthorBuilder
 {
     Name    = Name?.Localise(textResource),
     Url     = Url?.Localise(textResource),
     IconUrl = IconUrl?.Localise(textResource)
 };
Пример #3
0
 private string MakeTable(ITextResourceCollection textResource, IEnumerable <Helper> helpers)
 => "```\n" + helpers.Select(h => new[]
 {
     h.Abbreviations.Localise(textResource),
     new LocalisedString(HelperText.COST, h.BaseCost).Localise(textResource)
 }).ToArray()
 .Tableify() + "\n```";
Пример #4
0
        public virtual string Localise(ITextResourceCollection textResource)
        {
            if (Key == null)
            {
                return(null);
            }
            var prepped = _values.Select(v => v is ILocalisable ls ? ls.Localise(textResource) : v).ToArray();

            return(textResource.Format(Key, ReplyType, prepped));
        }
Пример #5
0
        public override string Localise(ITextResourceCollection tr)
        {
            if (Key == null)
            {
                return(null);
            }
            var prepped = Values.Select(v => v is ILocalisable ls ? ls.Localise(tr) : v)
                          .Select(v => tr.Formatter.Beautify(tr.FormatType, v))
                          .ToArray();

            return(tr.GetReplyType(ReplyType) + string.Format(Key, prepped));
        }
Пример #6
0
        public string Localise(ITextResourceCollection textResource)
        {
            string Format(string key)
            => $"`{key}{(RequiresInput ? $" <{ParamName}>" : "")}`";

            var text = Format($"-{ShortKey}");

            if (LongKey != null)
            {
                text += " / " + Format($"--{LongKey}");
            }

            return(text + $" = {textResource.GetResource(Description)}");
        }
Пример #7
0
        public static string[] GetNames(this EquipmentClass equipClass, ITextResourceCollection textResource)
        {
            var alt  = EquipmentClassText.LocalisableAlt(equipClass).Localise(textResource);
            var main = equipClass.ToLocalisable().Localise(textResource);

            if (alt == null)
            {
                return new string[] { main }
            }
            ;
            else
            {
                return new string[] { main }
            }.Concat(alt.Split(',')).ToArray();
Пример #8
0
        public virtual double MatchCertainty(ITextResourceCollection textResource, string text)
        {
            text = text.ToLower();
            var id     = Id.ToString().ToLower();
            var name   = Name.Localise(textResource).ToLower();
            var abbrev = Abbreviations?.Localise(textResource).ToLower().Split(',');

            return(new List <double>
            {
                id == text ? 0.95 : 0,
                name == text ? 0.9 : 0,
                abbrev?.Any(a => a == text) ?? false ? 0.9 : 0,
                id.StartsWith(text) ? 0.75 : 0,
                name.StartsWith(text) ? 0.7 : 0,
                id.Contains(text) ? 0.55 : 0,
                name.Contains(text) ? 0.5 : 0,
                id.Without(" ") == text.Without(" ") ? 0.35 : 0,
                name.Without(" ") == text.Without(" ") ? 0.3 : 0,
                id.Without(" ").StartsWith(text.Without(" ")) ? 0.15 : 0,
                name.Without(" ").StartsWith(text.Without(" ")) ? 0.1 : 0,
            }.Max());
        }
Пример #9
0
 object ILocalisable.Localise(ITextResourceCollection textResource)
 => Localise(textResource);
Пример #10
0
 public EmbedFooterBuilder Localise(ITextResourceCollection textResource)
 => new EmbedFooterBuilder
 {
     Text    = Text?.Localise(textResource),
     IconUrl = IconUrl?.Localise(textResource)
 };
Пример #11
0
 public virtual string Localise(ITextResourceCollection textResource)
 => $"**{Name.Localise(textResource)}** ({Id})";
Пример #12
0
 public override string Localise(ITextResourceCollection textResource)
 => LocalisationFunc?.Invoke(textResource);