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

Sub Reroll.Character
 On Local Error Goto Err.Trap32
 If Normal.User Then
    If UserRecord.Flags And Rerolled Then
       Strng="You've already re-rolled your character!"
       Call IO.O
       Exit Sub
    Endif
 Endif
 Strng="Re-roll character(y/n)? "
 No.Input.Out="Y"
 Call IO.I
 If Yes Then
    UserRecord.Flags=UserRecord.Flags Or Rerolled
    Do While Security.Guard
       Strng="Character re-roll:"
       Call IO.O
       Strng="Change class type/name(y/n)? "
       No.Input.Out="Y"
       Call IO.I
       If Yes Then
          Call Modify.Class
       Endif
       Strng="Character re-roll:"
       Call IO.O
       Strng="Change vital statistics(y/n)? "
       No.Input.Out="Y"
       Call IO.I
       If Yes Then
          Call Modify.Stats
       Endif
       Strng="Character re-roll:"
       Call IO.O
       Strng="Change character race type/name(y/n)? "
       No.Input.Out="Y"
       Call IO.I
       If Yes Then
          Call Modify.Race
       Endif
       Strng="Character re-roll:"
       Call IO.O
       Strng="Change weapon proficiency(y/n)? "
       No.Input.Out="Y"
       Call IO.I
       If Yes Then
          Call Modify.Proficiency
       Endif
       Strng="Character re-roll:"
       Call IO.O
       Strng="Change character alignment(y/n)? "
       No.Input.Out="Y"
       Call IO.I
       If Yes Then
          Call Modify.Alignment
       Endif
       Do While Security.Guard
          Strng="All changes finished(y/n)? "
          No.Input.Out="Y"
          Call IO.I
          If Yes Then
             Exit Sub
          Endif
          If No Then
             Exit Do
          Endif
       Loop
    Loop
 Endif
Err.Resume32:
 Exit Sub
Err.Trap32:
 Resume Err.Resume32
End Sub

Sub Modify.Alignment
 On Local Error Goto ErrorTrp11
 Do While Security.Guard
    Graphics.Off=False
    Strng="Player Alignment:"
    Call IO.O
    Strng="Press "+Enter$+" for default."
    Call IO.O
    Graphics.Off=True
    For Temp5=1 To MaxAlignment
       Strng=Mid$(Str$(Temp5),2)+"> "+Rtrim$(Alignment.Name1(Temp5))
       Call IO.O
    Next
    Strng="?"
    No.Input.Out="2"
    Call IO.I
    Temp2=Int(Val(Out2))
    If Temp2>=1 And Temp2<=3 Then
       Exit Do
    Endif
 Loop
 UserRecord.Align1=Temp2-2
 Do While Security.Guard
    Graphics.Off=False
    Strng="Player Alignment:"
    Call IO.O
    Strng="Press "+Enter$+" for default."
    Call IO.O
    Graphics.Off=True
    For Temp5=1 To MaxAlignment
       Strng=Mid$(Str$(Temp5),2)+"> "+Rtrim$(Alignment.Name2(Temp5))
       Call IO.O
    Next
    Strng="?"
    No.Input.Out="2"
    Call IO.I
    Temp2=Int(Val(Out2))
    If Temp2>=1 And Temp2<=3 Then
       Exit Do
    Endif
 Loop
 UserRecord.Align2=Temp2-2
ErrorRsm11:
 Exit Sub
ErrorTrp11:
 Resume ErrorRsm11
End Sub

Sub Modify.Class
 On Local Error Goto ErrorTrp12
 Do While Security.Guard
    Graphics.Off=False
    Strng="Select your character class:"
    Call IO.O
    Strng="Press "+Enter$+" for default."
    Call IO.O
    Temp1=MaxClasses
    If Config2(7) Then
       If Disable.DM=False Then
	  Temp1=MaxClasses+2
       Endif
    Endif
    Graphics.Off=True
    For Temp5=1 To Temp1
       Strng=Mid$(Str$(Temp5),2)
       If Temp5=MaxClasses+2 Then
	  Strng=Mask$
       Endif
       Strng=Strng+"> "+Rtrim$(Class.Name(Temp5))
       Call IO.O
    Next
    Strng="?"
    No.Input.Out="1"
    Call IO.I
    Temp5=Int(Val(Out2))
    If Out2=Mask$ Then
       Temp5=MaxClasses+2
    Endif
    If Temp5>=1 And Temp5<=Temp1 Then
       Exit Do
    Endif
 Loop
 UserRecord.ClassType=Temp5
 UserRecord.ClassName=Class.Name(UserRecord.ClassType)
