fix(@projects/magic-civilization): 🐛 preserve border-expansion timing with modifier
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
8c4e47d41e
commit
152facee0a
1 changed files with 22 additions and 11 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue