 Rem File: Cmd023.bas
 Rem Sub: Casino
 Rem $Include: 'dndbbs.inc'

 On Error Goto Main.Error
 If Chained=0 Then ' local mode
    Call Get.Node
    Call Open.Arrays
    Call Get.Config
    Call Increase.Files
    Call Make.FileNames
    Call Reset.Cursor
    Call Detect.Share
    Call Open.Files
    Call Read.Options
    Call Valid.Node
    Call Save.Screen2(0)
    Color 14,0
    Print "DNDBBS CMD023 - Casino"
    Var$=Nul
    If Command$<>Nul Then
       Var$=Command$
    Endif
    Call Alt.Login(Var,Var$)
    If Var=False Then
       If Lost.Carrier=False Then
          Color 14,0
          Print "Codename not found."
       Endif
       Call More.Prompt
       Goto Main.Resume
    Endif
    Call Search.Mess.File(User.Index,Var1)
    If Var1 Then
       Color 14,0
       Print "Codename is in use."
       Call More.Prompt
       Goto Main.Resume
    Endif
    Call Get.User.Stats(Var)
    Timeon=Timeit!
    Time.Left=3600!
    Date.On = Format$(Now,"mm-dd-yyyy")
    Time.On = Format$(Now,"hh:mm:ss")
 Endif
 Call Casino
Main.Resume:
 If Chained=-2 Then
    Chain DND.Path+"DNDBBS.EXE"
 Endif
 Call Clear.Status.Line
 Call ScreenANSI(1,37,7)
 Color 7, 0
 Cls
 Call Save.Screen2(-1)
' Locate Max.Row,1,1
 If TempX=0 Then TempX=1
 Locate TempX,1,1
 Color 15,0
 Print
 Print "Now exiting Casino.."
 Color 7,0
 Call Decrease.Files
 End
Main.Error:
 Resume Main.Resume

Sub Casino
 On Local Error Goto Error.Trap57
 Randomize Timer
 Gosub Get.Config
 If GuestLogin Then
    If GuestRecord.GuestAllowCasino=False Then
       Strng="Guests cannot use the casino.."
       Call IO.O
       Exit Sub
    Endif
 Endif
 Do While Lost.Carrier=False
    Call Casino.Status.Line
    Graphics.Off=False
    Strng="The Game Master says:"
    Call IO.O
    Strng="Welcome to the Casino!"
    Call IO.O
    If UserRecord.Gold<>Int(UserRecord.Gold) Then
       UserRecord.Gold=Int(UserRecord.Gold)
    Endif
    If UserRecord.Gold<0# Then
       UserRecord.Gold=0#
    Endif
    Call Amount2(UserRecord.Gold,VarQ$)
    Graphics.Off=True
    Strng="You have"+VarQ$+" Gold."
    Call IO.O
    Graphics.Off=False
    No.Input.Out="Q"
    If option8=0 Then
       Strng="Game number(1-8,?=List,H=Help,T=toggle,Q to Quit)? "
    Else
       Strng="Game number(1-8,?=List,H=Help,Q to Quit)? "
    Endif
    Call IO.I
    Select Case Lcase$(Out2)
    Case "?"
       Gosub Casino.Help
    Case "h"
       Stored.Parsed.Command1="CASINO"
       Call Read.Help
    Case "q"
       Exit Do
    Case "1"
       If option1 Then
          Strng="Option restricted."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             Do While Lost.Carrier=False
                Call Casino.Status.Line
                Graphics.Off=True
                If UserRecord.Gold<0# Then
                   UserRecord.Gold=0#
                Endif
                Call Amount2(UserRecord.Gold,VarQ$)
                Strng="You have"+VarQ$+" Gold."
                Call IO.O
                Graphics.Off=False
                Strng="Slot machine:"
                Call IO.O
                Graphics.Off=True
                No.Input.Out="Q"
                Strng="Bet(0=Help,Q=Quit)? "
                Call IO.I
                If Lcase$(Out2) = "q" Then
                   Exit Do
                Endif
                Bet# = Int(Val(Out2)+.5)
                Select Case Bet#
                Case SFalse
                   Graphics.Off=False
                   If Option14#<=0# Then Option14#=10000#
                   Call Amount2(Option14#,VarQ$)
                   Strng="Casino bets from 2 to"+VarQ$+" gold:"
                   Call IO.O
                   Graphics.Off=True
                   Strng="Payoffs:"
                   Call IO.O
                   Strng=Nul
                   Call IO.O
                   Strng="1 Death  =  Lose"
                   Call IO.O
                   Strng=Nul
                   Call IO.O
                   Strng="2 Ghoul  =  2 x bet,   2 Demon  =  12 x bet."
                   Call IO.O
                   Strng="2 Ghost  =  3 x bet,   2 Devil  =  15 x bet."
                   Call IO.O
                   Strng="2 Ghast  =  5 x bet,   2 Satan  =  18 x bet."
                   Call IO.O
                   Strng=Nul
                   Call IO.O
                   Strng="3 Ghoul  = 20 x bet,   3 Demon  =  60 x bet."
                   Call IO.O
                   Strng="3 Ghost  = 40 x bet,   3 Devil  =  75 x bet."
                   Call IO.O
                   Strng="3 Ghast  = 50 x bet,   3 Satan  = 100 x bet."
                   Call IO.O
                   Call More.Prompt
                Case 2# To Option14#
                   If Bet#>UserRecord.Gold Then
                      Strng="You don't have that much Gold!"
                      Call IO.O
                   Else
                      UserRecord.Gold=UserRecord.Gold-Bet#
                      If UserRecord.Gold<0# Then
                         UserRecord.Gold=0#
                      Endif
                      Call Write.Record(UserFile,User.Index)
                      Exit Do
                   Endif
                Case Else
                   Strng="You can't bet that much Gold!"
                   Call IO.O
                End Select
             Loop
             If Lcase$(Out2) = "q" Then
                Exit Do
             Endif
             Graphics.Off=True
             For Var=1 To 3
                Do While Lost.Carrier=False
                   Choice=Int(Rnd*7)+1
                   Select Case Choice
                   Case 1
                      If Len(option1$) Then
                         Out2=option1$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.75
                      Endif
                      If Temp# Then
                         Carriage.Return=True
                         Strng="{Ghoul}"
                         Call IO.O
                         Exit Do
                      Endif
                   Case 2
                      If Len(option2$) Then
                         Out2=option2$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.75
                      Endif
                      If Temp# Then
                         Carriage.Return=True
                         Strng="{Ghost}"
                         Call IO.O
                         Exit Do
                      Endif
                   Case 3
                      If Len(option3$) Then
                         Out2=option3$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.75
                      Endif
                      If Temp# Then
                         Carriage.Return=True
                         Strng="{Ghast}"
                         Call IO.O
                         Exit Do
                      Endif
                   Case 4
                      If Len(option4$) Then
                         Out2=option4$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.5
                      Endif
                      If Temp# Then
                         Carriage.Return=True
                         Strng="{Demon}"
                         Call IO.O
                         Exit Do
                      Endif
                   Case 5
                      If Len(option5$) Then
                         Out2=option5$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.5
                      Endif
                      If Temp# Then
                         Carriage.Return=True
                         Strng="{Devil}"
                         Call IO.O
                         Exit Do
                      Endif
                   Case 6
                      If Len(option6$) Then
                         Out2=option6$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.5
                      Endif
                      If Temp# Then
                         Carriage.Return=True
                         Strng="{Satan}"
                         Call IO.O
                         Exit Do
                      Endif
                   Case 7
                      If Len(option7$) Then
                         Out2=option7$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.25
                      Endif
                      If Temp# Then
                         Carriage.Return=True
                         Strng="{Death}"
                         Call IO.O
                         Exit Do
                      Endif
                   End Select
                Loop
                Select Case Var
                Case 1
                   Wheel1=Choice
                Case 2
                   Wheel2=Choice
                Case 3
                   Wheel3=Choice
                End Select
                If option12!>0! Then
                   Tmp1!=Timeit!
                   Do While Lost.Carrier=False
                      If Time.Elapsed(Tmp1!,option12!) Then
                         Exit Do
                      Endif
                   Loop
                   If option13 Then
                      Sound Option21, Option22
                      Call Put.Modem(Chr$(7))
                   Endif
                Endif
             Next
             Strng=Nul
             Call IO.O
             Graphics.Off=False
             If Wheel1=7 Or Wheel2=7 Or Wheel3=7 Then ' death
                Strng="You lose!"
                Call IO.O
             Else
                If Wheel1=Wheel2 And Wheel2=Wheel3 Then ' all 3 match
                   VarX=0
                   Select Case Wheel1
                   Case 1
                      Bet#=Bet#*20#
                   Case 2
                      Bet#=Bet#*40#
                   Case 3
                      Bet#=Bet#*50#
                   Case 4
                      Bet#=Bet#*60#
                   Case 5
                      Bet#=Bet#*75#
                   Case 6
                      Bet#=Bet#*100#
                      VarX=-1
                   End Select
                   UserRecord.Gold=UserRecord.Gold+Bet#
                   Call Write.Record(UserFile,User.Index)
                   Call Amount2(Bet#,VarQ$)
                   Strng="You win"+VarQ$+" Gold!"
                   Call IO.O
                   If UserRecord.Level<32767 Then
                      If VarX Then
                         If UserRecord.Level+Optionzz>32767 Then
                            UserRecord.Level=32767
                         Else
                            UserRecord.Level=UserRecord.Level+Optionzz
                         Endif
                         Strng="For 3 Satans your level increases to "+Form$(Cdbl(UserRecord.Level))+"."
                         Call IO.O
                         Call Write.Record(UserFile,User.Index)
                      Endif
                   Endif
                Else
                   ' two match
                   Wheel=False
                   If Wheel1=Wheel2 Then
                      Wheel=Wheel1
                   Endif
                   If Wheel2=Wheel3 Then
                      Wheel=Wheel2
                   Endif
                   If Wheel1=Wheel3 Then
                      Wheel=Wheel3
                   Endif
                   Select Case Wheel
                   Case 1
                      Bet#=Bet#*2#
                   Case 2
                      Bet#=Bet#*3#
                   Case 3
                      Bet#=Bet#*5#
                   Case 4
                      Bet#=Bet#*12#
                   Case 5
                      Bet#=Bet#*15#
                   Case 6
                      Bet#=Bet#*18#
                   Case Else
                      Strng="You lose!"
                      Call IO.O
                   End Select
                   If Wheel Then
                      UserRecord.Gold=UserRecord.Gold+Bet#
                      Call Write.Record(UserFile,User.Index)
                      Call Amount2(Bet#,VarQ$)
                      Strng="You win"+VarQ$+" Gold!"
                      Call IO.O
                   Endif
                Endif
             Endif
          Loop
       Endif
    Case "2"
       If option2 Then
          Strng="Option restricted."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             Do While Lost.Carrier=False
                Call Casino.Status.Line
                Graphics.Off=False
                Strng="Poison bottles:"
                Call IO.O
                Graphics.Off=True
                Strng="Bet(1-"+Mid$(Str$(option14),2)+")? "
                Call IO.I
                Bet=Int(Val(Out2)+.5)
                If Bet=False Then
                   Exit Do
                Else
                   If Bet<1 Or Bet>option14 Then
                      Strng="You can't bet that much Gold!"
                      Call IO.O
                   Else
                      If Bet>UserRecord.Gold Then
                         Strng="You don't have that much Gold!"
                         Call IO.O
                      Else
                         Exit Do
                      Endif
                   Endif
                Endif
             Loop
             If Bet=False Then
                Exit Do
             Endif
             Strng="Bottle number(1-10)? "
             Call IO.I
             Bottle=Int(Val(Out2)+.5)
             If Bottle<1 Or Bottle>10 Then
                Strng="Bottle number must be from 1-10."
                Call IO.O
             Else
                UserRecord.Gold=UserRecord.Gold-Bet
                If UserRecord.Gold<0# Then
                   UserRecord.Gold=0#
                Endif
                Call Write.Record(UserFile,User.Index)
                For Tmp=1 To Option23
                   Carriage.Return=True
                   If option20=1 Then
                      Strng="(glug) "
                   Else
                      Strng="(gulp) "
                   Endif
                   Call IO.O
                   If option12!>0! Then
                      Tmp1!=Timeit!
                      Do While Lost.Carrier=False
                         If Time.Elapsed(Tmp1!,option12!) Then
                            Exit Do
                         Endif
                      Loop
                      If option13 Then
                         Sound Option21, Option22
                         Call Put.Modem(Chr$(7))
                      Endif
                   Endif
                Next
                Call IO.O
                Graphics.Off=False
                Choice=Int(Rnd*10+1)
                If Bottle=Choice Then
                   Strng="You drank a poison bottle!"
                   Call IO.O
                   UserRecord.Poison=True
                   Strng="You've been poisoned!"
                   Call IO.O
                   If Chained=-2 Then
                      Temp2=Bottle
                      Prefix2=Nul
                      Out3="drinking a poison bottle"
                      Strng="You lose"
                      Call Hit.Player(Temp2)
                   Endif
                Else
                   If Len(option8$) Then
                      TempX=Bet
                      TempY=Bottle
                      TempZ=Choice
                      Out2=option8$
                      Call Equate(Temp#)
                   Else
                      Temp#=Cdbl(Bet+1000*Abs(Bottle-Choice)+Int(Rnd*100+1))
                   Endif
                   UserRecord.Gold=UserRecord.Gold+Temp#
                   Call Write.Record(UserFile,User.Index)
                   Call Amount2(Temp#,VarQ$)
                   Strng="You survived and won"+VarQ$+" Gold!"
                   Call IO.O
                Endif
             Endif
             Graphics.Off=True
             No.Input.Out="y"
             Strng="Play again(y/n)? "
             Call IO.I
             If Lcase$(Out2)="n" Then
                Exit Do
             Endif
          Loop
       Endif
    Case "3"
       If option3 Then
          Strng="Option restricted."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             Do While Lost.Carrier=False
                Call Casino.Status.Line
                Graphics.Off=False
                Strng="Russian roulette:"
                Call IO.O
                Graphics.Off=True
                Strng="Bet(1-"+Mid$(Str$(option16),2)+")? "
                Call IO.I
                Bet=Int(Val(Out2)+.5)
                If Bet=False Then
                   Exit Do
                Else
                   If Bet<1 Or Bet>option16 Then
                      Strng="You can't bet that much Gold!"
                      Call IO.O
                   Else
                      If Bet>UserRecord.Gold Then
                         Strng="You don't have that much Gold!"
                         Call IO.O
                      Else
                         UserRecord.Gold=UserRecord.Gold-Bet
                         If UserRecord.Gold<0# Then
                            UserRecord.Gold=0#
                         Endif
                         Call Write.Record(UserFile,User.Index)
                         Exit Do
                      Endif
                   Endif
                Endif
             Loop
             If Bet=False Then
                Exit Do
             Endif
             Choice=Int(Rnd*6+1)
             Try=False
             Graphics.Off=True
             Strng="-click-"
             Call IO.O
             Do While Lost.Carrier=False
                Graphics.Off=False
                Strng="Continue(y/n)? "
                Call IO.I
                If Lcase$(Out2) = "n" Then
                   Exit Do
                Endif
                Try=Try+1
                If Try=10 Then
                   If Len(option9$) Then
                      TempX=Bet
                      TempY=Bottle
                      TempZ=Choice
                      Out2=option9$
                      Call Equate(Temp#)
                   Else
                      Temp#=Cdbl(Bet+1000+Int(Rnd*100+1))
                   Endif
                   UserRecord.Gold=UserRecord.Gold+Temp#
                   Call Write.Record(UserFile,User.Index)
                   Graphics.Off=True
                   Call Amount2(Temp#,VarQ$)
                   Strng="You survived and won"+VarQ$+" Gold!"
                   Call IO.O
                   Exit Do
                Endif
                If Int(Rnd*6+1)=Choice Then
                   Graphics.Off=True
                   Strng="*bang*"
                   Call IO.O
                   Graphics.Off=False
                   Strng="You died and lost all your gold!"
                   Call IO.O
                   UserRecord.Gold=DFalse
                   If Chained=-2 Then
                      Message1="You just died!"
                      Call Player.Died
                   Endif
                   Exit Do
                Else
                   Graphics.Off=True
                   Strng="-click-"
                   Call IO.O
                Endif
             Loop
             Graphics.Off=False
             No.Input.Out="y"
             Strng="Play again(y/n)? "
             Call IO.I
             If Lcase$(Out2)="n" Then
                Exit Do
             Endif
          Loop
       Endif
   Case "4"
       If option4 Then
          Strng="Option restricted."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             Do While Lost.Carrier=False
                Call Casino.Status.Line
                Graphics.Off=False
                Strng="Shoot craps:"
                Call IO.O
                Graphics.Off=True
                Strng="Two six-sided dice,"
                Call IO.O
                Strng="First roll 7 or 11 wins (natural),"
                Call IO.O
                Strng="First roll 2, 3, or 12 loses (craps),"
                Call IO.O
                Strng="Point is 4, 5, 6, 8, 9, 10, rolls again"
                Call IO.O
                Strng="until point and wins, or 7 and loses."
                Call IO.O
                Graphics.Off=False
                Strng="Bet(1-"+Mid$(Str$(option15),2)+")? "
                Call IO.I
                Graphics.Off=True
                Bet=Int(Val(Out2)+.5)
                If Bet=False Then
                   Exit Do
                Else
                   If Bet<1 Or Bet>option15 Then
                      Strng="You can't bet that much Gold!"
                      Call IO.O
                   Else
                      If Bet>UserRecord.Gold Then
                         Strng="You don't have that much Gold!"
                         Call IO.O
                      Else
                         UserRecord.Gold=UserRecord.Gold-Bet
                         If UserRecord.Gold<0# Then
                            UserRecord.Gold=0#
                         Endif
                         Call Write.Record(UserFile,User.Index)
                         Exit Do
                      Endif
                   Endif
                Endif
             Loop
             If Bet=False Then
                Exit Do
             Endif
             Roll=Int(Rnd*6+1)+Int(Rnd*6+1)
             Strng="First roll is"+Str$(Roll)+"."
             Call IO.O
             Graphics.Off=False
             If Roll=7 Or Roll=11 Then
                UserRecord.Gold=UserRecord.Gold+Bet
                Call Write.Record(UserFile,User.Index)
                Strng="Natural! You win "+Form$(Cdbl(Bet))+" Gold!"
                Call IO.O
             Else
                If Roll=2 Or Roll=3 Or Roll=12 Then
                   Strng="Craps! You lose!"
                   Call IO.O
                Else
                   Graphics.Off=False
                   Strng="Your point is"+Str$(Roll)+"."
                   Call IO.O
                   Number=False
                   Do While Lost.Carrier=False
                      Number=Number+1
                      Roll2=Int(Rnd*6+1)+Int(Rnd*6+1)
                      Graphics.Off=True
                      Strng="Roll number"+Str$(Number)+" is"+Str$(Roll2)+"."
                      Call IO.O
                      Graphics.Off=False
                      If Roll2=7 Then
                         Strng="You lose!"
                         Call IO.O
                         Exit Do
                      Endif
                      If Roll2=Roll Then
                         Bet=Bet*Number+Int(Rnd*Bet+1)
                         UserRecord.Gold=UserRecord.Gold+Bet
                         Call Write.Record(UserFile,User.Index)
                         Strng="Your point! You win "+Form$(Cdbl(Bet))+" Gold!"
                         Call IO.O
                         Exit Do
                      Endif
                   Loop
                Endif
             Endif
             Graphics.Off=True
             Strng="Roll again(y/n)? "
             Call IO.I
             If Lcase$(Out2)="n" Then
                Exit Do
             Endif
          Loop
       Endif
    Case "5"
       If option5 Then
          Strng="Option restricted."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             Do While Lost.Carrier=False
                Call Casino.Status.Line
                Graphics.Off=False
                Strng="Hazard:"
                Call IO.O
                Graphics.Off=True
                Strng="Three six-sided dice,"
                Call IO.O
                Strng="A single dice wager pays,"
                Call IO.O
                Strng="   2-1 for one dice,"
                Call IO.O
                Strng="   3-1 for two dice,"
                Call IO.O
                Strng="   5-1 for three dice."
                Call IO.O
                Strng="A wager on triples pays 20-1."
                Call IO.O
                Strng="A wager on totals pays 20-1."
                Call IO.O
                Do While Lost.Carrier=False
                   Graphics.Off=False
                   Strng="Wager on (S)ingles, (T)riples, (D)ice totals? "
                   Call IO.I
                   Graphics.Off=True
                   Select Case Lcase$(Out2)
                   Case "s"
                      Strng="Select dice number(1-6)? "
                      Call IO.I
                      Choice=Int(Val(Out2)+.5)
                      If Choice>=1 And Choice<=6 Then
                         Wager=1
                         Exit Do
                      Endif
                   Case "t"
                      Strng="Select dice number(1-6)? "
                      Call IO.I
                      Choice=Int(Val(Out2)+.5)
                      If Choice>=1 And Choice<=6 Then
                         Wager=2
                         Exit Do
                      Endif
                   Case "d"
                      Strng="Select total of dice(4-17)? "
                      Call IO.I
                      Choice=Int(Val(Out2)+.5)
                      If Choice>=4 And Choice<=17 Then
                         Wager=3
                         Exit Do
                      Endif
                   Case Else
                      Exit Do
                   End Select
                Loop
                Strng="Bet(1-"+Mid$(Str$(option17),2)+")? "
                Call IO.I
                Bet=Int(Val(Out2)+.5)
                If Bet=False Then
                   Exit Do
                Else
                   If Bet<1 Or Bet>option17 Then
                      Strng="You can't bet that much Gold!"
                      Call IO.O
                   Else
                      If Bet>UserRecord.Gold Then
                         Strng="You don't have that much Gold!"
                         Call IO.O
                      Else
                         UserRecord.Gold=UserRecord.Gold-Bet
                         If UserRecord.Gold<0# Then
                            UserRecord.Gold=0#
                         Endif
                         Call Write.Record(UserFile,User.Index)
                         Exit Do
                      Endif
                   Endif
                Endif
             Loop
             If Bet=False Then
                Exit Do
             Endif
             Roll1=Int(Rnd*6+1)
             Roll2=Int(Rnd*6+1)
             Roll3=Int(Rnd*6+1)
             Graphics.Off=False
             Strng="Dice rolls:"+Str$(Roll1)+","+Str$(Roll2)+","+Str$(Roll3)+"."
             Call IO.O
             Graphics.Off=True
             Total=False
             Select Case Wager
             Case 1
                If Roll1=Choice Then
                   Total=Total+1
                Endif
                If Roll2=Choice Then
                   Total=Total+1
                Endif
                If Roll3=Choice Then
                   Total=Total+1
                Endif
                If Total=False Then
                   Strng="No singles. You Lose!"
                   Call IO.O
                Else
                   Strng="Dice show"+Str$(Total)+" singles."
                   Call IO.O
                   If Total=1 Then
                      Bet=Bet*2
                   Endif
                   If Total=2 Then
                      Bet=Bet*3
                   Endif
                   If Total=3 Then
                      Bet=Bet*5
                   Endif
                   UserRecord.Gold=UserRecord.Gold+Bet
                   Call Write.Record(UserFile,User.Index)
                   Strng="You win "+Form$(Cdbl(Bet))+" Gold!"
                   Call IO.O
                Endif
             Case 2
                If Roll1=Choice And Roll2=Choice And Roll3=Choice Then
                   Strng="Dice show triples!"
                   Call IO.O
                   Bet=Bet*20
                   UserRecord.Gold=UserRecord.Gold+Bet
                   Call Write.Record(UserFile,User.Index)
                   Strng="You win "+Form$(Cdbl(Bet))+" Gold!"
                   Call IO.O
                Else
                   Strng="No triples. You Lose!"
                   Call IO.O
                Endif
             Case 3
                If Roll1+Roll2+Roll3=Choice Then
                   Strng="Dice show your totals!"
                   Call IO.O
                   Bet=Bet*20
                   UserRecord.Gold=UserRecord.Gold+Bet
                   Call Write.Record(UserFile,User.Index)
                   Strng="You win "+Form$(Cdbl(Bet))+" Gold!"
                   Call IO.O
                Else
                   Strng="No totals. You Lose!"
                   Call IO.O
                Endif
             End Select
             Graphics.Off=False
             Strng="Roll again(y/n)? "
             Call IO.I
             If Lcase$(Out2)="n" Then
                Exit Do
             Endif
          Loop
       Endif
    Case "6"
       If option6 Then
          Strng="Option restricted."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             Graphics.Off=False
             Strng="The Graffiti Wall:"
             Call IO.O
             Graphics.Off=True
             If OptionZ1 Then
                Strng="[1]Read Graffiti"
             Else
                Strng="[*]Read Graffiti"
             Endif
             Call IO.O
             If OptionZ2 Then
                Strng="[2]Write Graffiti"
             Else
                Strng="[*]Write Graffiti"
             Endif
             Call IO.O
             If OptionZ3 Then
                Strng="[3]Search Graffiti"
             Else
                Strng="[*]Search Graffiti"
             Endif
             Call IO.O
             Graphics.Off=False
             Strng="Enter Graffiti Wall choice(? for info, q to quit)? "
             No.Input.Out="q"
             Call IO.I
             Select Case Ucase$(Out2)
             Case "?"
                Graphics.Off=False
                Strng="Graffiti Info:"
                Call IO.O
                Graphics.Off=True
                If UserRecord.Buffer22>0! Then
                   Strng="You have written to the wall "+Form$(Cdbl(UserRecord.Buffer22))+" times."
                   Strng=Strng+" For a total cost of "+Form$(UserRecord.Buffer24)+" gold."
                   Call IO.O
                Endif
                If UserRecord.Buffer23>0! Then
                   Strng="You have read the wall "+Form$(Cdbl(UserRecord.Buffer23))+" times."
                   Strng=Strng+" For a total cost of "+Form$(UserRecord.Buffer25)+" gold."
                   Call IO.O
                Endif
                VarQ#=0# : VarQ2#=0#
                Close #TempFile1
                Filename=DND.Path+"GRAFFITI.DAT"
                If Dir$(FileName)<>Nul Then
                   Open Filename For Input Shared As #TempFile1
                   Do Until Eof(TempFile1)
                      Line Input #TempFile1,VarQ$
                      VarQ#=VarQ#+1#
                      VarQ2#=VarQ2#+Len(VarQ$)+2#
                   Loop
                   Strng="The wall has "+Form$(VarQ#)+" lines written on it."
                   Strng=Strng+" For a total of "+Form$(VarQ2#)+" bytes."
                   Call IO.O
                Endif
                Call More.Prompt
             Case "1"
                If optionz1=false Then
                   Strng="Option restricted."
                   Call IO.O
                Else
                   Graphics.Off=False
                   Strng="Read Graffiti:"
                   Call IO.O
                   Graphics.Off=True
                   If option12# Then
                      VarX#=option12#
                   Else
                      VarX#=100#
                   Endif
                   Strng="Cost: "+Form$(VarX#)+" Gold to read(y/n)? "
                   Call IO.I
                   If Yes Then
                      Graphics.Off=True
                      If VarX#>UserRecord.Gold Then
                         Strng="You don't have that much Gold!"
                         Call IO.O
                      Else
                         Close #TempFile1
                         Filename=DND.Path+"GRAFFITI.DAT"
                         If Dir$(FileName)<>Nul Then
                            Call Out.File(FileName,"-3") ' 04/07/2020
                         Endif
                         Strng="End of Graffiti."
                         Call IO.O
                         Call More.Prompt
                         UserRecord.Gold=UserRecord.Gold-VarX#
                         If UserRecord.Gold<0# Then
                            UserRecord.Gold=0#
                         Endif
                         UserRecord.Buffer23=UserRecord.Buffer23+1!
                         UserRecord.Buffer25=UserRecord.Buffer25+VarX#
                         Call Write.Record(UserFile,User.Index)
                      Endif
                   Endif
                Endif
             Case "2"
                If optionz2=false Then
                   Strng="Option restricted."
                   Call IO.O
                Else
                   Graphics.Off=False
                   Strng="Write Graffiti:"
                   Call IO.O
                   Graphics.Off=True
                   If option10# Then
                      VarX#=option10#
                   Else
                      VarX#=10000#
                   Endif
                   Strng="Cost: "+Form$(VarX#)+" Gold per line."
                   Call IO.O
                   Graphics.Off=False
                   Strng="Enter number of lines to buy(1-19)?"
                   Call IO.I
                   Graphics.Off=True
                   Var1=Int(Val(Out2)+.5)
                   If Var1>=1 And Var1<=19 Then
                      Var#=Cdbl(Var1)*VarX#
                      If Var#>UserRecord.Gold Then
                         Strng="You don't have that much Gold!"
                         Call IO.O
                      Else
                         Redim Temp.ArrayS(1 To 19) As String
                         Strng="Enter message. Maximum"+Str$(Var1)+" lines."
                         Call IO.O
                         Message.Length=False
                         Do While Lost.Carrier=False
                            If Message.Length<Var1 Then
                               Strng="Press "+Enter$+" on a blank line to edit."
                               Call IO.O
                               Do While Lost.Carrier=False
                                  Graphics.Off=True
                                  If Message.Length=Var1 Then
                                     Word.Wrap=False
                                  Else
                                     Word.Wrap=True
                                  Endif
                                  Strng="?"
                                  Call IO.I
                                  If No.Input Then
                                     Exit Do
                                  Endif
                                  Message.Length=Message.Length+1
                                  Out2=Rtrim$(Out2)
                                  Out2=Left$(Out2,80)
                                  Temp.ArrayS(Message.Length)=Out2
                                  If Message.Length>=Var1 Then
                                     Strng="Message buffer full."
                                     Call IO.O
                                     Exit Do
                                  Endif
                               Loop
                            Endif
                            Last.Command.Number=23
                            Temp0=Var1
                            Call Edit.Message(VarX)
                            If VarX=True Then ' continue
                               If Message.Length>=Var1 Then
                                  Strng="Message buffer full."
                               Else
                                  Strng="Continue editing."
                               Endif
                               Call IO.O
                            Endif
                            If VarX=False Then ' abort
                               Exit Do
                            Endif
                            If VarX=1 Then ' store
                               If Message.Length=False Then
                                  Strng="No message text to store.."
                                  Call IO.O
                                  Exit Do
                               Endif
                               For Var1=Message.Length To 1 Step -1
                                  If Rtrim$(Ltrim$(Temp.ArrayS(Var1)))<>Nul Then
                                     Exit For
                                  Endif
                               Next
                               VarZ=0
                               If Var1 Then
                                  ' check disabled text in array
                                  If Len(Optionx0$) Then
                                     For Var=1 To Var1
                                        Var$=Temp.ArrayS(Var)
                                        Var2$=Optionx0$
                                        Do
                                           Var2=Instr(Var2$,";")
                                           If Var2 Then
                                              Var3$=Left$(Var2$,Var2-1)
                                              Var2$=Mid$(Var2$,Var2+1)
                                              Var3$=Ltrim$(Rtrim$(Var3$))
                                              If Len(Var3$) Then
                                                 Var3=Instr(Var$,Var3$)
                                                 If Var3 Then
                                                    VarZ=-1
                                                    Exit Do
                                                 Endif
                                              Endif
                                           Else
                                              Var3$=Ltrim$(Rtrim$(Var2$))
                                              If Len(Var3$) Then
                                                 Var3=Instr(Var$,Var3$)
                                                 If Var3 Then
                                                    VarZ=-1
                                                 Endif
                                              Endif
                                              Exit Do
                                           Endif
                                        Loop
                                        If VarZ Then
                                           Strng="Illegal text in line"+Str$(Var)+" position"+Str$(Var3)+"."
                                           Call IO.O
                                           If debug.mode Then
                                              Strng="Disable text is: "+Var3$
                                              Call IO.O
                                           Endif
                                           Exit For
                                        Endif
                                     Next
                                  Endif
                                  ' check disabled char in array
                                  If VarZ=0 Then
                                     If Len(Optionx1$) Then
                                        For Var=1 To Var1
                                           Var$=Temp.ArrayS(Var)
                                           For Var2=1 To Len(Optionx1$)
                                              Var3$ = Mid$(Optionx1$,Var2,1)
                                              Var3 = Instr(Var$,Var3$)
                                              If Var3 Then
                                                 Strng="Illegal character in line"+Str$(Var)+" position"+Str$(Var3)+"."
                                                 Call IO.O
                                                 If debug.mode Then
                                                    Strng="Disable char is: "+Var3$
                                                    Call IO.O
                                                 Endif
                                                 VarZ=-1
                                                 Exit For
                                              Endif
                                           Next
                                           If VarZ Then
                                              Exit For
                                           Endif
                                        Next
                                     Endif
                                  Endif
                                  ' write array to graffiti wall datafile
                                  If VarZ=0 Then
                                     Filename=DND.Path+"GRAFFITI.DAT"
                                     Close #TempFile1
                                     Open Filename For Append Shared As #TempFile1
                                     For Var=1 To Var1
                                        Print #TempFile1,Rtrim$(Temp.ArrayS(Var))
                                     Next
                                     Strng="Message stored on the Graffiti Wall."
                                     Call IO.O
                                     Var#=Cdbl(Var1)*VarX#
                                     Strng="Cost for"+Str$(Var1)+" lines is "+Form$(Var#)+" Gold.."
                                     Call IO.O
                                     UserRecord.Gold=UserRecord.Gold-Var#
                                     If UserRecord.Gold<0# Then
                                        UserRecord.Gold=0#
                                     Endif
                                     UserRecord.Buffer22=UserRecord.Buffer22+1!
                                     UserRecord.Buffer24=UserRecord.Buffer24+Var#
                                     Call Write.Record(UserFile,User.Index)
                                  Else
                                     Strng="No message stored on the Graffiti Wall."
                                     Call IO.O
                                  Endif
                               Endif
                               Exit Do
                            Endif
                         Loop
                      Endif
                   Endif
                Endif
             Case "3"
                If optionz3=false Then
                   Strng="Option restricted."
                   Call IO.O
                Else
                   Graphics.Off=False
                   Strng="Search Graffiti:"
                   Call IO.O
                   Graphics.Off=True
                   If option13# Then
                      VarX#=option13#
                   Else
                      VarX#=100#
                   Endif
                   Strng="Cost: "+Form$(VarX#)+" Gold to search(y/n)? "
                   Call IO.I
                   If Yes Then
                      Graphics.Off=True
                      If VarX#>UserRecord.Gold Then
                         Strng="You don't have that much Gold!"
                         Call IO.O
                      Else
                         Strng="Search text(? amd * allowed): "
                         Call IO.I
                         Temp1=0
                         Var2$=Lcase$(Out2)
                         Close #TempFile1
                         Filename=DND.Path+"GRAFFITI.DAT"
                         If Dir$(FileName)<>Nul Then
                            Open Filename For Input As #TempFile1
                            Do Until Eof(TempFile1)
                               Line Input #TempFile1, Var$
                               VarX = False
                               If Var2$ = Nul Then
                                  VarX = True
                               Else
                                  Out2 = Lcase$(Var2$)
                                  Out3 = Lcase$(Var$)
                                  Call InstrSUB2(VarX) ' see if out2 in out3
                               Endif
                               If VarX Then
                                  Strng=Var$
                                  No=0:Quit=0
                                  Call Convert.String
                                  Call Convert.ANSI(True,VarQ,VarR)
                                  If No Or Quit Then ' possible moreprompt
                                     Strng=Nul:Out2=Nul
                                     Exit Do
                                  Endif
                                  Graphics.On=True
                                  Call IO.O
                                  Graphics.On=False
                                  If Break Then
                                     Exit Do
                                  Endif
                                  Temp1=Temp1+1
                                  If Temp1>=User.Pagelength-2 Then
                                     Temp1=False
                                     Call More.Prompt
                                     If No Or Quit Then
                                        Exit Do
                                     Endif
                                  Endif
                               Endif
                            Loop
                         Endif
                         Strng="End of Graffiti."
                         Call IO.O
                         Call More.Prompt
                         UserRecord.Gold=UserRecord.Gold-VarX#
                         If UserRecord.Gold<0# Then
                            UserRecord.Gold=0#
                         Endif
                         Call Write.Record(UserFile,User.Index)
                      Endif
                   Endif
                Endif
             Case "Q"
                Exit Do
             End Select
          Loop
       Endif
    Case "7" ' impossible hangman
       If option7 Then
          Strng="Option restricted."
          Call IO.O
       Else
          Close #TempFile1
          Filename=DND.Path+"letter4.txt"
          If Dir$(Filename)=Nul Then
             Strng="Hangman is currently unavailable.."
             Call IO.O
          Else
             If option11# Then
                VarX#=option11#
             Else
                VarX#=1000#
             Endif
             Graphics.Off=False
             If Option15#<=0# Then Option15#=10000#
             Call Amount2(Option15#,VarQ$)
             Strng="Hangman pays"+VarQ$+" to win.."
             Call IO.O
             Strng="Guess a word in 6 guesses.."
             Call IO.O
             Call Amount2(VarX#,VarQ$)
             Strng="Hangman costs"+VarQ$+" gold to play..."
             Call IO.O
             If UserRecord.Gold<VarX# Then
                Strng="You don't have the gold to play!"
                Call IO.O
             Else
                Strng="Press Y to play for"+VarQ$+" gold:"
                Call IO.I
                If Lcase$(Out2)="y" Then
                   UserRecord.Gold=UserRecord.Gold-VarX#
                   If UserRecord.Gold<0# Then
                      UserRecord.Gold=0#
                   Endif
                   Call Write.Record(UserFile,User.Index)
                   Filename=DND.Path+"letter5.txt"
                   If Dir$(Filename)=Nul Then
                      Var=4
                   Else
                      Do While Lost.Carrier=False
                         Strng="Choose (4)letter/(5)letter word to guess: "
                         Call IO.I
                         If Out2="4" Then
                            Var=4
                            Exit Do
                         Endif
                         If Out2="5" Then
                            Var=5
                            Exit Do
                         Endif
                      LOOP
                   Endif
                   z$ = ""
                   l = 0
                   y = 0
                   q$ = "abcdefghijklmnopqrstuvwxyz"
                   DO While Lost.Carrier=False
                      Graphics.Off=False
                      Strng = "Remaining letters: " + q$
                      Call IO.O
                      If Var=4 Then
                         Strng = "_ _ _ _"
                      Else
                         Strng = "_ _ _ _ _"
                      Endif
                      If y Then
                         Mid$(Strng, 3, 1) = "y"
                      Endif
                      Strng="Word: " + Strng
                      Call IO.O
                      DO While Lost.Carrier=False
                         Graphics.Off=True
                         Strng="Letter#"+Str$(L + 1)+"? "
                         Call IO.I
                         x$ = Out2
                         Graphics.Off=False
                         IF LEN(x$) = 1 THEN
                            x$ = LCASE$(x$)
                            IF x$ >= "a" AND x$ <= "z" THEN
                               IF INSTR(z$, x$) OR (y = -1 AND x$="y") THEN
                                  Strng="Letter already selected.."
                                  Call IO.O
                               ELSE
                                  IF x$ = "y" THEN ' at least 1 vowel must match
                                     y = -1
                                     Strng = "Match"
                                     Call IO.O
                                  ELSE ' no letters match
                                     z$ = z$ + x$
                                     Strng = "No match"
                                     Call IO.O
                                     GOSUB DisplayHangman
                                     l = l + 1
                                  END IF
                                  ' remove letter
                                  q = Instr(q$, x$)
                                  q$ = Left$(q$, q - 1) + Mid$(q$, q + 1)
                                  EXIT DO
                               END IF
                            END IF
                         END IF
                      LOOP
                      IF l = 6 THEN
                         EXIT DO
                      END IF
                   LOOP
                   ' get dictionary file
                   If Var=4 Then
                      Filename=DND.Path+"letter4.txt"
                   Else
                      Filename=DND.Path+"letter5.txt"
                   Endif
                   ' count nonmatching words
                   t = 0
                   Close #TempFile1
                   Open Filename For Input Shared As #TempFile1
                   DO While Lost.Carrier=False
                      IF EOF(TempFile1) THEN
                         EXIT DO
                      END IF
                      LINE INPUT #TempFile1, s$
                      f = 0
                      FOR l = 1 TO 6
                         t$ = MID$(z$, l, 1)
                         IF INSTR(s$, t$) THEN
                            f = -1
                            EXIT FOR
                         END IF
                      NEXT
                      ' check for at least 1 vowel
                      IF y THEN
                         IF INSTR(s$, "y") = 0 THEN
                            f = -1
                         ELSE
                            IF MID$(s$, 2, 1) <> "y" THEN
                               f = -1
                            END IF
                         END IF
                      END IF
                      IF f = 0 THEN
                         t = t + 1
                      END IF
                   LOOP
                   ' select random nonmatching word
                   z = Int(Rnd*t+1)
                   ' find nonmatching word
                   s$ = ""
                   u = 0
                   Close #TempFile1
                   Open Filename For Input Shared As #TempFile1
                   DO While Lost.Carrier=False
                      IF EOF(TempFile1) THEN
                         EXIT DO
                      END IF
                      LINE INPUT #TempFile1, s$
                      f = 0
                      FOR l = 1 TO 6
                         t$ = MID$(z$, l, 1)
                         IF INSTR(s$, t$) THEN
                            f = -1
                            EXIT FOR
                         END IF
                      NEXT
                      ' check for at least 1 vowel
                      IF y THEN
                         IF INSTR(s$, "y") = 0 THEN
                            f = -1
                         ELSE
                            IF MID$(s$, 2, 1) <> "y" THEN
                               f = -1
                            END IF
                         END IF
                      END IF
                      IF f = 0 THEN
                         u = u + 1
                      END IF
                      IF u = z THEN
                         EXIT DO
                      END IF
                   LOOP
                   Graphics.Off=True
                   IF t = 0 THEN ' doesn't happen
                      UserRecord.Gold=UserRecord.Gold+VarX#*2#
                      Strng="You win!!"
                      Call IO.O
                   ELSE
                      Strng = "You lose!!"
                      Call IO.O
                      If Debug.Mode Then
                         Strng="Unmatched words:"+Str$(t)
                         Call IO.O
                         Strng="Selected word:"+Str$(z)
                         Call IO.O
                      Endif
                      Strng = "The word was: " + s$
                      Call IO.O
                   END IF
                   Call More.Prompt
                Endif
             Endif
          Endif
       Endif
    Case "8" ' rob casino
       If option9 Then
          Strng="Option restricted."
          Call IO.O
       Else
          If UserRecord.Level=0 Then
             Strng="You can't! Your level is too low!"
             Call IO.O
          Else
             If UserRecord.Stats(2)<Option2z Then
                Strng="You can't! Your intelligence is too low!"
                Call IO.O
             Else
                Strng="Are you sure you want to rob the casino(y/n)? "
                No.Input.Out="N"
                Call IO.I
                If Yes Then
                   If Len(Optionz1$) Then
                      Out2=Optionz1$
                      Call Equate(Temp#)
                   Else
                      Temp#=Rnd>.99
                   Endif
                   If Temp# Then
                      Strng="Success! You rob the Casino!"
                      Call IO.O
                      VarQQ=0
                      If Optionz10!>0! Then
                         If UserRecord.Level<32767 Then
                            VarQQ=-1
                            VarZZ!=Csng(UserRecord.Level)
                            If VarZZ!+Optionz10!>32767! Then
                               UserRecord.Level=32767
                            Else
                               UserRecord.Level=UserRecord.Level+Optionz10!
                            Endif
                            Strng="Your level is now "+Form$(Cdbl(UserRecord.Level))+"."
                            Call IO.O
                         Endif
                      Endif
                      If Optionz10#>0# Then
                         VarQQ=-1
                         UserRecord.Gold=UserRecord.Gold+Optionz10#
                         Call Amount2(UserRecord.Gold,Var$)
                         Strng="You now have"+Var$+" Gold!"
                         Call IO.O
                      Endif
                      If VarQQ=0 Then
                         Strng="Nothing happens!"
                         Call IO.O
                      Endif
                   Else
                      If Rnd>.5 Then
                         Strng="You got caught! The Game Master shoots you in the head!"
                      Else
                         Strng="You got caught! The Game Master blows your brains out with a shotgun!"
                      Endif
                      Call IO.O
                      If Len(Option1z$) Then
                         Out2=Option1z$
                         Call Equate(Temp#)
                      Else
                         Temp#=Rnd<.75
                      Endif
                      If Temp# Then
                         UserRecord.Level=UserRecord.Level-Option1z
                         If UserRecord.Level<0 Then UserRecord.Level=0
                         If UserRecord.Level=0 Then
                            Strng="You lose all your levels!"
                         Else
                            If Option1z=1 Then
                               Strng="You lose 1 level!"
                            Else
                               Strng="You lose"+Str$(Option1z)+" levels!"
                            Endif
                         Endif
                         If UserRecord.Level=1 Then
                            Strng=Strng+" You now have 1 level!"
                         Else
                            Strng=Strng+" You now have "+Form$(Cdbl(UserRecord.Level))+" levels!"
                         Endif
                         Call IO.O
                      Endif
                      If Option3z>0 Then
                         Out2=Option3z$
                         Call Equate(Temp#)
                         Var1=Cint(Temp#)
                         If Var1>=1 And Var1<=7 Then
                            If UserRecord.Stats(Var1)>0 Then
                               UserRecord.Stats(Var1)=UserRecord.Stats(Var1)-Option3z
                               If UserRecord.Stats(Var1)<0 Then UserRecord.Stats(Var1)=0
                               Strng="You lost"+Str$(Option3z)+" "+Lcase$(Rtrim$(Stat(Var1)))+" point"
                               If Option3z=1 Then Strng=Strng+"!" Else Strng=Strng+"s!"
                               Call IO.O
                            Endif
                         Endif
                      Endif
                   Endif
                   Call Write.Record(UserFile,User.Index)
                Else
                   Strng="Nothing happens!"
                   Call IO.O
                Endif
             Endif
          Endif
       Endif
    Case "t"
       If option8 Then
          Strng="Option restricted."
          Call IO.O
       Else
          If option13 Then option13=0 else option13=-1
          strng="Sound toggled on."
          If option13=0 then strng="Sound toggled off."
          Call io.o
       Endif
    Case Else
       Strng="Type '?' for help."
       Call IO.O
    End Select
 Loop
 Exit Sub

Casino.Help:
 Graphics.Off=False
 Strng="The Game Master says 'here is the list of games'"
 Call IO.O
 Graphics.Off=True
 Var$="" : If option8=0 Then Var$="  "
 If option1 Then
    Strng="[*]Slot Machine"
 Else
    Strng="[1]Slot Machine"
 Endif
 Strng=Var$+Strng
 Call IO.O
 If option2 Then
    Strng="[*]Poison Bottles"
 Else
    Strng="[2]Poison Bottles"
 Endif
 Strng=Var$+Strng
 Call IO.O
 If option3 Then
    Strng="[*]Russian Roulette"
 Else
    Strng="[3]Russian Roulette"
 Endif
 Strng=Var$+Strng
 Call IO.O
 If option4 Then
    Strng="[*]Craps Dice Game"
 Else
    Strng="[4]Craps Dice Game"
 Endif
 Strng=Var$+Strng
 Call IO.O
 If option5 Then
    Strng="[*]Hazard Dice Game"
 Else
    Strng="[5]Hazard Dice Game"
 Endif
 Strng=Var$+Strng
 Call IO.O
 If option6 Then
    Strng="[*]Graffiti Wall"
 Else
    Strng="[6]Graffiti Wall"
 Endif
 Strng=Var$+Strng
 Call IO.O
 If option7 Then
    Strng="[*]Hangman Game"
 Else
    Strng="[7]Hangman Game"
 Endif
 Strng=Var$+Strng
 Call IO.O
 If option9 Then
    Strng="[*]Rob Casino"
 Else
    Strng="[8]Rob Casino"
 Endif
 Strng=Var$+Strng
 Call IO.O
 Strng="[H]Help List"
 Strng=Var$+Strng
 Call IO.O
 If option8=0 Then
    Graphics.Off=False
    Strng="Utility:"
    Call IO.O
    Graphics.Off=True
    Strng="  [T]oggle sound"
    Call IO.O
 Endif
Return

DisplayHangman:
 Graphics.Off=False
 Strng = "Used letters:" + z$
 Call IO.O
 Graphics.Off=True
 SELECT CASE L
 CASE 0
    Strng = "+---+--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  / \ ":Call IO.O
    Strng = "|  \-/ ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
 CASE 1
    Strng = "+---+--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  / \ ":Call IO.O
    Strng = "|  \-/ ":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
 CASE 2
    Strng = "+---+--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  / \ ":Call IO.O
    Strng = "|  \-/ ":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "| --|  ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
 CASE 3
    Strng = "+---+--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  / \ ":Call IO.O
    Strng = "|  \-/ ":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "| --|--":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
 CASE 4
    Strng = "+---+--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  / \ ":Call IO.O
    Strng = "|  \-/ ":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "| --|--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  /   ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
 CASE 5
    Strng = "+---+--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  / \ ":Call IO.O
    Strng = "|  \-/ ":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "| --|--":Call IO.O
    Strng = "|   |  ":Call IO.O
    Strng = "|  / \ ":Call IO.O
    Strng = "|      ":Call IO.O
    Strng = "|      ":Call IO.O
 CASE 6
 END SELECT
 RETURN
Get.Config:
 VarX=0
 Gosub Reset.Options
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD023]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Goto Next.Read
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Goto Next.Read
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Gosub Parse.Options
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read:
 Close #TempFile1
 Filename$=DND.Path+"CMD023.CFG"
 If Dir$(Filename$)="" Then
    Return
 Endif
 Open Filename$ For Input As #TempFile1
 Do
    If Eof(TempFile1) Then
       Exit Do
    Endif
    Line Input #TempFile1, Var$
    Var$=Ltrim$(Rtrim$(Var$))
    If Left$(Var$,1)<>";" Then
       VarX$=UserRecord.CodeName
       VarX$=Rtrim$(VarX$)
       VarX$=Ucase$(VarX$)
       If Ucase$(Var$)="["+VarX$+"]" Then
          VarZ=0
          Gosub Reset.Options
          Do
             If Eof(TempFile1) Then
                Exit Do
             Endif
             Line Input #TempFile1, Var$
             If Ucase$(Var$)="[END]" Then
                Return
             Endif
             Var=Instr(Var$,"=")
             If Var Then
                Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
                Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
                Gosub Parse.Options
             Endif
          Loop
       Endif
   Endif
 Loop
 Return
Reset.Options:
 Optionzz=1
 Option1z=1
 Option2z=10
 Option3z=0
 Option3z$="1"
 Option1z$="RND<.75"
 Optionz1$="RND>.99"
 Optionz10!=1!
 Optionz10#=10#
 Option12!=1!
 Option12#=100#
 Option13#=100#
 Option14#=10000#
 Option15#=10000#
 Option13=True
 Option14=1000
 Option15=1000
 Option16=1000
 Option17=1000
 Option20=1
 Option23=3
 ' graffiti settings
 OptionZ1=True
 OptionZ2=True
 OptionZ3=True
 Optionx0$=""
 Optionx1$=""
 ' sound frequency
 Option21 = 900
 ' sound duration
 Option22 = 6
 Return
Parse.Options:
 Select Case Lcase$(Var2$)
 Case "slot.machine.max.win"
    If Int(Val(Var3$)+.5)>0 And Int(Val(Var3$)+.5)<=32767 Then
       Optionzz=Int(Val(Var3$)+.5)
    Endif
 Case "slot.machine"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option1=-1
    End Select
 Case "poison.bottles"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option2=-1
    End Select
 Case "russian.roulette"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option3=-1
    End Select
 Case "craps.dice.game"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option4=-1
    End Select
 Case "hazard.dice.game"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option5=-1
    End Select
 Case "graffiti.wall"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option6=-1
    End Select
 Case "read.graffiti.wall"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       optionz1=0
    End Select
 Case "write.graffiti.wall"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       optionz2=0
    End Select
 Case "search.graffiti.wall"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       optionz3=0
    End Select
 Case "disable.graffiti.text"
    Optionx0$=Var3$
 Case "disable.graffiti.char"
    Optionx1$=Var3$
 Case "hangman.game"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option7=-1
    End Select
 Case "rob.casino"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option9=-1
    End Select
 Case "rob.success.equation"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          Optionz1$=Mid$(Var3$,2)
          Optionz1$=Left$(Optionz1$,Len(Optionz1$)-1)
       Endif
    Endif
 Case "rob.lose.equation"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          Option1z$=Mid$(Var3$,2)
          Option1z$=Left$(Option1z$,Len(Option1z$)-1)
       Endif
    Endif
 Case "rob.lose.level"
    Var=Int(Val(Var3$)+.5)
    If Var>=1 And Var<=10 Then
       Option1z=Var
    Endif
 Case "rob.success.level"
    Var!=Int(Val(Var3$)+.5)
    If Var!>=0! And Var!<=10! Then
       Optionz10!=Var!
    Endif
 Case "rob.success.gold"
    Var#=Int(Val(Var3$)+.5)
    If Var#>=0# Then
       Optionz10#=Var#
    Endif
 Case "required.intelligence"
    Var=Int(Val(Var3$)+.5)
    If Var>=1 And Var<=250 Then
       Option2z=Var
    Endif
 Case "stats.point.loss.equation"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          Option3z$=Mid$(Var3$,2)
          Option3z$=Left$(Option3z$,Len(Option3z$)-1)
       Endif
    Endif
 Case "stats.point.loss"
    Var=Int(Val(Var3$)+.5)
    If Var>=1 And Var<=10 Then
       Option3z=Var
    Endif
 Case "toggle.sound"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option8=-1
    End Select
 Case "slot.wheel.ghoul"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option1$=Mid$(Var3$,2)
          option1$=Left$(option1$,Len(option1$)-1)
       Endif
    Endif
 Case "slot.wheel.ghost"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option2$=Mid$(Var3$,2)
          option2$=Left$(option2$,Len(option2$)-1)
       Endif
    Endif
 Case "slot.wheel.ghast"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option3$=Mid$(Var3$,2)
          option3$=Left$(option3$,Len(option3$)-1)
       Endif
    Endif
 Case "slot.wheel.demon"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option4$=Mid$(Var3$,2)
          option4$=Left$(option4$,Len(option4$)-1)
       Endif
    Endif
 Case "slot.wheel.devil"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option5$=Mid$(Var3$,2)
          option5$=Left$(option5$,Len(option5$)-1)
       Endif
    Endif
 Case "slot.wheel.satan"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option6$=Mid$(Var3$,2)
          option6$=Left$(option6$,Len(option6$)-1)
       Endif
    Endif
 Case "slot.wheel.death"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option7$=Mid$(Var3$,2)
          option7$=Left$(option7$,Len(option7$)-1)
       Endif
    Endif
 Case "poison.bottle.win.amount"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option8$=Mid$(Var3$,2)
          option8$=Left$(option8$,Len(option8$)-1)
       Endif
    Endif
 Case "russian.roulette.win.amount"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option9$=Mid$(Var3$,2)
          option9$=Left$(option9$,Len(option9$)-1)
       Endif
    Endif
 Case "graffiti.wall.cost"
    option10#=Cdbl(Int(Val(Var3$))+.5)
 Case "hangman.game.cost"
    option11#=Int(Val(Var3$)+.5)
 Case "time.delay"
    If Int(Val(Var3$)+.5)>=0 And Int(Val(Var3$)+.5)<=10 Then
       option12!=Csng(Int(Val(Var3$)+.5))
    Endif
 Case "maximum.slot.machine"
    option14#=Cdbl(Int(Val(Var3$)+.5))
 Case "hangman.win.amount"
    option15#=Cdbl(Int(Val(Var3$)+.5))
 Case "graffiti.read.cost"
    option12#=Cdbl(Int(Val(Var3$)+.5))
 Case "graffiti.search.cost"
    option13#=Cdbl(Int(Val(Var3$)+.5))
 Case "bottle.bet"
    If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=32767 Then
       option14=Int(Val(Var3$)+.5)
    Endif
 Case "craps.bet"
    If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=32767 Then
       option15=Int(Val(Var3$)+.5)
    Endif
 Case "russian.bet"
    If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=32767 Then
       option16=Int(Val(Var3$)+.5)
    Endif
 Case "dice.bet"
    If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=32767 Then
       option17=Int(Val(Var3$)+.5)
    Endif
 Case "allow.bell"
    Select Case Lcase$(Var3$)
    Case "0", "false", "off"
       option13=0
    End Select
 Case "bottle.display"
    If Int(Val(Var3$)+.5)=2 Then
       option20=Int(Val(Var3$)+.5)
    Endif
 Case "bottle.count"
    If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=10 Then
       option23=Int(Val(Var3$)+.5)
    Endif
 Case "sound.frequency"
    If Int(Val(Var3$)+.5)>=37 And Int(Val(Var3$)+.5)<=32767 Then
       option21=Int(Val(Var3$)+.5)
    Endif
 Case "sound.duration"
    If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=32767 Then
       option22=Int(Val(Var3$)+.5)
    Endif
 End Select
 Return
Error.Resume57:
 Exit Sub
Error.Trap57:
 Strng="Casino crashed:"+Str$(Err)
 Call IO.O
 Resume Error.Resume57
End Sub

Sub Casino.Status.Line
 On Local Error Goto Error.Trap58
 Temp$=UserRecord.CodeName
 Temp$=Rtrim$(Temp$)
 Temp$=Lcase$(Temp$)
 Mid$(Temp$,1,1)=Ucase$(Mid$(Temp$,1,1))
 Temp$=Temp$+" > "
 If UserRecord.Gold<0# Then
    UserRecord.Gold=0#
 Endif
 Call Amount2(UserRecord.Gold,VarQ$)
 Temp$=Temp$+"Gold:"+VarQ$+" "
 Call Amount2(UserRecord.Bank,VarQ$)
 Temp$=Temp$+"Bank:"+VarQ$
 Temp$=Left$(Temp$,79)
 Temp$=Temp$+Space$(79-Len(Temp$))
 Call Display.Status.Line(True)
Error.Resume58:
 Exit Sub
Error.Trap58:
 Resume Error.Resume58
End Sub

Sub Clear.Status.Line
 On Local Error Goto Error.Trap58a
 Temp$=Space$(79)
 Call Display.Status.Line(False)
Error.Resume58a:
 Exit Sub
Error.Trap58a:
 Resume Error.Resume58a
End Sub

Sub Alt.Login(Var,Var$)
 On Local Error Goto ErrorTrp25
 If Instr(Var$,"/N:") Then
    Var$=Left$(Var$,Instr(Var$,"/N:")-1)
 Endif
 Out2=Nul
 Var=False
 If Len(Var$) Then
    Var2=Instr(Var$,Chr$(34))
    If Var2 Then
       Var$=Mid$(Var$,Var2+1)
       Var2=Instr(Var$,Chr$(34))
       If Var2 Then
          Out2=Left$(Var$,Var2-1)
          If Out2=Nul Then
             Exit Sub
          Endif
       Else
          Exit Sub
       Endif
    Else
       Exit Sub
    Endif
 Endif
Start.Login:
 If Out2=Nul Then
    Graphics.Off=False
    Strng="Enter codename(?=list,*=search): "
    Call IO.I
 Endif
 Strng=Lcase$(Rtrim$(Out2))
 Out2=Nul
 If Len(Strng)=0 Then
    Exit Sub
 Endif
 If Strng="?" Then
    Temp1=False
    For Temp1!=1! To Lof(UserFile)/UserRecLen
       Call Read.Record(UserFile,Temp1!)
       Out3=UserRecord.CodeName
       Out3=Lcase$(Rtrim$(Out3))
       If Out3<>"<deleted>" Then
          Strng=Out3
          Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
          Strng=Rtrim$(UserRecord.Prefix1)+Strng
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          Strng=Strng+" (level "+Form$(Cdbl(UserRecord.Level))+")"
          If UserRecord.ClassType=AsstDM Then
             Strng=Strng+" [AsstDM]"
          Endif
          If UserRecord.ClassType=DM Then
             Strng=Strng+" [DM]"
          Endif
          If UserRecord.Flags And Special.Char4 Then
             Strng=Strng+" [Sysop]"
          Endif
          Call Search.Mess.File(Temp1!,Var1)
          If Var1 Then
             Strng=Strng+" {online}"
          Endif
          Call IO.O
          Temp1=Temp1+1
          If Temp1>=User.Pagelength-2 Then
             Temp1=False
             Call More.Prompt
             If No Or Quit Then
                Exit For
             Endif
          Endif
       Endif
    Next
    If Temp1 Then
       Call More.Prompt
    Endif
    Out2=Nul
    Goto Start.Login
 Endif
 If Strng="*" Then
    Strng="Enter codename search(?,* allowed): "
    Call IO.I
    Var2$=Lcase$(Out2)
    Temp1=False
    Var2=False
    For Temp1!=1! To Lof(UserFile)/UserRecLen
       Call Read.Record(UserFile,Temp1!)
       Out3=UserRecord.CodeName
       Out3=Lcase$(Rtrim$(Out3))
       If Out3<>"<deleted>" Then
          Out2=Var2$
          Call InstrSUB2(VarX)
          If VarX Then
             Var2=True
             Strng=Out3
             Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
             Strng=Rtrim$(UserRecord.Prefix1)+Strng
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Strng=Strng+" (level "+Form$(Cdbl(UserRecord.Level))+")"
             If UserRecord.ClassType=AsstDM Then
                Strng=Strng+" [AsstDM]"
             Endif
             If UserRecord.ClassType=DM Then
                Strng=Strng+" [DM]"
             Endif
             If UserRecord.Flags And Special.Char4 Then
                Strng=Strng+" [Sysop]"
             Endif
             Call Search.Mess.File(Temp1!,Var1)
             If Var1 Then
                Strng=Strng+" {online}"
             Endif
             Call IO.O
             Temp1=Temp1+1
             If Temp1>=User.Pagelength-2 Then
                Temp1=False
                Call More.Prompt
                If No Or Quit Then
                   Exit For
                Endif
             Endif
          Endif
       Endif
    Next
    If Var2=False Then
       Strng="Codename not found."
       Call IO.O
    Endif
    If Temp1 Then
       Call More.Prompt
    Endif
    Out2=Nul
    Goto Start.Login
 Endif
 For User.Index=1! To Lof(UserFile)/UserRecLen
    Call Read.Record(UserFile,User.Index)
    Out3=UserRecord.CodeName
    Out3=Lcase$(Rtrim$(Out3))
    If Strng=Out3 Then
       Var=True ' valid name
       Exit Sub
    Endif
 Next
 User.Index=SFalse
 Exit Sub
ErrorRsm25:
 Exit Sub
ErrorTrp25:
 Security.Guard=False
 Resume ErrorRsm25
End Sub

Sub Get.Node
 On Local Error Goto Node.Error
 Var$=Command$
 Var$=Ltrim$(Rtrim$(Var$))
 If Instr(Var$,"/N:") Then
    Var$=Mid$(Var$,Instr(Var$,"/N:")+3)
    Select Case Len(Var$)
    Case 0
       Node=0
       NodeX=Nul
       Exit Sub
    Case 1 ' 0-9,A-Z
       Select Case Var$
       Case "0" To "9"
          Node=Val(Var$)+1
          NodeX=Var$
       Case "A" To "Z"
          Node=Asc(Var$)-54
          NodeX=Var$
       Case Else
          Goto Node.Error
       End Select
    Case 2 ' 10-99
       VarX=Int(Val(Var$)+.5)
       If VarX>=10 And VarX<=99 Then
          Node=VarX+27 ' 37-126
          NodeX=Mid$(Str$(VarX),2) ' 10-99
       Else
          Goto Node.Error
       Endif
    Case Else
       Goto Node.Error
    End Select
 Endif
 Exit Sub
Node.Error:
 Color 14,0
 Out2="CMD023 Module - Casino"+Chr$(13)+Chr$(10)
 Out3="Error reading node. Node must be <nul>,0-9,A-Z,10-99."
 Call Terminate.Program
End Sub

Sub Valid.Node
 On Local Error Goto ErrorTrap11
 If Node>=False And Node<=MaxNodes Then
    VarX2=Node+1
    Call Read.Message.Record(MessWorkFile1,VarX2)
    If MessWorkRecord1.ActiveNode Then
       If Rtrim$(NodeX)=Nul Then
          Strng="Node -, already active."
       Else
          Strng="Node "+NodeX+", already active."
       Endif
       Goto ErrorTrap11
    Else
       Strng=Rtrim$(MessWorkRecord1.UserName)
       Call Valid.Name(Strng)
       If TempA Then
          If Rtrim$(NodeX)=Nul Then
             Strng="Node -, active codename."
          Else
             Strng="Node "+NodeX+", active codename."
          Endif
          Goto ErrorTrap11
       Endif
    Endif
 Else
    Strng="Node '"+NodeX+"' is not a valid node number."
    Goto ErrorTrap11
 Endif
ErrorResume11:
 Exit Sub
ErrorTrap11:
 Color 14,0
 Out2="CMD023 Module - Casino"+Chr$(13)+Chr$(10)
 Out3=Strng
 Call Terminate.Program
End Sub

Sub Open.Arrays
 On Local Error Goto Array.Error
 Call Plex.Function(26)
 If (OutregsX.AX And &HFF)=&HFF Then
    Local.ANSI.Color=True
 Else
    Local.ANSI.Color=False
 Endif
 Local.Avatar.Color=False
 Call Plex.Function(27)
 If (OutregsX.AX And &HFF)=&HFF Then
    If (OutregsX.DX And &HFF)=&H16 Then
       Local.Avatar.Color=True
    Endif
 Endif
 Local.Mode=True
 Lost.Carrier=False
 Call Read.Rows(Max.Row)
 Locate Max.Row,1,1
 Call VideoInt(15,0)
 Video.Page=OutregsX.BX
Redim Alignment.Name1(1 To MaxAlignment) As String*7,_
 Alignment.Name2(1 To MaxAlignment) As String*7,_
 Class.Name(1 To MaxClassNames) As String*15,_
 Direction(1 To MaxDirections) As String*9,_
 High.Class.Name(1 To MaxClassNames) As String*15,_
 InventoryNames(1 To MaxItems) As String*8,_
 Numeral(1 To MaxNumerals) As String*5,_
 Race(1 To MaxRaces) As String*8,_
 Room.Array(1 To MaxRoomArrays) As String*40,_
 Stat(1 To MaxStats) As String*12,_
 Training.Stats(1 To MaxClassNames,1 To MaxTrainStats) As Integer,_
 Weapon.Type.Name(1 To MaxWeapons) As String*9
 Exit Sub
Array.Error:
 Color 14,0
 Out2="CMD023 Module - Casino"+Chr$(13)+Chr$(10)
 Out3="Error opening arrays. Free more RAM."
 Call Terminate.Program
End Sub

Sub Get.Config
 On Local Error Goto Config.Error
 DND.Path=Environ$("DNDBBS")
 If DND.Path<>Nul Then
    If Right$(DND.Path,1)<>"\" Then
       DND.Path=DND.Path+"\"
    Endif
 Endif
 FileName=DND.Path+"DND"+NodeX+".CFG"
 Close #TempFile1
 Open FileName For Input Shared As #TempFile1
 Line Input #TempFile1,Var$
 For Temp1=1 To MaxConfigArray1
    Input #TempFile1,Var!
 Next
 For Temp1=1 To MaxConfigArray2
    Input #TempFile1,Var%
    Select Case Temp1
    Case 48
       Allow.High.Class=Var%
    Case 81
       Allow.Remote.Edit=Var%
    Case 86
       User.Echo=Var%
    Case 87
       User.Linefeeds=Var%
    Case 88
       User.Linelength=Var%
    Case 89
       User.Pagelength=Var%
    Case 90
       User.Wordwrap=Var%
    Case 111
       Disable.DM=Var%
    Case 112
       Disable.Nodes=Var%
    Case 113
       Disable.Sysop=Var%
    End Select
 Next
 For Temp1=1 To MaxConfigArray3
    Line Input #TempFile1,Var$
    Select Case Temp1
    Case 1
       Prelog.FileName=Var$
    Case 3
       Welcome.FileName=Var$
    Case 4
       Notice.FileName=Var$
    Case 11
       Data.Path1=Var$
    Case 12
       MonClass.FileName=Var$
    Case 13
       MonTalk.FileName=Var$
    Case 15
       File.Extension1=Var$
    Case 16
       Room.FileName=Var$
    Case 17
       Object.FileName=Var$
    Case 18
       Monster.FileName=Var$
    Case 19
       Treasure.FileName=Var$
    Case 20
       Spell.FileName=Var$
    Case 21
       User.FileName=Var$
    Case 22
       NonPlayer.FileName=Var$
    Case 28
       Logoff.FileName=Var$
    Case 38
       Logoff.Help.FileName=Var$
    Case 51
       Usage.FileName=Var$
    Case 52
       Data.Path2=Var$
    Case 53
       Data.Path3=Var$
    Case 54
       Data.Path4=Var$
    Case 55
       Help.FileName1=Var$
    Case 56
       Help.Filename2=Var$
    Case 57
       Team.FileName=Var$
    Case 58
       Public.FileName=Var$
    Case 59
       Message.Base.FileName=Var$
    Case 60
       Private.FileName=Var$
    Case 61
       Help.FileName3=Var$
    Case 62
       File.Extension2=Var$
    Case 65
       Catalog.FileName=Var$
    Case 68
       MessWork.FileName=Var$
    Case 71
       Action.FileName=Var$
    Case 72
       Day.File.FileName=Var$
    Case 76
       Help.FileName4=Var$
    Case 80
       Container.FileName=Var$
    Case 85
       ANSIPrefixChar=Var$
    Case 86
       UserInv.FileName=Var$
    Case 87
       CtnInv.FileName=Var$
    Case 88
       TeamInv.FileName=Var$
    Case 89
       RoomInv.FileName=Var$
    Case 90
       MonInv.FileName=Var$
    Case 91
       Inline.FileName2=Var$
    Case 92
       Inline.FileName1=Var$
    Case 93
       Room.Desc.FileName=Var$
    End Select
 Next
 For Temp1=1 To 10
    For Temp2=1 To 4
       Input #TempFile1,Training.Stats(Temp1,Temp2)
    Next
 Next
 For Temp1=1 To 20
    Line Input #TempFile1,Room.Array(Temp1)
 Next
 MessWork.FileName=Data.Path3+MessWork.FileName
 For Temp1=1 To 10
    Line Input #TempFile1,High.Class.Name(Temp1)
 Next
 For Temp1=1 To 8
    Line Input #TempFile1,Race(Temp1)
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,Class.Name(Temp1)
 Next
 For Temp1=1 To 7
    Line Input #TempFile1,Stat(Temp1)
 Next
 For Temp1=1 To 12
    Line Input #TempFile1,Direction(Temp1)
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,Numeral(Temp1)
 Next
 For Temp1=1 To 4
    Line Input #TempFile1,Weapon.Type.Name(Temp1)
 Next
 For Temp1=1 To 3
    Line Input #TempFile1,Alignment.Name1(Temp1)
 Next
 For Temp1=1 To 3
    Line Input #TempFile1,Alignment.Name2(Temp1)
 Next
 For Temp1=1 To MaxUserCommands
    Line Input #TempFile1,Var$
    For Temp2=1 To 3
       Line Input #TempFile1,Var$
    Next
    Input #TempFile1,Var%
    For Temp2=1 To 8
       Input #TempFile1,Var%
    Next
    For Temp2=1 To 4
       Input #TempFile1,Var%
    Next
    Input #TempFile1,Var%
    Input #TempFile1,Var%
 Next
 For Temp1=1 To MaxDMcommands
    Line Input #TempFile1,Var$
    Input #TempFile1,Var%
    For Temp2=1 To 3
       Input #TempFile1,Var%
    Next
 Next
 For Temp1=1 To MaxSysopCommands
    Line Input #TempFile1,Var$
    Input #TempFile1,Var%
 Next
 For Temp1=1 To MaxNodeCommands
    Line Input #TempFile1,Var$
    For Temp2=1 To 8
       Input #TempFile1,Var%
    Next
 Next
 For Temp1=1 To MaxLetters
    Input #TempFile1,Var%
 Next
 For Temp1=1 To MaxStrips
    Line Input #TempFile1,Var$
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,Var$
    Input #TempFile1,Var%
    Input #TempFile1,Var%
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,InventoryNames(Temp1)
 Next
 Exit Sub
Config.Error:
 Color 14,0
 Out2="CMD023 Module - Casino"+Chr$(13)+Chr$(10)
 Out3="Error reading "+Lcase$(FileName)+" (error:"+Str$(Err)+"). Run Dndcnfg."
 Call Terminate.Program
End Sub

Sub Increase.Files
 On Local Error Goto Increase.Error
 Close
 Call StdinInt(62,0)
 PSP.Segment=OutregsX.BX
 Def Seg=PSP.Segment
 Command.Line=&H80
 Command.Tail=Command.Line+60
 For Var=1 To 54
    Poke Command.Tail+Var-1,&HFF
 Next
 For Var=1 To 4
    File.Handle=Peek(&H18+Var-1)
    Poke Command.Tail+Var-1,File.Handle
 Next
 Poke &H32,54
 Poke &H34,Command.Tail
 Def Seg
 Close
 Exit Sub
Increase.Error:
 Color 14,0
 Out2="Error increasing file handles."+Chr$(13)+Chr$(10)
 Out3="Increase files= in config.sys or config.nt, or run Dndcnfg."
 Call Terminate.Program
End Sub

Sub Make.FileNames
 On Local Error Goto Make.Error
 Out2=Environ$("DNDDAT")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path1=Out2
 Endif
 Out2=Environ$("DNDDOC")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path2=Out2
 Endif
 Out2=Environ$("DNDTEMP")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path3=Out2
 Endif
 Out2=Environ$("DNDMESS")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path4=Out2
 Endif
 DOS.Exit="EDTDOS"+Rtrim$(NodeX)+".BAT"
 Day.File.FileName=Data.Path1+Day.File.FileName
 Catalog.FileName=Data.Path2+Catalog.FileName+File.Extension2
 Logoff.FileName=Data.Path1+Logoff.FileName+File.Extension1
 Notice.FileName=Data.Path1+Notice.FileName+File.Extension1
 Prelog.FileName=Data.Path1+Prelog.FileName+File.Extension1
 Welcome.FileName=Data.Path1+Welcome.FileName+File.Extension1
 User.FileName=Data.Path1+User.FileName+File.Extension1
 NonPlayer.FileName=Data.Path1+NonPlayer.FileName+File.Extension1
 Room.FileName=Data.Path1+Room.FileName+File.Extension1
 Object.FileName=Data.Path1+Object.FileName+File.Extension1
 Monster.FileName=Data.Path1+Monster.FileName+File.Extension1
 Treasure.FileName=Data.Path1+Treasure.FileName+File.Extension1
 MonTalk.FileName=Data.Path1+MonTalk.FileName+File.Extension1
 MonClass.FileName=Data.Path1+MonClass.FileName+File.Extension1
 Spell.FileName=Data.Path1+Spell.FileName+File.Extension1
 Action.FileName=Data.Path1+Action.FileName+File.Extension1
 Team.FileName=Data.Path1+Team.FileName+File.Extension1
 Container.FileName=Data.Path1+Container.FileName+File.Extension1
 Message.Base.FileName=Data.Path4+Message.Base.FileName+File.Extension1
 Logon.Help.FileName=Data.Path1+Help.FileName3+File.Extension1
 UserInv.FileName=Data.Path1+UserInv.FileName+File.Extension1
 CtnInv.FileName=Data.Path1+CtnInv.FileName+File.Extension1
 TeamInv.FileName=Data.Path1+TeamInv.FileName+File.Extension1
 RoomInv.FileName=Data.Path1+RoomInv.FileName+File.Extension1
 MonInv.FileName=Data.Path1+MonInv.FileName+File.Extension1
 Room.Desc.FileName=Data.Path1+Room.Desc.FileName+File.Extension1
 Usage.FileName=Data.Path1+Usage.FileName+File.Extension1
 Help.FileName1=Data.Path1+Help.FileName1+File.Extension1
 Help.FileName2=Data.Path1+Help.FileName2+File.Extension1
 Logoff.Help.FileName=Data.Path1+Logoff.Help.FileName+File.Extension1
 Exit Sub
Make.Error:
 Color 14,0
 Out2="CMD023 Module - Casino"+Chr$(13)+Chr$(10)
 Out3="Error making "+Lcase$(FileName)+" (error:"+Str$(Err)+"). Increase files= in config.sys or run Dndcnfg."+Chr$(13)+Chr$(10)
 Call Terminate.Program
End Sub

Sub Open.Files
 On Local Error Goto Open.Error
 Close
 ActionRecLen=Len(ActionRecord)
 BufferRecLen=Len(BufferRecord)
 ContainerRecLen=Len(ContainerRecord)
 HelpRecLen1=Len(HelpRecord1)
 HelpRecLen2=Len(HelpRecord2)
 HelpRecLen3=Len(HelpRecord3)
 MessBaseRecLen=Len(MessageBaseRecord)
 MessageRecLen=Len(BufferRecord)
 MonsterRecLen=Len(MonsterRecord)
 NewMessRecLen=Len(NewMessages)
 TableRecLen=Len(TableRecord)
 UserRecLen=Len(UserRecord)
 UserProfileRecLen=Len(UserProfile)
 MonClassRecLen=Len(MonClassRecord)
 MonTalkRecLen=Len(BufferRecord)
 NonPlayerRecLen=Len(MonsterRecord)
 ObjectRecLen=Len(ObjectRecord)
 RoomDescLen=Len(BufferRecord)
 RoomRecLen=Len(RoomRecord)
 SpellRecLen=Len(SpellRecord)
 TeamRecLen=Len(TeamRecord)
 TreasureRecLen=Len(TreasureRecord)
 MessWorkRecLen1=Len(MessWorkRecord1)
 MessWorkRecLen2=Len(MessWorkRecord2)
 MessWorkRecLen3=Len(MessWorkRecord3)
 MessWorkRecLen5=Len(MessWorkRecord5)
 MessWorkRecLen4=Len(MessWorkRecord4)
 MessWorkRecLen6=Len(MessWorkRecord6)
 MessWorkRecLen7=Len(MessWorkRecord7)
 FileName=DND.Path+"ACCOUNTS.SIC"
 Open FileName For Random Shared As #SicFile Len=UserProfileRecLen

 FileName=User.FileName
 Open FileName For Random Shared As #UserFile Len=UserRecLen
 Open FileName For Random Shared As #UserFile2 Len=UserRecLen

 FileName=NonPlayer.FileName
 Open FileName For Random Shared As #NonPlayerFile Len=NonPlayerRecLen
 FileName=Room.FileName
 Open FileName For Random Shared As #RoomFile Len=RoomRecLen
 FileName=Object.FileName
 Open FileName For Random Shared As #ObjectFile Len=ObjectRecLen
 FileName=Monster.FileName
 Open FileName For Random Shared As #MonsterFile Len=MonsterRecLen
 FileName=Treasure.FileName
 Open FileName For Random Shared As #TreasureFile Len=TreasureRecLen
 FileName=MonTalk.FileName
 Open FileName For Random Shared As #MonTalkFile Len=MonTalkRecLen
 FileName=MonClass.FileName
 Open FileName For Random Shared As #MonClassFile Len=MonClassRecLen
 FileName=Spell.FileName
 Open FileName For Random Shared As #SpellFile Len=SpellRecLen
 FileName=Action.FileName
 Open FileName For Random Shared As #ActionFile Len=ActionRecLen
 FileName=Help.FileName1
 Open FileName For Random Shared As #HelpFile1 Len=HelpRecLen1
 FileName=Team.FileName
 Open FileName For Random Shared As #TeamFile Len=TeamRecLen
 FileName=Container.FileName
 Open FileName For Random Shared As #ContainerFile Len=ContainerRecLen
 FileName=Message.Base.FileName
 Open FileName For Random Shared As #MessBaseFile Len=MessBaseRecLen
 FileName=UserInv.FileName
 Open FileName For Random Shared As #UserInvFile Len=MessWorkRecLen6
 FileName=CtnInv.FileName
 Open FileName For Random Shared As #CtnInvFile Len=MessWorkRecLen6
 FileName=TeamInv.FileName
 Open FileName For Random Shared As #TeamInvFile Len=MessWorkRecLen6
 FileName=RoomInv.FileName
 Open FileName For Random Shared As #RoomInvFile Len=MessWorkRecLen6
 FileName=MonInv.FileName
 Open FileName For Random Shared As #MonInvFile Len=MessWorkRecLen6
 FileName=Room.Desc.FileName
 Open FileName For Random Shared As #RoomDescFile Len=RoomDescLen
 FileName=MessWork.FileName+"1"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile1 Len=MessWorkRecLen1
 FileName=MessWork.FileName+"2"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile2 Len=MessWorkRecLen2
 FileName=MessWork.FileName+"6"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile6 Len=MessWorkRecLen6
 FileName=MessWork.FileName+"7"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile7 Len=MessWorkRecLen7
 Exit Sub
Open.Error:
 Color 14,0
 Out2="CMD023 Module - Casino"+Chr$(13)+Chr$(10)
 Out3="Error opening "+Lcase$(FileName)+" (error:"+Str$(Err)+"). Increase files= in config.sys or run Dndcnfg."+Chr$(13)+Chr$(10)
 Call Terminate.Program
End Sub

Sub Read.Options
 On Local Error Goto Error.Trap13
 Redim Options.Array(1 To 165) As String
 Options.Lines=165
 Var=0
 Close #TempFile1
 Filename=DND.Path+"option"+nodex+".cfg"
 If Dir$(Filename)<>Nul Then
    Open Filename For Input As #TempFile1
    Do
       If Eof(TempFile1) Then
          Exit Do
       Endif
       Line Input #TempFile1, Var$
       Var$=Rtrim$(Var$)
       If Left$(Var$,1)=";" Then
          Eat$ = Nul
       Else
          If Len(Var$) Then
             Var=Var+1
             If Var>Options.Lines Then
                Options.Lines=Options.Lines+10
                Redim Preserve Options.Array(1 To Options.Lines) As String
             Endif
             Options.Array(Var)=Var$
          Endif
       Endif
    Loop
 Endif
 Options.Lines=Var
Error.Resume13:
 Exit Sub
Error.Trap13:
 Color 14,0
 Out2="CMD023 Module - Casino"+Chr$(13)+Chr$(10)
 Out3="Error"+Str$(Err)+" reading "+FileName+". Edit file and restart."
 Call Terminate.Program
 Resume Error.Resume13
End Sub

Sub Reset.Cursor
 On Local Error Goto ErrMain13
 Call ScreenANSI(1,37,7)
 Locate Max.Row-1,1,1
 Graphics.Off=False
 Line.Length=False
MainExit13:
 Exit Sub
ErrMain13:
 Resume MainExit13
End Sub

Sub Detect.Share
 On Local Error Goto ErrResume149b
 Call Plex.Function(16)
 If (OutregsX.AX And &HFF)=&HFF Then
    Share.Installed=True
 Else
    Share.Installed=False
 Endif
 Windows.Detected = False
 Call Plex.Function(22)
 If OutregsX.BX>0 Then
    Windows.Detected = True
    ' store windows version
    Win.Minor=OutregsX.BX And &HFF
    Win.Major=(OutregsX.BX And &HFF00)/256
 Endif
ErrExit149b:
 Exit Sub
ErrResume149b:
 Resume ErrExit149b
End Sub

Sub Read.Rows(Var)
 On Local Error Goto Error.Trap62x
 Temp1=50
 Locate 50,1,0
 Var=50
 Exit Sub
Next.Trap1:
 Temp1=43
 Locate 43,1,0
 Var=43
 Exit Sub
Next.Trap2:
 Temp1=25
 Locate 25,1,0
 Var=25
 Exit Sub
Next.Trap3:
 Var=12
Error.Resume62x:
 Exit Sub
Error.Trap62x:
 If Temp1=50 Then
    Resume Next.Trap1
 Endif
 If Temp1=43 Then
    Resume Next.Trap2
 Endif
 If Temp1=25 Then
    Resume Next.Trap3
 Endif
 Resume Error.Resume62x
End Sub

Sub Search.Mess.File(Var1!,Var2)
 On Local Error Goto ErrMain41
 Var2=False
 For TempA=False To MaxNodes
    Call Read.Message.Record(MessWorkFile1,TempA+1)
    Var$=MessWorkRecord1.UserName
    Select Case Rtrim$(Lcase$(Var$))
    Case "login", "logoff", "relogin"
       TempB=False
    Case Deleted$, Offline$
       TempB=False
    Case Else
       TempB=True
    End Select
    If TempB Then
       If MessWorkRecord1.UserIndex=Var1! Then
          Var2=True
          Exit For
       Endif
    Endif
 Next
MainExit41:
 Exit Sub
ErrMain41:
 Resume MainExit41
End Sub

Sub Save.Screen2(Var)
 On Local Error Goto Error.Trap62
 If Var=False Then
    VarX3=(Max.Row-1)*80+80
    Redim Temp.ArrayY(VarX3) As Long
    Redim Temp.ArrayZ(VarX3) As Double
    For Var1=1 To Max.Row
       For Var2=1 To 80
          TempZ1=Screen(Var1,Var2)
          TempZ2=Screen(Var1,Var2,1)
          VarX2=(Var1-1)*80+Var2
          Temp.ArrayY(VarX2)=TempZ1
          Temp.ArrayZ(VarX2)=TempZ2
       Next
    Next
 Else
    Cls
    For VarX=Max.Row To 1 Step -1
       For VarY=1 To 80
          VarX2=(VarX-1)*80+VarY
          If Temp.ArrayY(VarX2)<>32 Then
             Goto Next.Line
          Endif
       Next
    Next
Next.Line:
    TempX=VarX
    For Var1=1 To VarX ' Max.Row
       For Var2=1 To 80
          VarX2=(Var1-1)*80+Var2
          VarB=Int(Temp.ArrayZ(VarX2)/16)
          VarF=Temp.ArrayZ(VarX2) Mod 16
          TempZ1=Temp.ArrayY(VarX2)
          Locate Var1,Var2,0
          Color VarF,VarB
          Print Chr$(TempZ1);
       Next
    Next
 Endif
Error.Resume62:
 Exit Sub
Error.Trap62:
 Resume Error.Resume62
End Sub

Sub Amount2(Var#,Var$)
 VarX$=Ltrim$(Str$(Var#)) ' 1.111D308
 V=Instr(VarX$,"D")
 If V Then
    If Mid$(VarX$,2,1)="." Then
       VarX$=Left$(VarX$,1)+Mid$(VarX$,V)
    Endif
    Var$=" "+VarX$
 Else
    Var$=" "+Form$(Var#)
 Endif
End Sub
