From 0fbd49f36ae3bca02d4f97ef1295029a4d77c8ed Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sat, 23 Aug 2025 18:47:42 +0200 Subject: [PATCH] Add new miracles: Divine Mandate and Prosperity Boom; update buff application logic and game state calculations --- Mods/Miracles/communal_effort.json | 4 ---- Mods/Miracles/divine_mandate.json | 18 ++++++++++++++++ Mods/Miracles/prosperity_boom.json | 16 ++++++++++++++ Mods/Miracles/unlock_age_of_industry.json | 1 + Mods/Miracles/unlock_settlement.json | 11 +++++++++- Scripts/Core/Effects/ApplyBuffEffect.cs | 4 +++- Scripts/Core/Effects/Buff.cs | 7 +++--- Scripts/Core/GameLogic.cs | 26 +++++++++++++++++++---- Scripts/Core/GameState.cs | 1 + Scripts/Singletons/GameBus.cs | 2 +- 10 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 Mods/Miracles/divine_mandate.json create mode 100644 Mods/Miracles/prosperity_boom.json diff --git a/Mods/Miracles/communal_effort.json b/Mods/Miracles/communal_effort.json index 92b5cb4..d30aa43 100644 --- a/Mods/Miracles/communal_effort.json +++ b/Mods/Miracles/communal_effort.json @@ -13,10 +13,6 @@ "type": "AddResource", "targetResource": "Corruption", "value": 3 - }, - { - "type": "UnlockMiracle", - "miraclesToUnlock": [ "unlock_age_of_industry" ] } ] } diff --git a/Mods/Miracles/divine_mandate.json b/Mods/Miracles/divine_mandate.json new file mode 100644 index 0000000..274b2f6 --- /dev/null +++ b/Mods/Miracles/divine_mandate.json @@ -0,0 +1,18 @@ +{ + "name": "Divine Mandate", + "faithCost": 1500, + "followersRequired": 350, + "productionRequired": 100, + "unlockedByDefault": false, + "effects": [ + { + "type": "ModifyStat", + "targetStat": "FollowersPerSecond", + "op": "Add", + "value": 0.5 + }, + { + "type": "DestroySelf" + } + ] +} diff --git a/Mods/Miracles/prosperity_boom.json b/Mods/Miracles/prosperity_boom.json new file mode 100644 index 0000000..49dd776 --- /dev/null +++ b/Mods/Miracles/prosperity_boom.json @@ -0,0 +1,16 @@ +{ + "name": "Prosperity Boom", + "faithCost": 2000, + "followersRequired": 1200, + "productionRequired": 800, + "unlockedByDefault": false, + "effects": [ + { + "type": "ApplyBuff", + "buffId": "prosperity_buff", + "targetStat": "FollowersPerSecond", + "multiplier": 5.0, + "duration": 60 + } + ] +} diff --git a/Mods/Miracles/unlock_age_of_industry.json b/Mods/Miracles/unlock_age_of_industry.json index 54ca36f..547be93 100644 --- a/Mods/Miracles/unlock_age_of_industry.json +++ b/Mods/Miracles/unlock_age_of_industry.json @@ -14,6 +14,7 @@ "globalization", "harness_the_sun", "tame_the_atom", + "prosperity_boom", "unlock_space_age" ] }, diff --git a/Mods/Miracles/unlock_settlement.json b/Mods/Miracles/unlock_settlement.json index 824779f..8dce181 100644 --- a/Mods/Miracles/unlock_settlement.json +++ b/Mods/Miracles/unlock_settlement.json @@ -6,7 +6,16 @@ "effects": [ { "type": "UnlockMiracle", - "miraclesToUnlock": [ "erect_shrine", "communal_effort", "sustainable_practices", "ritual_of_cleansing", "gods_endurance", "geological_survey" ] + "miraclesToUnlock": [ + "erect_shrine", + "communal_effort", + "sustainable_practices", + "ritual_of_cleansing", + "gods_endurance", + "geological_survey", + "divine_mandate", + "unlock_age_of_industry" + ] }, { "type": "DestroySelf" } ], diff --git a/Scripts/Core/Effects/ApplyBuffEffect.cs b/Scripts/Core/Effects/ApplyBuffEffect.cs index 8d40908..bcd94e8 100644 --- a/Scripts/Core/Effects/ApplyBuffEffect.cs +++ b/Scripts/Core/Effects/ApplyBuffEffect.cs @@ -23,7 +23,9 @@ public partial class ApplyBuffEffect : Effect { Name = $"{TargetStat} x{Multiplier}", Multiplier = Multiplier, - Duration = Duration + Duration = Duration, + TargetStat = TargetStat, + BuffId = BuffId }; gameState.ActiveBuffs.Add(newBuff); diff --git a/Scripts/Core/Effects/Buff.cs b/Scripts/Core/Effects/Buff.cs index 0bafe85..e62bc16 100644 --- a/Scripts/Core/Effects/Buff.cs +++ b/Scripts/Core/Effects/Buff.cs @@ -4,9 +4,10 @@ namespace ParasiticGod.Scripts.Core.Effects; public class Buff { - public Guid InstanceId { get; } = Guid.NewGuid(); // Unique identifier - public string BuffId { get; set; } // Identifier for the type of buff - public string Name { get; set; } // For display purposes + public Guid InstanceId { get; } = Guid.NewGuid(); + public string BuffId { get; set; } + public string Name { get; set; } + public Stat TargetStat { get; set; } public float Multiplier { get; set; } = 1.0f; public double Duration { get; set; } } \ No newline at end of file diff --git a/Scripts/Core/GameLogic.cs b/Scripts/Core/GameLogic.cs index 0922a64..f6432dd 100644 --- a/Scripts/Core/GameLogic.cs +++ b/Scripts/Core/GameLogic.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using ParasiticGod.Scripts.Singletons; namespace ParasiticGod.Scripts.Core; @@ -12,12 +13,29 @@ public class GameLogic { totalMultiplier *= buff.Multiplier; } - var faithPerSecond = state.Get(Stat.Followers) * state.Get(Stat.FaithPerFollower) * totalMultiplier; + + var faithMultiplier = state.ActiveBuffs + .Where(b => b.TargetStat == Stat.FaithPerFollower) + .Aggregate(1.0f, (acc, buff) => acc * buff.Multiplier); + var productionMultiplier = state.ActiveBuffs + .Where(b => b.TargetStat == Stat.ProductionPerSecond) + .Aggregate(1.0f, (acc, buff) => acc * buff.Multiplier); + var followerMultiplier = state.ActiveBuffs + .Where(b => b.TargetStat == Stat.FollowersPerSecond) + .Aggregate(1.0f, (acc, buff) => acc * buff.Multiplier); + var corruptionMultiplier = state.ActiveBuffs + .Where(b => b.TargetStat == Stat.CorruptionPerSecond) + .Aggregate(1.0f, (acc, buff) => acc * buff.Multiplier); + + var faithPerSecond = state.Get(Stat.Followers) * state.Get(Stat.FaithPerFollower) * faithMultiplier; + var productionPerSecond = state.Get(Stat.ProductionPerSecond) * productionMultiplier; + var followersPerSecond = state.Get(Stat.FollowersPerSecond) * followerMultiplier; + var corruptionPerSecond = state.Get(Stat.CorruptionPerSecond) * corruptionMultiplier; state.Modify(Stat.Faith, faithPerSecond * delta); - state.Modify(Stat.Production, state.Get(Stat.ProductionPerSecond) * delta); - state.Modify(Stat.Corruption, state.Get(Stat.CorruptionPerSecond) * delta); - state.Modify(Stat.Followers, state.Get(Stat.FollowersPerSecond) * delta); + state.Modify(Stat.Production, productionPerSecond * delta); + state.Modify(Stat.Corruption, corruptionPerSecond * delta); + state.Modify(Stat.Followers, followersPerSecond * delta); for (var i = state.ActiveBuffs.Count - 1; i >= 0; i--) { diff --git a/Scripts/Core/GameState.cs b/Scripts/Core/GameState.cs index 019cb03..aaaa095 100644 --- a/Scripts/Core/GameState.cs +++ b/Scripts/Core/GameState.cs @@ -24,6 +24,7 @@ public class GameState Set(Stat.FaithPerFollower, 0.5); Set(Stat.ProductionPerSecond, 0.0); Set(Stat.CorruptionPerSecond, 0.01); + Set(Stat.FollowersPerSecond, 0); } public double Get(Stat stat) => _stats[stat].Value; diff --git a/Scripts/Singletons/GameBus.cs b/Scripts/Singletons/GameBus.cs index 9e80d6d..28e22a4 100644 --- a/Scripts/Singletons/GameBus.cs +++ b/Scripts/Singletons/GameBus.cs @@ -55,7 +55,7 @@ public partial class GameBus : Node { _gameLogic.UpdateGameState(_gameState, delta); StateChanged?.Invoke(_gameState); - + if (_gameState.Get(Stat.Corruption) >= 100) { GetTree().ChangeSceneToPacked(_gameOverScene);