Open tile on first tap when Double Click or Fast Flag by @sergeiwork

This commit is contained in:
Lucas Lima 2020-07-01 23:06:39 -03:00
parent c613a87b8c
commit 135c1733a2
No known key found for this signature in database
GPG key ID: C5EEF4C30BFBF8D7
2 changed files with 31 additions and 2 deletions

View file

@ -294,8 +294,13 @@ class GameController {
}
}
ActionResponse.SwitchMark -> {
if (isCovered) switchMark()
1
if (!hasMines) {
plantMinesExcept(id, true)
openTile()
} else if (isCovered) {
switchMark()
1
} else 0
}
ActionResponse.HighlightNeighbors -> {
if (minesAround != 0) highlight() else 0

View file

@ -831,4 +831,28 @@ class GameControllerTest {
}
}
}
@Test
fun testIfDoubleClickPlantMinesOnFirstClick() {
gameControllerOf(9, 9, 72, 200L).run {
updateGameControl(GameControl.fromControlType(ControlStyle.DoubleClick))
assertFalse(hasMines)
assertEquals(0, field.filterNot { it.isCovered }.count())
singleClick(40)
assertTrue(hasMines)
at(40).findNeighbors().forEach { assertFalse(it.isCovered) }
}
}
@Test
fun testIfFastFlagPlantMinesOnFirstClick() {
gameControllerOf(9, 9, 72, 200L).run {
updateGameControl(GameControl.fromControlType(ControlStyle.FastFlag))
assertFalse(hasMines)
assertEquals(0, field.filterNot { it.isCovered }.count())
singleClick(40)
assertTrue(hasMines)
at(40).findNeighbors().forEach { assertFalse(it.isCovered) }
}
}
}