Use fixed point arithmetic for progress/quality
This commit is contained in:
@@ -9,5 +9,5 @@ internal sealed class AdvancedTouch : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => s.ActionStates.TouchComboIdx == 2 ? 18 : 46;
|
public override int CPCost(Simulator s) => s.ActionStates.TouchComboIdx == 2 ? 18 : 46;
|
||||||
public override float Efficiency(Simulator s) => 1.50f;
|
public override int Efficiency(Simulator s) => 150;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public abstract class BaseAction
|
|||||||
|
|
||||||
// Instanced properties
|
// Instanced properties
|
||||||
public abstract int CPCost(Simulator s);
|
public abstract int CPCost(Simulator s);
|
||||||
public virtual float Efficiency(Simulator s) => 0f;
|
public virtual int Efficiency(Simulator s) => 0;
|
||||||
public virtual float SuccessRate(Simulator s) => 1f;
|
public virtual float SuccessRate(Simulator s) => 1f;
|
||||||
|
|
||||||
public virtual bool CanUse(Simulator s) =>
|
public virtual bool CanUse(Simulator s) =>
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ internal sealed class BasicSynthesis : BaseAction
|
|||||||
|
|
||||||
public override int CPCost(Simulator s) => 0;
|
public override int CPCost(Simulator s) => 0;
|
||||||
// Basic Synthesis Mastery Trait
|
// Basic Synthesis Mastery Trait
|
||||||
public override float Efficiency(Simulator s) => s.Input.Stats.Level >= 31 ? 1.20f : 1.00f;
|
public override int Efficiency(Simulator s) => s.Input.Stats.Level >= 31 ? 120 : 100;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ internal sealed class BasicTouch : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 18;
|
public override int CPCost(Simulator s) => 18;
|
||||||
public override float Efficiency(Simulator s) => 1.00f;
|
public override int Efficiency(Simulator s) => 100;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ internal sealed class ByregotsBlessing : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 24;
|
public override int CPCost(Simulator s) => 24;
|
||||||
public override float Efficiency(Simulator s) => 1.00f + (0.20f * s.GetEffectStrength(EffectType.InnerQuiet));
|
public override int Efficiency(Simulator s) => 100 + (20 * s.GetEffectStrength(EffectType.InnerQuiet));
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) => s.HasEffect(EffectType.InnerQuiet) && base.CanUse(s);
|
public override bool CanUse(Simulator s) => s.HasEffect(EffectType.InnerQuiet) && base.CanUse(s);
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ internal sealed class CarefulSynthesis : BaseAction
|
|||||||
|
|
||||||
public override int CPCost(Simulator s) => 7;
|
public override int CPCost(Simulator s) => 7;
|
||||||
// Careful Synthesis Mastery Trait
|
// Careful Synthesis Mastery Trait
|
||||||
public override float Efficiency(Simulator s) => s.Input.Stats.Level >= 82 ? 1.80f : 1.50f;
|
public override int Efficiency(Simulator s) => s.Input.Stats.Level >= 82 ? 180 : 150;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ internal sealed class DelicateSynthesis : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 32;
|
public override int CPCost(Simulator s) => 32;
|
||||||
public override float Efficiency(Simulator s) => 1.00f;
|
public override int Efficiency(Simulator s) => 100;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ internal sealed class FocusedSynthesis : BaseAction
|
|||||||
public override bool IncreasesProgress => true;
|
public override bool IncreasesProgress => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 5;
|
public override int CPCost(Simulator s) => 5;
|
||||||
public override float Efficiency(Simulator s) => 2.00f;
|
public override int Efficiency(Simulator s) => 200;
|
||||||
public override float SuccessRate(Simulator s) => s.ActionStates.Observed ? 1.00f : 0.50f;
|
public override float SuccessRate(Simulator s) => s.ActionStates.Observed ? 1.00f : 0.50f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ internal sealed class FocusedTouch : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 18;
|
public override int CPCost(Simulator s) => 18;
|
||||||
public override float Efficiency(Simulator s) => 1.50f;
|
public override int Efficiency(Simulator s) => 150;
|
||||||
public override float SuccessRate(Simulator s) => s.ActionStates.Observed ? 1.00f : 0.50f;
|
public override float SuccessRate(Simulator s) => s.ActionStates.Observed ? 1.00f : 0.50f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ internal sealed class Groundwork : BaseAction
|
|||||||
public override int DurabilityCost => 20;
|
public override int DurabilityCost => 20;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 18;
|
public override int CPCost(Simulator s) => 18;
|
||||||
public override float Efficiency(Simulator s)
|
public override int Efficiency(Simulator s)
|
||||||
{
|
{
|
||||||
// Groundwork Mastery Trait
|
// Groundwork Mastery Trait
|
||||||
var ret = s.Input.Stats.Level >= 86 ? 3.60f : 3.00f;
|
var ret = s.Input.Stats.Level >= 86 ? 360 : 300;
|
||||||
return s.Durability < s.CalculateDurabilityCost(DurabilityCost) ? ret / 2 : ret;
|
return s.Durability < s.CalculateDurabilityCost(DurabilityCost) ? ret / 2 : ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ internal sealed class HastyTouch : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 0;
|
public override int CPCost(Simulator s) => 0;
|
||||||
public override float Efficiency(Simulator s) => 1.00f;
|
public override int Efficiency(Simulator s) => 100;
|
||||||
public override float SuccessRate(Simulator s) => 0.60f;
|
public override float SuccessRate(Simulator s) => 0.60f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ internal sealed class IntensiveSynthesis : BaseAction
|
|||||||
public override bool IncreasesProgress => true;
|
public override bool IncreasesProgress => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 6;
|
public override int CPCost(Simulator s) => 6;
|
||||||
public override float Efficiency(Simulator s) => 4.00f;
|
public override int Efficiency(Simulator s) => 400;
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) =>
|
public override bool CanUse(Simulator s) =>
|
||||||
(s.Condition == Condition.Good || s.Condition == Condition.Excellent || s.HasEffect(EffectType.HeartAndSoul))
|
(s.Condition == Condition.Good || s.Condition == Condition.Excellent || s.HasEffect(EffectType.HeartAndSoul))
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ internal sealed class MuscleMemory : BaseAction
|
|||||||
public override bool IncreasesProgress => true;
|
public override bool IncreasesProgress => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 6;
|
public override int CPCost(Simulator s) => 6;
|
||||||
public override float Efficiency(Simulator s) => 3.00f;
|
public override int Efficiency(Simulator s) => 300;
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) => s.IsFirstStep && base.CanUse(s);
|
public override bool CanUse(Simulator s) => s.IsFirstStep && base.CanUse(s);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ internal sealed class PreciseTouch : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 18;
|
public override int CPCost(Simulator s) => 18;
|
||||||
public override float Efficiency(Simulator s) => 1.50f;
|
public override int Efficiency(Simulator s) => 150;
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) =>
|
public override bool CanUse(Simulator s) =>
|
||||||
(s.Condition == Condition.Good || s.Condition == Condition.Excellent || s.HasEffect(EffectType.HeartAndSoul))
|
(s.Condition == Condition.Good || s.Condition == Condition.Excellent || s.HasEffect(EffectType.HeartAndSoul))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ internal sealed class PreparatoryTouch : BaseAction
|
|||||||
public override int DurabilityCost => 20;
|
public override int DurabilityCost => 20;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 40;
|
public override int CPCost(Simulator s) => 40;
|
||||||
public override float Efficiency(Simulator s) => 2.00f;
|
public override int Efficiency(Simulator s) => 200;
|
||||||
|
|
||||||
public override void UseSuccess(Simulator s)
|
public override void UseSuccess(Simulator s)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ internal sealed class PrudentSynthesis : BaseAction
|
|||||||
public override int DurabilityCost => base.DurabilityCost / 2;
|
public override int DurabilityCost => base.DurabilityCost / 2;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 18;
|
public override int CPCost(Simulator s) => 18;
|
||||||
public override float Efficiency(Simulator s) => 1.80f;
|
public override int Efficiency(Simulator s) => 180;
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) =>
|
public override bool CanUse(Simulator s) =>
|
||||||
!(s.HasEffect(EffectType.WasteNot) || s.HasEffect(EffectType.WasteNot2))
|
!(s.HasEffect(EffectType.WasteNot) || s.HasEffect(EffectType.WasteNot2))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ internal sealed class PrudentTouch : BaseAction
|
|||||||
public override int DurabilityCost => base.DurabilityCost / 2;
|
public override int DurabilityCost => base.DurabilityCost / 2;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 25;
|
public override int CPCost(Simulator s) => 25;
|
||||||
public override float Efficiency(Simulator s) => 1.00f;
|
public override int Efficiency(Simulator s) => 100;
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) =>
|
public override bool CanUse(Simulator s) =>
|
||||||
!(s.HasEffect(EffectType.WasteNot) || s.HasEffect(EffectType.WasteNot2))
|
!(s.HasEffect(EffectType.WasteNot) || s.HasEffect(EffectType.WasteNot2))
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ internal sealed class RapidSynthesis : BaseAction
|
|||||||
|
|
||||||
public override int CPCost(Simulator s) => 0;
|
public override int CPCost(Simulator s) => 0;
|
||||||
// Rapid Synthesis Mastery Trait
|
// Rapid Synthesis Mastery Trait
|
||||||
public override float Efficiency(Simulator s) => s.Input.Stats.Level >= 63 ? 5.00f : 2.50f;
|
public override int Efficiency(Simulator s) => s.Input.Stats.Level >= 63 ? 500 : 250;
|
||||||
public override float SuccessRate(Simulator s) => 0.50f;
|
public override float SuccessRate(Simulator s) => 0.50f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ internal sealed class Reflect : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 6;
|
public override int CPCost(Simulator s) => 6;
|
||||||
public override float Efficiency(Simulator s) => 1.00f;
|
public override int Efficiency(Simulator s) => 100;
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) => s.IsFirstStep && base.CanUse(s);
|
public override bool CanUse(Simulator s) => s.IsFirstStep && base.CanUse(s);
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ internal sealed class StandardTouch : BaseAction
|
|||||||
public override bool IncreasesQuality => true;
|
public override bool IncreasesQuality => true;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => s.ActionStates.TouchComboIdx == 1 ? 18 : 32;
|
public override int CPCost(Simulator s) => s.ActionStates.TouchComboIdx == 1 ? 18 : 32;
|
||||||
public override float Efficiency(Simulator s) => 1.25f;
|
public override int Efficiency(Simulator s) => 125;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ internal sealed class TrainedFinesse : BaseAction
|
|||||||
public override int DurabilityCost => 0;
|
public override int DurabilityCost => 0;
|
||||||
|
|
||||||
public override int CPCost(Simulator s) => 32;
|
public override int CPCost(Simulator s) => 32;
|
||||||
public override float Efficiency(Simulator s) => 1.00f;
|
public override int Efficiency(Simulator s) => 100;
|
||||||
|
|
||||||
public override bool CanUse(Simulator s) =>
|
public override bool CanUse(Simulator s) =>
|
||||||
s.GetEffectStrength(EffectType.InnerQuiet) == 10
|
s.GetEffectStrength(EffectType.InnerQuiet) == 10
|
||||||
|
|||||||
+19
-19
@@ -213,51 +213,51 @@ public class Simulator
|
|||||||
return (int)Math.Ceiling(amt);
|
return (int)Math.Ceiling(amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CalculateProgressGain(float efficiency, bool dryRun = true)
|
public int CalculateProgressGain(int efficiency, bool dryRun = true)
|
||||||
{
|
{
|
||||||
var buffModifier = 1.00f;
|
var buffModifier = 100;
|
||||||
if (HasEffect(EffectType.MuscleMemory))
|
if (HasEffect(EffectType.MuscleMemory))
|
||||||
{
|
{
|
||||||
buffModifier += 1.00f;
|
buffModifier += 100;
|
||||||
if (!dryRun)
|
if (!dryRun)
|
||||||
RemoveEffect(EffectType.MuscleMemory);
|
RemoveEffect(EffectType.MuscleMemory);
|
||||||
}
|
}
|
||||||
if (HasEffect(EffectType.Veneration))
|
if (HasEffect(EffectType.Veneration))
|
||||||
buffModifier += 0.50f;
|
buffModifier += 50;
|
||||||
|
|
||||||
var conditionModifier = Condition switch
|
var conditionModifier = Condition switch
|
||||||
{
|
{
|
||||||
Condition.Malleable => 1.50f,
|
Condition.Malleable => 150,
|
||||||
_ => 1.00f
|
_ => 100
|
||||||
};
|
};
|
||||||
|
|
||||||
var progressGain = (int)(Input.BaseProgressGain * efficiency * conditionModifier * buffModifier);
|
var progressGain = (int)((long)Input.BaseProgressGain * efficiency * conditionModifier * buffModifier / 1e6);
|
||||||
return progressGain;
|
return progressGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CalculateQualityGain(float efficiency, bool dryRun = true)
|
public int CalculateQualityGain(int efficiency, bool dryRun = true)
|
||||||
{
|
{
|
||||||
var buffModifier = 1.00f;
|
var buffModifier = 100;
|
||||||
if (HasEffect(EffectType.GreatStrides))
|
if (HasEffect(EffectType.GreatStrides))
|
||||||
{
|
{
|
||||||
buffModifier += 1.00f;
|
buffModifier += 100;
|
||||||
if (!dryRun)
|
if (!dryRun)
|
||||||
RemoveEffect(EffectType.GreatStrides);
|
RemoveEffect(EffectType.GreatStrides);
|
||||||
}
|
}
|
||||||
if (HasEffect(EffectType.Innovation))
|
if (HasEffect(EffectType.Innovation))
|
||||||
buffModifier += 0.50f;
|
buffModifier += 50;
|
||||||
|
|
||||||
buffModifier *= 1 + (GetEffectStrength(EffectType.InnerQuiet) * 0.10f);
|
var iqModifier = 100 + (GetEffectStrength(EffectType.InnerQuiet) * 10);
|
||||||
|
|
||||||
var conditionModifier = Condition switch
|
var conditionModifier = Condition switch
|
||||||
{
|
{
|
||||||
Condition.Poor => 0.50f,
|
Condition.Poor => 50,
|
||||||
Condition.Good => Input.Stats.HasSplendorousBuff ? 1.75f : 1.50f,
|
Condition.Good => Input.Stats.HasSplendorousBuff ? 175 : 150,
|
||||||
Condition.Excellent => 4.00f,
|
Condition.Excellent => 400,
|
||||||
_ => 1.00f,
|
_ => 100,
|
||||||
};
|
};
|
||||||
|
|
||||||
var qualityGain = (int)(Input.BaseQualityGain * efficiency * conditionModifier * buffModifier);
|
var qualityGain = (int)((long)Input.BaseQualityGain * efficiency * conditionModifier * iqModifier * buffModifier / 1e8);
|
||||||
return qualityGain;
|
return qualityGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,10 +297,10 @@ public class Simulator
|
|||||||
ReduceCPRaw(CalculateCPCost(amount));
|
ReduceCPRaw(CalculateCPCost(amount));
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void IncreaseProgress(float efficiency) =>
|
public void IncreaseProgress(int efficiency) =>
|
||||||
IncreaseProgressRaw(CalculateProgressGain(efficiency, false));
|
IncreaseProgressRaw(CalculateProgressGain(efficiency, false));
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void IncreaseQuality(float efficiency) =>
|
public void IncreaseQuality(int efficiency) =>
|
||||||
IncreaseQualityRaw(CalculateQualityGain(efficiency, false));
|
IncreaseQualityRaw(CalculateQualityGain(efficiency, false));
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -49,6 +49,8 @@ public struct ActionSet
|
|||||||
static ActionSet()
|
static ActionSet()
|
||||||
{
|
{
|
||||||
AcceptedActionsLUT = new int[Enum.GetValues<ActionType>().Length];
|
AcceptedActionsLUT = new int[Enum.GetValues<ActionType>().Length];
|
||||||
|
for (var i = 0; i < AcceptedActionsLUT.Length; i++)
|
||||||
|
AcceptedActionsLUT[i] = -1;
|
||||||
for (var i = 0; i < AcceptedActions.Length; i++)
|
for (var i = 0; i < AcceptedActions.Length; i++)
|
||||||
AcceptedActionsLUT[(byte)AcceptedActions[i]] = i;
|
AcceptedActionsLUT[(byte)AcceptedActions[i]] = i;
|
||||||
}
|
}
|
||||||
@@ -57,7 +59,7 @@ public struct ActionSet
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static int FromAction(ActionType action)
|
private static int FromAction(ActionType action)
|
||||||
{
|
{
|
||||||
var ret = Simulator.AcceptedActionsLUT[(byte)action];
|
var ret = AcceptedActionsLUT[(byte)action];
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
throw new ArgumentOutOfRangeException(nameof(action), action, $"Action {action} is unsupported in {nameof(ActionSet)}.");
|
throw new ArgumentOutOfRangeException(nameof(action), action, $"Action {action} is unsupported in {nameof(ActionSet)}.");
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user