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

Sub Alchemist
 On Local Error Goto Err.Trap20
 TempA=True
 If Config2(50)=False Then
    Call In.Room(16)
 Endif
 If TempA=False Then
    Strng="Find the Alchemists Shoppe!"
    Call IO.O
    If Sysop Or Local.Mode Then
       Strng="Alchemists shoppe: "+Rtrim$(Room.Array(16))
       Call IO.O
    Endif
    Exit Sub
 Endif
 Call Check.User.Items
 If Temp7!<=SFalse Then ' object
    Strng="The Alchemist says: That can't be recharged here!"
    Call IO.O
    Exit Sub
 Endif
 Temp1!=TreasureRecord.Spell
 If Temp1!<=SFalse Or Temp1!>Lof(SpellFile)/SpellRecLen Then
    Strng="The Alchemist says: You can't recharge that here!"
    Call IO.O
    Exit Sub
 Endif
 Call Read.Record(SpellFile,Temp1!)
 If SpellRecord.SpellType=4 Then ' wish spell
    Strng="The Alchemist says: I won't recharge that item!"
    Call IO.O
    Exit Sub
 Endif
 If MessWorkRecord6.Charges>False Then
    Strng="The Alchemist says: That's not discharged!"
    Call IO.O
    Exit Sub
 Endif
 Temp!=Int(TreasureRecord.Gold*Config1(18))
 If Temp!=SFalse Then
    Temp!=1!
 Endif
 If Temp!>UserRecord.Gold Then
    Strng="The Alchemist says: You don't have enough gold!"
    Call IO.O
    Exit Sub
 Endif
 Strng="The Alchemist says: How about"+Str$(Temp!)+" gold?"
 No.Input.Out="y"
 Call IO.I
 If Yes Then
    UserRecord.Gold=UserRecord.Gold-Temp!
    MessWorkRecord6.Charges=TreasureRecord.Charges
    Call Write.Record(MessWorkFile6,Temp5!)
    Strng="The Alchemist chants an invocation."
    Call IO.O
    Exit Sub
 Endif
 If Rnd>.5 Then
    Strng="The Alchemist says: Too bad!"
 Else
    Strng="The Alchemist says: Ho hum!"
 Endif
 Call IO.O
Err.Resume20:
 Exit Sub
Err.Trap20:
 Resume Err.Resume20
End Sub
