Add new miracles: Divine Mandate and Prosperity Boom; update buff application logic and game state calculations

This commit is contained in:
2025-08-23 18:47:42 +02:00
parent 8ae0e7e80c
commit 0fbd49f36a
10 changed files with 76 additions and 14 deletions

View File

@@ -13,10 +13,6 @@
"type": "AddResource", "type": "AddResource",
"targetResource": "Corruption", "targetResource": "Corruption",
"value": 3 "value": 3
},
{
"type": "UnlockMiracle",
"miraclesToUnlock": [ "unlock_age_of_industry" ]
} }
] ]
} }

View File

@@ -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"
}
]
}

View File

@@ -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
}
]
}

View File

@@ -14,6 +14,7 @@
"globalization", "globalization",
"harness_the_sun", "harness_the_sun",
"tame_the_atom", "tame_the_atom",
"prosperity_boom",
"unlock_space_age" "unlock_space_age"
] ]
}, },

View File

@@ -6,7 +6,16 @@
"effects": [ "effects": [
{ {
"type": "UnlockMiracle", "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" } { "type": "DestroySelf" }
], ],

View File

@@ -23,7 +23,9 @@ public partial class ApplyBuffEffect : Effect
{ {
Name = $"{TargetStat} x{Multiplier}", Name = $"{TargetStat} x{Multiplier}",
Multiplier = Multiplier, Multiplier = Multiplier,
Duration = Duration Duration = Duration,
TargetStat = TargetStat,
BuffId = BuffId
}; };
gameState.ActiveBuffs.Add(newBuff); gameState.ActiveBuffs.Add(newBuff);

View File

@@ -4,9 +4,10 @@ namespace ParasiticGod.Scripts.Core.Effects;
public class Buff public class Buff
{ {
public Guid InstanceId { get; } = Guid.NewGuid(); // Unique identifier public Guid InstanceId { get; } = Guid.NewGuid();
public string BuffId { get; set; } // Identifier for the type of buff public string BuffId { get; set; }
public string Name { get; set; } // For display purposes public string Name { get; set; }
public Stat TargetStat { get; set; }
public float Multiplier { get; set; } = 1.0f; public float Multiplier { get; set; } = 1.0f;
public double Duration { get; set; } public double Duration { get; set; }
} }

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using ParasiticGod.Scripts.Singletons; using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scripts.Core; namespace ParasiticGod.Scripts.Core;
@@ -12,12 +13,29 @@ public class GameLogic
{ {
totalMultiplier *= buff.Multiplier; 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.Faith, faithPerSecond * delta);
state.Modify(Stat.Production, state.Get(Stat.ProductionPerSecond) * delta); state.Modify(Stat.Production, productionPerSecond * delta);
state.Modify(Stat.Corruption, state.Get(Stat.CorruptionPerSecond) * delta); state.Modify(Stat.Corruption, corruptionPerSecond * delta);
state.Modify(Stat.Followers, state.Get(Stat.FollowersPerSecond) * delta); state.Modify(Stat.Followers, followersPerSecond * delta);
for (var i = state.ActiveBuffs.Count - 1; i >= 0; i--) for (var i = state.ActiveBuffs.Count - 1; i >= 0; i--)
{ {

View File

@@ -24,6 +24,7 @@ public class GameState
Set(Stat.FaithPerFollower, 0.5); Set(Stat.FaithPerFollower, 0.5);
Set(Stat.ProductionPerSecond, 0.0); Set(Stat.ProductionPerSecond, 0.0);
Set(Stat.CorruptionPerSecond, 0.01); Set(Stat.CorruptionPerSecond, 0.01);
Set(Stat.FollowersPerSecond, 0);
} }
public double Get(Stat stat) => _stats[stat].Value; public double Get(Stat stat) => _stats[stat].Value;

View File

@@ -55,7 +55,7 @@ public partial class GameBus : Node
{ {
_gameLogic.UpdateGameState(_gameState, delta); _gameLogic.UpdateGameState(_gameState, delta);
StateChanged?.Invoke(_gameState); StateChanged?.Invoke(_gameState);
if (_gameState.Get(Stat.Corruption) >= 100) if (_gameState.Get(Stat.Corruption) >= 100)
{ {
GetTree().ChangeSceneToPacked(_gameOverScene); GetTree().ChangeSceneToPacked(_gameOverScene);