Option Strict Off
Option Explicit On
Friend Class spell
	
	Public Rune1 As Byte
	Public Rune2 As Byte
	Public Rune3 As Byte
	Public Rune4 As Byte
	Public Difficulty As Byte
	Public Skill As Byte
	Public word6 As Integer
	
	Public Function SpellType() As Integer
		SpellType = word6 And &HF
	End Function
	Public Function Result() As Integer
        Result = CUShort((word6 And &H3F0) / &H10)
	End Function
	Public Function Fatigue() As Integer
        Fatigue = CUShort((word6 And &HFC00) / &H400)
	End Function
	
	'UPGRADE_NOTE: tostring was upgraded to tostring_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Public Function tostring_Renamed() As String
		If Rune1 >= 96 And Rune1 < 102 Then
			tostring_Renamed = Trim(Str(Rune1 - 95))
		Else
			tostring_Renamed = "x"
		End If
		
		If Rune2 >= 102 And Rune2 < 108 Then
			tostring_Renamed = tostring_Renamed & Trim(Str(Rune2 - 101))
		ElseIf Rune2 = 0 Then 
			tostring_Renamed = tostring_Renamed & "x"
		Else
			tostring_Renamed = tostring_Renamed & "?"
		End If
		If Rune3 >= 108 And Rune3 < 114 Then
			tostring_Renamed = tostring_Renamed & Trim(Str(Rune3 - 107))
		ElseIf Rune3 = 0 Then 
			tostring_Renamed = tostring_Renamed & "x"
		Else
			tostring_Renamed = tostring_Renamed & "?"
		End If
		If Rune4 >= 114 And Rune4 < 120 Then
			tostring_Renamed = tostring_Renamed & Trim(Str(Rune4 - 113))
		ElseIf Rune4 = 0 Then 
			tostring_Renamed = tostring_Renamed & "x"
		Else
			tostring_Renamed = tostring_Renamed & "?"
		End If
		
		tostring_Renamed = Trim(tostring_Renamed)
		
	End Function
    Public Sub setspelltype(ByRef num As Short)
        Dim l1 As Integer

        If num > 15 Then
            num = 15
        End If
        If num < 0 Then
            num = 0
        End If

        word6 = (word6 And &HFFF0)
        l1 = num
        word6 = word6 + l1
    End Sub
	
    Public Sub setresult(ByRef num As Short)
        Dim l1 As Integer

        If num > 63 Then
            num = 63
        End If
        If num < 0 Then
            num = 0
        End If

        word6 = (word6 And &HFC0F)
        l1 = num
        l1 = l1 * &H10
        word6 = word6 + l1
    End Sub
	
    Public Sub setfatigue(ByRef num As Short)
        Dim l1 As Integer

        If num > 64 Then
            num = 64
        End If
        If num < 0 Then
            num = 0
        End If

        word6 = (word6 And &H3FF)
        l1 = num
        l1 = l1 * &H400
        word6 = word6 + l1
    End Sub
End Class