 Rem File: Cmd078.bas
 Rem Sub: Weapon.List
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 078 -- Weapon.List."
    Color 7,0
    End
 Endif
 Call Weapon.List
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Weapon.List
 On Local Error Goto Err.Trap31
 TempA=True
 If Config2(50)=False Then
    Call In.Room(14)
 Endif
 If TempA=False Then
    Strng="Find the Weapons Shoppe!"
    Call IO.O
    If Sysop Or Local.Mode Then
       Strng="Weapons shoppe: "+Rtrim$(Room.Array(14))
       Call IO.O
    Endif
    Exit Sub
 Endif
 Strng="The Blacksmith says: Here's a list of my inventory."
 Call IO.O
 Graphics.Off=True
 Strng="To purchase, type 'buy #', for example: Buy 12."
 Call IO.O
 Gosub Header
 Temp8=3
 Var$=Config3(74)
 Allow.Break=True
 Break=False
 Continuous=False
 Var2=False
 Do
    Allow.Break=True
    If Instr(Var$,",") Then
       Var!=Int(Val(Left$(Var$,Instr(Var$,",")-1))+.5)
       Var$=Mid$(Var$,Instr(Var$,",")+1)
    Else
       Var!=Int(Val(Var$)+.5)
       Var$=Nul
    Endif
    Var2=Var2+1
    If Var2>999 Then
       Exit Do
    Endif
    If Var!>SFalse And Var!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,Var!)
       Temp1=TreasureRecord.Weight
       Temp2#=TreasureRecord.Gold
       Temp3=False
       If TreasureRecord.Spell Then
          Call Read.Record(SpellFile,TreasureRecord.Spell)
          Temp3=SpellRecord.Level
       Else
          If TreasureRecord.Plus Then
             Temp3=TreasureRecord.Plus
          Endif
       Endif
       Temp4=TreasureRecord.Charges
       Strng=Mid$(Str$(Var2),2)
       Strng=Strng+Space$(5-Len(Str$(Var2)))
       Carriage.Return=True
       Graphics.Off=True
       Call IO.O
       Graphics.Off=False
       Strng=Rtrim$(TreasureRecord.TreasureName)
       Call Capitalize(Strng)
       Strng2=String$(30-Len(Strng),".")
       Strng=Rtrim$(TreasureRecord.Prefix1)+Strng
       Call Convert.ANSI(True,VarQ,VarR)
       Carriage.Return=True
       Graphics.On=True
       Call IO.O
       Graphics.On=False
       Call Amount2(Cdbl(Temp1),VarX$)
       Strng=Strng2+Space$(7-Len(VarX$))+VarX$
       If Temp3 Then
          Call Amount2(Cdbl(Temp3),VarX$)
          Strng=Strng+Space$(7-Len(VarX$))+VarX$
       Else
          Strng=Strng+"  <n/a>"
       Endif
       Call Amount2(Cdbl(Temp4),VarX$)
       Strng=Strng+Space$(8-Len(VarX$))+VarX$
       Call Amount2(Temp2#,VarX$)
       Strng=Strng+" "+VarX$
    Else
       Strng=Mid$(Str$(Var2),2)
       Strng=Strng+Space$(5-Len(Str$(Var2)))
       Strng=Strng+"<none>"
       Strng=Strng+String$(24,".")
       Strng=Strng+"      0      0       0  <n/a>"
    Endif
    Graphics.Off=True
    Call IO.O
    If Break Then
       Exit Do
    Endif
    If Var$=Nul Then
       Exit Do
    Endif
    Temp8=Temp8+1
    If Temp8>=User.Pagelength-2 Then
       Temp8=1
       If Continuous=False Then
          Call More.Prompt
          If No Or Quit Then
             Exit Do
          Endif
          Gosub Header
       Endif
    Endif
 Loop
 If Temp8>1 Then
    Call More.Prompt
 Endif
 Allow.Break=False
 Break=False
 Exit Sub
Header:
 Strng=Mask$+Mask$+Mask$+" Treasure Item                  Weight   Plus Charges  Gold"
 Call IO.O
 Return
Err.Resume31:
 Exit Sub
Err.Trap31:
 Resume Err.Resume31
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
