| 1 |
|
| 2 |
Imports System.Drawing |
| 3 |
|
| 4 |
Public Class clsAdventure |
| 5 |
|
| 6 |
Friend dictAllItems As ItemDictionary |
| 7 |
Public htblLocations As LocationHashTable |
| 8 |
Friend htblObjects As ObjectHashTable |
| 9 |
Friend htblTasks As TaskHashTable |
| 10 |
Friend htblEvents As EventHashTable |
| 11 |
Friend htblCharacters As CharacterHashTable |
| 12 |
Friend htblGroups As GroupHashTable |
| 13 |
Friend htblVariables As VariableHashTable |
| 14 |
Friend htblALRs As ALRHashTable |
| 15 |
Friend htblHints As HintHashTable |
| 16 |
Friend htblUDFs As UDFHashTable |
| 17 |
Friend htblAllProperties As PropertyHashTable |
| 18 |
Friend htblObjectProperties As PropertyHashTable |
| 19 |
Friend htblCharacterProperties As PropertyHashTable |
| 20 |
Friend htblLocationProperties As PropertyHashTable |
| 21 |
Friend htblAllTopicKeys As StringArrayList |
| 22 |
Friend htblSynonyms As SynonymHashTable |
| 23 |
Friend listKnownWords As List(Of String) |
| 24 |
Public Map As clsMap |
| 25 |
|
| 26 |
Private oIntroduction As Description |
| 27 |
Private oWinningText As Description |
| 28 |
Private sTitle As String |
| 29 |
Private sAuthor As String |
| 30 |
Private sNotUnderstood As String |
| 31 |
Private sFilename As String |
| 32 |
Private sFullPath As String |
| 33 |
Private bChanged As Boolean |
| 34 |
|
| 35 |
Public ReadOnly Property DynamicObjects As IEnumerable(Of clsObject) |
| 36 |
Get |
| 37 |
Return htblObjects.Values.Where(Function(o) o.IsStatic = False) |
| 38 |
End Get |
| 39 |
End Property |
| 40 |
|
| 41 |
Public listExcludedItems As New HashSet(Of String) ' Library items removed, so we don't keep reloading them |
| 42 |
|
| 43 |
|
| 44 |
Public dVersion As Double |
| 45 |
Private iMaxScore As Integer |
| 46 |
Public iScore As Integer |
| 47 |
Public Turns As Integer |
| 48 |
Public sReferencedText(4) As String |
| 49 |
Friend sConversationCharKey As String ' Who we are in conversation with |
| 50 |
Friend sConversationNode As String ' Where we currently are in the conversation tree |
| 51 |
Friend sGameFilename As String |
| 52 |
Public eGameState As clsAction.EndGameEnum = clsAction.EndGameEnum.Running |
| 53 |
Friend bDisplayedWinLose As Boolean = False |
| 54 |
Friend qTasksToRun As New Generic.Queue(Of String) |
| 55 |
Friend iElapsed As Integer |
| 56 |
Friend sDirectionsRE(11) As String |
| 57 |
Friend lstTasks As List(Of clsTask) ' Simply a list, sorted by priority |
| 58 |
Friend dictRandValues As New Dictionary(Of String, List(Of Integer)) |
| 59 |
|
| 60 |
|
| 61 |
Public Enum TaskExecutionEnum |
| 62 |
HighestPriorityTask |
| 63 |
HighestPriorityPassingTask ' v4 logic - tries to execute first matching passing task, if that fails first matching failing task |
| 64 |
End Enum |
| 65 |
Friend TaskExecution As TaskExecutionEnum = TaskExecutionEnum.HighestPriorityTask |
| 66 |
|
| 67 |
Private _UserStatus As String |
| 68 |
Public Property sUserStatus As String |
| 69 |
Get |
| 70 |
Return _UserStatus |
| 71 |
End Get |
| 72 |
Set(value As String) |
| 73 |
_UserStatus = value |
| 74 |
End Set |
| 75 |
End Property |
| 76 |
|
| 77 |
Private sCoverFilename As String |
| 78 |
Friend Property CoverFilename As String |
| 79 |
Get |
| 80 |
Return sCoverFilename |
| 81 |
End Get |
| 82 |
Set(value As String) |
| 83 |
If value <> sCoverFilename Then |
| 84 |
Try |
| 85 |
If BabelTreatyInfo.Stories(0).Cover Is Nothing Then BabelTreatyInfo.Stories(0).Cover = New clsBabelTreatyInfo.clsStory.clsCover |
| 86 |
With BabelTreatyInfo.Stories(0).Cover |
| 87 |
.imgCoverArt = Nothing |
| 88 |
If IO.File.Exists(value) Then |
| 89 |
Dim iLength As Integer = CInt(FileLen(value)) |
| 90 |
Dim bytImage As Byte() |
| 91 |
Dim fs As New IO.FileStream(value, IO.FileMode.Open, IO.FileAccess.Read) |
| 92 |
ReDim bytImage(iLength - 1) |
| 93 |
fs.Read(bytImage, 0, CInt(iLength)) |
| 94 |
.imgCoverArt = bytImage |
| 95 |
fs.Close() |
| 96 |
.Format = IO.Path.GetExtension(value).ToLower.Substring(1) |
| 97 |
End If |
| 98 |
End With |
| 99 |
Catch ex As Exception |
| 100 |
ErrMsg("Failed to set Cover Art", ex) |
| 101 |
End Try |
| 102 |
sCoverFilename = value |
| 103 |
End If |
| 104 |
End Set |
| 105 |
End Property |
| 106 |
|
| 107 |
Friend Password As String |
| 108 |
|
| 109 |
Friend lCharMentionedThisTurn As New Generic.Dictionary(Of clsCharacter.GenderEnum, Generic.List(Of String)) |
| 110 |
|
| 111 |
Public BabelTreatyInfo As New clsBabelTreatyInfo |
| 112 |
|
| 113 |
|
| 114 |
Public Class v4Media |
| 115 |
Public iOffset As Integer |
| 116 |
Public iLength As Integer |
| 117 |
Public bImage As Boolean ' else Sound |
| 118 |
|
| 119 |
Public Sub New(ByVal iOffset As Integer, iLength As Integer, bImage As Boolean) |
| 120 |
Me.iOffset = iOffset |
| 121 |
Me.iLength = iLength |
| 122 |
Me.bImage = bImage |
| 123 |
End Sub |
| 124 |
End Class |
| 125 |
Public dictv4Media As Dictionary(Of String, v4Media) ' Filename |
| 126 |
|
| 127 |
|
| 128 |
Public ReadOnly Property Version As String |
| 129 |
Get |
| 130 |
If Adventure.dVersion = 0 Then Return "N/A" |
| 131 |
Dim sVersion As String = String.Format("{0:0.000000}", Adventure.dVersion) ' E.g. 5.000020 |
| 132 |
Return sVersion(0) & "." & CInt(sVersion.Substring(2, 2)) & "." & CInt(sVersion.Substring(4, 4)) |
| 133 |
End Get |
| 134 |
End Property |
| 135 |
|
| 136 |
|
| 137 |
Public Property Changed() As Boolean |
| 138 |
Get |
| 139 |
Return bChanged |
| 140 |
End Get |
| 141 |
Set(ByVal Value As Boolean) |
| 142 |
bChanged = Value |
| 143 |
End Set |
| 144 |
End Property |
| 145 |
|
| 146 |
Private dtLastUpdated As Date |
| 147 |
Friend Property LastUpdated() As Date |
| 148 |
Get |
| 149 |
If dtLastUpdated > Date.MinValue Then |
| 150 |
Return dtLastUpdated |
| 151 |
Else |
| 152 |
Return Now |
| 153 |
End If |
| 154 |
End Get |
| 155 |
Set(ByVal value As Date) |
| 156 |
dtLastUpdated = value |
| 157 |
End Set |
| 158 |
End Property |
| 159 |
|
| 160 |
Public Property KeyPrefix As String |
| 161 |
|
| 162 |
Private oPlayer As clsCharacter |
| 163 |
Public Property Player() As clsCharacter |
| 164 |
Get |
| 165 |
If oPlayer Is Nothing Then |
| 166 |
For Each ch As clsCharacter In Adventure.htblCharacters.Values |
| 167 |
If ch.CharacterType = clsCharacter.CharacterTypeEnum.Player Then |
| 168 |
oPlayer = ch |
| 169 |
Return ch |
| 170 |
End If |
| 171 |
Next |
| 172 |
If Adventure.htblCharacters.Count > 0 Then |
| 173 |
For Each ch As clsCharacter In Adventure.htblCharacters.Values |
| 174 |
oPlayer = ch |
| 175 |
Return ch |
| 176 |
Next |
| 177 |
End If |
| 178 |
Else |
| 179 |
Return oPlayer |
| 180 |
End If |
| 181 |
Return Nothing |
| 182 |
End Get |
| 183 |
Set(ByVal Value As clsCharacter) |
| 184 |
oPlayer = Value |
| 185 |
End Set |
| 186 |
End Property |
| 187 |
|
| 188 |
|
| 189 |
' Returns a list of all references to images within the adventure |
| 190 |
Public ReadOnly Property Images As List(Of String) |
| 191 |
Get |
| 192 |
Dim lImages As New List(Of String) |
| 193 |
If Adventure.CoverFilename <> "" Then lImages.Add(Adventure.CoverFilename) |
| 194 |
|
| 195 |
For Each sd As SingleDescription In AllDescriptions ' d |
| 196 |
Dim s As String = sd.Description |
| 197 |
s = s.Replace(" src =", " src=") |
| 198 |
Dim i As Integer = s.IndexOf("<img ") |
| 199 |
While i > -1 |
| 200 |
Dim j As Integer = s.IndexOf(" src=", i) |
| 201 |
If j > -1 Then |
| 202 |
Dim k As Integer = s.IndexOf(">", i) |
| 203 |
Dim sTag As String = s.Substring(j + 5, k - j - 5) |
| 204 |
If sTag.StartsWith("""") Then sTag = sTag.Substring(1) |
| 205 |
If sTag.EndsWith("""") Then sTag = sTag.Substring(0, sTag.Length - 1) |
| 206 |
If Not lImages.Contains(sTag) AndAlso (IO.File.Exists(sTag) OrElse sTag.StartsWith("http")) Then lImages.Add(sTag) |
| 207 |
End If |
| 208 |
i = s.IndexOf("<img ", i + 1) |
| 209 |
End While |
| 210 |
Next |
| 211 |
|
| 212 |
Return lImages |
| 213 |
End Get |
| 214 |
End Property |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
Friend ReadOnly Property AllDescriptions As List(Of SingleDescription) |
| 219 |
Get |
| 220 |
Dim lDescriptions As New List(Of SingleDescription) |
| 221 |
For Each sd As SingleDescription In Adventure.Introduction |
| 222 |
lDescriptions.Add(sd) |
| 223 |
Next |
| 224 |
For Each sd As SingleDescription In Adventure.WinningText |
| 225 |
lDescriptions.Add(sd) |
| 226 |
Next |
| 227 |
For Each itm As clsItem In Adventure.dictAllItems.Values |
| 228 |
For Each d As Description In itm.AllDescriptions |
| 229 |
For Each sd As SingleDescription In d |
| 230 |
lDescriptions.Add(sd) |
| 231 |
Next |
| 232 |
Next |
| 233 |
Next |
| 234 |
Return lDescriptions |
| 235 |
End Get |
| 236 |
End Property |
| 237 |
|
| 238 |
|
| 239 |
Public BlorbMappings As New Dictionary(Of String, Integer) |
| 240 |
|
| 241 |
|
| 242 |
Public Property Score() As Integer |
| 243 |
Get |
| 244 |
If htblVariables.ContainsKey("Score") Then |
| 245 |
iScore = htblVariables("Score").IntValue |
| 246 |
End If |
| 247 |
Return iScore |
| 248 |
End Get |
| 249 |
Set(ByVal value As Integer) |
| 250 |
If value <> iScore Then |
| 251 |
If htblVariables.ContainsKey("Score") Then |
| 252 |
htblVariables("Score").IntValue = value |
| 253 |
End If |
| 254 |
End If |
| 255 |
iScore = value |
| 256 |
UserSession.UpdateStatusBar() |
| 257 |
End Set |
| 258 |
End Property |
| 259 |
|
| 260 |
Public Property MaxScore() As Integer |
| 261 |
Get |
| 262 |
If htblVariables.ContainsKey("MaxScore") Then |
| 263 |
iMaxScore = htblVariables("MaxScore").IntValue |
| 264 |
End If |
| 265 |
Return iMaxScore |
| 266 |
End Get |
| 267 |
Set(ByVal value As Integer) |
| 268 |
If value <> iMaxScore Then |
| 269 |
If htblVariables.ContainsKey("MaxScore") Then |
| 270 |
htblVariables("MaxScore").IntValue = value |
| 271 |
End If |
| 272 |
End If |
| 273 |
iMaxScore = value |
| 274 |
End Set |
| 275 |
End Property |
| 276 |
|
| 277 |
#Region "Key Stuff" |
| 278 |
Public Function IsItemLibrary(ByVal sKey As String) As Boolean |
| 279 |
|
| 280 |
If AllKeys.Contains(sKey) Then |
| 281 |
Select Case GetTypeFromKeyNice(sKey) |
| 282 |
Case "Location" |
| 283 |
Return htblLocations(sKey).IsLibrary |
| 284 |
Case "Object" |
| 285 |
Return htblObjects(sKey).IsLibrary |
| 286 |
Case "Task" |
| 287 |
Return htblTasks(sKey).IsLibrary |
| 288 |
Case "Event" |
| 289 |
Return htblEvents(sKey).IsLibrary |
| 290 |
Case "Character" |
| 291 |
Return htblCharacters(sKey).IsLibrary AndAlso sKey <> Player.Key |
| 292 |
Case "Group" |
| 293 |
Return htblGroups(sKey).IsLibrary |
| 294 |
Case "Variable" |
| 295 |
Return htblVariables(sKey).IsLibrary |
| 296 |
Case "Text Override" |
| 297 |
Return htblALRs(sKey).IsLibrary |
| 298 |
Case "Hint" |
| 299 |
Return htblHints(sKey).IsLibrary |
| 300 |
Case "Property" |
| 301 |
Return htblAllProperties(sKey).IsLibrary |
| 302 |
Case "UserFunction" |
| 303 |
Return htblUDFs(sKey).IsLibrary |
| 304 |
Case "Synonym" |
| 305 |
Return htblSynonyms(sKey).IsLibrary |
| 306 |
End Select |
| 307 |
Else |
| 308 |
Return False |
| 309 |
End If |
| 310 |
|
| 311 |
End Function |
| 312 |
|
| 313 |
|
| 314 |
Public Function GetItemFromKey(ByVal sKey As String) As clsItem |
| 315 |
|
| 316 |
If sKey = "" Then Return Nothing |
| 317 |
|
| 318 |
If htblLocations.ContainsKey(sKey) Then Return htblLocations(sKey) |
| 319 |
If htblObjects.ContainsKey(sKey) Then Return htblObjects(sKey) |
| 320 |
If htblTasks.ContainsKey(sKey) Then Return htblTasks(sKey) |
| 321 |
If htblEvents.ContainsKey(sKey) Then Return htblEvents(sKey) |
| 322 |
If htblCharacters.ContainsKey(sKey) OrElse sKey = THEPLAYER Then Return htblCharacters(sKey) |
| 323 |
If htblGroups.ContainsKey(sKey) Then Return htblGroups(sKey) |
| 324 |
If htblVariables.ContainsKey(sKey) Then Return htblVariables(sKey) |
| 325 |
If htblALRs.ContainsKey(sKey) Then Return htblALRs(sKey) |
| 326 |
If htblHints.ContainsKey(sKey) Then Return htblHints(sKey) |
| 327 |
If htblAllProperties.ContainsKey(sKey) Then Return htblAllProperties(sKey) |
| 328 |
If htblUDFs.ContainsKey(sKey) Then Return htblUDFs(sKey) |
| 329 |
If htblSynonyms.ContainsKey(sKey) Then Return htblSynonyms(sKey) |
| 330 |
|
| 331 |
Return Nothing |
| 332 |
|
| 333 |
End Function |
| 334 |
|
| 335 |
|
| 336 |
Public Function GetTypeFromKey(ByVal sKey As String) As System.Type |
| 337 |
|
| 338 |
GetTypeFromKey = Nothing |
| 339 |
|
| 340 |
Select Case sKey |
| 341 |
Case "ReferencedObject", "ReferencedObjects", "ReferencedObject1", "ReferencedObject2", "ReferencedObject3", "ReferencedObject4", "ReferencedObject5" |
| 342 |
Return GetType(clsObject) |
| 343 |
Case "ReferencedCharacter", "ReferencedCharacters", "ReferencedCharacter1", "ReferencedCharacter2", "ReferencedCharacter3", "ReferencedCharacter4", "ReferencedCharacter5" |
| 344 |
Return GetType(clsCharacter) |
| 345 |
Case "ReferencedLocation" |
| 346 |
Return GetType(clsLocation) |
| 347 |
End Select |
| 348 |
If htblLocations.ContainsKey(sKey) Then Return htblLocations(sKey).GetType |
| 349 |
If htblObjects.ContainsKey(sKey) Then Return htblObjects(sKey).GetType |
| 350 |
If htblTasks.ContainsKey(sKey) Then Return htblTasks(sKey).GetType |
| 351 |
If htblEvents.ContainsKey(sKey) Then Return htblEvents(sKey).GetType |
| 352 |
If htblCharacters.ContainsKey(sKey) OrElse sKey = THEPLAYER Then Return htblCharacters(sKey).GetType |
| 353 |
If htblGroups.ContainsKey(sKey) Then Return htblGroups(sKey).GetType |
| 354 |
If htblVariables.ContainsKey(sKey) Then Return htblVariables(sKey).GetType |
| 355 |
If htblALRs.ContainsKey(sKey) Then Return htblALRs(sKey).GetType |
| 356 |
If htblHints.ContainsKey(sKey) Then Return htblHints(sKey).GetType |
| 357 |
If htblAllProperties.ContainsKey(sKey) Then Return htblAllProperties(sKey).GetType |
| 358 |
If htblUDFs.ContainsKey(sKey) Then Return htblUDFs(sKey).GetType |
| 359 |
If htblSynonyms.ContainsKey(sKey) Then Return htblSynonyms(sKey).GetType |
| 360 |
|
| 361 |
End Function |
| 362 |
|
| 363 |
|
| 364 |
Public Function GetTypeFromKeyNice(ByVal sKey As String, Optional ByVal bPlural As Boolean = False) As String |
| 365 |
|
| 366 |
If bPlural Then |
| 367 |
If htblLocations.ContainsKey(sKey) Then Return "Locations" |
| 368 |
If htblObjects.ContainsKey(sKey) Then Return "Objects" |
| 369 |
If htblTasks.ContainsKey(sKey) Then Return "Tasks" |
| 370 |
If htblEvents.ContainsKey(sKey) Then Return "Events" |
| 371 |
If htblCharacters.ContainsKey(sKey) Then Return "Characters" |
| 372 |
If htblGroups.ContainsKey(sKey) Then Return "Groups" |
| 373 |
If htblVariables.ContainsKey(sKey) Then Return "Variables" |
| 374 |
If htblALRs.ContainsKey(sKey) Then Return "Text Overrides" |
| 375 |
If htblHints.ContainsKey(sKey) Then Return "Hints" |
| 376 |
If htblAllProperties.ContainsKey(sKey) Then Return "Properties" |
| 377 |
If htblUDFs.ContainsKey(sKey) Then Return "User Functions" |
| 378 |
If htblSynonyms.ContainsKey(sKey) Then Return "Synonyms" |
| 379 |
Else |
| 380 |
If htblLocations.ContainsKey(sKey) Then Return "Location" |
| 381 |
If htblObjects.ContainsKey(sKey) Then Return "Object" |
| 382 |
If htblTasks.ContainsKey(sKey) Then Return "Task" |
| 383 |
If htblEvents.ContainsKey(sKey) Then Return "Event" |
| 384 |
If htblCharacters.ContainsKey(sKey) Then Return "Character" |
| 385 |
If htblGroups.ContainsKey(sKey) Then Return "Group" |
| 386 |
If htblVariables.ContainsKey(sKey) Then Return "Variable" |
| 387 |
If htblALRs.ContainsKey(sKey) Then Return "Text Override" |
| 388 |
If htblHints.ContainsKey(sKey) Then Return "Hint" |
| 389 |
If htblAllProperties.ContainsKey(sKey) Then Return "Property" |
| 390 |
If htblUDFs.ContainsKey(sKey) Then Return "User Function" |
| 391 |
If htblSynonyms.ContainsKey(sKey) Then Return "Synonym" |
| 392 |
End If |
| 393 |
|
| 394 |
Return "" |
| 395 |
|
| 396 |
End Function |
| 397 |
|
| 398 |
|
| 399 |
Public Function GetNameFromKey(ByVal sKey As String, Optional ByVal bQuoted As Boolean = True, Optional ByVal bPrefixItem As Boolean = True, Optional ByVal bPCase As Boolean = False) As String |
| 400 |
|
| 401 |
Dim sQ As String = "" |
| 402 |
Dim sO As String = "" |
| 403 |
Dim sC As String = "" |
| 404 |
|
| 405 |
GetNameFromKey = Nothing |
| 406 |
|
| 407 |
If sKey Is Nothing Then |
| 408 |
ErrMsg("Bad Key") |
| 409 |
Return Nothing |
| 410 |
End If |
| 411 |
|
| 412 |
If bQuoted Then |
| 413 |
sQ = "'" |
| 414 |
Else |
| 415 |
sO = "[ " |
| 416 |
sC = " ]" |
| 417 |
End If |
| 418 |
|
| 419 |
|
| 420 |
If sKey.StartsWith("Referenced") Then |
| 421 |
Select Case sLeft(sKey, 16) |
| 422 |
Case "ReferencedCharac" |
| 423 |
Select Case sKey |
| 424 |
Case "ReferencedCharacters" |
| 425 |
Return sO & sKey.Replace("ReferencedCharacters", "Referenced Characters") & sC |
| 426 |
Case "ReferencedCharacter" |
| 427 |
Return sO & sKey.Replace("ReferencedCharacter", "Referenced Character") & sC |
| 428 |
Case Else |
| 429 |
Return sO & sKey.Replace("ReferencedCharacter", "Referenced Character ") & sC |
| 430 |
End Select |
| 431 |
Case "ReferencedDirect" |
| 432 |
Select Case sKey |
| 433 |
Case "ReferencedDirections" |
| 434 |
Return sO & sKey.Replace("ReferencedDirections", "Referenced Directions") & sC |
| 435 |
Case "ReferencedDirection" |
| 436 |
Return sO & sKey.Replace("ReferencedDirection", "Referenced Direction") & sC |
| 437 |
Case Else |
| 438 |
Return sO & sKey.Replace("ReferencedDirection", "Referenced Direction ") & sC |
| 439 |
End Select |
| 440 |
Case "ReferencedObject" |
| 441 |
Select Case sKey |
| 442 |
Case "ReferencedObjects" |
| 443 |
Return sO & sKey.Replace("ReferencedObjects", "Referenced Objects") & sC |
| 444 |
Case "ReferencedObject" |
| 445 |
Return sO & sKey.Replace("ReferencedObject", "Referenced Object") & sC |
| 446 |
Case Else |
| 447 |
Return sO & sKey.Replace("ReferencedObject", "Referenced Object ") & sC |
| 448 |
End Select |
| 449 |
Case "ReferencedNumber" |
| 450 |
Select Case sKey |
| 451 |
Case "ReferencedNumbers" |
| 452 |
Return sO & sKey.Replace("ReferencedNumbers", "Referenced Numbers") & sC |
| 453 |
Case "ReferencedNumber" |
| 454 |
Return sO & sKey.Replace("ReferencedNumber", "Referenced Number") & sC |
| 455 |
Case Else |
| 456 |
Return sO & sKey.Replace("ReferencedNumber", "Referenced Number ") & sC |
| 457 |
End Select |
| 458 |
Case "ReferencedText" |
| 459 |
Select Case sKey |
| 460 |
Case "ReferencedText" |
| 461 |
Return sO & sKey.Replace("ReferencedText", "Referenced Text") & sC |
| 462 |
Case Else |
| 463 |
Return sO & sKey.Replace("ReferencedText", "Referenced Text ") & sC |
| 464 |
End Select |
| 465 |
Case "ReferencedLocati" |
| 466 |
Select Case sKey |
| 467 |
Case "ReferencedLocation" |
| 468 |
Return sO & sKey.Replace("ReferencedLocation", "Referenced Location") & sC |
| 469 |
End Select |
| 470 |
Case "ReferencedItem" |
| 471 |
Return sO & sKey.Replace("ReferencedItem", "Referenced Item") & sC |
| 472 |
End Select |
| 473 |
ElseIf sKey.StartsWith("Parameter-") Then |
| 474 |
Return sO & sKey.Replace("Parameter-", "") & sC |
| 475 |
End If |
| 476 |
If sKey = ANYOBJECT Then Return sO & "Any Object" & sC |
| 477 |
If sKey = ANYCHARACTER Then Return sO & "Any Character" & sC |
| 478 |
If sKey = NOOBJECT Then Return sO & "No Object" & sC |
| 479 |
If sKey = THEFLOOR Then Return sO & IIf(bPCase, "The Floor", "the Floor").ToString & sC |
| 480 |
If sKey = THEPLAYER Then Return IIf(bPCase, sO & "The Player Character" & sC, "the Player character").ToString |
| 481 |
If sKey = CHARACTERPROPERNAME Then Return IIf(bPrefixItem, IIf(bPCase, "Property ", "property "), "").ToString & sQ & "Name" & sQ |
| 482 |
If sKey = PLAYERLOCATION Then Return IIf(bPCase, sO & "The Player's Location" & sC, "the Player's location").ToString |
| 483 |
|
| 484 |
If htblLocations.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Location ", "location "), "").ToString & sQ & htblLocations(sKey).ShortDescription.ToString & sQ |
| 485 |
If htblObjects.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Object ", "object "), "").ToString & sQ & htblObjects(sKey).FullName & sQ |
| 486 |
If htblTasks.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Task ", "task "), "").ToString & sQ & htblTasks(sKey).Description & sQ |
| 487 |
If htblEvents.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Event ", "event "), "").ToString & sQ & htblEvents(sKey).Description & sQ |
| 488 |
If htblCharacters.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Character ", "character "), "").ToString & sQ & htblCharacters(sKey).Name(, False, False) & sQ |
| 489 |
If htblGroups.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Group ", "group "), "").ToString & sQ & htblGroups(sKey).Name & sQ |
| 490 |
If htblVariables.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Variable ", "variable "), "").ToString & sQ & htblVariables(sKey).Name & sQ |
| 491 |
If htblALRs.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Text Override ", "text override "), "").ToString & sQ & htblALRs(sKey).OldText & sQ |
| 492 |
If htblHints.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Hint ", "hint "), "").ToString & sQ & htblHints(sKey).Question & sQ |
| 493 |
If htblAllProperties.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Property ", "property "), "").ToString & sQ & htblAllProperties(sKey).Description & sQ |
| 494 |
If htblUDFs.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "User Function ", "user function "), "").ToString & sQ & htblUDFs(sKey).Name & sQ |
| 495 |
If htblSynonyms.ContainsKey(sKey) Then Return IIf(bPrefixItem, IIf(bPCase, "Synonym ", "synonym "), "").ToString & sQ & htblSynonyms(sKey).CommonName & sQ |
| 496 |
|
| 497 |
Return sKey |
| 498 |
|
| 499 |
End Function |
| 500 |
|
| 501 |
#End Region |
| 502 |
|
| 503 |
|
| 504 |
Public Enum TasksListEnum |
| 505 |
AllTasks |
| 506 |
GeneralTasks |
| 507 |
GeneralAndOverrideableSpecificTasks |
| 508 |
SpecificTasks |
| 509 |
SystemTasks |
| 510 |
End Enum |
| 511 |
' Could probably speed things up by making these permanent, defining on Adventure load, for Runner anyway |
| 512 |
Friend Function Tasks(ByVal eTasksList As TasksListEnum) As TaskHashTable |
| 513 |
|
| 514 |
Dim htblSubTasks As New TaskHashTable |
| 515 |
|
| 516 |
Select Case eTasksList |
| 517 |
Case TasksListEnum.AllTasks |
| 518 |
htblSubTasks = htblTasks |
| 519 |
Case TasksListEnum.GeneralTasks |
| 520 |
For Each Task As clsTask In htblTasks.Values |
| 521 |
If Task.TaskType = clsTask.TaskTypeEnum.General Then htblSubTasks.Add(Task, Task.Key) |
| 522 |
Next |
| 523 |
Case TasksListEnum.GeneralAndOverrideableSpecificTasks |
| 524 |
For Each Task As clsTask In htblTasks.Values |
| 525 |
If Task.TaskType = clsTask.TaskTypeEnum.General Then htblSubTasks.Add(Task, Task.Key) |
| 526 |
' A specific task is overrideable if any of the specifics are unspecified |
| 527 |
If Task.TaskType = clsTask.TaskTypeEnum.Specific Then |
| 528 |
If Task.Specifics IsNot Nothing Then |
| 529 |
For Each s As clsTask.Specific In Task.Specifics |
| 530 |
If s.Keys.Count = 1 Then |
| 531 |
If s.Keys(0) = "" Then |
| 532 |
htblSubTasks.Add(Task, Task.Key) |
| 533 |
Exit For |
| 534 |
End If |
| 535 |
End If |
| 536 |
Next |
| 537 |
End If |
| 538 |
End If |
| 539 |
Next |
| 540 |
Case TasksListEnum.SpecificTasks |
| 541 |
For Each Task As clsTask In htblTasks.Values |
| 542 |
If Task.TaskType = clsTask.TaskTypeEnum.Specific Then htblSubTasks.Add(Task, Task.Key) |
| 543 |
Next |
| 544 |
Case TasksListEnum.SystemTasks |
| 545 |
For Each Task As clsTask In htblTasks.Values |
| 546 |
If Task.TaskType = clsTask.TaskTypeEnum.System Then htblSubTasks.Add(Task, Task.Key) |
| 547 |
Next |
| 548 |
End Select |
| 549 |
|
| 550 |
Return htblSubTasks |
| 551 |
|
| 552 |
End Function |
| 553 |
|
| 554 |
|
| 555 |
Friend Function Objects(ByVal sPropertyKey As String, Optional ByVal sPropertyValue As String = "") As ObjectHashTable |
| 556 |
|
| 557 |
Dim htblSubObjects As New ObjectHashTable |
| 558 |
|
| 559 |
For Each ob As clsObject In Adventure.htblObjects.Values |
| 560 |
If ob.HasProperty(sPropertyKey) Then |
| 561 |
If sPropertyValue = "" OrElse ob.GetPropertyValue(sPropertyKey) = sPropertyValue Then |
| 562 |
htblSubObjects.Add(ob, ob.Key) |
| 563 |
End If |
| 564 |
End If |
| 565 |
Next |
| 566 |
|
| 567 |
Return htblSubObjects |
| 568 |
|
| 569 |
End Function |
| 570 |
|
| 571 |
|
| 572 |
Friend Property Introduction() As Description |
| 573 |
Get |
| 574 |
Return oIntroduction |
| 575 |
End Get |
| 576 |
Set(ByVal Value As Description) |
| 577 |
oIntroduction = Value |
| 578 |
End Set |
| 579 |
End Property |
| 580 |
|
| 581 |
Friend Property WinningText() As Description |
| 582 |
Get |
| 583 |
Return oWinningText |
| 584 |
End Get |
| 585 |
Set(ByVal Value As Description) |
| 586 |
oWinningText = Value |
| 587 |
End Set |
| 588 |
End Property |
| 589 |
|
| 590 |
Public Property Title() As String |
| 591 |
Get |
| 592 |
Return sTitle |
| 593 |
End Get |
| 594 |
Set(ByVal Value As String) |
| 595 |
sTitle = Value |
| 596 |
End Set |
| 597 |
End Property |
| 598 |
|
| 599 |
Public Property Author() As String |
| 600 |
Get |
| 601 |
Return sAuthor |
| 602 |
End Get |
| 603 |
Set(ByVal Value As String) |
| 604 |
sAuthor = Value |
| 605 |
End Set |
| 606 |
End Property |
| 607 |
|
| 608 |
Private sDefaultFontName As String = "Arial" |
| 609 |
Public Property DefaultFontName As String |
| 610 |
Get |
| 611 |
Return sDefaultFontName |
| 612 |
End Get |
| 613 |
Set(value As String) |
| 614 |
If value <> "" Then sDefaultFontName = value |
| 615 |
End Set |
| 616 |
End Property |
| 617 |
|
| 618 |
Public Property DeveloperDefaultBackgroundColour As Integer = DEFAULT_BACKGROUNDCOLOUR |
| 619 |
Public Property DeveloperDefaultInputColour As Integer = DEFAULT_INPUTCOLOUR |
| 620 |
Public Property DeveloperDefaultOutputColour As Integer = DEFAULT_OUTPUTCOLOUR |
| 621 |
Public Property DeveloperDefaultLinkColour As Integer = DEFAULT_LINKCOLOUR |
| 622 |
|
| 623 |
Private iDefaultFontSize As Integer = 12 |
| 624 |
Public Property DefaultFontSize As Integer |
| 625 |
Get |
| 626 |
Return iDefaultFontSize |
| 627 |
End Get |
| 628 |
Set(value As Integer) |
| 629 |
If value >= 8 AndAlso value <= 36 Then iDefaultFontSize = value |
| 630 |
End Set |
| 631 |
End Property |
| 632 |
|
| 633 |
Dim _iWaitTurns As Integer = 3 |
| 634 |
Public Property WaitTurns As Integer |
| 635 |
Get |
| 636 |
Return _iWaitTurns |
| 637 |
End Get |
| 638 |
Set(value As Integer) |
| 639 |
_iWaitTurns = Math.Max(value, 0) |
| 640 |
End Set |
| 641 |
End Property |
| 642 |
|
| 643 |
Public Property NotUnderstood() As String |
| 644 |
Get |
| 645 |
Return sNotUnderstood |
| 646 |
End Get |
| 647 |
Set(ByVal Value As String) |
| 648 |
sNotUnderstood = Value |
| 649 |
End Set |
| 650 |
End Property |
| 651 |
|
| 652 |
Public Property Filename() As String |
| 653 |
Get |
| 654 |
Return sFilename |
| 655 |
End Get |
| 656 |
Set(ByVal Value As String) |
| 657 |
sFilename = Value |
| 658 |
End Set |
| 659 |
End Property |
| 660 |
|
| 661 |
Public Property FullPath() As String |
| 662 |
Get |
| 663 |
Return sFullPath |
| 664 |
End Get |
| 665 |
Set(ByVal Value As String) |
| 666 |
sFullPath = Value |
| 667 |
End Set |
| 668 |
End Property |
| 669 |
|
| 670 |
Private bShowFirstRoom As Boolean = True |
| 671 |
Public Property ShowFirstRoom() As Boolean |
| 672 |
Get |
| 673 |
Return bShowFirstRoom |
| 674 |
End Get |
| 675 |
Set(ByVal value As Boolean) |
| 676 |
bShowFirstRoom = value |
| 677 |
End Set |
| 678 |
End Property |
| 679 |
|
| 680 |
Private bShowExits As Boolean = True |
| 681 |
Public Property ShowExits() As Boolean |
| 682 |
Get |
| 683 |
Return bShowExits |
| 684 |
End Get |
| 685 |
Set(ByVal value As Boolean) |
| 686 |
bShowExits = value |
| 687 |
End Set |
| 688 |
End Property |
| 689 |
|
| 690 |
Private bEnableMenu As Boolean = True |
| 691 |
Public Property EnableMenu As Boolean |
| 692 |
Get |
| 693 |
Return bEnableMenu |
| 694 |
End Get |
| 695 |
Set(value As Boolean) |
| 696 |
bEnableMenu = value |
| 697 |
End Set |
| 698 |
End Property |
| 699 |
|
| 700 |
Private bEnableDebugger As Boolean = True |
| 701 |
Public Property EnableDebugger As Boolean |
| 702 |
Get |
| 703 |
Return bEnableDebugger |
| 704 |
End Get |
| 705 |
Set(value As Boolean) |
| 706 |
bEnableDebugger = value |
| 707 |
End Set |
| 708 |
End Property |
| 709 |
|
| 710 |
Public Sub New() |
| 711 |
|
| 712 |
Title = "Untitled" |
| 713 |
Author = "Anonymous" |
| 714 |
sFilename = "untitled.taf" |
| 715 |
sGameFilename = "" |
| 716 |
With UserSession |
| 717 |
.sIt = "" |
| 718 |
.sThem = "" |
| 719 |
.sHim = "" |
| 720 |
.sHer = "" |
| 721 |
End With |
| 722 |
For i As Integer = 0 To 11 |
| 723 |
Enabled(CType(i, EnabledOptionEnum)) = True |
| 724 |
Next |
| 725 |
Turns = 0 |
| 726 |
dictAllItems = New ItemDictionary |
| 727 |
htblLocations = New LocationHashTable |
| 728 |
htblObjects = New ObjectHashTable |
| 729 |
htblTasks = New TaskHashTable |
| 730 |
htblEvents = New EventHashTable |
| 731 |
htblCharacters = New CharacterHashTable |
| 732 |
htblGroups = New GroupHashTable |
| 733 |
htblVariables = New VariableHashTable |
| 734 |
htblALRs = New ALRHashTable |
| 735 |
htblHints = New HintHashTable |
| 736 |
htblUDFs = New UDFHashTable |
| 737 |
htblAllProperties = New PropertyHashTable |
| 738 |
htblObjectProperties = New PropertyHashTable |
| 739 |
htblCharacterProperties = New PropertyHashTable |
| 740 |
htblLocationProperties = New PropertyHashTable |
| 741 |
htblSynonyms = New SynonymHashTable |
| 742 |
Introduction = New Description |
| 743 |
WinningText = New Description |
| 744 |
'#If Not www Then |
| 745 |
Map = New clsMap |
| 746 |
'#End If |
| 747 |
|
| 748 |
sDirectionsRE(DirectionsEnum.North) = "North/N" |
| 749 |
sDirectionsRE(DirectionsEnum.NorthEast) = "NorthEast/NE/North-East/N-E" |
| 750 |
sDirectionsRE(DirectionsEnum.East) = "East/E" |
| 751 |
sDirectionsRE(DirectionsEnum.SouthEast) = "SouthEast/SE/South-East/S-E" |
| 752 |
sDirectionsRE(DirectionsEnum.South) = "South/S" |
| 753 |
sDirectionsRE(DirectionsEnum.SouthWest) = "SouthWest/SW/South-West/S-W" |
| 754 |
sDirectionsRE(DirectionsEnum.West) = "West/W" |
| 755 |
sDirectionsRE(DirectionsEnum.NorthWest) = "NorthWest/NW/North-West/N-W" |
| 756 |
sDirectionsRE(DirectionsEnum.In) = "In/Inside" |
| 757 |
sDirectionsRE(DirectionsEnum.Out) = "Out/O/Outside" |
| 758 |
sDirectionsRE(DirectionsEnum.Up) = "Up/U" |
| 759 |
sDirectionsRE(DirectionsEnum.Down) = "Down/D" |
| 760 |
|
| 761 |
For Each eGen As clsCharacter.GenderEnum In New clsCharacter.GenderEnum() {clsCharacter.GenderEnum.Male, clsCharacter.GenderEnum.Female, clsCharacter.GenderEnum.Unknown} |
| 762 |
lCharMentionedThisTurn.Add(eGen, New Generic.List(Of String)) |
| 763 |
Next |
| 764 |
|
| 765 |
End Sub |
| 766 |
|
| 767 |
Friend Enum EnabledOptionEnum |
| 768 |
ShowExits |
| 769 |
EightPointCompass |
| 770 |
BattleSystem |
| 771 |
Sound |
| 772 |
Graphics |
| 773 |
UserStatusBox |
| 774 |
Score |
| 775 |
ControlPanel |
| 776 |
Debugger |
| 777 |
Map |
| 778 |
AutoComplete |
| 779 |
MouseClicks |
| 780 |
End Enum |
| 781 |
|
| 782 |
Private bEnabled(11) As Boolean |
| 783 |
Friend Property Enabled(ByVal eOption As EnabledOptionEnum) As Boolean |
| 784 |
Get |
| 785 |
Return bEnabled(eOption) |
| 786 |
End Get |
| 787 |
Set(ByVal Value As Boolean) |
| 788 |
bEnabled(eOption) = Value |
| 789 |
End Set |
| 790 |
End Property |
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
Friend ReadOnly Property AllKeys() As List(Of String) ' StringArrayList |
| 797 |
Get |
| 798 |
Dim salKeys As New List(Of String) 'stringArrayList |
| 799 |
|
| 800 |
For Each sKey As String In Me.htblALRs.Keys |
| 801 |
salKeys.Add(sKey) |
| 802 |
Next |
| 803 |
For Each sKey As String In Me.htblCharacters.Keys |
| 804 |
salKeys.Add(sKey) |
| 805 |
Next |
| 806 |
For Each sKey As String In Me.htblEvents.Keys |
| 807 |
salKeys.Add(sKey) |
| 808 |
Next |
| 809 |
For Each sKey As String In Me.htblGroups.Keys |
| 810 |
salKeys.Add(sKey) |
| 811 |
Next |
| 812 |
For Each sKey As String In Me.htblHints.Keys |
| 813 |
salKeys.Add(sKey) |
| 814 |
Next |
| 815 |
For Each skey As String In Me.htblLocations.Keys |
| 816 |
salKeys.Add(skey) |
| 817 |
Next |
| 818 |
For Each skey As String In Me.htblObjects.Keys |
| 819 |
salKeys.Add(skey) |
| 820 |
Next |
| 821 |
For Each sKey As String In Me.htblAllProperties.Keys |
| 822 |
salKeys.Add(sKey) |
| 823 |
Next |
| 824 |
For Each sKey As String In Me.htblTasks.Keys |
| 825 |
salKeys.Add(sKey) |
| 826 |
Next |
| 827 |
For Each sKey As String In Me.htblVariables.Keys |
| 828 |
salKeys.Add(sKey) |
| 829 |
Next |
| 830 |
For Each sKey As String In Me.htblUDFs.Keys |
| 831 |
salKeys.Add(sKey) |
| 832 |
Next |
| 833 |
|
| 834 |
Return salKeys |
| 835 |
|
| 836 |
End Get |
| 837 |
End Property |
| 838 |
|
| 839 |
End Class |