Erstes Spiel: 'Scheiß Spiel'

  • So ich stelle mal mein Spiel vor: Scheiß Spiel.
    Ziel ist es durch würfeln alle Sticks am Ende weg zu bekommen und somit den Computer damit zu besiegen!
    Einfach auf Würfeln klicken, der Rest geht von selbst ;)

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    $Form1 = GUICreate("'Scheiß Spiel'", 596, 138, 192, 124)
    $1 = GUICtrlCreateCheckbox("1", 16, 88, 25, 17)
    $2 = GUICtrlCreateCheckbox("2", 48, 48, 25, 17)
    $3 = GUICtrlCreateCheckbox("3", 144, 16, 33, 17)
    $4 = GUICtrlCreateCheckbox("4", 232, 48, 25, 17)
    $5 = GUICtrlCreateCheckbox("5", 272, 88, 25, 17)
    $6 = GUICtrlCreateRadio("6", 144, 88, 25, 17)
    $Group1 = GUICtrlCreateGroup("Spielfeld", 8, 0, 321, 129)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup("Würfel", 336, 0, 161, 129)
    $Label1 = GUICtrlCreateLabel("Spieler 1 ist dran!", 344, 16, 129, 17)
    $Button1 = GUICtrlCreateButton("Würflen", 344, 48, 147, 41, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("weiter", 344, 87, 147, 41, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group3 = GUICtrlCreateGroup("Sticks", 504, 0, 89, 129)
    $Label2 = GUICtrlCreateLabel("Du:", 512, 16, 21, 17)
    $SticksP = GUICtrlCreateLabel("IIIIIIIII", 512, 32, 71, 33)
    $Label4 = GUICtrlCreateLabel("Computer:", 512, 72, 52, 17)
    $SticksC = GUICtrlCreateLabel("IIIIIIIII", 513, 86, 71, 33)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    $next = False
    MsgBox(0, "Hilfe", "Drücke F1 für die Hilfe!")
    HotKeySet("{F1}", "_Help")
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    _GoUser()
    Case $Button2
    _weiter("User")
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _GoPC()
    $next = False
    $W = Random(1, 6, 1)
    $nNext = Random(0, 1, 1)
    If $nNext = 1 Then _weiter("PC")
    GUICtrlSetData($Label1, "Computer hat " & $W & " gewürfelt!")
    Switch $W
    Case 1
    If GUICtrlRead($1) = $GUI_CHECKED Then
    GUICtrlSetState($1, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksC)
    GUICtrlSetData($SticksC, $sticks & "I")
    MsgBox(0, "Nächster", "Du bist der nächste!")
    Else
    GUICtrlSetState($1, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksC)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksC, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Verloren!", "Tut mir leid aber der Computer hat gewonnen!")
    EndIf
    _GoPC()
    EndIf
    Case 2
    If GUICtrlRead($2) = $GUI_CHECKED Then
    GUICtrlSetState($2, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksC)
    GUICtrlSetData($SticksC, $sticks & "I")
    MsgBox(0, "Nächster", "Du bist der nächste!")
    Else
    GUICtrlSetState($2, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksC)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksC, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Verloren!", "Tut mir leid aber der Computer hat gewonnen!")
    EndIf
    _GoPC()
    EndIf
    Case 3
    If GUICtrlRead($3) = $GUI_CHECKED Then
    GUICtrlSetState($3, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksC)
    GUICtrlSetData($SticksC, $sticks & "I")
    MsgBox(0, "Nächster", "Du bist der nächste!")
    Else
    GUICtrlSetState($3, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksC)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksC, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Verloren!", "Tut mir leid aber der Computer hat gewonnen!")
    EndIf
    _GoPC()
    EndIf
    Case 4
    If GUICtrlRead($4) = $GUI_CHECKED Then
    GUICtrlSetState($1, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksC)
    GUICtrlSetData($SticksC, $sticks & "I")
    MsgBox(0, "Nächster", "Du bist der nächste!")
    Else
    GUICtrlSetState($4, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksC)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksC, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Verloren!", "Tut mir leid aber der Computer hat gewonnen!")
    EndIf
    _GoPC()
    EndIf
    Case 5
    If GUICtrlRead($5) = $GUI_CHECKED Then
    GUICtrlSetState($5, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksC)
    GUICtrlSetData($SticksC, $sticks & "I")
    MsgBox(0, "Nächster", "Du bist der nächste!")
    Else
    GUICtrlSetState($5, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksC)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksC, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Verloren!", "Tut mir leid aber der Computer hat gewonnen!")
    EndIf
    _GoPC()
    EndIf
    Case 6
    GUICtrlSetState($6, $GUI_CHECKED)
    Sleep(1000)
    GUICtrlSetState($6, $GUI_UNCHECKED)
    _GoPC()
    EndSwitch
    EndFunc ;==>_GoPC

    [/autoit] [autoit][/autoit] [autoit]

    Func _GoUser()
    $W = Random(1, 6, 1)
    $next = True
    GUICtrlSetData($Label1, "Spieler 1 hat " & $W & " gewürfelt!")
    Switch $W
    Case 1
    If GUICtrlRead($1) = $GUI_CHECKED Then
    GUICtrlSetState($1, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksP)
    GUICtrlSetData($SticksP, $sticks & "I")
    MsgBox(0, "Eins Ziehen!", "Tut mir leid! Aber du musst ein Stick ziehen!")
    _GoPC()
    Else
    GUICtrlSetState($1, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksP)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksP, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Gewonnen!", "Glückwunsch! Du hast den Computer geschlagen und gewonnen!")
    EndIf
    EndIf
    Case 2
    If GUICtrlRead($2) = $GUI_CHECKED Then
    GUICtrlSetState($2, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksP)
    MsgBox(0, "", $sticks)
    GUICtrlSetData($SticksP, $sticks & "I")
    MsgBox(0, "Eins Ziehen!", "Tut mir leid! Aber du musst ein Stick ziehen!")
    _GoPC()
    Else
    GUICtrlSetState($2, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksP)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksP, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Gewonnen!", "Glückwunsch! Du hast den Computer geschlagen und gewonnen!")
    EndIf
    EndIf
    Case 3
    If GUICtrlRead($3) = $GUI_CHECKED Then
    GUICtrlSetState($3, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksP)
    GUICtrlSetData($SticksP, $sticks & "I")
    MsgBox(0, "Eins Ziehen!", "Tut mir leid! Aber du musst ein Stick ziehen!")
    _GoPC()
    Else
    GUICtrlSetState($3, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksP)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksP, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Gewonnen!", "Glückwunsch! Du hast den Computer geschlagen und gewonnen!")
    EndIf
    EndIf
    Case 4
    If GUICtrlRead($4) = $GUI_CHECKED Then
    GUICtrlSetState($1, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksP)
    GUICtrlSetData($SticksP, $sticks & "I")
    MsgBox(0, "Eins Ziehen!", "Tut mir leid! Aber du musst ein Stick ziehen!")
    _GoPC()
    Else
    GUICtrlSetState($4, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksP)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksP, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Gewonnen!", "Glückwunsch! Du hast den Computer geschlagen und gewonnen!")
    EndIf
    EndIf
    Case 5
    If GUICtrlRead($5) = $GUI_CHECKED Then
    GUICtrlSetState($5, $GUI_UNCHECKED)
    $sticks = GUICtrlRead($SticksP)
    GUICtrlSetData($SticksP, $sticks & "I")
    MsgBox(0, "Eins Ziehen!", "Tut mir leid! Aber du musst ein Stick ziehen!")
    _GoPC()
    Else
    GUICtrlSetState($5, $GUI_CHECKED)
    $sticks = GUICtrlRead($SticksP)
    If Not $sticks = "" Then
    GUICtrlSetData($SticksP, StringRight($sticks, StringLen($sticks) - 1))
    Else
    MsgBox(0, "Gewonnen!", "Glückwunsch! Du hast den Computer geschlagen und gewonnen!")
    EndIf
    EndIf
    Case 6
    GUICtrlSetState($6, $GUI_CHECKED)
    MsgBox(0, "6 Gewürfelt", "Glückwunsch du hast die 6 gewürfelt!")
    GUICtrlSetState($6, $GUI_UNCHECKED)
    EndSwitch
    EndFunc ;==>_GoUser

    [/autoit] [autoit][/autoit] [autoit]

    Func _Help()
    MsgBox(0, "Hilfe", "Das Ziel ist es möglichst schnell alle Sticks weg zu bekommen." & @CRLF & _
    "Dazu Würfelst du, und setzt einen Stick auf das Feld das du gewürfelt hast. Das Script macht dies sogar automatisch." & @CRLF & _
    "Ist in dem Feld jedoch schon ein Stick musst du diesen herausnehmen und der Gegner ist dran." & @CRLF & _
    "Bist du dran und hattest gerade einmal gewürfelt, kannst du den Würfel weiter geben!")
    EndFunc ;==>_Help

    [/autoit] [autoit][/autoit] [autoit]

    Func _weiter($who)
    Switch $who
    Case "User"
    If $next = True Then
    _GoPC()
    Else
    MsgBox(0, "Tut mir leid!", "Tut mir leid, aber du musst noch einmal würfeln!")
    EndIf
    Case "PC"
    If $next = False Then
    _GoUser()
    Else
    EndIf
    EndSwitch
    EndFunc ;==>_weiter

    [/autoit]
  • Hey

    Ich finde das Spiel gar nicht schlecht, zumindest von den Befehlen her die du benutzt hast.
    Die Idee des Spiels ist auch gut, also weiß ich gar nicht was dich bewegt hat das Spiel so zu taufen. Ich kenn das Spiel übrigens und ich finde du hast das sehr gut umgesetzt, jedoch ist bei der Version die ich kenne die Anordnung folgende:

    #####
    #1#4#
    #2#5#
    #3#6#
    #####

    Ich finde es so wie du es gemacht hast aber auch gut :thumbup:

    Also Tolles Spiel

    DFPWare

  • Wenn du Arrays verwendest, kannst du den Code übrigens deutlich abkürzen ;)

  • Hey, sry voll vergessen das ich das hier gepostet hatte *g*
    Das Spiel kenne ich aus dem Urlaub dort hatte es ein Kneipenbesitzer mir vorgestellt unter dem Namen, einen anderen Namen hatte ich trotz googlen nicht gefunden!
    Mal schauen ob ich das noch mit Arrays mache evntl. auch einen Mehrspieler? Naja mal schauen..
    @Xeno
    Nach 4 Jahren hat dein Spiel endlich einer gescriptet *g*
    PS: Was mir gerade auffällt ist das es noch keine "Weiter geben Funktion" gibt
    Edit: Script erweitert!