Skip to content

Commit

Permalink
Minor proc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Nov 17, 2024
1 parent 4b4cc9f commit feb046b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
8 changes: 8 additions & 0 deletions Simulator/ActionProc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Craftimizer.Simulator;

public enum ActionProc : byte
{
None,
UsedBasicTouch,
AdvancedTouch
}
13 changes: 5 additions & 8 deletions Simulator/ActionStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ namespace Craftimizer.Simulator;
[StructLayout(LayoutKind.Auto)]
public record struct ActionStates
{
public byte TouchComboIdx;
public ActionProc Combo;
public byte CarefulObservationCount;
public bool UsedHeartAndSoul;
public bool UsedQuickInnovation;
public bool UsedTrainedPerfection;
public bool ObserveCombo;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void MutateState(BaseAction baseAction)
{
if (baseAction is BasicTouch)
TouchComboIdx = 1;
else if (TouchComboIdx == 1 && baseAction is StandardTouch)
TouchComboIdx = 2;
Combo = ActionProc.UsedBasicTouch;
else if ((Combo == ActionProc.UsedBasicTouch && baseAction is StandardTouch) || baseAction is Observe)
Combo = ActionProc.AdvancedTouch;
else
TouchComboIdx = 0;
Combo = ActionProc.None;

if (baseAction is CarefulObservation)
CarefulObservationCount++;
Expand All @@ -35,7 +34,5 @@ public void MutateState(BaseAction baseAction)

if (baseAction is TrainedPerfection)
UsedTrainedPerfection = true;

ObserveCombo = baseAction is Observe;
}
}
2 changes: 1 addition & 1 deletion Simulator/Actions/AdvancedTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ internal sealed class AdvancedTouch() : BaseAction(
defaultCPCost: 46, defaultEfficiency: 150)
{
public override int CPCost(Simulator s) =>
(s.ActionStates.TouchComboIdx == 2 || s.ActionStates.ObserveCombo) ? 18 : 46;
(s.ActionStates.Combo == ActionProc.AdvancedTouch) ? 18 : 46;
}
2 changes: 1 addition & 1 deletion Simulator/Actions/RefinedTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class RefinedTouch() : BaseAction(
public override void UseSuccess(Simulator s)
{
base.UseSuccess(s);
if (s.ActionStates.TouchComboIdx == 1)
if (s.ActionStates.Combo == ActionProc.UsedBasicTouch)
s.StrengthenEffect(EffectType.InnerQuiet);
}
}
2 changes: 1 addition & 1 deletion Simulator/Actions/StandardTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ internal sealed class StandardTouch() : BaseAction(
)
{
public override int CPCost(Simulator s) =>
s.ActionStates.TouchComboIdx == 1 ? 18 : 32;
s.ActionStates.Combo == ActionProc.UsedBasicTouch ? 18 : 32;
}
8 changes: 4 additions & 4 deletions Solver/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ private bool ShouldUseAction(ActionType action, BaseAction baseAction)
return false;

// don't allow combo actions if the combo is already in progress
if (ActionStates.TouchComboIdx != 0 &&
if (ActionStates.Combo != ActionProc.None &&
(action is ActionType.StandardTouchCombo or ActionType.AdvancedTouchCombo or ActionType.RefinedTouchCombo))
return false;

// only allow Advanced Touch when Observing
if (ActionStates.ObserveCombo && action is not ActionType.AdvancedTouch)
// when combo'd, only allow Advanced Touch
if (ActionStates.Combo == ActionProc.AdvancedTouch && action is not ActionType.AdvancedTouch)
return false;

// don't allow pure quality moves under Veneration
Expand Down Expand Up @@ -140,7 +140,7 @@ private bool ShouldUseAction(ActionType action, BaseAction baseAction)

// don't allow Refined Touch without a combo
if (action is ActionType.RefinedTouch &&
ActionStates.TouchComboIdx != 1)
ActionStates.Combo != ActionProc.UsedBasicTouch)
return false;

// don't allow Immaculate Mends that are too inefficient
Expand Down

0 comments on commit feb046b

Please sign in to comment.