Versus map size on the match page; the size sets the number of seats

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-06 09:32:40 +01:00
1 parent 7b927b0df7
commit 6880324e33
22 files changed
+59 -1

No files matched your search

+11
View File
@@ -673,6 +673,17 @@ fn teams_from(sides: &[u8], v: Option<&Value>) -> Vec<(u8, u8)> {
sides.iter().copied().zip(teams).collect()
}
// versus map sizes and how many master seats each one has
pub const MATCH_SIZES: [usize; 7] = [80, 96, 128, 160, 192, 224, 256];
pub fn seats_for(size: usize) -> &'static [u8] {
match size {
0..=80 => &[0, 2],
81..=96 => &[0, 2, 3],
_ => &[0, 2, 3, 4],
}
}
fn seats_from(v: Option<&Value>) -> Vec<SeatInfo> {
v.and_then(|x| x.as_array())
.map(|arr| {
+5 -1
View File
@@ -358,7 +358,11 @@ fn account_action(a: MenuAction, cloud: &mut Cloud, menu: &mut Menu, app: &mut A
}
}
MenuAction::MatchJoin(code) => app.client.join(&code),
MenuAction::MatchCreate => app.client.create_land(&[0, 2, 3, 4], app.settings.map_w, app.settings.map_h, app.settings.difficulty, app.settings.surface, app.settings.events),
MenuAction::MatchCreate => {
// the map size decides the number of master seats
let n = app.settings.match_size;
app.client.create_land(lobby::seats_for(n), n, n, app.settings.difficulty, app.settings.surface, app.settings.events)
}
MenuAction::MatchCoopCreate(mission) => {
let all = campaign::missions();
if let Some(d) = all.get(mission) {
+23
View File
@@ -238,6 +238,7 @@ enum Btn {
Tab(usize),
Change(usize, i32),
MapW(i32),
MatchSize(i32),
Land,
MapH(i32),
Difficulty(i32),
@@ -437,6 +438,7 @@ pub struct Menu {
pub error: Option<String>, // message on the login and account pages
pub match_ui: MatchUi, // copied state of the multiplayer relay, shown on the Match page
pub coop_mission: usize, // co-op campaign mission selected on the Match page
match_size: usize, // the versus map size (from the settings, for drawing)
pub coop_editor: bool, // the Match page offers a campaign document instead of the built-in missions
pub coop_league: bool, // ... and that document is the co-op campaign "League against the Lightwatch"
league_doc: Option<CampaignDoc>, // the co-op campaign, built the first time it is chosen
@@ -497,6 +499,7 @@ impl Menu {
error: None,
match_ui: MatchUi::default(),
coop_mission: crate::campaign::coop_mission_indexes().first().copied().unwrap_or(0),
match_size: 128,
coop_editor: false,
coop_league: false,
league_doc: None,
@@ -682,6 +685,12 @@ impl Menu {
MenuAction::Consumed
}
Some(Btn::Start) => MenuAction::NewGame,
Some(Btn::MatchSize(d)) => {
let sizes = crate::lobby::MATCH_SIZES;
let k = sizes.iter().position(|&s| s >= settings.match_size).unwrap_or(2) as i32;
settings.match_size = sizes[(k + d).clamp(0, sizes.len() as i32 - 1) as usize];
MenuAction::SettingsChanged
}
Some(Btn::MapW(d)) => {
settings.map_w = (settings.map_w as i32 + d * 32).clamp(MIN_SIZE as i32, MAX_SIZE as i32) as usize;
MenuAction::SettingsChanged
@@ -953,6 +962,7 @@ impl Menu {
self.buttons.clear();
self.lang_opts.clear();
self.cur_lang = settings.language.clone();
self.match_size = settings.match_size;
let Some(page) = self.page else {
self.lang_open = None;
return;
@@ -2053,6 +2063,19 @@ impl Menu {
}
}
}
// a new versus match: the map size and with it the number of seats
if !ui.started && !ui.room_open() {
let n = self.match_size;
let seats = crate::lobby::seats_for(n).len();
let r = Rect::new(ix, yy, 4.0 * CW(), CH() * 2.0);
button(gfx, r, "<", r.contains(vec2(mx, my)), FRAME);
self.buttons.push((r, Btn::MatchSize(-1)));
gfx.text(&trf("net.map_size", &[n.to_string(), n.to_string(), seats.to_string()]), ix + 5.0 * CW(), yy + CH() * 0.5, S(), TXT);
let r = Rect::new(ix + 30.0 * CW(), yy, 4.0 * CW(), CH() * 2.0);
button(gfx, r, ">", r.contains(vec2(mx, my)), FRAME);
self.buttons.push((r, Btn::MatchSize(1)));
yy += CH() * 2.4;
}
self.field(gfx, ix, yy, w, &tr("net.join_hint"), 0, false);
self.field(gfx, ix, yy + CH() * 2.4, w, &tr("net.chat"), 1, false);
yy += CH() * 4.8;
+2
View File
@@ -163,6 +163,7 @@ pub struct Settings {
pub hints: bool,
pub difficulty: u8, // rival masters in free games: 0 easy, 1 medium, 2 hard
pub map_w: usize, // size of new maps (64..256)
pub match_size: usize, // versus matches: the map is match_size x match_size (see lobby::seats_for)
pub map_h: usize,
pub surface: bool, // new free games: the eastern half lies above ground (forest)
pub events: bool, // random events in free games and versus matches
@@ -201,6 +202,7 @@ impl Default for Settings {
hints: true,
difficulty: 1,
map_w: 64,
match_size: 128,
map_h: 64,
surface: false,
events: true,