Final missions above ground (M30, co-op M20), surface option for versus matches, docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ae41228ab
commit
f27dbea2f1
28 files changed
+111
-49
No files matched your search
+16
-2
@@ -90,6 +90,7 @@ pub struct StartInfo {
|
||||
pub teams: Vec<(u8, u8)>, // (side, team) of a versus match
|
||||
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
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
@@ -223,6 +224,18 @@ impl MatchClient {
|
||||
self.send_create(sides, map_w, map_h, difficulty, None);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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 Ok(mut msg) = serde_json::from_str::<Value>(text) {
|
||||
msg["surface"] = json!(true);
|
||||
*text = msg.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_coop(&mut self, mission: usize, sides: &[u8], map_w: usize, map_h: usize, difficulty: u8) {
|
||||
self.send_create(sides, map_w, map_h, difficulty, Some(mission));
|
||||
}
|
||||
@@ -550,7 +563,8 @@ impl MatchClient {
|
||||
// a resumed editor campaign run goes on like the next mission of a running one
|
||||
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() };
|
||||
self.start = Some(StartInfo { seed, map_w, map_h, difficulty, sides, local_side, mission, ai, doc, editor, teams, next: resume, carry });
|
||||
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 });
|
||||
self.error = None;
|
||||
self.status = None;
|
||||
}
|
||||
@@ -581,7 +595,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 });
|
||||
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.error = None;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user