generated from tipragot/rust
Start game from the lobby by the admin #86
|
@ -69,7 +69,7 @@ fn lobby_ui(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add(egui::Slider::new(&mut (*map_size), 0..=10).text("map size"));
|
ui.add(egui::Slider::new(&mut (*map_size), 0..=5).text("map size"));
|
||||||
|
|
||||||
if ui.button("Run the game").clicked() {
|
if ui.button("Run the game").clicked() {
|
||||||
for player in all_players_query.iter() {
|
for player in all_players_query.iter() {
|
||||||
|
@ -77,10 +77,27 @@ fn lobby_ui(
|
||||||
player.uuid,
|
player.uuid,
|
||||||
StartGame(StartMapGeneration {
|
StartGame(StartMapGeneration {
|
||||||
seed: 0,
|
seed: 0,
|
||||||
radius: 10,
|
radius: get_map_sizes(all_players_query.iter().count() as u64)
|
||||||
|
[*map_size as usize] as u16
|
||||||
|
* 2,
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_map_sizes(number_of_players: u64) -> Vec<u64> {
|
||||||
|
let mut result = Vec::with_capacity(6);
|
||||||
|
|
||||||
|
let mut current = 0;
|
||||||
|
while result.len() < 6 {
|
||||||
|
current += 1;
|
||||||
|
|
||||||
|
if (current * 6) % number_of_players == 0 {
|
||||||
|
result.push(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue