76 lines
2.8 KiB
C#
76 lines
2.8 KiB
C#
namespace BlueLaminate.Core.Tradeups;
|
|
|
|
/// <summary>
|
|
/// The ordered weapon-skin rarity tiers that participate in a 10-input tradeup.
|
|
/// The ordinal value IS the tier order: a tradeup consumes 10 inputs of tier T and
|
|
/// produces an output at the next tier present in the same collection.
|
|
/// <para>
|
|
/// Only the six weapon tiers are modelled. The catalogue also carries
|
|
/// <c>Contraband</c> (the Howl) and <c>Extraordinary</c> (gloves), and knives are
|
|
/// stored as <c>Covert</c>; none of those are weapon tradeup tiers, so
|
|
/// <see cref="TryParse"/> reports them as "not a weapon tier" rather than mapping
|
|
/// them. See the eligibility rules in <see cref="TradeupGraphBuilder"/>.
|
|
/// </para>
|
|
/// </summary>
|
|
public enum WeaponRarity
|
|
{
|
|
Consumer = 1,
|
|
Industrial = 2,
|
|
MilSpec = 3,
|
|
Restricted = 4,
|
|
Classified = 5,
|
|
Covert = 6,
|
|
}
|
|
|
|
public static class WeaponRarityExtensions
|
|
{
|
|
/// <summary>
|
|
/// Maps a <c>skins.rarity</c> string literal to its weapon tier.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// <c>true</c> with <paramref name="rarity"/> set when the literal is one of the
|
|
/// six weapon tiers; <c>false</c> for <c>Contraband</c>/<c>Extraordinary</c>
|
|
/// (valid catalogue rarities that are not weapon tradeup tiers).
|
|
/// </returns>
|
|
/// <exception cref="ArgumentException">
|
|
/// The literal is none of the known catalogue rarities. Thrown deliberately so a
|
|
/// catalogue rename surfaces loudly instead of silently dropping a whole tier.
|
|
/// </exception>
|
|
public static bool TryParse(string rarity, out WeaponRarity result)
|
|
{
|
|
switch (rarity)
|
|
{
|
|
case "Consumer Grade":
|
|
result = WeaponRarity.Consumer;
|
|
return true;
|
|
case "Industrial Grade":
|
|
result = WeaponRarity.Industrial;
|
|
return true;
|
|
case "Mil-Spec Grade":
|
|
result = WeaponRarity.MilSpec;
|
|
return true;
|
|
case "Restricted":
|
|
result = WeaponRarity.Restricted;
|
|
return true;
|
|
case "Classified":
|
|
result = WeaponRarity.Classified;
|
|
return true;
|
|
case "Covert":
|
|
result = WeaponRarity.Covert;
|
|
return true;
|
|
|
|
// Known, valid catalogue rarities that are not weapon tradeup tiers.
|
|
case "Contraband": // The Howl
|
|
case "Extraordinary": // Gloves
|
|
result = default;
|
|
return false;
|
|
|
|
default:
|
|
throw new ArgumentException(
|
|
$"Unknown skin rarity literal '{rarity}'. The catalogue may have renamed a "
|
|
+ "rarity; update WeaponRarityExtensions.TryParse so a tier isn't silently dropped.",
|
|
nameof(rarity));
|
|
}
|
|
}
|
|
}
|