#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Ratemal!", 218, 186, 259, 164)
$Group1 = GUICtrlCreateGroup("Optionen", 8, 8, 201, 57)
$Label1 = GUICtrlCreateLabel("Zahl von:", 16, 32, 49, 17)
$Input1 = GUICtrlCreateInput("1", 72, 30, 49, 21)
$Label2 = GUICtrlCreateLabel("bis:", 128, 33, 20, 17)
$Input2 = GUICtrlCreateInput("100", 152, 30, 49, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Spielfeld", 8, 72, 201, 105)
$Label3 = GUICtrlCreateLabel("Dein Tip:", 18, 96, 47, 17)
$Input3 = GUICtrlCreateInput("", 72, 94, 49, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label4 = GUICtrlCreateLabel("Tips:", 18, 120, 27, 17)
$Input4 = GUICtrlCreateInput("", 71, 119, 49, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label5 = GUICtrlCreateLabel("Hilfe:", 18, 149, 28, 17)
$Input5 = GUICtrlCreateInput("", 71, 146, 49, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button1 = GUICtrlCreateButton("Tip abgeben", 128, 128, 73, 41, 0)
$Button2 = GUICtrlCreateButton("Neues Spiel", 128, 87, 73, 41, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

_main()

func _main()
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button2
			_gamestart()
			ExitLoop

	EndSwitch
WEnd
EndFunc

Func _gamestart()
	GUICtrlSetState($Input3, $GUI_ENABLE)
	GUICtrlSetState($Input4, $GUI_ENABLE)
	GUICtrlSetState($Input5, $GUI_ENABLE)
	GUICtrlSetData($Input3, "")
	GUICtrlSetData($Input4, "")
	GUICtrlSetData($Input5, "")
	$KI = Random(GUICtrlRead($Input1), guictrlread($Input2), 1)
	While 1
		$Msg = GUIGetMsg()
		Switch $msg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			$READ = GUICtrlRead($Input3)
			If $READ = $KI Then
				GUICtrlSetData($Input4, ""&guictrlread($Input4)+1)
				MsgBox(64, "Ratemal!", "Du hast die Zahl mit "&guictrlread($Input4)&" Versuchen erraten!")
				GUICtrlSetData($Input3, "")
				GUICtrlSetData($Input4, "")
				GUICtrlSetData($Input5, "")
				GUICtrlSetState($Input3, $GUI_DISABLE)
				GUICtrlSetState($Input4, $GUI_DISABLE)
				GUICtrlSetState($Input5, $GUI_DISABLE)
				_main()
			Else
				GUICtrlSetData($Input4, ""&guictrlread($Input4)+1)
				If $READ > $KI Then
					GUICtrlSetData($input5, "Kleiner!")
				EndIf
				If $READ < $KI Then
					GUICtrlSetData($input5, "Größer!")
				EndIf
			EndIf
		EndSwitch
	WEnd
EndFunc
