From 152facee0a04d5824bcb844c1fb053aef3b7562b Mon Sep 17 00:00:00 2001 From: Natalie Date: Tue, 28 Apr 2026 00:10:30 -0400 Subject: [PATCH] =?UTF-8?q?fix(@projects/magic-civilization):=20?= =?UTF-8?q?=F0=9F=90=9B=20preserve=20border-expansion=20timing=20with=20mo?= =?UTF-8?q?difier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- src/simulator/api-gdext/src/lib.rs | 33 ++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/simulator/api-gdext/src/lib.rs b/src/simulator/api-gdext/src/lib.rs index d133b0c1..c630f0b5 100644 --- a/src/simulator/api-gdext/src/lib.rs +++ b/src/simulator/api-gdext/src/lib.rs @@ -1385,20 +1385,31 @@ impl GdCity { self.inner.process_culture(&ty) } - /// Process culture accumulation with a percentage modifier added to the - /// raw culture gain. `total_pct` is the SUM of all percentage bonuses - /// (cult_pct + border_pct + difficulty_culture_mult - 1.0). Rust owns - /// both the raw gain and the percent-bonus application — no GDScript-side - /// post-call adjustment needed (warcouncil p1-39 Rail-1 port, 2026-04-27). - /// Returns true if border expansion is ready post-bonus. + /// Process culture accumulation with a percentage modifier on the gained + /// culture. Mirrors the original GDScript flow exactly to preserve + /// border-expansion timing parity: + /// 1. Run base process_culture (raw gain added, can_expand evaluated) + /// 2. Add EXTRA gain = raw_gain × total_pct (matches the GDScript + /// `set_culture_stored(post + gained * total_pct)` pattern) + /// `total_pct` is the SUM of all percentage bonuses + /// (cult_pct + border_pct + difficulty_culture_mult - 1.0). + /// Returns true if border expansion is ready (post-bonus). Warcouncil + /// p1-39 Rail-1 port, 2026-04-27 — preserves seed-determinism vs the + /// pre-port GDScript caller. #[func] fn process_culture_with_modifier(&mut self, tile_yields_json: GString, total_pct: f64) -> bool { let ty = Self::parse_tile_yields(&tile_yields_json.to_string()); - let yields = self.inner.get_yields(&ty); - let raw_gain = yields.culture; - let scaled_gain = raw_gain * (1.0 + total_pct.max(-1.0)); - self.inner.culture_stored += scaled_gain; - self.inner.can_expand() + let pre = self.inner.culture_stored; + let mut can_expand = self.inner.process_culture(&ty); + if total_pct > 0.0 { + let post = self.inner.culture_stored; + let raw_gain = post - pre; + if raw_gain > 0.0 { + self.inner.culture_stored = post + raw_gain * total_pct; + can_expand = self.inner.can_expand(); + } + } + can_expand } /// Add production production.