ErrorRsm12:
 Exit Sub
ErrorTrp12:
 Resume ErrorRsm12
End Sub

Sub Modify.Race
 On Local Error Goto ErrorTrp15
 Do While Security.Guard
    Graphics.Off=False
    Strng="Select your character race:"
    Call IO.O
    Strng="Press "+Enter$+" for default."
    Call IO.O
    Graphics.Off=True
    For Temp5=1 To MaxRaces
       Strng=Mid$(Str$(Temp5),2)+">"+Rtrim$(Race(Temp5))
       Call IO.O
    Next
    Strng="?"
    No.Input.Out="1"
    Call IO.I
    Temp2=Int(Val(Out2))
    If Temp2>=1 And Temp2<=MaxRaces Then
       UserRecord.Race=Temp2
       Exit Do
    Endif
 Loop
ErrorRsm15:
 Exit Sub
ErrorTrp15:
 Resume ErrorRsm15
End Sub

Sub Modify.Proficiency
 On Local Error Goto ErrorTrp16
 Do While Security.Guard
    Graphics.Off=False
    Strng="Weapon Proficiency:"
    Call IO.O
    Strng="Clerics may only use blunt or pole type weapons."
    Call IO.O
    Strng="Press "+Enter$+" for default."
    Call IO.O
    Graphics.Off=True
    For Temp5=1 To MaxWeapons
       Strng=Mid$(Str$(Temp5),2)+"> "+Rtrim$(Weapon.Type.Name(Temp5))
       Call IO.O
    Next
    Strng="?"
    If UserRecord.ClassType=Cleric Then
       No.Input.Out="1"
    Else
       No.Input.Out="3"
    Endif
    Call IO.I
    Temp2=Int(Val(Out2))
    If UserRecord.ClassType=Cleric Then
       If Temp2=1 Or Temp2=2 Then
	  Exit Do
       Endif
    Else
       If Temp2>=1 And Temp2<=4 Then
	  Exit Do
       Endif
    Endif
 Loop
 UserRecord.Proficiency=Temp2
 For Temp3=1 To MaxWeapons
    UserRecord.Weapons(Temp3)=False
 Next
 UserRecord.Weapons(Temp2)=10
ErrorRsm16:
 Exit Sub
ErrorTrp16:
 Resume ErrorRsm16
End Sub

Sub Modify.Stats
 On Local Error Goto ErrorTrp13
 Do While Security.Guard
    Do While Security.Guard
       Graphics.Off=False
       Strng="Enter character statistics, range from"
       Strng=Strng+Str$(Config2(8))+" to"+Str$(Config2(9))+"."
       Call IO.O
       Strng="Average less than or equal to"+Str$(Config1(4))+"."
       Call IO.O
       Strng="Press "+Enter$+" for default."
       Call IO.O
       Temp!=SFalse
       For Temp2=1 To MaxStats
	  Do While Security.Guard
	     Graphics.Off=True
	     Strng=Rtrim$(Stat(Temp2))+">"
	     No.Input.Out=Mid$(Str$(Config1(4)),2)
	     Call IO.I
	     Temp=Int(Val(Out2))
	     If Temp<Config2(8) Or Temp>Config2(9) Then
		Graphics.Off=False
		Strng="The average statistic must range from"+_
		Str$(Config2(8))+" to"+Str$(Config2(9))+"."
		Call IO.O
	     Else
		Temp!=Temp!+Temp
		UserRecord.Stats(Temp2)=Temp
		Exit Do
	     Endif
	  Loop
       Next
       Temp!=Temp!/7!
       TempX$=Str$(Temp!)
       TempX=Instr(TempX$,".")
       If TempX=False Then
	  Out2=TempX$
       Else
	  Out2=Left$(TempX$,TempX-1)+"."+Mid$(TempX$,TempX+1,1)
       Endif
       Graphics.Off=False
       If Temp!<=Config1(4) Then
	  Exit Do
       Endif
       Strng="Average"+Out2+" to high. Try again."
       Call IO.O
    Loop
    Strng="Your average is"+Out2+". Change anything(y/n)? "
    No.Input.Out="N"
    Call IO.I
    If No Then
       Exit Do
    Endif
 Loop
ErrorRsm13:
 Exit Sub
ErrorTrp13:
 Resume ErrorRsm13
End Sub

