 Rem File: Cmd035.bas
 Rem Sub: Curse.Self
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 035 -- Bless.Self/Curse.Self."
    Color 7,0
    End
 Endif
 If TempX Then
    Call Bless.Self
 Else
    Call Curse.Self
 Endif
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Bless.Self
 On Local Error Goto ErrorTrap31
 Gosub Get.Config1
 If Len(option1$) Then
    Out2=option1$
    Call Equate(Temp#)
 Else
    Temp#=Rnd>.75
 Endif
 If Temp# Then
    Temp2=Parse.Temp
    If Temp2<=0 Then
       Temp2=1
    Endif
    If Option3 And Normal.User Then
       Temp2=1
    Endif
    If Temp2>Option2 Then
       Temp2=Option2
    Endif
    If UserRecord.Stats(6)+Temp2<32767 Then
       UserRecord.Stats(6)=UserRecord.Stats(6)+Temp2
       Call Write.Record(UserFile,User.Index)

       Strng=Rtrim$(Stat(6))
       Strng="gained "+Form$(Cdbl(Temp2))+" "+Strng+" point"
       If Temp2>1 Then
          Strng=Strng+"s"
       Endif
       Call Update.DayFile(Strng,False,2)
       If Node>False Then
          Out2=Lcase$(Rtrim$(UserRecord.CodeName))
          Out2=Out2+" just got blessed!"
          Call Send.Mess(8,SFalse,Room,Out2)
       Endif
       Strng="You feel a magical glow about you!"
       Call IO.O
       Strng="Your piety is now "+Form$(Cdbl(UserRecord.Stats(6)))+"!"
       Call IO.O
       'Call New.Stats
       Exit Sub
    Endif
 Endif
 Strng="Nothing happens!"
 Call IO.O
 Exit Sub
Get.Config1:
 Option2=10
 Option3=0
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD035]" 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.Options1
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read:
 Close #TempFile1
 Filename$=DND.Path+"CMD035.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
          Option2=10
          Option3=0
          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.Options1
             Endif
          Loop
       Endif
    Endif
 Loop
 Return
Parse.Options1:
 Select Case Lcase$(Var2$)
 Case "bless.self"
    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 "bless.amount"
    Var3=Int(Val(Var3$)+.5)
    If Var3>=1 And Var3<=32767 Then
       Option2=Var3
    Endif
 Case "normal.user"
    Select Case Lcase$(Var3$)
    Case "-1", "on", "true
       Option3=-1
    End Select
 End Select
 Return
ErrorResume31:
 Exit Sub
ErrorTrap31:
 Resume ErrorResume31
End Sub

Sub Curse.Self
 On Local Error Goto ErrorTrap32
 Gosub Get.Config2
 If Len(option1$) Then
    Out2=option1$
    Call Equate(Temp#)
 Else
    Temp#=Rnd>.8
 Endif
 If Temp# Then
    Temp2=Parse.Temp
    If Temp2<=0 Then
       Temp2=1
    Endif
    If Option3 And Normal.User Then
       Temp2=1
    Endif
    If Temp2>Option2 Then
       Temp2=Option2
    Endif
    If UserRecord.Stats(6)-Temp2<=False Then
       UserRecord.Stats(6)=0
    Else
       UserRecord.Stats(6)=UserRecord.Stats(6)-Temp2
    Endif
    Call Write.Record(UserFile,User.Index)

    Strng=Rtrim$(Stat(6))
    Strng="lost "+Form$(Cdbl(Temp2))+" "+Strng+" point"
    If Temp2>1 Then
       Strng=Strng+"s"
    Endif
    Call Update.DayFile(Strng,False,2)
    If Node>False Then
       Out2=Lcase$(Rtrim$(UserRecord.CodeName))
       Out2=Out2+" just got cursed!"
       Call Send.Mess(8,SFalse,Room,Out2)
    Endif
    Strng="You feel a darkening about you!"
    Call IO.O
    Strng="Your piety is now "+Form$(Cdbl(UserRecord.Stats(6)))+"!"
    Call IO.O
    'Call New.Stats
    Exit Sub
 Endif
 Strng="Nothing happens!"
 Call IO.O
 Exit Sub
Get.Config2:
 Option2=10
 option3=false
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read2
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD035]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Goto Next.Read2
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Goto Next.Read2
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Gosub Parse.Options2
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read2:
 Close #TempFile1
 Filename$=DND.Path+"CMD035.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
          Option2=10
          option3=false
          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.Options2
             Endif
          Loop
       Endif
    Endif
 Loop
 Return
Parse.Options2:
 Select Case Lcase$(Var2$)
 Case "curse.self"
    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 "curse.amount"
    Var3=Int(Val(Var3$)+.5)
    If Var3>=1 And Var3<=32767 Then
       Option2=Var3
    Endif
 Case "normal.user"
    Select Case Lcase$(Var3$)
    Case "-1", "on", "true
       Option3=-1
    End Select
 End Select
 Return
ErrorResume32:
 Exit Sub
ErrorTrap32:
 Resume ErrorResume32
End Sub
