From bc4e3c7fd05a495234e3378a273e5e166882fbc4 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 24 Mar 2024 19:39:45 +0200
Subject: [PATCH 46/46] Add Culture_Pct effect type

See RM #353

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/daieffects.c             |  4 ++++
 common/culture.c                    | 10 ++++++++--
 doc/README.effects                  |  4 ++++
 gen_headers/enums/effects_enums.def |  1 +
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ai/default/daieffects.c b/ai/default/daieffects.c
index 3cca89aa71..a307ba9a8a 100644
--- a/ai/default/daieffects.c
+++ b/ai/default/daieffects.c
@@ -628,6 +628,10 @@ adv_want dai_effect_value(struct player *pplayer,
     /* ...and history effect to accumulate those points for 50 turns. */
     v += amount * 5;
     break;
+  case EFT_CULTURE_PCT:
+    /* Assume that this multiplies accumulation of 5 history points / turn */
+    v += amount * 5 * 5 / 100;
+    break;
   case EFT_TECH_COST_FACTOR:
     v -= amount * 50;
     break;
diff --git a/common/culture.c b/common/culture.c
index 6ce15f53ca..b6ead7ebcd 100644
--- a/common/culture.c
+++ b/common/culture.c
@@ -28,7 +28,9 @@
 ****************************************************************************/
 int city_culture(const struct city *pcity)
 {
-  return pcity->history + get_city_bonus(pcity, EFT_PERFORMANCE);
+  return pcity->history
+    + get_city_bonus(pcity, EFT_PERFORMANCE)
+    * (100 + get_city_bonus(pcity, EFT_CULTURE_PCT)) / 100;
 }
 
 /************************************************************************//**
@@ -37,6 +39,7 @@ int city_culture(const struct city *pcity)
 int city_history_gain(const struct city *pcity)
 {
   return get_city_bonus(pcity, EFT_HISTORY)
+    * (100 + get_city_bonus(pcity, EFT_CULTURE_PCT)) / 100
     + pcity->history * game.info.history_interest_pml / 1000;
 }
 
@@ -45,7 +48,9 @@ int city_history_gain(const struct city *pcity)
 ****************************************************************************/
 int player_culture(const struct player *plr)
 {
-  int culture = plr->history + get_player_bonus(plr, EFT_NATION_PERFORMANCE);
+  int culture = plr->history
+    + get_player_bonus(plr, EFT_NATION_PERFORMANCE)
+    * (100 + get_player_bonus(plr, EFT_CULTURE_PCT)) / 100;
 
   city_list_iterate(plr->cities, pcity) {
     culture += city_culture(pcity);
@@ -61,5 +66,6 @@ int player_culture(const struct player *plr)
 int nation_history_gain(const struct player *pplayer)
 {
   return get_player_bonus(pplayer, EFT_NATION_HISTORY)
+    * (100 + get_player_bonus(pplayer, EFT_CULTURE_PCT)) / 100
     + pplayer->history * game.info.history_interest_pml / 1000;
 }
diff --git a/doc/README.effects b/doc/README.effects
index 7d68e094b9..38e8d01d04 100644
--- a/doc/README.effects
+++ b/doc/README.effects
@@ -322,6 +322,10 @@ Conquest_Tech_Pct
     Percent chance that a player conquering a city learns a tech from the
     former owner.
 
+Culture_Pct
+    Percent change to culture, both to current performance and to
+    the accumulating history.
+
 Defend_Bonus
     Increases defensive bonuses of units. Any unit requirements on this effect
     will be applied to the _attacking_ unit type. Requirements about
diff --git a/gen_headers/enums/effects_enums.def b/gen_headers/enums/effects_enums.def
index 8bed19dbff..73d08870de 100644
--- a/gen_headers/enums/effects_enums.def
+++ b/gen_headers/enums/effects_enums.def
@@ -162,6 +162,7 @@ values
   SURPLUS_WASTE_PCT_BY_REL_DISTANCE "Surplus_Waste_Pct_By_Rel_Distance"
   TECH_LEAKAGE                      "Tech_Leakage"
   IMPR_UPKEEP_REDUCTION             "Impr_Upkeep_Reduction"
+  CULTURE_PCT                       "Culture_Pct"
   USER_EFFECT_1                     "User_Effect_1"
   USER_EFFECT_2                     "User_Effect_2"
   USER_EFFECT_3                     "User_Effect_3"
-- 
2.43.0

