73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using UnityEngine;
|
|
|
|
namespace NightclubArcadia.Skills
|
|
{
|
|
public enum DcBand
|
|
{
|
|
Trivial = 8,
|
|
Routine = 11,
|
|
Hard = 14,
|
|
Specialist = 17,
|
|
BuildDefining = 20,
|
|
}
|
|
|
|
public static class DcBands
|
|
{
|
|
static readonly int[] BandValues =
|
|
{
|
|
(int)DcBand.Trivial,
|
|
(int)DcBand.Routine,
|
|
(int)DcBand.Hard,
|
|
(int)DcBand.Specialist,
|
|
(int)DcBand.BuildDefining,
|
|
};
|
|
|
|
public static bool TryParse(string input, out int dc)
|
|
{
|
|
dc = 0;
|
|
if (string.IsNullOrWhiteSpace(input))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
input = input.Trim();
|
|
|
|
if (int.TryParse(input, NumberStyles.Integer, CultureInfo.InvariantCulture, out var numeric))
|
|
{
|
|
dc = numeric;
|
|
if (!IsBandValue(numeric))
|
|
{
|
|
Debug.LogWarning(
|
|
$"[DcBands] DC {numeric} is not a named band " +
|
|
$"(8 / 11 / 14 / 17 / 20). Prefer band names.");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
if (Enum.TryParse<DcBand>(input, ignoreCase: true, out var band))
|
|
{
|
|
dc = (int)band;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static bool IsBandValue(int dc)
|
|
{
|
|
for (var i = 0; i < BandValues.Length; i++)
|
|
{
|
|
if (BandValues[i] == dc)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|