diff --git a/ModiBuff/ModiBuff.Tests/ModiBuff.Tests.csproj b/ModiBuff/ModiBuff.Tests/ModiBuff.Tests.csproj index 2929ae7..5869f34 100644 --- a/ModiBuff/ModiBuff.Tests/ModiBuff.Tests.csproj +++ b/ModiBuff/ModiBuff.Tests/ModiBuff.Tests.csproj @@ -2,15 +2,10 @@ disable - false - 7.2 - Library - net6.0 - false @@ -27,4 +22,4 @@ - + \ No newline at end of file diff --git a/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs b/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs index 10c2866..72c3848 100644 --- a/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs +++ b/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs @@ -33,6 +33,9 @@ private void SaveLoadStateAndSetup(ModifierRecipes saveRecipes) } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -46,6 +49,9 @@ public void SaveRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveNamesRecipeLoad() { const string name = "InitDamage"; @@ -66,6 +72,9 @@ public void SaveNamesRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveStackRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -83,6 +92,9 @@ public void SaveStackRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveAddDamageRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -96,6 +108,9 @@ public void SaveAddDamageRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveIntervalRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -111,6 +126,9 @@ public void SaveIntervalRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveModifierActionRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -131,6 +149,9 @@ public void SaveModifierActionRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveRemoveRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -147,6 +168,9 @@ public void SaveRemoveRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveRefreshIntervalRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -165,6 +189,9 @@ public void SaveRefreshIntervalRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveRefreshDurationRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -184,6 +211,9 @@ public void SaveRefreshDurationRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveRemoveStackRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -201,6 +231,9 @@ public void SaveRemoveStackRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveRemoveCallbackUnitRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -219,6 +252,9 @@ public void SaveRemoveCallbackUnitRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveDispelRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -240,6 +276,9 @@ public void SaveDispelRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveTagRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -254,6 +293,9 @@ public void SaveTagRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveRemoveTagRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); @@ -268,6 +310,9 @@ public void SaveRemoveTagRecipeLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveSetTagRecipeLoad() { var saveRecipes = new ModifierRecipes(IdManager, EffectTypeIdManager); diff --git a/ModiBuff/ModiBuff.Tests/SaveLoadTests.cs b/ModiBuff/ModiBuff.Tests/SaveLoadTests.cs index ba5d35d..7a48331 100644 --- a/ModiBuff/ModiBuff.Tests/SaveLoadTests.cs +++ b/ModiBuff/ModiBuff.Tests/SaveLoadTests.cs @@ -60,6 +60,9 @@ private void LoadGameState(string gameStateFile, out Unit[] loadedUnits) } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveUnitLoad() { AddRecipe("AddDamageExtraState") @@ -86,6 +89,9 @@ public void SaveUnitLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveEffectCooldownCheckLoad() { AddRecipe("AddDamageExtraState") @@ -111,6 +117,9 @@ public void SaveEffectCooldownCheckLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveLoadStatusEffect() { AddRecipe("InitStun") @@ -133,6 +142,9 @@ public void SaveLoadStatusEffect() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveLoadEventCallbackState() { AddRecipe("InitCallbackState") @@ -161,6 +173,9 @@ public void SaveLoadEventCallbackState() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveLoadApplierState() { AddRecipe("InitDamageChecks") @@ -184,6 +199,9 @@ public void SaveLoadApplierState() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveLoadTargetId() { AddRecipe("DoT") @@ -209,6 +227,9 @@ public void SaveLoadTargetId() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveNewModifierIdLoad() { AddRecipe("DoT") @@ -234,6 +255,9 @@ public void SaveNewModifierIdLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveNewModifierApplierIdLoad() { AddRecipe("DoT") @@ -266,6 +290,9 @@ public void SaveNewModifierApplierIdLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveNewEffectIdLoad() { AddEffect("InitDamage", new DamageEffect(5)); @@ -288,6 +315,9 @@ public void SaveNewEffectIdLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveModifierNewEffectLoad() { AddRecipe("InitHeal") @@ -338,6 +368,9 @@ public void SaveStatusEffectGenIdLoad() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveCallbackLocalVarState() { AddRecipe("InitTakeFiveDamageOnTenDamageTaken") @@ -372,6 +405,10 @@ public void SaveCallbackLocalVarState() [Test] public void SavePoisonEffectLoad() { +#if !MODIBUFF_SYSTEM_TEXT_JSON + Setup(); + Assert.Ignore("MODIBUFF_SYSTEM_TEXT_JSON not defined. Skipping test."); +#else SerializationExtensions.AddCustomValueType>(element => { var dictionary = new Dictionary(); @@ -379,6 +416,7 @@ public void SavePoisonEffectLoad() dictionary.Add(int.Parse(kvp.Name), kvp.Value.GetInt32()); return dictionary; }); +#endif AddRecipe(CentralizedCustomLogicTests.PoisonRecipe); AddRecipe("PoisonThorns") @@ -418,6 +456,10 @@ public void SavePoisonEffectLoad() [Test] public void SaveCallbackLocalTupleVarState() { +#if !MODIBUFF_SYSTEM_TEXT_JSON + Setup(); + Assert.Ignore("MODIBUFF_SYSTEM_TEXT_JSON not defined. Skipping test."); +#else SerializationExtensions.AddCustomValueType>(element => { float[] array = new float[2]; @@ -426,6 +468,7 @@ public void SaveCallbackLocalTupleVarState() array[i++] = kvp.Value.GetSingle(); return new Tuple(array[0], array[1]); }); +#endif AddRecipe("InitTakeFiveDamageOnTenDamageTaken") .Callback(CallbackType.CurrentHealthChanged, () => @@ -473,6 +516,9 @@ public void SaveCallbackLocalTupleVarState() } [Test] +#if !MODIBUFF_SYSTEM_TEXT_JSON + [Ignore("MODIBUFF_SYSTEM_TEXT_JSON not set. Skipping test")] +#endif public void SaveCallbackEffectLocalFloatVarState() { AddRecipe("StunnedFourTimesDispelAllStatusEffects") diff --git a/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipeSaveLoad.cs b/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipeSaveLoad.cs index e2bec46..9036243 100644 --- a/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipeSaveLoad.cs +++ b/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipeSaveLoad.cs @@ -120,6 +120,7 @@ public void LoadState(SaveData saveData) } } +#if MODIBUFF_SYSTEM_TEXT_JSON (IEffect, EffectOn) HandleEffect(SaveInstruction instruction) { var values = ((System.Text.Json.JsonElement)instruction.Values).EnumerateObject(); @@ -189,6 +190,7 @@ public void LoadState(SaveData saveData) return ((IEffect)constructor.Invoke(effectStates), effectOn.Value); } +#endif } public record SaveInstruction @@ -206,8 +208,9 @@ public SaveInstruction(object values, int instructionId) Values = values; InstructionId = instructionId; } - +#if MODIBUFF_SYSTEM_TEXT_JSON public object[] GetValues(params Type[] types) => ((System.Text.Json.JsonElement)Values).GetValues(types); +#endif public sealed record Initialize : SaveInstruction { diff --git a/ModiBuff/ModiBuff/ModiBuff.csproj b/ModiBuff/ModiBuff/ModiBuff.csproj index 1872886..29179c6 100644 --- a/ModiBuff/ModiBuff/ModiBuff.csproj +++ b/ModiBuff/ModiBuff/ModiBuff.csproj @@ -21,16 +21,15 @@ - TRACE MODIBUFF_SYSTEM_TEXT_JSON + TRACE - TRACE MODIBUFF_SYSTEM_TEXT_JSON + TRACE -