Debian Codegraph @

terps/frankendrift/FrankenDrift.Adrift/clsGroup.vb

raw
1 Public Class clsGroup
2 Inherits clsItem
3
4 Private sName As String
5
6 Public Enum GroupTypeEnum
7 Locations = 0
8 Objects = 1
9 Characters = 2
10 End Enum
11 Private eGroupType As GroupTypeEnum
12
13 Friend htblProperties As New PropertyHashTable
14
15 Private sarlMembers As New StringArrayList
16 Friend Property arlMembers() As StringArrayList
17 Get
18 If Key = ALLROOMS Then
19 sarlMembers.Clear()
20 For Each sKey As String In Adventure.htblLocations.Keys
21 sarlMembers.Add(sKey)
22 Next
23 End If
24 Return sarlMembers
25 End Get
26 Set(ByVal value As StringArrayList)
27 sarlMembers = value
28 End Set
29 End Property
30
31 Public Property Name() As String
32 Get
33 Return sName
34 End Get
35 Set(ByVal Value As String)
36 sName = Value
37 End Set
38 End Property
39
40 Public Property GroupType() As GroupTypeEnum
41 Get
42 Return eGroupType
43 End Get
44 Set(ByVal Value As GroupTypeEnum)
45 eGroupType = Value
46 End Set
47 End Property
48
49 Public ReadOnly Property RandomKey() As String
50 Get
51 Return arlMembers(Random(Me.arlMembers.Count - 1))
52 End Get
53 End Property
54 Public Overrides ReadOnly Property Clone() As clsItem
55 Get
56 Return CType(Me.MemberwiseClone, clsGroup)
57 End Get
58 End Property
59
60 Public Overrides ReadOnly Property CommonName() As String
61 Get
62 Return Name
63 End Get
64 End Property
65
66
67 Friend Overrides ReadOnly Property AllDescriptions() As System.Collections.Generic.List(Of SharedModule.Description)
68 Get
69 Dim all As New Generic.List(Of Description)
70 Return all
71 End Get
72 End Property
73
74
75 Friend Overrides Function FindStringLocal(sSearchString As String, Optional sReplace As String = Nothing, Optional bFindAll As Boolean = True, Optional ByRef iReplacements As Integer = 0) As Object
76 Dim iCount As Integer = iReplacements
77 iReplacements += MyBase.FindStringInStringProperty(Me.sName, sSearchString, sReplace, bFindAll)
78 Return iReplacements - iCount
79 End Function
80
81 Public Overrides Function ReferencesKey(ByVal sKey As String) As Integer
82
83 Dim iCount As Integer = 0
84 For Each d As Description In AllDescriptions
85 iCount += d.ReferencesKey(sKey)
86 Next
87 If Not Key = ALLROOMS AndAlso Me.arlMembers.Contains(sKey) Then iCount += 1
88 iCount += htblProperties.ReferencesKey(sKey)
89
90 Return iCount
91
92 End Function
93
94 Public Overrides Function DeleteKey(ByVal sKey As String) As Boolean
95
96 For Each d As Description In AllDescriptions
97 If Not d.DeleteKey(sKey) Then Return False
98 Next
99 If arlMembers.Contains(sKey) Then arlMembers.Remove(sKey)
100 If Not htblProperties.DeleteKey(sKey) Then Return False
101
102 Return True
103 End Function
104
105 End Class