Random events: earthquakes, overflowing rivers, new gold veins (free games and versus, can be switched off)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-05 23:58:28 +01:00
1 parent 5239e4b5a3
commit c6d82027dd
26 files changed
+313 -10

No files matched your search

+5 -1
View File
@@ -90,6 +90,7 @@ struct Room {
doc: Option<Value>, // editor campaign of a co-op match (sent to every client at the start)
resume: Option<(u32, Value)>, // a resumed editor campaign run: its seed and what the masters carry
surface: bool, // a free match half above ground
events: bool, // random events in a free match
}
#[derive(Debug)]
@@ -384,7 +385,7 @@ impl Netplay {
}
let name = self.clients.get(&conn).map(|c| c.name.clone()).unwrap_or_else(|| "Guest".into());
let seats = sides.iter().map(|s| (*s, new_seat(*s, false))).collect::<HashMap<_, _>>();
let room = Room { code: code.clone(), sides, seats, pending: HashMap::new(), turn: 0, started: false, paused: false, missing: false, seed: None, map_w, map_h, difficulty, mission, doc, resume, surface: msg.get("surface").and_then(|v| v.as_bool()).unwrap_or(false) };
let room = Room { code: code.clone(), sides, seats, pending: HashMap::new(), turn: 0, started: false, paused: false, missing: false, seed: None, map_w, map_h, difficulty, mission, doc, resume, surface: msg.get("surface").and_then(|v| v.as_bool()).unwrap_or(false), events: msg.get("events").and_then(|v| v.as_bool()).unwrap_or(false) };
self.rooms.insert(code.clone(), room);
if let Some(c) = self.clients.get_mut(&conn) {
c.room = Some(code.clone());
@@ -652,6 +653,9 @@ impl Netplay {
if r.surface {
m["surface"] = json!(true);
}
if r.events {
m["events"] = json!(true);
}
if let Some((_, carry)) = &r.resume {
m["carry"] = carry.clone();
m["resume"] = json!(true);