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:
1 parent
5239e4b5a3
commit
c6d82027dd
26 files changed
+313
-10
No files matched your search
+8
-5
@@ -91,6 +91,7 @@ pub struct StartInfo {
|
||||
pub next: bool, // the next mission of a running editor campaign co-op match
|
||||
pub carry: Vec<(u8, crate::campaign::Carry)>, // what every side brings into that mission
|
||||
pub surface: bool, // a free match whose eastern half lies above ground
|
||||
pub events: bool, // random events in a free match
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
@@ -225,12 +226,13 @@ impl MatchClient {
|
||||
}
|
||||
|
||||
// a free match; `surface`: its eastern half lies above ground
|
||||
pub fn create_land(&mut self, sides: &[u8], map_w: usize, map_h: usize, difficulty: u8, surface: bool) {
|
||||
pub fn create_land(&mut self, sides: &[u8], map_w: usize, map_h: usize, difficulty: u8, surface: bool, events: bool) {
|
||||
let n = self.outbox.len();
|
||||
self.send_create(sides, map_w, map_h, difficulty, None);
|
||||
if let (true, Some(text)) = (surface, self.outbox.get_mut(n)) {
|
||||
if let (true, Some(text)) = (surface || events, self.outbox.get_mut(n)) {
|
||||
if let Ok(mut msg) = serde_json::from_str::<Value>(text) {
|
||||
msg["surface"] = json!(true);
|
||||
msg["surface"] = json!(surface);
|
||||
msg["events"] = json!(events);
|
||||
*text = msg.to_string();
|
||||
}
|
||||
}
|
||||
@@ -564,7 +566,8 @@ impl MatchClient {
|
||||
let resume = editor && v.get("resume").and_then(|x| x.as_bool()).unwrap_or(false);
|
||||
let carry: Vec<(u8, crate::campaign::Carry)> = if resume { v.get("carry").cloned().and_then(|c| serde_json::from_value(c).ok()).unwrap_or_default() } else { Vec::new() };
|
||||
let surface = v.get("surface").and_then(|x| x.as_bool()).unwrap_or(false);
|
||||
self.start = Some(StartInfo { seed, map_w, map_h, difficulty, sides, local_side, mission, ai, doc, editor, teams, next: resume, carry, surface });
|
||||
let events = v.get("events").and_then(|x| x.as_bool()).unwrap_or(false);
|
||||
self.start = Some(StartInfo { seed, map_w, map_h, difficulty, sides, local_side, mission, ai, doc, editor, teams, next: resume, carry, surface, events });
|
||||
self.error = None;
|
||||
self.status = None;
|
||||
}
|
||||
@@ -595,7 +598,7 @@ impl MatchClient {
|
||||
}
|
||||
r.ai = ai.clone();
|
||||
}
|
||||
self.start = Some(StartInfo { seed, map_w, map_h, difficulty, sides, local_side, mission: Some(mission), ai, doc: Some(doc), editor: true, teams, next: true, carry, surface: false });
|
||||
self.start = Some(StartInfo { seed, map_w, map_h, difficulty, sides, local_side, mission: Some(mission), ai, doc: Some(doc), editor: true, teams, next: true, carry, surface: false, events: false });
|
||||
self.error = None;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user