|
@@ -1,15 +1,15 @@
|
|
#/!usr/bin/python
|
|
#/!usr/bin/python
|
|
-#Chunyuyulong-MT2018
|
|
|
|
|
|
+#Chunyuyulong,JeremyGabrysch,SimonPense -MT2018
|
|
|
|
|
|
import Tkinter as tk
|
|
import Tkinter as tk
|
|
import sys,time,random #Module einsetzen
|
|
import sys,time,random #Module einsetzen
|
|
from tkMessageBox import *
|
|
from tkMessageBox import *
|
|
|
|
|
|
-Buttons1 = [] #global Variablen deffinieren
|
|
|
|
|
|
+Buttons1 = [] #globale Variablen definieren
|
|
ButtonS1 = []
|
|
ButtonS1 = []
|
|
-Buttons2 = [] #Buttens fur Gitter ButtenS fur Funktionschalter
|
|
|
|
|
|
+Buttons2 = [] #Knoepfe fuer Gitter und fuer Funktionsschalter
|
|
ButtonS2 = []
|
|
ButtonS2 = []
|
|
-ButtonP1 ={'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0, #Daten speicher von einzene Stuck
|
|
|
|
|
|
+ButtonP1 ={'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0, #Daten der Felder werden gespeichert
|
|
'8':0,'9':0,'10':0,'11':0,'12':0,'13':0,'14':0,
|
|
'8':0,'9':0,'10':0,'11':0,'12':0,'13':0,'14':0,
|
|
'15':0,'16':0,'17':0,'18':0,'19':0,'20':0,'21':0,
|
|
'15':0,'16':0,'17':0,'18':0,'19':0,'20':0,'21':0,
|
|
'22':0,'23':0,'24':0,'25':0,'26':0,'27':0,'28':0,
|
|
'22':0,'23':0,'24':0,'25':0,'26':0,'27':0,'28':0,
|
|
@@ -25,12 +25,12 @@ ButtonP2 ={'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,
|
|
'36':0,'37':0,'38':0,'39':0,'40':0,'41':0,'42':0,
|
|
'36':0,'37':0,'38':0,'39':0,'40':0,'41':0,'42':0,
|
|
'43':0,'44':0,'45':0,'46':0,'47':0,'48':0,'49':0}
|
|
'43':0,'44':0,'45':0,'46':0,'47':0,'48':0,'49':0}
|
|
|
|
|
|
-ai = 0 #Ob Singelplayer
|
|
|
|
-Scf = 0 #gewehlte Schiff Mark
|
|
|
|
-PW = 2 #Player switch
|
|
|
|
-Rot = 0 #Rotation Mark
|
|
|
|
-Wel = 0 #Spiele Mark
|
|
|
|
-z= [] #speicher von AI Darstellung
|
|
|
|
|
|
+ai = 0 #Auswaehlen Singelplayer
|
|
|
|
+Scf = 0 #Auswahl fuer Schiffsmarkierung
|
|
|
|
+PW = 2 #Player Auswahl
|
|
|
|
+Rot = 0 #Rotationsbutton
|
|
|
|
+Wel = 0 #Spiel beginnen
|
|
|
|
+z= [] #Speichern der AI Aufstellung
|
|
SumS=[] #gesetzte Schiffe
|
|
SumS=[] #gesetzte Schiffe
|
|
|
|
|
|
def p1(): #P1 start
|
|
def p1(): #P1 start
|
|
@@ -39,7 +39,7 @@ def p1(): #P1 start
|
|
zlh = 200
|
|
zlh = 200
|
|
for wl in range(7): #Gitter Massstab
|
|
for wl in range(7): #Gitter Massstab
|
|
Zahlen = tk.Label(root1,text = str(wl+1),font = '30').place(x = zlh ,y = 50, width = 50, height = 50)
|
|
Zahlen = tk.Label(root1,text = str(wl+1),font = '30').place(x = zlh ,y = 50, width = 50, height = 50)
|
|
- zlh = zlh +50
|
|
|
|
|
|
+ zlh = zlh +50 #y-Achse mit Zahlen
|
|
zlv = 100
|
|
zlv = 100
|
|
z = 'A','B','C','D','E','F','G'
|
|
z = 'A','B','C','D','E','F','G'
|
|
for wh in range(7):
|
|
for wh in range(7):
|
|
@@ -206,24 +206,24 @@ def p1(): #P1 start
|
|
Buttons1.append(Button49)
|
|
Buttons1.append(Button49)
|
|
Buttons1[48].place(x = 500 ,y = 400, width = 50, height = 50)
|
|
Buttons1[48].place(x = 500 ,y = 400, width = 50, height = 50)
|
|
#Funktion Buttens
|
|
#Funktion Buttens
|
|
- ButtonSS = tk.Button(root1,text = '1 Stuck',bg = 'yellow',command = lambda:schiffwehlen(1))
|
|
|
|
|
|
+ ButtonSS = tk.Button(root1,text = 'Boot (1)',bg = 'yellow',command = lambda:schiffwehlen(1))
|
|
ButtonS1.append(ButtonSS)
|
|
ButtonS1.append(ButtonSS)
|
|
- ButtonS1[0].place(x = 50 ,y = 200, width = 50, height = 50)
|
|
|
|
- ButtonSM1 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(2))
|
|
|
|
|
|
+ ButtonS1[0].place(x = 50 ,y = 200, width = 100, height = 50)
|
|
|
|
+ ButtonSM1 = tk.Button(root1,text = 'U-Boot (2)',bg = 'yellow',command = lambda:schiffwehlen(2))
|
|
ButtonS1.append(ButtonSM1)
|
|
ButtonS1.append(ButtonSM1)
|
|
ButtonS1[1].place(x = 50 ,y = 300, width = 100, height = 50)
|
|
ButtonS1[1].place(x = 50 ,y = 300, width = 100, height = 50)
|
|
- ButtonSM2 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(3))
|
|
|
|
|
|
+ ButtonSM2 = tk.Button(root1,text = 'U-Boot (2)',bg = 'yellow',command = lambda:schiffwehlen(3))
|
|
ButtonS1.append(ButtonSM2)
|
|
ButtonS1.append(ButtonSM2)
|
|
ButtonS1[2].place(x = 50 ,y = 400, width = 100, height = 50)
|
|
ButtonS1[2].place(x = 50 ,y = 400, width = 100, height = 50)
|
|
- ButtonSL = tk.Button(root1,text = '5 Stuck',bg = 'yellow',command = lambda:schiffwehlen(4))
|
|
|
|
|
|
+ ButtonSL = tk.Button(root1,text = 'Kreuzer (5)',bg = 'yellow',command = lambda:schiffwehlen(4))
|
|
ButtonS1.append(ButtonSL)
|
|
ButtonS1.append(ButtonSL)
|
|
ButtonS1[3].place(x = 50 ,y = 500, width = 250, height = 50)
|
|
ButtonS1[3].place(x = 50 ,y = 500, width = 250, height = 50)
|
|
- ButtonR = tk.Button(root1,text = 'Rotation',bg = 'green',command = Rot)
|
|
|
|
|
|
+ ButtonR = tk.Button(root1,text = 'Rotieren!',bg = 'green',command = Rot)
|
|
ButtonS1.append(ButtonR)
|
|
ButtonS1.append(ButtonR)
|
|
ButtonS1[4].place(x = 50 ,y = 100, width = 100, height = 50)
|
|
ButtonS1[4].place(x = 50 ,y = 100, width = 100, height = 50)
|
|
- ButtonEX = tk.Button(root1,text = 'Exit',bg = 'red',command = lambda:ex(root1))
|
|
|
|
|
|
+ ButtonEX = tk.Button(root1,text = 'Beenden',bg = 'red',command = lambda:ex(root1))
|
|
ButtonS1.append(ButtonEX)
|
|
ButtonS1.append(ButtonEX)
|
|
- ButtonS1[5].place(x = 1150 ,y = 20, width = 50, height = 50)
|
|
|
|
|
|
+ ButtonS1[5].place(x = 10 ,y = 20, width = 100, height = 50)
|
|
root1.mainloop()
|
|
root1.mainloop()
|
|
|
|
|
|
|
|
|
|
@@ -403,22 +403,22 @@ def p2(): #gleiche wir erst
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- ButtonSS = tk.Button(root1,text = '1 Stuck',bg = 'yellow',command = lambda:schiffwehlen(1))
|
|
|
|
|
|
+ ButtonSS = tk.Button(root1,text = 'Boot (1)',bg = 'yellow',command = lambda:schiffwehlen(1))
|
|
ButtonS2.append(ButtonSS)
|
|
ButtonS2.append(ButtonSS)
|
|
- ButtonS2[0].place(x = 650 ,y = 200, width = 50, height = 50)
|
|
|
|
- ButtonSM1 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(2))
|
|
|
|
|
|
+ ButtonS2[0].place(x = 650 ,y = 200, width = 100, height = 50)
|
|
|
|
+ ButtonSM1 = tk.Button(root1,text = 'U-Boot (2)',bg = 'yellow',command = lambda:schiffwehlen(2))
|
|
ButtonS2.append(ButtonSM1)
|
|
ButtonS2.append(ButtonSM1)
|
|
ButtonS2[1].place(x = 650 ,y = 300, width = 100, height = 50)
|
|
ButtonS2[1].place(x = 650 ,y = 300, width = 100, height = 50)
|
|
- ButtonSM2 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(3))
|
|
|
|
|
|
+ ButtonSM2 = tk.Button(root1,text = 'U-Boot (2)',bg = 'yellow',command = lambda:schiffwehlen(3))
|
|
ButtonS2.append(ButtonSM2)
|
|
ButtonS2.append(ButtonSM2)
|
|
ButtonS2[2].place(x = 650 ,y = 400, width = 100, height = 50)
|
|
ButtonS2[2].place(x = 650 ,y = 400, width = 100, height = 50)
|
|
- ButtonSL = tk.Button(root1,text = '5 Stuck',bg = 'yellow',command = lambda:schiffwehlen(4))
|
|
|
|
|
|
+ ButtonSL = tk.Button(root1,text = 'Kreuzer (5)',bg = 'yellow',command = lambda:schiffwehlen(4))
|
|
ButtonS2.append(ButtonSL)
|
|
ButtonS2.append(ButtonSL)
|
|
ButtonS2[3].place(x = 650 ,y = 500, width = 250, height = 50)
|
|
ButtonS2[3].place(x = 650 ,y = 500, width = 250, height = 50)
|
|
- ButtonR = tk.Button(root1,text = 'Rotation',bg = 'green',command = Rot)
|
|
|
|
|
|
+ ButtonR = tk.Button(root1,text = 'Rotieren!',bg = 'green',command = Rot)
|
|
ButtonS2.append(ButtonR)
|
|
ButtonS2.append(ButtonR)
|
|
ButtonS2[4].place(x = 650 ,y = 100, width = 100, height = 50)
|
|
ButtonS2[4].place(x = 650 ,y = 100, width = 100, height = 50)
|
|
- ButtonSw = tk.Button(root1,text = 'fertig',bg = 'green',command = wehlen)
|
|
|
|
|
|
+ ButtonSw = tk.Button(root1,text = 'Fertig!',bg = 'green',command = wehlen)
|
|
ButtonS2.append(ButtonSw)
|
|
ButtonS2.append(ButtonSw)
|
|
ButtonS2[5].place(x = 1000 ,y = 500, width = 120, height = 50)
|
|
ButtonS2[5].place(x = 1000 ,y = 500, width = 120, height = 50)
|
|
|
|
|
|
@@ -430,7 +430,7 @@ def wehlen(): #Funktion von Start Spiele
|
|
Buttons2[i].configure(bg = "lightblue")
|
|
Buttons2[i].configure(bg = "lightblue")
|
|
Wel = 1
|
|
Wel = 1
|
|
if ai == 1:
|
|
if ai == 1:
|
|
- ButtonSede = tk.Button(root1,text = 'AI Turn',command = lambda:Versuch_AI(Buttons1,ButtonP1))
|
|
|
|
|
|
+ ButtonSede = tk.Button(root1,text = 'AI ist dran',command = lambda:Versuch_AI(Buttons1,ButtonP1))
|
|
ButtonS2.append(ButtonSede)
|
|
ButtonS2.append(ButtonSede)
|
|
ButtonS2[6].place(x = 600 ,y = 30, width = 100, height = 50)
|
|
ButtonS2[6].place(x = 600 ,y = 30, width = 100, height = 50)
|
|
Versuch_AI(Buttons1,ButtonP1)
|
|
Versuch_AI(Buttons1,ButtonP1)
|
|
@@ -442,13 +442,13 @@ def Wintest(): #Siege Proben
|
|
dic1 = (ButtonP1.values())
|
|
dic1 = (ButtonP1.values())
|
|
dic2 = (ButtonP2.values())
|
|
dic2 = (ButtonP2.values())
|
|
if 1 not in dic1 and ai == 1:
|
|
if 1 not in dic1 and ai == 1:
|
|
- WinAI= showinfo(title='Leide!',message='AI WINN!!!')
|
|
|
|
|
|
+ WinAI= showinfo(title='Schade!',message='AI GEWINNT!!!')
|
|
root1.destroy()
|
|
root1.destroy()
|
|
elif 1 not in dic1 and ai == 0:
|
|
elif 1 not in dic1 and ai == 0:
|
|
- Win1= showinfo(title='Congratulate!',message='P2 WINN!!!')
|
|
|
|
|
|
+ Win1= showinfo(title='GLUECKWUNSCH!',message='P2 GEWINNT!!!')
|
|
root1.destroy()
|
|
root1.destroy()
|
|
elif 1 not in dic2:
|
|
elif 1 not in dic2:
|
|
- Win2= showinfo(title='Congratulate!',message='P1 WINN!!!')
|
|
|
|
|
|
+ Win2= showinfo(title='GLUECKWUNSCH!',message='P1 GEWINNT!!!')
|
|
root1.destroy()
|
|
root1.destroy()
|
|
|
|
|
|
def Versuch_AI(Buttons,Button): #AI versuch
|
|
def Versuch_AI(Buttons,Button): #AI versuch
|
|
@@ -703,9 +703,9 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Wintest()
|
|
Wintest()
|
|
PW = 2
|
|
PW = 2
|
|
elif Buttons == Buttons1 and PW == 2 and ai == 1:
|
|
elif Buttons == Buttons1 and PW == 2 and ai == 1:
|
|
- achtung= showinfo(title='Achtung!!',message='das ist SingelPlayer!Bitten Sie das Button "AI Turn" klicken!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!!',message='Singleplayermodus! Button "AI Turn" klicken, um weiter zu spielen!')
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!!',message='Sollen Aendere Player wehlen!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!!',message='Der Andere Spieler ist an der Reihe!')
|
|
else:
|
|
else:
|
|
if Rot == 1: #Schiffe setzen
|
|
if Rot == 1: #Schiffe setzen
|
|
if Scf == 1:
|
|
if Scf == 1:
|
|
@@ -714,7 +714,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1)] = 1
|
|
Button[str(i+1)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt!')
|
|
elif Scf == 2:
|
|
elif Scf == 2:
|
|
if i>41:
|
|
if i>41:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
|
|
@@ -724,7 +724,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1-7)] = 1
|
|
Button[str(i+1-7)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
else:
|
|
else:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
|
|
Buttons[i].configure(bg = "yellow")
|
|
Buttons[i].configure(bg = "yellow")
|
|
@@ -733,7 +733,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1+7)] = 1
|
|
Button[str(i+1+7)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif Scf == 3:
|
|
elif Scf == 3:
|
|
if i>41:
|
|
if i>41:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
|
|
@@ -743,7 +743,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1-7)] = 1
|
|
Button[str(i+1-7)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
else:
|
|
else:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
|
|
Buttons[i].configure(bg = "yellow")
|
|
Buttons[i].configure(bg = "yellow")
|
|
@@ -752,7 +752,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1+7)] = 1
|
|
Button[str(i+1+7)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif Scf == 4:
|
|
elif Scf == 4:
|
|
if i <21:
|
|
if i <21:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1+28)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1+28)] == 0:
|
|
@@ -762,7 +762,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
i = i + 7
|
|
i = i + 7
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif i/7 == 3:
|
|
elif i/7 == 3:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1-7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1-7)] == 0:
|
|
Buttons[i-7].configure(bg = "yellow")
|
|
Buttons[i-7].configure(bg = "yellow")
|
|
@@ -777,7 +777,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+21)] = 1
|
|
Button[str(i+21)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif i/7 == 4:
|
|
elif i/7 == 4:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
|
|
Buttons[i-14].configure(bg = "yellow")
|
|
Buttons[i-14].configure(bg = "yellow")
|
|
@@ -792,7 +792,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1+14)] = 1
|
|
Button[str(i+1+14)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt!')
|
|
elif i/7 == 5:
|
|
elif i/7 == 5:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
|
|
Buttons[i-21].configure(bg = "yellow")
|
|
Buttons[i-21].configure(bg = "yellow")
|
|
@@ -807,7 +807,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1+7)] = 1
|
|
Button[str(i+1+7)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif i/7 == 6:
|
|
elif i/7 == 6:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1-28)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+1-28)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
|
|
Buttons[i-28].configure(bg = "yellow")
|
|
Buttons[i-28].configure(bg = "yellow")
|
|
@@ -822,7 +822,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1)] = 1
|
|
Button[str(i+1)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt!')
|
|
Rot = 0
|
|
Rot = 0
|
|
else:
|
|
else:
|
|
if Scf == 1:
|
|
if Scf == 1:
|
|
@@ -831,7 +831,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1)] = 1
|
|
Button[str(i+1)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif Scf == 2 :
|
|
elif Scf == 2 :
|
|
if i%7 == 6:
|
|
if i%7 == 6:
|
|
if Button[str(i+1)] == 0 and Button[str(i)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i)] == 0:
|
|
@@ -841,7 +841,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i)] = 1
|
|
Button[str(i)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt!')
|
|
else:
|
|
else:
|
|
if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
|
|
Buttons[i].configure(bg = "yellow")
|
|
Buttons[i].configure(bg = "yellow")
|
|
@@ -850,7 +850,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1+1)] = 1
|
|
Button[str(i+1+1)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif Scf == 3 :
|
|
elif Scf == 3 :
|
|
if i%7 == 6:
|
|
if i%7 == 6:
|
|
if Button[str(i+1)] == 0 and Button[str(i)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i)] == 0:
|
|
@@ -860,7 +860,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i)] = 1
|
|
Button[str(i)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
else:
|
|
else:
|
|
if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
|
|
Buttons[i].configure(bg = "yellow")
|
|
Buttons[i].configure(bg = "yellow")
|
|
@@ -869,7 +869,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1+1)] = 1
|
|
Button[str(i+1+1)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif Scf == 4:
|
|
elif Scf == 4:
|
|
if i%7<3:
|
|
if i%7<3:
|
|
if Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0 and Button[str(i+4)] == 0 and Button[str(i+5)] == 0:
|
|
if Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0 and Button[str(i+4)] == 0 and Button[str(i+5)] == 0:
|
|
@@ -879,7 +879,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
i = i + 1
|
|
i = i + 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif i%7 == 3:
|
|
elif i%7 == 3:
|
|
if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0:
|
|
if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0:
|
|
Buttons[i-1].configure(bg = "yellow")
|
|
Buttons[i-1].configure(bg = "yellow")
|
|
@@ -894,7 +894,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+1+3)] = 1
|
|
Button[str(i+1+3)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
|
|
|
|
elif i%7 == 4:
|
|
elif i%7 == 4:
|
|
if Button[str(i-2)] == 0 and Button[str(i-1)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i)] == 0:
|
|
if Button[str(i-2)] == 0 and Button[str(i-1)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i)] == 0:
|
|
@@ -910,7 +910,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+3)] = 1
|
|
Button[str(i+3)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif i%7 == 5:
|
|
elif i%7 == 5:
|
|
if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i-2)] == 0:
|
|
if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i-2)] == 0:
|
|
Buttons[i-3].configure(bg = "yellow")
|
|
Buttons[i-3].configure(bg = "yellow")
|
|
@@ -925,7 +925,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Button[str(i+2)] = 1
|
|
Button[str(i+2)] = 1
|
|
Scf = 0
|
|
Scf = 0
|
|
else:
|
|
else:
|
|
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Diese(s) Feld(er) ist/sind schon belegt')
|
|
elif i%7 == 6:
|
|
elif i%7 == 6:
|
|
if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i-2)] == 0 and Button[str(i-3)] == 0:
|
|
if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i-2)] == 0 and Button[str(i-3)] == 0:
|
|
Buttons[i-4].configure(bg = "yellow")
|
|
Buttons[i-4].configure(bg = "yellow")
|
|
@@ -941,7 +941,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
Scf = 0
|
|
Scf = 0
|
|
|
|
|
|
if len(SumS) == 4: #Ob alle Schiffe wird gesetzte
|
|
if len(SumS) == 4: #Ob alle Schiffe wird gesetzte
|
|
- ButtonSw = tk.Button(root1,text = 'Player waechseln',bg = 'green',command = was)
|
|
|
|
|
|
+ ButtonSw = tk.Button(root1,text = 'Spieler wechseln',bg = 'green',command = was)
|
|
ButtonS1.append(ButtonSw)
|
|
ButtonS1.append(ButtonSw)
|
|
ButtonS1[6].place(x = 450 ,y = 500, width = 120, height = 50)
|
|
ButtonS1[6].place(x = 450 ,y = 500, width = 120, height = 50)
|
|
|
|
|
|
@@ -949,7 +949,7 @@ def color(i,Buttons,Button): #Grundfunktion von einzele Button
|
|
def schiffwehlen(W): #Spieler schiffe Wehlen
|
|
def schiffwehlen(W): #Spieler schiffe Wehlen
|
|
global Scf
|
|
global Scf
|
|
if W in SumS:
|
|
if W in SumS:
|
|
- achtung= showinfo(title='Achtung!',message='Das Schiff schon gesetzt wird!')
|
|
|
|
|
|
+ achtung= showinfo(title='Achtung!',message='Das Schiff wurde schon gesetzt!')
|
|
else:
|
|
else:
|
|
if W == 1:
|
|
if W == 1:
|
|
Scf = 1
|
|
Scf = 1
|
|
@@ -964,7 +964,7 @@ def schiffwehlen(W):
|
|
SumS.append(W)
|
|
SumS.append(W)
|
|
Scf = 4
|
|
Scf = 4
|
|
else:
|
|
else:
|
|
- print 'falsch eingeben'
|
|
|
|
|
|
+ print 'falsche Eingabe!'
|
|
def was(): #AI moeglich fuer P2
|
|
def was(): #AI moeglich fuer P2
|
|
p2()
|
|
p2()
|
|
if ai == 1:
|
|
if ai == 1:
|
|
@@ -977,16 +977,16 @@ def menu(): #Menu
|
|
fens = tk.Canvas(root,width = 800,height = 600,bg = 'lightblue')
|
|
fens = tk.Canvas(root,width = 800,height = 600,bg = 'lightblue')
|
|
fens.pack()
|
|
fens.pack()
|
|
|
|
|
|
- thema = tk.Label(root,text = "Schiffe Versenkung!",font = "Arial 30",fg = "White",padx = 50,pady = 10,background="blue",relief="ridge",borderwidth=10)
|
|
|
|
|
|
+ thema = tk.Label(root,text = "Schiffe Versenken!",font = "Arial 30",fg = "White",padx = 50,pady = 10,background="blue",relief="ridge",borderwidth=10)
|
|
thema.place(height=100, width=400 ,x = 200, y = 100)
|
|
thema.place(height=100, width=400 ,x = 200, y = 100)
|
|
- button1 = tk.Button(root,text = "Man vs AI",bg = 'black',activebackground = 'Green',font = '20',fg = 'White',command = lambda:sing())
|
|
|
|
- button1.place(x = 200, y = 250,height = 50,width = 120)
|
|
|
|
- button2 = tk.Button(root,text = "Man vs Man",bg = 'black',activebackground = 'Blue',font = '20',fg = 'White',command = lambda:muti())
|
|
|
|
- button2.place(x = 500, y = 250,height = 50,width = 120)
|
|
|
|
|
|
+ button1 = tk.Button(root,text = "Mensch vs AI",bg = 'black',activebackground = 'Green',font = '20',fg = 'White',command = lambda:sing())
|
|
|
|
+ button1.place(x = 200, y = 250,height = 50,width = 150)
|
|
|
|
+ button2 = tk.Button(root,text = "Mensch vs Mensch",bg = 'black',activebackground = 'Blue',font = '20',fg = 'White',command = lambda:muti())
|
|
|
|
+ button2.place(x = 500, y = 250,height = 50,width = 150)
|
|
button3 = tk.Button(root,text = "Hilfe",bg = 'black',activebackground = 'White',font = '20',fg = 'White',command = lambda:Hilfe())
|
|
button3 = tk.Button(root,text = "Hilfe",bg = 'black',activebackground = 'White',font = '20',fg = 'White',command = lambda:Hilfe())
|
|
- button3.place(x = 200, y = 400,height = 50,width = 120)
|
|
|
|
- button4 = tk.Button(root,text = "EXIT",bg = 'red',font = '20',fg = 'White',command = lambda:ex(root))
|
|
|
|
- button4.place(x = 500, y = 400,height = 50,width = 120)
|
|
|
|
|
|
+ button3.place(x = 200, y = 400,height = 50,width = 150)
|
|
|
|
+ button4 = tk.Button(root,text = "Beenden",bg = 'red',font = '20',fg = 'White',command = lambda:ex(root))
|
|
|
|
+ button4.place(x = 500, y = 400,height = 50,width = 150)
|
|
|
|
|
|
root.mainloop()
|
|
root.mainloop()
|
|
|
|
|
|
@@ -994,20 +994,20 @@ def sing(): #Singl player
|
|
global ai
|
|
global ai
|
|
global root1
|
|
global root1
|
|
root1 = tk.Tk()
|
|
root1 = tk.Tk()
|
|
- root1.title('Schiffe Versenkung')
|
|
|
|
|
|
+ root1.title('Schiffe Versenken')
|
|
ai = 1
|
|
ai = 1
|
|
p1()
|
|
p1()
|
|
|
|
|
|
def muti(): #multi player
|
|
def muti(): #multi player
|
|
global root1
|
|
global root1
|
|
root1 = tk.Tk()
|
|
root1 = tk.Tk()
|
|
- root1.title('Schiffe Versenkung')
|
|
|
|
|
|
+ root1.title('Schiffe Versenken')
|
|
p1()
|
|
p1()
|
|
|
|
|
|
def Hilfe(): #Hilfe
|
|
def Hilfe(): #Hilfe
|
|
Hilfe = tk.Tk()
|
|
Hilfe = tk.Tk()
|
|
- Hilfe.title('Help')
|
|
|
|
- text = tk.Label(Hilfe,text = "Diese Programm wird entwicklert, um das Spiel Schiffe Versenkung durchzufuehren.",font = "Arial 15").pack()
|
|
|
|
|
|
+ Hilfe.title('Hilfe')
|
|
|
|
+ text = tk.Label(Hilfe,text = "Dieses Programm wurde entwickelt, um das Spiel Schiffe Versenken zu Spielen.",font = "Arial 15").pack()
|
|
button1 = tk.Button(Hilfe,text = 'Zuruck',bg = "green",font = "20",command = lambda:ex(Hilfe)).pack()
|
|
button1 = tk.Button(Hilfe,text = 'Zuruck',bg = "green",font = "20",command = lambda:ex(Hilfe)).pack()
|
|
|
|
|
|
def ex(root):
|
|
def ex(root):
|