Merge pull request #116 from lucasnlm/fix-first-open
Open tile on first tap when Double Click or Fast Flag by @sergeiwork
This commit is contained in:
commit
417b1af887
2 changed files with 31 additions and 2 deletions
|
@ -294,8 +294,13 @@ class GameController {
|
|||
}
|
||||
}
|
||||
ActionResponse.SwitchMark -> {
|
||||
if (isCovered) switchMark()
|
||||
if (!hasMines) {
|
||||
plantMinesExcept(id, true)
|
||||
openTile()
|
||||
} else if (isCovered) {
|
||||
switchMark()
|
||||
1
|
||||
} else 0
|
||||
}
|
||||
ActionResponse.HighlightNeighbors -> {
|
||||
if (minesAround != 0) highlight() else 0
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue