more settings fuckery - does not compile
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
namespace HighRollerClassic.DataStructures;
|
||||
|
||||
public class Misc
|
||||
public static class Misc
|
||||
{
|
||||
/// <summary>
|
||||
/// Appends message if error par is true
|
||||
|
||||
@@ -2,5 +2,9 @@ namespace HighRollerClassic.DataStructures;
|
||||
|
||||
public enum SettingValueType
|
||||
{
|
||||
|
||||
Multiplier,
|
||||
Roll,
|
||||
Colour,
|
||||
MaxBet,
|
||||
Step,
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Settings
|
||||
/// Contains data about each multiplier, roll, etc.
|
||||
/// </summary>
|
||||
public List<SettingsRoll> Rolls { get; private set; } = new();
|
||||
// todo we'll make this a new class because we have 3 roll methods already 'polluting' this class
|
||||
|
||||
/// <summary>
|
||||
/// Adds roll
|
||||
@@ -46,6 +47,11 @@ public class Settings
|
||||
return null;
|
||||
}
|
||||
|
||||
public void RemoveRoll(SettingsRoll roll)
|
||||
{
|
||||
Rolls.Remove(roll);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates new roll
|
||||
/// </summary>
|
||||
|
||||
@@ -1,22 +1,95 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace HighRollerClassic.DataStructures;
|
||||
|
||||
public class TrackedValue<TParent, TValue>
|
||||
/// <summary>
|
||||
/// Tracks value and its validity and changes
|
||||
/// </summary>
|
||||
public class TrackedValue
|
||||
{
|
||||
public TValue Value { get; set; }
|
||||
public bool IsValid { get; set; }
|
||||
public bool HasChanged { get; set; }
|
||||
private SettingValueType type;
|
||||
private Configuration configuration;
|
||||
|
||||
private uint? Value { get;
|
||||
set
|
||||
{
|
||||
SetValue(value);
|
||||
field = value;
|
||||
}
|
||||
}
|
||||
private Vector4? colourValue { get; set; }
|
||||
|
||||
public bool IsValid { get; private set; }
|
||||
public bool HasChanged { get; private set; }
|
||||
|
||||
private const uint MinRoll = 1;
|
||||
private const uint MaxRoll = 999;
|
||||
private const uint MaxGil = 999_999_999;
|
||||
|
||||
private Func<uint, bool> multiplierRollValid = v => v is >= MinRoll and <= MaxRoll;
|
||||
private Func<uint, bool> maxBetValid = v => v <= MaxGil;
|
||||
private bool multiplierValid => Value is not null;
|
||||
private bool rollValid => Value is >= MinRoll and <= MaxRoll;
|
||||
private bool maxBetValid => Value is <= MaxGil;
|
||||
private bool stepValid => CheckStepValid();
|
||||
|
||||
private static bool StepValid(uint step, uint bet)
|
||||
public TrackedValue(uint? value, SettingValueType type, Configuration configuration)
|
||||
{
|
||||
return step <= bet;
|
||||
Initialise(type, configuration);
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public TrackedValue(Vector4? value, SettingValueType type, Configuration configuration)
|
||||
{
|
||||
Initialise(type, configuration);
|
||||
colourValue = value;
|
||||
}
|
||||
|
||||
private void Initialise(SettingValueType type, Configuration configuration)
|
||||
{
|
||||
this.type = type;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
private bool CheckStepValid()
|
||||
{
|
||||
return Value <= configuration.Settings.MaxBet;
|
||||
}
|
||||
|
||||
private void SetValue(uint? value)
|
||||
{
|
||||
bool? valid = null;
|
||||
bool? change = null;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SettingValueType.Multiplier:
|
||||
valid = multiplierValid;
|
||||
break;
|
||||
case SettingValueType.Roll:
|
||||
valid = rollValid;
|
||||
break;
|
||||
case SettingValueType.Colour:
|
||||
valid = true;
|
||||
break;
|
||||
case SettingValueType.MaxBet:
|
||||
valid = maxBetValid;
|
||||
change = value == configuration.Settings.MaxBet;
|
||||
break;
|
||||
case SettingValueType.Step:
|
||||
valid = stepValid;
|
||||
change = value == configuration.Settings.Step;
|
||||
break;
|
||||
}
|
||||
|
||||
if (valid.HasValue) IsValid = valid.Value;
|
||||
if (change.HasValue) HasChanged = change.Value;
|
||||
}
|
||||
|
||||
private void SetColourValue(Vector4? value)
|
||||
{
|
||||
IsValid = true; // colour will always be valid because we set it from colour picker
|
||||
HasChanged = true; // todo we have to check
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user