final
This commit is contained in:
58
BlueLaminate/BlueLaminate.Core/Tradeups/WearBand.cs
Normal file
58
BlueLaminate/BlueLaminate.Core/Tradeups/WearBand.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
namespace BlueLaminate.Core.Tradeups;
|
||||
|
||||
/// <summary>
|
||||
/// The five CS2 wear bands, defined by absolute float thresholds (independent of any
|
||||
/// individual skin's float range). A produced item's band — and therefore which
|
||||
/// listings it competes with — is read straight off its absolute float.
|
||||
/// </summary>
|
||||
public enum WearBand
|
||||
{
|
||||
FactoryNew,
|
||||
MinimalWear,
|
||||
FieldTested,
|
||||
WellWorn,
|
||||
BattleScarred,
|
||||
}
|
||||
|
||||
public static class WearBands
|
||||
{
|
||||
// Upper-exclusive boundaries: FN [0,0.07) MW [0.07,0.15) FT [0.15,0.38)
|
||||
// WW [0.38,0.45) BS [0.45,1.0].
|
||||
public const decimal MinimalWearFloor = 0.07m;
|
||||
public const decimal FieldTestedFloor = 0.15m;
|
||||
public const decimal WellWornFloor = 0.38m;
|
||||
public const decimal BattleScarredFloor = 0.45m;
|
||||
|
||||
/// <summary>The wear band an absolute float value falls into.</summary>
|
||||
public static WearBand FromFloat(decimal floatValue) => floatValue switch
|
||||
{
|
||||
< MinimalWearFloor => WearBand.FactoryNew,
|
||||
< FieldTestedFloor => WearBand.MinimalWear,
|
||||
< WellWornFloor => WearBand.FieldTested,
|
||||
< BattleScarredFloor => WearBand.WellWorn,
|
||||
_ => WearBand.BattleScarred,
|
||||
};
|
||||
|
||||
/// <summary>The absolute float range [min, max) that defines this band — used to scope a
|
||||
/// CSFloat query to the band the produced output lands in.</summary>
|
||||
public static (decimal Min, decimal Max) Bounds(this WearBand band) => band switch
|
||||
{
|
||||
WearBand.FactoryNew => (0.00m, MinimalWearFloor),
|
||||
WearBand.MinimalWear => (MinimalWearFloor, FieldTestedFloor),
|
||||
WearBand.FieldTested => (FieldTestedFloor, WellWornFloor),
|
||||
WearBand.WellWorn => (WellWornFloor, BattleScarredFloor),
|
||||
WearBand.BattleScarred => (BattleScarredFloor, 1.00m),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(band), band, null),
|
||||
};
|
||||
|
||||
/// <summary>The full wear name as it appears in listing data ("Factory New", …).</summary>
|
||||
public static string ToName(this WearBand band) => band switch
|
||||
{
|
||||
WearBand.FactoryNew => "Factory New",
|
||||
WearBand.MinimalWear => "Minimal Wear",
|
||||
WearBand.FieldTested => "Field-Tested",
|
||||
WearBand.WellWorn => "Well-Worn",
|
||||
WearBand.BattleScarred => "Battle-Scarred",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(band), band, null),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user