feat(atlas): add gravity, orbital period, rotation + sync-wiki command

Schema: added orbital_period_days and rotation_period_hours to bodies
table. Proposal format now includes surface_gravity, orbital_period_days,
rotation_period_hours with sensible defaults per body type.

New sync-wiki command generates a Celestial Bodies section in wiki
pages from DB data. All 16 fields rendered including Year (d) and
Day (h). Re-authored Gateway (GJ 71) with full physics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 18:26:42 +01:00
co-authored by Claude Opus 4.6
parent b77c94a6d8
commit 05c3227b53
4 changed files with 89 additions and 23 deletions
+55 -11
View File
@@ -236,6 +236,9 @@ struct ProposalBody {
inhabited: bool,
population: Option<i64>,
mass_class: Option<String>,
surface_gravity: Option<f64>,
orbital_period_days: Option<f64>,
rotation_period_hours: Option<f64>,
atmosphere: Option<String>,
biome_summary: Option<String>,
hydrosphere: Option<String>,
@@ -806,6 +809,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: Some("terrestrial".into()),
surface_gravity: Some(0.38),
orbital_period_days: Some(88.0),
rotation_period_hours: Some(1408.0),
atmosphere: Some("none".into()),
biome_summary: Some("barren".into()),
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -831,6 +837,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: Some("terrestrial".into()),
surface_gravity: Some(0.9),
orbital_period_days: Some(365.0),
rotation_period_hours: Some(24.0),
atmosphere: Some("breathable".into()),
biome_summary: Some("temperate".into()),
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -857,6 +866,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: Some("terrestrial".into()),
surface_gravity: Some(0.85),
orbital_period_days: Some(400.0),
rotation_period_hours: Some(26.0),
atmosphere: Some("breathable".into()),
biome_summary: Some("temperate".into()),
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -884,6 +896,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: Some("terrestrial".into()),
surface_gravity: Some(0.5),
orbital_period_days: Some(2000.0),
rotation_period_hours: Some(18.0),
atmosphere: Some("thin".into()),
biome_summary: Some("frozen".into()),
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -903,6 +918,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: None,
surface_gravity: None,
orbital_period_days: None,
rotation_period_hours: None,
atmosphere: None,
biome_summary: None,
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -928,6 +946,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: Some("gas_giant".into()),
surface_gravity: None,
orbital_period_days: Some(4300.0),
rotation_period_hours: Some(10.0),
atmosphere: Some("dense".into()),
biome_summary: None,
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -944,6 +965,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: Some("dwarf".into()),
surface_gravity: Some(0.1),
orbital_period_days: Some(3.5 * m as f64),
rotation_period_hours: Some(3.5 * 24.0 * m as f64),
atmosphere: Some("none".into()),
biome_summary: Some("barren".into()),
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -964,6 +988,9 @@ fn generate_body_matrix(
proper_name: None,
population: None,
mass_class: None,
surface_gravity: None,
orbital_period_days: None,
rotation_period_hours: None,
atmosphere: None,
biome_summary: None,
hydrosphere: None, economic_role: None, settlement_pattern: None, industrial_corridor: None,
@@ -1104,10 +1131,11 @@ fn cmd_commit_system(conn: &Connection, path: &str) {
for body in &proposal.bodies {
tx.execute(
"INSERT INTO bodies (body_id, system_id, parent_body_id, body_type, orbit_index,
proper_name, inhabited, population, mass_class, atmosphere,
proper_name, inhabited, population, mass_class, surface_gravity,
orbital_period_days, rotation_period_hours, atmosphere,
biome_summary, hydrosphere, economic_role, settlement_pattern,
industrial_corridor)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15)",
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18)",
params![
body.body_id,
proposal.system_id,
@@ -1118,6 +1146,9 @@ fn cmd_commit_system(conn: &Connection, path: &str) {
body.inhabited as i32,
body.population.unwrap_or(0),
body.mass_class,
body.surface_gravity,
body.orbital_period_days,
body.rotation_period_hours,
body.atmosphere,
body.biome_summary,
body.hydrosphere,
@@ -1270,6 +1301,7 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
.prepare(
"SELECT body_id, proper_name, body_type, orbit_index, parent_body_id,
inhabited, population, mass_class, atmosphere, surface_gravity,
orbital_period_days, rotation_period_hours,
biome_summary, hydrosphere, economic_role, settlement_pattern,
industrial_corridor
FROM bodies WHERE system_id = ?1
@@ -1288,6 +1320,8 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
mass_class: Option<String>,
atmosphere: Option<String>,
gravity: Option<f64>,
orbital_days: Option<f64>,
rotation_hours: Option<f64>,
biome: Option<String>,
hydro: Option<String>,
econ: Option<String>,
@@ -1308,11 +1342,13 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
mass_class: row.get(7)?,
atmosphere: row.get(8)?,
gravity: row.get(9)?,
biome: row.get(10)?,
hydro: row.get(11)?,
econ: row.get(12)?,
settlement: row.get(13)?,
industrial: row.get(14)?,
orbital_days: row.get(10)?,
rotation_hours: row.get(11)?,
biome: row.get(12)?,
hydro: row.get(13)?,
econ: row.get(14)?,
settlement: row.get(15)?,
industrial: row.get(16)?,
})
})
.unwrap()
@@ -1373,8 +1409,8 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
// Bodies table
if !bodies.is_empty() {
section.push_str("| Orbit | ID | Name | Type | Inhabited | Population | Mass | Gravity | Atmosphere | Biome | Hydrosphere | Economy | Settlement | Industrial |\n");
section.push_str("|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n");
section.push_str("| Orbit | ID | Name | Type | Inhabited | Pop | Mass | Gravity | Year (d) | Day (h) | Atmo | Biome | Hydro | Economy | Settlement | Industrial |\n");
section.push_str("|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n");
// First pass: top-level bodies (no parent)
for b in &bodies {
@@ -1388,8 +1424,10 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
"—".to_string()
};
let grav = b.gravity.map(|g| format!("{:.2}g", g)).unwrap_or_else(|| "—".to_string());
let year = b.orbital_days.map(|d| format!("{:.0}", d)).unwrap_or_else(|| "—".to_string());
let day = b.rotation_hours.map(|h| format!("{:.1}", h)).unwrap_or_else(|| "—".to_string());
section.push_str(&format!(
"| {} | `{}` | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} |\n",
"| {} | `{}` | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} |\n",
b.orbit,
b.id,
name,
@@ -1398,6 +1436,8 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
pop,
b.mass_class.as_deref().unwrap_or("—"),
grav,
year,
day,
b.atmosphere.as_deref().unwrap_or("—"),
b.biome.as_deref().unwrap_or("—"),
b.hydro.as_deref().unwrap_or("—"),
@@ -1416,8 +1456,10 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
"—".to_string()
};
let mgrav = m.gravity.map(|g| format!("{:.2}g", g)).unwrap_or_else(|| "—".to_string());
let myear = m.orbital_days.map(|d| format!("{:.0}", d)).unwrap_or_else(|| "—".to_string());
let mday = m.rotation_hours.map(|h| format!("{:.1}", h)).unwrap_or_else(|| "—".to_string());
section.push_str(&format!(
"| ↳ {}.{} | `{}` | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} |\n",
"| ↳ {}.{} | `{}` | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} | {} |\n",
b.orbit,
m.orbit,
m.id,
@@ -1427,6 +1469,8 @@ fn cmd_sync_wiki(conn: &Connection, system_id: Option<&str>, wiki_dir: &str) {
mpop,
m.mass_class.as_deref().unwrap_or("—"),
mgrav,
myear,
mday,
m.atmosphere.as_deref().unwrap_or("—"),
m.biome.as_deref().unwrap_or("—"),
m.hydro.as_deref().unwrap_or("—"),