protected override void CheckingNewRevealed(Vector2Int currentnewrevealed)
    {
        //count the number of neighbores of this tile
        List <Vector2Int> newClosedHiddenNeighbors = new List <Vector2Int>();

        ClosedHiddenNeighbores.Add(currentnewrevealed, newClosedHiddenNeighbors);

        for (int j = 0; j < Operators.Length; j++)
        {
            Vector2Int current = currentnewrevealed + Operators[j];
            if (Flaged.Contains(current))
            {
                Closed[currentnewrevealed]--;
            }
            else if (MinesweeperElementInfo.InBounds(current, BoardSize.x, BoardSize.y))
            {
                if (Open.ContainsKey(current) || Safe.Contains(current) || Mine.Contains(current))
                {
                    newClosedHiddenNeighbors.Add(current);
                    List <Vector2Int> clist = HiddenClosedRelations[current];
                    clist.Add(currentnewrevealed);
                }
                else if (!InvalidTiles[current.x, current.y] && !Closed.ContainsKey(current))
                {
                    Open.Add(current, 0);
                    newClosedHiddenNeighbors.Add(current);
                    List <Vector2Int> clist = new List <Vector2Int>();
                    HiddenClosedRelations.Add(current, clist);
                    clist.Add(currentnewrevealed);
                }
            }
        }
    }
Пример #2
0
        public void RightClick([Frozen] Cell cell, Flaged sut)
        {
            // Act
            sut.RightClick();

            // Assert
            cell.CoverState.Should().BeOfType <Covered>();
        }
 /// <summary>
 /// Iterates through 'currentnewrevealed', checking if 'currentnewrevealed' can be discarded,
 /// while adding new open tile
 /// </summary>
 /// <param name="currentnewrevealed"></param>
 protected virtual void CheckingNewRevealed(Vector2Int currentnewrevealed)
 {
     for (int j = 0; j < Operators.Length; j++)
     {
         Vector2Int current = currentnewrevealed + Operators[j];
         if (Flaged.Contains(current))
         {
             Closed[currentnewrevealed]--;
         }
         else if (MinesweeperElementInfo.InBounds(current, BoardSize.x, BoardSize.y))
         {
             //i wanted to make the minesweeper and the solver independent from eachother, thats why i didn't simply passed the minesweeperelementinfo object at 'current' tile
             if (!InvalidTiles[current.x, current.y] && !Open.ContainsKey(current) && !Closed.ContainsKey(current) && !Safe.Contains(current) && !Mine.Contains(current))
             {
                 Open.Add(current, 0);
             }
         }
     }
 }
 protected virtual void OnAddingFlaged(Vector2Int currentmine)
 {
     Flaged.Add(currentmine);
 }
Пример #5
0
 public void ReturnToString(Flaged sut)
 {
     // Assert
     sut.ToString().Should().Be("A");
 }