Game Development Reference
In-Depth Information
ByRef blanks As Integer) As Collection
'Look at line above and see the integers are all ByRef!
Dim BlankSquares As New Collection
'Text of revealed squares are blank = 0 or a number
If RevealedSquare.Text <> "" Then
sees = CInt(RevealedSquare.Text)
End If
'Get the counts of what they show
Dim Sq As Square
For Each Sq In Neighbors
'We want hidden squares only
If Not Sq.IsRevealed Then
'Count the flags and blanks
Select Case Sq.Text
Case ""
blanks += 1
BlankSquares.Add(Sq,PlayingField.KeyFromRC(Sq.R,Sq.C))
Case Square.ShowFlag
flags += 1
End Select
End If
Next
'The caller often needs the blank squares as a group
Return BlankSquares
End Function
This routine collects the stats and writes them back onto the passed-in para-
meters. VB defaults to call by value, so we have to make sure that we use the ByRef
keyword. This function returns a collection holding any blank squares. Armed
with this helper routine, our first rule is easy to write. Create a class and name it
RuleOne . Mark it to inherit from BasicRule . The only code we have to add is the
Matches routine.
Public Class RuleOne
Inherits BasicRule
Public Overrides Function Matches(ByVal RevealedSquare As Square) As Integer
'Clear out anything from before
Me.SquaresList.Clear()
'Do not run on a hidden square!
 
Search Nedrilad ::




Custom Search