From 1994027ea8428f1d91f64b3ec34aef1042895e4b Mon Sep 17 00:00:00 2001 From: Pokachi Date: Sun, 30 May 2021 16:36:25 -0700 Subject: [PATCH 1/4] Added Card Sell Multiplier, changed the display to %, and fixed a sbug with gold pile value display --- DifficultyMod/Core/DifficultyPatcher.cs | 16 ++++++- DifficultyMod/Core/DifficultySettings.cs | 47 ++++++++++++++++++--- DifficultyMod/Properties/AssemblyInfo.cs | 2 +- DifficultyMod/UI/DifficultyMenu.cs | 53 +++++++++++++++--------- 4 files changed, 91 insertions(+), 27 deletions(-) diff --git a/DifficultyMod/Core/DifficultyPatcher.cs b/DifficultyMod/Core/DifficultyPatcher.cs index 89beeff..9c674c3 100644 --- a/DifficultyMod/Core/DifficultyPatcher.cs +++ b/DifficultyMod/Core/DifficultyPatcher.cs @@ -1,8 +1,10 @@ using Boardgame; using Boardgame.BoardEntities; +using Boardgame.BoardgameActions; using Boardgame.Data; using Boardgame.Networking; using Boardgame.SerializableEvents; +using DataKeys; using HarmonyLib; using System.Collections.Generic; using System.Reflection; @@ -55,7 +57,7 @@ public static int ModifyEnemyAttackMultiplier(int defaultAttack, PieceConfig pie private static bool IsPrivateGame() { - CreateGameMode gameMode = (CreateGameMode)(typeof(GameStateMachine).GetField("createGameMode", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(StateMachine)); + CreateGameMode gameMode = (CreateGameMode) typeof(GameStateMachine).GetField("createGameMode", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(StateMachine); return gameMode == CreateGameMode.Private; } @@ -137,5 +139,17 @@ static void Postfix(SerializableEventPickup __instance) } } } + + [HarmonyPatch(typeof(CardHandController), "GetCardSellValue")] + class CardSaleMultiplierPatcher + { + static void Postfix(ref int __result) + { + if (IsPrivateGame()) + { + __result = (int) (__result * DifficultySettings.CardSaleMultiplier); + } + } + } } } diff --git a/DifficultyMod/Core/DifficultySettings.cs b/DifficultyMod/Core/DifficultySettings.cs index f688a0f..5fea920 100644 --- a/DifficultyMod/Core/DifficultySettings.cs +++ b/DifficultyMod/Core/DifficultySettings.cs @@ -10,6 +10,7 @@ public static class DifficultySettings private const string MELON_PREF_ENEMY_ATTACK_MULTIPLIER_NAME = "EnemyAttackMultiplier"; private const string MELON_PREF_ENERGY_GAIN_MULTIPLIER_NAME = "EnergyGainMultiplier"; private const string MELON_PREF_GOLD_PILE_GAIN_MULTIPLIER_NAME = "GoldGainMultiplier"; + private const string MELON_PREF_CARD_SALE_MULTIPLIER_NAME = "CardSaleMultiplier"; private const float ENEMY_HP_MULTIPLIER_MIN = 0.25f; private const float ENEMY_HP_MULTIPLIER_MAX = 5f; @@ -19,14 +20,17 @@ public static class DifficultySettings private const float ENERGY_GAIN_MULTIPLIER_MAX = 5f; private const float GOLD_PILE_GAIN_MULTIPLIER_MIN = 0.1f; private const float GOLD_PILE_GAIN_MULTIPLIER_MAX = 5f; + private const float CARD_SALE_MULTIPLIER_MIN = 0.1f; + private const float CARD_SALE_MULTIPLIER_MAX = 5f; public static void RegisterSettings() { MelonPreferences.CreateCategory(MELON_PREF_NAME, "Demeo Difficulty Settings"); - MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_ENEMY_HP_MULTIPLIER_NAME, 1f, "Enemy HP Multiplier"); - MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_ENEMY_ATTACK_MULTIPLIER_NAME, 1f, "Enemy Attack Multiplier"); - MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_ENERGY_GAIN_MULTIPLIER_NAME, 1f, "Energy Gain Multiplier"); - MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_GOLD_PILE_GAIN_MULTIPLIER_NAME, 1f, "Gold Pile Gain Multiplier"); + MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_ENEMY_HP_MULTIPLIER_NAME, 1f, "Enemy HP"); + MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_ENEMY_ATTACK_MULTIPLIER_NAME, 1f, "Enemy Attack"); + MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_ENERGY_GAIN_MULTIPLIER_NAME, 1f, "Energy Gain"); + MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_GOLD_PILE_GAIN_MULTIPLIER_NAME, 1f, "Gold Gained From Gold Pile"); + MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_CARD_SALE_MULTIPLIER_NAME, 1f, "Gold Gained From Selling Cards"); } public static float EnemyHPMultiplier @@ -79,6 +83,19 @@ public static float GoldPileGainMultiplier } + public static float CardSaleMultiplier + { + get + { + return MelonPreferences.GetEntryValue(MELON_PREF_NAME, MELON_PREF_CARD_SALE_MULTIPLIER_NAME); + } + set + { + MelonPreferences.SetEntryValue(MELON_PREF_NAME, MELON_PREF_CARD_SALE_MULTIPLIER_NAME, value); + } + + } + public static void DecreaseEnemyHPMultiplier(Action callBack) { if (EnemyHPMultiplier > ENEMY_HP_MULTIPLIER_MIN) @@ -146,7 +163,7 @@ public static void DecreaseGoldPileGainMultiplier(Action callBack) GoldPileGainMultiplier = (float)Math.Round(GoldPileGainMultiplier - 0.1f, 2); } - callBack(EnergyGainMultiplier); + callBack(GoldPileGainMultiplier); } public static void IncreaseGoldPileGainMultiplier(Action callBack) @@ -158,5 +175,25 @@ public static void IncreaseGoldPileGainMultiplier(Action callBack) callBack(GoldPileGainMultiplier); } + + public static void DecreaseCardSaleMultiplier(Action callBack) + { + if (CardSaleMultiplier > CARD_SALE_MULTIPLIER_MIN) + { + CardSaleMultiplier = (float)Math.Round(CardSaleMultiplier - 0.1f, 2); + } + + callBack(CardSaleMultiplier); + } + + public static void IncreaseCardSaleMultiplier(Action callBack) + { + if (CardSaleMultiplier < CARD_SALE_MULTIPLIER_MAX) + { + CardSaleMultiplier = (float)Math.Round(CardSaleMultiplier + 0.1f, 2); + } + + callBack(CardSaleMultiplier); + } } } \ No newline at end of file diff --git a/DifficultyMod/Properties/AssemblyInfo.cs b/DifficultyMod/Properties/AssemblyInfo.cs index 2de7338..e0659e2 100644 --- a/DifficultyMod/Properties/AssemblyInfo.cs +++ b/DifficultyMod/Properties/AssemblyInfo.cs @@ -18,7 +18,7 @@ // Melon Loader -[assembly: MelonInfo(typeof(DifficultyMod), "Difficulty Mod", "0.1.1", "Reena")] +[assembly: MelonInfo(typeof(DifficultyMod), "Difficulty Mod", "0.2", "Reena")] [assembly: MelonGame("Resolution Games", "Demeo")] // Setting ComVisible to false makes the types in this assembly not visible diff --git a/DifficultyMod/UI/DifficultyMenu.cs b/DifficultyMod/UI/DifficultyMenu.cs index 6cd5dd0..c8b84d2 100644 --- a/DifficultyMod/UI/DifficultyMenu.cs +++ b/DifficultyMod/UI/DifficultyMenu.cs @@ -52,24 +52,24 @@ public void Initialize() // Enemy HP Multiplier GameObject enemyHPMultiplier = CreateContainer(difficultySettingsPageOne.transform, "Enemy HP Multiplier"); - CreateText(enemyHPMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 3.25f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy HP Multiplier", TextAlignmentOptions.Center, FontStyles.Normal); - TextMeshPro enemyHPMultiplierValue = CreateText(enemyHPMultiplier.transform, new Vector3(0.036f, 0.15f, 0.4f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy HP Multiplier Text", DifficultySettings.EnemyHPMultiplier.ToString(), TextAlignmentOptions.Center, FontStyles.Normal); - CreateButton(enemyHPMultiplier.transform, new Vector3(-1f, 0.15f, 0.4f), "Enemy HP Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnemyHPMultiplier(text => { UpdateText(enemyHPMultiplierValue, text); }); }); - CreateButton(enemyHPMultiplier.transform, new Vector3(1.1f, 0.15f, 0.4f), "Enemy HP Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnemyHPMultiplier(text => { UpdateText(enemyHPMultiplierValue, text); }); }); + CreateText(enemyHPMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy HP", TextAlignmentOptions.Center, FontStyles.Normal); + TextMeshPro enemyHPMultiplierValue = CreateText(enemyHPMultiplier.transform, new Vector3(0.036f, 0.15f, 0.4f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy HP Multiplier Text", floatToPercentStr(DifficultySettings.EnemyHPMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); + CreateButton(enemyHPMultiplier.transform, new Vector3(-1.2f, 0.15f, 0.4f), "Enemy HP Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnemyHPMultiplier(text => { UpdateText(enemyHPMultiplierValue, text); }); }); + CreateButton(enemyHPMultiplier.transform, new Vector3(1.3f, 0.15f, 0.4f), "Enemy HP Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnemyHPMultiplier(text => { UpdateText(enemyHPMultiplierValue, text); }); }); // Enemy Attack Multiplier GameObject enemyAttackMultiplier = CreateContainer(difficultySettingsPageOne.transform, "Enemy Attack Multiplier"); - CreateText(enemyAttackMultiplier.transform, new Vector3(0.036f, 0.15f, -.6f), 3.25f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy Attack Multiplier", TextAlignmentOptions.Center, FontStyles.Normal); - TextMeshPro enemyAttackMultiplierValue = CreateText(enemyAttackMultiplier.transform, new Vector3(0.036f, 0.15f, -1.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy Attack Multiplier Text", DifficultySettings.EnemyAttackMultiplier.ToString(), TextAlignmentOptions.Center, FontStyles.Normal); - CreateButton(enemyAttackMultiplier.transform, new Vector3(-1f, 0.15f, -1.6f), "Enemy Attack Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnemyAttackMultiplier(text => { UpdateText(enemyAttackMultiplierValue, text); }); }); - CreateButton(enemyAttackMultiplier.transform, new Vector3(1.1f, 0.15f, -1.6f), "Enemy Attack Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnemyAttackMultiplier(text => { UpdateText(enemyAttackMultiplierValue, text); }); }); + CreateText(enemyAttackMultiplier.transform, new Vector3(0.036f, 0.15f, -.6f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy Attack", TextAlignmentOptions.Center, FontStyles.Normal); + TextMeshPro enemyAttackMultiplierValue = CreateText(enemyAttackMultiplier.transform, new Vector3(0.036f, 0.15f, -1.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy Attack Multiplier Text", floatToPercentStr(DifficultySettings.EnemyAttackMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); + CreateButton(enemyAttackMultiplier.transform, new Vector3(-1.2f, 0.15f, -1.6f), "Enemy Attack Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnemyAttackMultiplier(text => { UpdateText(enemyAttackMultiplierValue, text); }); }); + CreateButton(enemyAttackMultiplier.transform, new Vector3(1.3f, 0.15f, -1.6f), "Enemy Attack Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnemyAttackMultiplier(text => { UpdateText(enemyAttackMultiplierValue, text); }); }); // Energy Gain Multiplier GameObject energyGainMultiplier = CreateContainer(difficultySettingsPageOne.transform, "Energy Gain Multiplier"); - CreateText(energyGainMultiplier.transform, new Vector3(0.036f, 0.15f, -2.6f), 3.25f, new Color(0.0392f, 0.0157f, 0, 1), "Energy Gain Multiplier", TextAlignmentOptions.Center, FontStyles.Normal); - TextMeshPro energyGainMultiplierValue = CreateText(energyGainMultiplier.transform, new Vector3(0.036f, 0.15f, -3.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Energy Gain Multiplier Text", DifficultySettings.EnergyGainMultiplier.ToString(), TextAlignmentOptions.Center, FontStyles.Normal); - CreateButton(energyGainMultiplier.transform, new Vector3(-1f, 0.15f, -3.6f), "Energy Gain Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnergyGainMultiplier(text => { UpdateText(energyGainMultiplierValue, text); }); }); - CreateButton(energyGainMultiplier.transform, new Vector3(1.1f, 0.15f, -3.6f), "Energy Gain Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnergyGainMultiplier(text => { UpdateText(energyGainMultiplierValue, text); }); }); + CreateText(energyGainMultiplier.transform, new Vector3(0.036f, 0.15f, -2.6f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Energy Gain", TextAlignmentOptions.Center, FontStyles.Normal); + TextMeshPro energyGainMultiplierValue = CreateText(energyGainMultiplier.transform, new Vector3(0.036f, 0.15f, -3.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Energy Gain Multiplier Text", floatToPercentStr(DifficultySettings.EnergyGainMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); + CreateButton(energyGainMultiplier.transform, new Vector3(-1.2f, 0.15f, -3.6f), "Energy Gain Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnergyGainMultiplier(text => { UpdateText(energyGainMultiplierValue, text); }); }); + CreateButton(energyGainMultiplier.transform, new Vector3(1.3f, 0.15f, -3.6f), "Energy Gain Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnergyGainMultiplier(text => { UpdateText(energyGainMultiplierValue, text); }); }); // Navigation Button GameObject pageOneNavigationButtons = CreateContainer(difficultySettingsPageOne.transform, "Navigation Buttons"); @@ -86,18 +86,26 @@ public void Initialize() // Header CreateText(difficultySettingsPageTwo.transform, new Vector3(0.036f, 0.15f, 2.4f), 3f, new Color(0.878f, 0.752f, 0.384f, 1), "Difficulty Menu", TextAlignmentOptions.Center, FontStyles.UpperCase); + // Gold Pile Multiplier + GameObject goldPileMultiplier = CreateContainer(difficultySettingsPageTwo.transform, "Gold Pile Multiplier"); + CreateText(goldPileMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Gold Pile Amount", TextAlignmentOptions.Center, FontStyles.Normal); + TextMeshPro goldPileMultiplierValue = CreateText(goldPileMultiplier.transform, new Vector3(0.036f, 0.15f, 0.4f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Gold Pile Multiplier Text", floatToPercentStr(DifficultySettings.GoldPileGainMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); + CreateButton(goldPileMultiplier.transform, new Vector3(-1.2f, 0.15f, 0.4f), "Gold Pile Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseGoldPileGainMultiplier(text => { UpdateText(goldPileMultiplierValue, text); }); }); + CreateButton(goldPileMultiplier.transform, new Vector3(1.3f, 0.15f, 0.4f), "Gold Pile Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseGoldPileGainMultiplier(text => { UpdateText(goldPileMultiplierValue, text); }); }); + + // Card Sale Multiplier + GameObject cardSaleMultiplier = CreateContainer(difficultySettingsPageTwo.transform, "Card Sale Multiplier"); + CreateText(cardSaleMultiplier.transform, new Vector3(0.036f, 0.15f, -0.6f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Card Selling Price", TextAlignmentOptions.Center, FontStyles.Normal); + TextMeshPro cardSaleMultiplierValue = CreateText(cardSaleMultiplier.transform, new Vector3(0.036f, 0.15f, -1.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Card Sale Multiplier Text", floatToPercentStr(DifficultySettings.CardSaleMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); + CreateButton(cardSaleMultiplier.transform, new Vector3(-1.2f, 0.15f, -1.6f), "Card Sale Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseCardSaleMultiplier(text => { UpdateText(cardSaleMultiplierValue, text); }); }); + CreateButton(cardSaleMultiplier.transform, new Vector3(1.3f, 0.15f, -1.6f), "Card Sale Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseCardSaleMultiplier(text => { UpdateText(cardSaleMultiplierValue, text); }); }); + // Navigation Button GameObject pageTwoNavigationButtons = CreateContainer(difficultySettingsPageTwo.transform, "Navigation Buttons"); CreateButton(pageTwoNavigationButtons.transform, new Vector3(-1.5f, 0.15f, -5.6f), "Previous Page", "DreadArrowDown", () => { ChangePage((currentPage - 1) % TOTAL_PAGES); }, new Vector3(0.7f, 0.7f, 0.7f)); CreateText(pageTwoNavigationButtons.transform, new Vector3(0.036f, 0.15f, -5.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Page 2", TextAlignmentOptions.Center, FontStyles.Normal); CreateButton(pageTwoNavigationButtons.transform, new Vector3(1.6f, 0.15f, -5.6f), "Next Page", "DreadArrowUp", () => { ChangePage((currentPage + 1) % TOTAL_PAGES); }, new Vector3(0.7f, 0.7f, 0.7f)); - // Gold Pile Multiplier - GameObject goldPileMultiplier = CreateContainer(difficultySettingsPageTwo.transform, "Gold Pile Multiplier"); - CreateText(goldPileMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 3.25f, new Color(0.0392f, 0.0157f, 0, 1), "Gold Pile Multiplier", TextAlignmentOptions.Center, FontStyles.Normal); - TextMeshPro goldPileMultiplierValue = CreateText(goldPileMultiplier.transform, new Vector3(0.036f, 0.15f, 0.4f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Gold Pile Multiplier Text", DifficultySettings.GoldPileGainMultiplier.ToString(), TextAlignmentOptions.Center, FontStyles.Normal); - CreateButton(goldPileMultiplier.transform, new Vector3(-1f, 0.15f, 0.4f), "Gold Pile Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseGoldPileGainMultiplier(text => { UpdateText(goldPileMultiplierValue, text); }); }); - CreateButton(goldPileMultiplier.transform, new Vector3(1.1f, 0.15f, 0.4f), "Gold Pile Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseGoldPileGainMultiplier(text => { UpdateText(goldPileMultiplierValue, text); }); }); #endregion Second_Page MelonLogger.Msg("Initialized UI Elements."); @@ -120,9 +128,14 @@ private static void ChangePage(int newPage) } } - private static void UpdateText(TextMeshPro textMeshPro, float text) + private static string floatToPercentStr(float number) + { + return number * 100 + "%"; + } + + private static void UpdateText(TextMeshPro textMeshPro, float number) { - textMeshPro.SetText(text.ToString()); + textMeshPro.SetText(floatToPercentStr(number)); } private static GameObject CreateContainer(Transform parent, string containerName) From 4cfa0463a308f0869da6581d6a07c40eb042304e Mon Sep 17 00:00:00 2001 From: Pokachi Date: Sun, 30 May 2021 17:38:54 -0700 Subject: [PATCH 2/4] Add card cost multiplier --- DifficultyMod/Core/DifficultyPatcher.cs | 45 +++++++++++++++++++++--- DifficultyMod/Core/DifficultySettings.cs | 41 +++++++++++++++++++++ DifficultyMod/UI/DifficultyMenu.cs | 17 ++++++--- 3 files changed, 94 insertions(+), 9 deletions(-) diff --git a/DifficultyMod/Core/DifficultyPatcher.cs b/DifficultyMod/Core/DifficultyPatcher.cs index 9c674c3..bd34a44 100644 --- a/DifficultyMod/Core/DifficultyPatcher.cs +++ b/DifficultyMod/Core/DifficultyPatcher.cs @@ -1,10 +1,9 @@ using Boardgame; using Boardgame.BoardEntities; -using Boardgame.BoardgameActions; +using Boardgame.Cards; using Boardgame.Data; using Boardgame.Networking; using Boardgame.SerializableEvents; -using DataKeys; using HarmonyLib; using System.Collections.Generic; using System.Reflection; @@ -32,7 +31,7 @@ public static int ModifyEnemyHPMultiplier(int defaultHP, PieceConfig pieceConfig if (pieceConfig.HasPieceType(DataKeys.PieceType.Enemy)) { - return (int)(defaultHP * DifficultySettings.EnemyHPMultiplier); + return (int) (defaultHP * DifficultySettings.EnemyHPMultiplier); } return defaultHP; @@ -49,7 +48,7 @@ public static int ModifyEnemyAttackMultiplier(int defaultAttack, PieceConfig pie if (pieceConfig.HasPieceType(DataKeys.PieceType.Enemy)) { - return (int)(defaultAttack * DifficultySettings.EnemyAttackMultiplier); + return (int) (defaultAttack * DifficultySettings.EnemyAttackMultiplier); } return defaultAttack; @@ -151,5 +150,43 @@ static void Postfix(ref int __result) } } } + + + public static int ModifyCardCostInShop(int defaultCardCost) + { + + // Do not modify the Attack if the game is public (i.e. anyone can join without room code) + if (!IsPrivateGame()) + { + return defaultCardCost; + } + + return (int) (defaultCardCost * DifficultySettings.CardCostMultiplier); + } + + [HarmonyPatch(typeof(CardShopView), "Show", typeof(CardShopEntry[]), typeof(ICardCategoryProvider))] + class CardCosMultiplierPatcher + { + static MethodInfo m_MyExtraMethod = AccessTools.Method(typeof(DifficultyPatcher), nameof(ModifyCardCostInShop), new[] { typeof(int) }); + + static IEnumerable Transpiler(IEnumerable instructions) + { + foreach (CodeInstruction instruction in instructions) + { + if (instruction.opcode == OpCodes.Ldfld) + { + string strOperand = instruction.operand.ToString(); + if (strOperand.Contains("System.Int32 cost")) + { + yield return instruction; + yield return new CodeInstruction(OpCodes.Call, m_MyExtraMethod); + + continue; + } + } + yield return instruction; + } + } + } } } diff --git a/DifficultyMod/Core/DifficultySettings.cs b/DifficultyMod/Core/DifficultySettings.cs index 5fea920..ce39539 100644 --- a/DifficultyMod/Core/DifficultySettings.cs +++ b/DifficultyMod/Core/DifficultySettings.cs @@ -11,6 +11,7 @@ public static class DifficultySettings private const string MELON_PREF_ENERGY_GAIN_MULTIPLIER_NAME = "EnergyGainMultiplier"; private const string MELON_PREF_GOLD_PILE_GAIN_MULTIPLIER_NAME = "GoldGainMultiplier"; private const string MELON_PREF_CARD_SALE_MULTIPLIER_NAME = "CardSaleMultiplier"; + private const string MELON_PREF_CARD_COST_MULTIPLIER_NAME = "CardCostMultiplier"; private const float ENEMY_HP_MULTIPLIER_MIN = 0.25f; private const float ENEMY_HP_MULTIPLIER_MAX = 5f; @@ -22,6 +23,8 @@ public static class DifficultySettings private const float GOLD_PILE_GAIN_MULTIPLIER_MAX = 5f; private const float CARD_SALE_MULTIPLIER_MIN = 0.1f; private const float CARD_SALE_MULTIPLIER_MAX = 5f; + private const float CARD_COST_MULTIPLIER_MIN = 0.1f; + private const float CARD_COST_MULTIPLIER_MAX = 5f; public static void RegisterSettings() { @@ -31,8 +34,10 @@ public static void RegisterSettings() MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_ENERGY_GAIN_MULTIPLIER_NAME, 1f, "Energy Gain"); MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_GOLD_PILE_GAIN_MULTIPLIER_NAME, 1f, "Gold Gained From Gold Pile"); MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_CARD_SALE_MULTIPLIER_NAME, 1f, "Gold Gained From Selling Cards"); + MelonPreferences.CreateEntry(MELON_PREF_NAME, MELON_PREF_CARD_COST_MULTIPLIER_NAME, 1f, "Gold Cost When Buying Cards"); } + #region Properties public static float EnemyHPMultiplier { get @@ -96,6 +101,21 @@ public static float CardSaleMultiplier } + public static float CardCostMultiplier + { + get + { + return MelonPreferences.GetEntryValue(MELON_PREF_NAME, MELON_PREF_CARD_COST_MULTIPLIER_NAME); + } + set + { + MelonPreferences.SetEntryValue(MELON_PREF_NAME, MELON_PREF_CARD_COST_MULTIPLIER_NAME, value); + } + + } + #endregion Properties + + #region Property_Modifier public static void DecreaseEnemyHPMultiplier(Action callBack) { if (EnemyHPMultiplier > ENEMY_HP_MULTIPLIER_MIN) @@ -195,5 +215,26 @@ public static void IncreaseCardSaleMultiplier(Action callBack) callBack(CardSaleMultiplier); } + + public static void DecreaseCardCostMultiplier(Action callBack) + { + if (CardCostMultiplier > CARD_COST_MULTIPLIER_MIN) + { + CardCostMultiplier = (float)Math.Round(CardCostMultiplier - 0.1f, 2); + } + + callBack(CardCostMultiplier); + } + + public static void IncreaseCardCostMultiplier(Action callBack) + { + if (CardCostMultiplier < CARD_COST_MULTIPLIER_MAX) + { + CardCostMultiplier = (float)Math.Round(CardCostMultiplier + 0.1f, 2); + } + + callBack(CardCostMultiplier); + } + #endregion Property_Modifier } } \ No newline at end of file diff --git a/DifficultyMod/UI/DifficultyMenu.cs b/DifficultyMod/UI/DifficultyMenu.cs index c8b84d2..2d11a79 100644 --- a/DifficultyMod/UI/DifficultyMenu.cs +++ b/DifficultyMod/UI/DifficultyMenu.cs @@ -52,21 +52,21 @@ public void Initialize() // Enemy HP Multiplier GameObject enemyHPMultiplier = CreateContainer(difficultySettingsPageOne.transform, "Enemy HP Multiplier"); - CreateText(enemyHPMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy HP", TextAlignmentOptions.Center, FontStyles.Normal); + CreateText(enemyHPMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 4.4f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy HP", TextAlignmentOptions.Center, FontStyles.Normal); TextMeshPro enemyHPMultiplierValue = CreateText(enemyHPMultiplier.transform, new Vector3(0.036f, 0.15f, 0.4f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy HP Multiplier Text", floatToPercentStr(DifficultySettings.EnemyHPMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); CreateButton(enemyHPMultiplier.transform, new Vector3(-1.2f, 0.15f, 0.4f), "Enemy HP Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnemyHPMultiplier(text => { UpdateText(enemyHPMultiplierValue, text); }); }); CreateButton(enemyHPMultiplier.transform, new Vector3(1.3f, 0.15f, 0.4f), "Enemy HP Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnemyHPMultiplier(text => { UpdateText(enemyHPMultiplierValue, text); }); }); // Enemy Attack Multiplier GameObject enemyAttackMultiplier = CreateContainer(difficultySettingsPageOne.transform, "Enemy Attack Multiplier"); - CreateText(enemyAttackMultiplier.transform, new Vector3(0.036f, 0.15f, -.6f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy Attack", TextAlignmentOptions.Center, FontStyles.Normal); + CreateText(enemyAttackMultiplier.transform, new Vector3(0.036f, 0.15f, -.6f), 4.4f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy Attack", TextAlignmentOptions.Center, FontStyles.Normal); TextMeshPro enemyAttackMultiplierValue = CreateText(enemyAttackMultiplier.transform, new Vector3(0.036f, 0.15f, -1.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Enemy Attack Multiplier Text", floatToPercentStr(DifficultySettings.EnemyAttackMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); CreateButton(enemyAttackMultiplier.transform, new Vector3(-1.2f, 0.15f, -1.6f), "Enemy Attack Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnemyAttackMultiplier(text => { UpdateText(enemyAttackMultiplierValue, text); }); }); CreateButton(enemyAttackMultiplier.transform, new Vector3(1.3f, 0.15f, -1.6f), "Enemy Attack Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnemyAttackMultiplier(text => { UpdateText(enemyAttackMultiplierValue, text); }); }); // Energy Gain Multiplier GameObject energyGainMultiplier = CreateContainer(difficultySettingsPageOne.transform, "Energy Gain Multiplier"); - CreateText(energyGainMultiplier.transform, new Vector3(0.036f, 0.15f, -2.6f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Energy Gain", TextAlignmentOptions.Center, FontStyles.Normal); + CreateText(energyGainMultiplier.transform, new Vector3(0.036f, 0.15f, -2.6f), 4.4f, new Color(0.0392f, 0.0157f, 0, 1), "Energy Gain", TextAlignmentOptions.Center, FontStyles.Normal); TextMeshPro energyGainMultiplierValue = CreateText(energyGainMultiplier.transform, new Vector3(0.036f, 0.15f, -3.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Energy Gain Multiplier Text", floatToPercentStr(DifficultySettings.EnergyGainMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); CreateButton(energyGainMultiplier.transform, new Vector3(-1.2f, 0.15f, -3.6f), "Energy Gain Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseEnergyGainMultiplier(text => { UpdateText(energyGainMultiplierValue, text); }); }); CreateButton(energyGainMultiplier.transform, new Vector3(1.3f, 0.15f, -3.6f), "Energy Gain Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseEnergyGainMultiplier(text => { UpdateText(energyGainMultiplierValue, text); }); }); @@ -88,18 +88,25 @@ public void Initialize() // Gold Pile Multiplier GameObject goldPileMultiplier = CreateContainer(difficultySettingsPageTwo.transform, "Gold Pile Multiplier"); - CreateText(goldPileMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Gold Pile Amount", TextAlignmentOptions.Center, FontStyles.Normal); + CreateText(goldPileMultiplier.transform, new Vector3(0.036f, 0.15f, 1.4f), 4.4f, new Color(0.0392f, 0.0157f, 0, 1), "Gold Pile Amount", TextAlignmentOptions.Center, FontStyles.Normal); TextMeshPro goldPileMultiplierValue = CreateText(goldPileMultiplier.transform, new Vector3(0.036f, 0.15f, 0.4f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Gold Pile Multiplier Text", floatToPercentStr(DifficultySettings.GoldPileGainMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); CreateButton(goldPileMultiplier.transform, new Vector3(-1.2f, 0.15f, 0.4f), "Gold Pile Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseGoldPileGainMultiplier(text => { UpdateText(goldPileMultiplierValue, text); }); }); CreateButton(goldPileMultiplier.transform, new Vector3(1.3f, 0.15f, 0.4f), "Gold Pile Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseGoldPileGainMultiplier(text => { UpdateText(goldPileMultiplierValue, text); }); }); // Card Sale Multiplier GameObject cardSaleMultiplier = CreateContainer(difficultySettingsPageTwo.transform, "Card Sale Multiplier"); - CreateText(cardSaleMultiplier.transform, new Vector3(0.036f, 0.15f, -0.6f), 4.5f, new Color(0.0392f, 0.0157f, 0, 1), "Card Selling Price", TextAlignmentOptions.Center, FontStyles.Normal); + CreateText(cardSaleMultiplier.transform, new Vector3(0.036f, 0.15f, -0.6f), 4.4f, new Color(0.0392f, 0.0157f, 0, 1), "Card Selling Price", TextAlignmentOptions.Center, FontStyles.Normal); TextMeshPro cardSaleMultiplierValue = CreateText(cardSaleMultiplier.transform, new Vector3(0.036f, 0.15f, -1.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Card Sale Multiplier Text", floatToPercentStr(DifficultySettings.CardSaleMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); CreateButton(cardSaleMultiplier.transform, new Vector3(-1.2f, 0.15f, -1.6f), "Card Sale Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseCardSaleMultiplier(text => { UpdateText(cardSaleMultiplierValue, text); }); }); CreateButton(cardSaleMultiplier.transform, new Vector3(1.3f, 0.15f, -1.6f), "Card Sale Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseCardSaleMultiplier(text => { UpdateText(cardSaleMultiplierValue, text); }); }); + // Card Cost Multiplier + GameObject cardCostMultiplier = CreateContainer(difficultySettingsPageTwo.transform, "Card Cost Multiplier"); + CreateText(cardCostMultiplier.transform, new Vector3(0.036f, 0.15f, -2.6f), 4.4f, new Color(0.0392f, 0.0157f, 0, 1), "Card Buying Price", TextAlignmentOptions.Center, FontStyles.Normal); + TextMeshPro cardCostMultiplierValue = CreateText(cardCostMultiplier.transform, new Vector3(0.036f, 0.15f, -3.6f), 7f, new Color(0.0392f, 0.0157f, 0, 1), "Card Cost Multiplier Text", floatToPercentStr(DifficultySettings.CardCostMultiplier), TextAlignmentOptions.Center, FontStyles.Normal); + CreateButton(cardCostMultiplier.transform, new Vector3(-1.2f, 0.15f, -3.6f), "Card Cost Multiplier Down", "DreadArrowDown", () => { DifficultySettings.DecreaseCardCostMultiplier(text => { UpdateText(cardCostMultiplierValue, text); }); }); + CreateButton(cardCostMultiplier.transform, new Vector3(1.3f, 0.15f, -3.6f), "Card Cost Multiplier Up", "DreadArrowUp", () => { DifficultySettings.IncreaseCardCostMultiplier(text => { UpdateText(cardCostMultiplierValue, text); }); }); + // Navigation Button GameObject pageTwoNavigationButtons = CreateContainer(difficultySettingsPageTwo.transform, "Navigation Buttons"); CreateButton(pageTwoNavigationButtons.transform, new Vector3(-1.5f, 0.15f, -5.6f), "Previous Page", "DreadArrowDown", () => { ChangePage((currentPage - 1) % TOTAL_PAGES); }, new Vector3(0.7f, 0.7f, 0.7f)); From 28ec71c17f21beecd0cb602f820b512196660e66 Mon Sep 17 00:00:00 2001 From: Pokachi <38444751+Pokachi@users.noreply.github.com> Date: Sun, 30 May 2021 17:49:59 -0700 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 565b8c7..c854114 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This mod depends on MelonLoader v0.3.1, available [here](https://github.com/Lava 1. Once MelonLoader is installed, run the game once to setup all the directories. # INSTALLATION: -1. Go to the [releases](https://github.com/Pokachi/DemeoMods/releases/tag/0.1) tab and download the DifficultyMod.dll file from the latest release. +1. Go to the [releases](https://github.com/Pokachi/DemeoMods/releases) tab and download the DifficultyMod.dll file from the latest release. 1. Put the DifficultyMod.dll under Mod folder created by MelonLoader in your game directory. From 02a42e3e704e2dbf4d4930cb4469f8f8b7ef2015 Mon Sep 17 00:00:00 2001 From: Pokachi <38444751+Pokachi@users.noreply.github.com> Date: Sun, 30 May 2021 17:50:59 -0700 Subject: [PATCH 4/4] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c854114..2076cdc 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,11 @@ Difficulty Mods is currently working in progress. This mod aims to adjust variou 1. Adjust Enemy HP 1. Adjust Enemy Damage 1. Adjust Energy Gain from discard, killing enemy, and attacking (might separate this into 3 separating settings, not sure) -1. Adjust Gold Gain from Gold Piles +1. Adjust Gold Gained from Gold Piles +1. Adjust Card Selling Price in the Shop in between Levels. +1. Adjust Card Costs in the Shops in between Levels. ### Planned Features -1. Selling Card Multiplier 1. Enable Enemy Opening Doors Toggle 1. Enable Coin Flip Toggle 1. Ability to Set Coin Flip Damage