-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCraftLine.cs
More file actions
22 lines (20 loc) · 1022 Bytes
/
Copy pathCraftLine.cs
File metadata and controls
22 lines (20 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Globalization;
using RustPlusBot.Features.ItemData.Data;
using RustPlusBot.Features.ItemData.Naming;
namespace RustPlusBot.Features.Commands.Formatting;
/// <summary>Formats the one-line craft-recipe reply.</summary>
internal static class CraftLine
{
/// <summary>Formats the ingredients and craft time for an item.</summary>
/// <param name="item">The item (must have non-null <see cref="ItemRecord.Craft"/>).</param>
/// <param name="names">Resolves ingredient item ids to names.</param>
public static string Format(ItemRecord item, IItemNameResolver names)
{
ArgumentNullException.ThrowIfNull(item);
ArgumentNullException.ThrowIfNull(names);
ArgumentNullException.ThrowIfNull(item.Craft);
var parts = item.Craft.Ingredients
.Select(g => string.Create(CultureInfo.InvariantCulture, $"{names.Resolve(g.ItemId)} ×{g.Quantity}"));
return string.Create(CultureInfo.InvariantCulture, $"{item.Name}: {string.Join(", ", parts)}");
}
}