if the number of mines arround is =0, then we UpdateIt the collection to change the Status value of every surrounding cell.if the number of mines arround is >0, nothing happens.the toggle of the cell is triggered thanks to the default value.We use Patch to change the Status value of ThisItem (one click=1, 2 clicks=2) The default value of the toggle is "ThisItem.Status=2", knowing that the field = 2 means the cell is revealed. So I came up with the workaround of having toggles in each cell. I did not try that, and I'm not sure how to do it (seems like recusion anyway). And again.Īs proposed on Twitter, we could prepare a list of every cell to reveal for each cell in the collection. If a cell has no surrounding mines, then reveal the next cells. The first clic allows you to "flag" the cell (if you think theres a mine in it), the 2nd clic reveals the cell. Then the user just clic on every cell he thinks has no mine in it.If the cell has one or more mine around, simply display the number of mines around.If the cell that is revealed has no mine around, then we need to reveal all the surrounding cells.So we have do either generate the mines right during the clic, or get rid of all the mines in this area (I choosed the later). This first cell and the surrounding ones can't contain a mine. Harder means more rows and columns, and more mines. The grid gets generated depending on the level.We can summarize the steps in the game like this: The goal is to reveal every cell that do not contain a mine. The rule is pretty simple : a grid of cells contains a certain number of mines. The best example I found was the game Mine Sweeper (old school cool !). As a challenge, I tried to implemente the logic of recursion in Power Apps.
0 Comments
Leave a Reply. |