summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorstale <stale@masba.net>2022-07-11 12:06:17 -0300
committerstale <stale@masba.net>2022-07-11 12:07:01 -0300
commit02098f0d579259545584e246f64ed5e41be9537b (patch)
tree891761e153fb80affe85b74420426db9e4ec1dd8 /src/main.rs
parent13a044a9cf21671e168d1669723605bf35ed8f60 (diff)
implement reveal on lose
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index ce1cd45..7a85e63 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -309,7 +309,7 @@ async fn empty_rooms(rooms: &RoomMap) -> Vec<RoomId> {
}
fn room_from_form(uid: RoomId, rinfo: &HashMap<String,String>, conf: &Conf) -> Result<(types::Room, bool), Rejection> {
- if let (Some(w),Some(h),Some(num),Some(denom),public,asfm,rborders,Some(limit)) = (
+ if let (Some(w),Some(h),Some(num),Some(denom),public,asfm,rborders,revealol,Some(limit)) = (
rinfo.get("bwidth").and_then(|w| w.parse::<NonZeroUsize>().ok()),
rinfo.get("bheight").and_then(|h| h.parse::<NonZeroUsize>().ok()),
rinfo.get("mineratio-n").and_then(|n| n.parse::<usize>().ok()),
@@ -317,12 +317,16 @@ fn room_from_form(uid: RoomId, rinfo: &HashMap<String,String>, conf: &Conf) -> R
rinfo.get("public").map(|s| s == "on").unwrap_or(false),
rinfo.get("allsafe1move").map(|s| s == "on").unwrap_or(false),
rinfo.get("rborders").map(|s| s == "on").unwrap_or(false),
+ rinfo.get("revealonlose").map(|s| s == "on").unwrap_or(false),
rinfo.get("limit").and_then(|l| l.parse::<NonZeroUsize>().ok()),
) {
if w.get()*h.get() > conf.limits.board_area {
return Err(warp::reject::custom(BoardTooBig))
}
- let board_conf = minesweeper::BoardConf { w, h, mine_ratio: (num,denom), always_safe_first_move: asfm, revealed_borders: rborders };
+ let board_conf = minesweeper::BoardConf {
+ w, h, mine_ratio: (num,denom),
+ always_safe_first_move: asfm, revealed_borders: rborders, reveal_on_lose: revealol
+ };
let name = {
let n = rinfo.get("rname").unwrap().to_owned();
if n.is_empty() { uid.to_string() } else { n }