1.9.0.0 (Testing) Release
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Craftimizer.Simulator;
|
||||
|
||||
public enum ActionCategory
|
||||
@@ -13,6 +16,25 @@ public enum ActionCategory
|
||||
|
||||
public static class ActionCategoryUtils
|
||||
{
|
||||
private static readonly ReadOnlyDictionary<ActionCategory, ActionType[]> SortedActions;
|
||||
|
||||
static ActionCategoryUtils()
|
||||
{
|
||||
SortedActions = new(
|
||||
Enum.GetValues<ActionType>()
|
||||
.Where(a => a.Category() != ActionCategory.Combo)
|
||||
.GroupBy(a => a.Category())
|
||||
.ToDictionary(g => g.Key, g => g.OrderBy(a => a.Level()).ToArray()));
|
||||
}
|
||||
|
||||
public static IReadOnlyList<ActionType> GetActions(this ActionCategory me)
|
||||
{
|
||||
if (SortedActions.TryGetValue(me, out var actions))
|
||||
return actions;
|
||||
|
||||
throw new ArgumentException($"Unknown action category {me}", nameof(me));
|
||||
}
|
||||
|
||||
public static string GetDisplayName(this ActionCategory category) =>
|
||||
category switch
|
||||
{
|
||||
|
||||
@@ -48,7 +48,8 @@ public abstract class BaseAction
|
||||
s.ActionStates.MutateState(this);
|
||||
s.ActionCount++;
|
||||
|
||||
s.ActiveEffects.DecrementDuration();
|
||||
if (IncreasesStepCount)
|
||||
s.ActiveEffects.DecrementDuration();
|
||||
}
|
||||
|
||||
public virtual void UseSuccess(Simulator s)
|
||||
|
||||
@@ -14,10 +14,13 @@ internal abstract class BaseBuffAction : BaseAction
|
||||
public override void UseSuccess(Simulator s) =>
|
||||
s.AddEffect(Effect, Duration);
|
||||
|
||||
public sealed override string GetTooltip(Simulator s, bool addUsability)
|
||||
public override string GetTooltip(Simulator s, bool addUsability)
|
||||
{
|
||||
var builder = new StringBuilder(base.GetTooltip(s, addUsability));
|
||||
builder.AppendLine($"{Duration} Steps");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
protected string GetBaseTooltip(Simulator s, bool addUsability) =>
|
||||
base.GetTooltip(s, addUsability);
|
||||
}
|
||||
|
||||
@@ -15,4 +15,7 @@ internal sealed class CarefulObservation : BaseAction
|
||||
public override bool CanUse(Simulator s) => s.Input.Stats.IsSpecialist && s.ActionStates.CarefulObservationCount < 3;
|
||||
|
||||
public override void UseSuccess(Simulator s) => s.StepCondition();
|
||||
|
||||
public override string GetTooltip(Simulator s, bool addUsability) =>
|
||||
$"{base.GetTooltip(s, addUsability)}Specialist Only";
|
||||
}
|
||||
|
||||
@@ -14,4 +14,7 @@ internal sealed class HeartAndSoul : BaseBuffAction
|
||||
public override int CPCost(Simulator s) => 0;
|
||||
|
||||
public override bool CanUse(Simulator s) => s.Input.Stats.IsSpecialist && !s.ActionStates.UsedHeartAndSoul;
|
||||
|
||||
public override string GetTooltip(Simulator s, bool addUsability) =>
|
||||
$"{GetBaseTooltip(s, addUsability)}Specialist Only";
|
||||
}
|
||||
|
||||
@@ -14,14 +14,16 @@ internal sealed class Manipulation : BaseBuffAction
|
||||
|
||||
public override void Use(Simulator s)
|
||||
{
|
||||
if (s.HasEffect(EffectType.Manipulation))
|
||||
s.RestoreDurability(5);
|
||||
|
||||
s.ReduceCP(CPCost(s));
|
||||
s.ReduceDurability(DurabilityCost);
|
||||
|
||||
UseSuccess(s);
|
||||
|
||||
s.ReduceCP(CPCost(s));
|
||||
|
||||
s.IncreaseStepCount();
|
||||
|
||||
s.ActionStates.MutateState(this);
|
||||
s.ActionCount++;
|
||||
|
||||
if (IncreasesStepCount)
|
||||
s.ActiveEffects.DecrementDuration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,7 @@ internal sealed class TrainedEye : BaseAction
|
||||
|
||||
public override void UseSuccess(Simulator s) =>
|
||||
s.IncreaseQualityRaw(s.Input.Recipe.MaxQuality - s.Quality);
|
||||
|
||||
public override string GetTooltip(Simulator s, bool addUsability) =>
|
||||
$"{base.GetTooltip(s, addUsability)}+{s.Input.Recipe.MaxQuality - s.Quality} Quality";
|
||||
}
|
||||
|
||||
@@ -82,6 +82,11 @@ public record struct Effects
|
||||
_ => 0
|
||||
};
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsIndefinite(EffectType effect) =>
|
||||
effect is EffectType.InnerQuiet or EffectType.HeartAndSoul;
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly byte GetStrength(EffectType effect) =>
|
||||
|
||||
@@ -25,6 +25,8 @@ public record struct SimulationState
|
||||
74, 76, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, 96, 98, 100
|
||||
};
|
||||
public readonly int HQPercent => HQPercentTable[(int)Math.Clamp((float)Quality / Input.Recipe.MaxQuality * 100, 0, 100)];
|
||||
public readonly int Collectability => Math.Max(Quality / 10, 1);
|
||||
public readonly int MaxCollectability => Math.Max(Input.Recipe.MaxQuality / 10, 1);
|
||||
|
||||
public readonly bool IsFirstStep => StepCount == 0;
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ public class Simulator
|
||||
return ActionResponse.ActionNotUnlocked;
|
||||
if (action == ActionType.Manipulation && !Input.Stats.CanUseManipulation)
|
||||
return ActionResponse.ActionNotUnlocked;
|
||||
if (action is ActionType.CarefulObservation or ActionType.HeartAndSoul && !Input.Stats.IsSpecialist)
|
||||
return ActionResponse.ActionNotUnlocked;
|
||||
if (baseAction.CPCost(this) > CP)
|
||||
return ActionResponse.NotEnoughCP;
|
||||
return ActionResponse.CannotUseAction;
|
||||
|
||||
Reference in New Issue
Block a user