diff options
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | assets/index.html | 1 | ||||
-rw-r--r-- | src/main.rs | 6 | ||||
-rw-r--r-- | src/minesweeper.rs | 5 |
5 files changed, 11 insertions, 5 deletions
@@ -1423,7 +1423,7 @@ dependencies = [ [[package]] name = "websweeper" -version = "1.4.0" +version = "1.5.0" dependencies = [ "ammonia", "flate2", @@ -1,6 +1,6 @@ [package] name = "websweeper" -version = "1.4.0" +version = "1.5.0" authors = ["stale <stale@masba.net>"] edition = "2021" diff --git a/assets/index.html b/assets/index.html index 614ccd0..4f38797 100644 --- a/assets/index.html +++ b/assets/index.html @@ -28,6 +28,7 @@ <label>safe first move (if possible) <input name="allsafe1move" type="checkbox" checked></label><br> <label>revealed borders <input name="rborders" type="checkbox"></label><br> <label>reveal on lose <input name="revealonlose" type="checkbox" checked></label><br> + <label>number tile revealing <input name="numtilereveal" type="checkbox" checked></label><br> <label>player limit <input name="limit" type="number" value="32"></label><br> <button id="createbtn">create</button> </fieldset> diff --git a/src/main.rs b/src/main.rs index c884dbc..0c81844 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,revealol,Some(limit)) = ( + if let (Some(w),Some(h),Some(num),Some(denom),public,asfm,rborders,revealol,ntiler,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()), @@ -318,6 +318,7 @@ fn room_from_form(uid: RoomId, rinfo: &HashMap<String,String>, conf: &Conf) -> R 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("numtilereveal").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 { @@ -325,7 +326,8 @@ fn room_from_form(uid: RoomId, rinfo: &HashMap<String,String>, conf: &Conf) -> R } let board_conf = minesweeper::BoardConf { w, h, mine_ratio: (num,denom), - always_safe_first_move: asfm, revealed_borders: rborders, reveal_on_lose: revealol + always_safe_first_move: asfm, revealed_borders: rborders, + reveal_on_lose: revealol, num_tile_reveal: ntiler, }; let name = { let n = rinfo.get("rname").unwrap().to_owned(); diff --git a/src/minesweeper.rs b/src/minesweeper.rs index f4c5511..1e95f0d 100644 --- a/src/minesweeper.rs +++ b/src/minesweeper.rs @@ -35,6 +35,7 @@ pub struct BoardConf { pub always_safe_first_move: bool, pub revealed_borders: bool, pub reveal_on_lose: bool, + pub num_tile_reveal: bool, } impl std::fmt::Display for BoardConf { @@ -49,6 +50,7 @@ pub struct Board { pub height: NonZeroUsize, pub hidden_tiles: usize, pub mine_count: usize, + pub num_tile_reveal: bool, } #[derive(Debug)] pub enum MoveType { @@ -120,6 +122,7 @@ impl Board { height: h, hidden_tiles: area, mine_count, + num_tile_reveal: conf.num_tile_reveal, }; if conf.revealed_borders { let (w,h) = (w.get(),h.get()); @@ -210,7 +213,7 @@ impl Board { pub fn reveal(&mut self, pos: BoardPos) -> bool { if let Some(off) = pos.rel_offset(&self) { let v = self.data[off]; - if 1 <= v && v <= 8 { + if self.num_tile_reveal && 1 <= v && v <= 8 { self.reveal_numtile(pos) } else { self.flood_reveal(pos) |