Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Théo BOUTEMY
siam
Commits
0080b025
Commit
0080b025
authored
May 31, 2021
by
Pauline LEYRIT
Browse files
boite de dialogue + vainqueurs
parent
1a130c0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
appli2.py
View file @
0080b025
...
...
@@ -5,6 +5,7 @@ from PyQt5.QtGui import *
from
PyQt5.QtCore
import
*
import
sys
import
time
import
numpy
as
np
from
pieces
import
Piece
,
Montagne
,
Animal
,
Elephant
,
Rhinoceros
from
table_de_jeu
import
Plateau
...
...
@@ -242,7 +243,7 @@ class Window(QMainWindow):
self
.
joueur
=
self
.
ele
self
.
prochain
=
self
.
rh
self
.
dernier_bouton
=
''
self
.
mont_sorti
=
self
.
m
1
self
.
mont_sorti
=
self
.
m
ont
[
0
]
#listes regroupants les infos sur chaque pions
...
...
@@ -347,7 +348,7 @@ class Window(QMainWindow):
self
.
pion_select
.
setPos
(
x0
,
y0
)
else
:
self
.
tourne
()
self
.
liste_rh_qg
[
i
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
self
.
joueur_qg
[
self
.
pion_select_num
-
1
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
# ajouter la possibilité de tourner quand ca marchera
...
...
@@ -359,32 +360,39 @@ class Window(QMainWindow):
# self.pion_select.setFlag(QGraphicsItem.ItemIsMovable)
if
self
.
dernier_bouton
==
'entrer'
:
i
=
6
l
=
6
if
self
.
joueur
==
self
.
rh
:
i
=
-
2
x0
,
y0
=
65.5
*
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
-
(
i
)),
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
1
]
-
(
self
.
pion_select_num
-
1
)
)
*
65.5
l
=
-
2
x0
,
y0
=
65.5
*
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
-
(
l
)),
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
1
]
-
(
self
.
pion_select_num
-
1
)
)
*
65.5
print
(
x0
,
y0
,
'x0'
,
self
.
joueur
[
self
.
pion_select_num
-
1
])
#+2 et self.pion_select_num - 1 car prend les déplacements par rapport aux coords originales
x
,
y
=
self
.
pion_select
.
x
()
-
x0
,
self
.
pion_select
.
y
()
-
y0
# mouvement par rapport à la dernière case
print
(
x
,
y
)
bool
=
True
if
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
in
[
0
,
1
,
2
,
3
,
4
]
and
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
1
]
in
[
0
,
1
,
2
,
3
,
4
]:
print
(
'la piece est déjà rentrée sur le plateau'
)
print
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
)
bool
=
False
print
(
bool
)
bool1
=
True
for
k
in
range
(
len
(
self
.
rh
)):
if
(
self
.
joueur
[
self
.
pion_select_num
-
1
]
==
self
.
joueur
[
k
].
coords
and
k
!=
self
.
pion_select_num
-
1
)
or
(
self
.
joueur
[
self
.
pion_select_num
-
1
]
==
self
.
prochain
[
k
].
coords
)
or
(
k
<
3
and
self
.
joueur
[
self
.
pion_select_num
-
1
]
==
self
.
mont
[
k
].
coords
):
bool1
=
False
print
(
'case déjà prise'
)
print
(
bool1
)
if
bool
and
bool1
:
print
(
x
,
y
,
'x, y'
)
print
(
self
.
pion_select_num
-
1
)
if
not
-
10
<
x
<
10
:
if
x
>
0
:
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
+=
(
x
//
60
)
*
x
/
x
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
+=
((
x
//
60
)
*
x
/
x
)
print
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
])
else
:
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
+=
(
x
//
60
)
*
x
/
x
+
1
# -65//60 = 2
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
+=
((
x
//
60
)
*
x
/
x
+
1
)
# -65//60 = 2
print
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
])
if
not
-
10
<
y
<
10
:
if
y
>
0
:
...
...
@@ -397,7 +405,8 @@ class Window(QMainWindow):
i
=
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
j
=
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
1
]
if
(
i
==
0
or
i
==
4
and
-
1
<
j
<
5
)
or
(
j
==
4
or
j
==
0
and
-
1
<
j
<
5
):
print
(
i
,
j
)
if
((
i
==
0
or
i
==
4
)
and
-
1
<
j
<
5
)
or
((
j
==
4
or
j
==
0
)
and
-
1
<
i
<
5
):
#self.joueur[self.pion_select_num - 1].tourner()
print
(
"emplacement ok"
)
self
.
tourne
()
...
...
@@ -406,12 +415,20 @@ class Window(QMainWindow):
print
(
'une pièce ne peut entrer sur le plateau que sur une case extérieure : rééssayez '
)
bool2
=
False
self
.
pion_select
.
setPos
(
0
,
0
)
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
=
0
,
0
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
=
l
,
self
.
pion_select_num
-
1
print
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
)
else
:
self
.
pion_select
.
setPos
(
0
,
0
)
self
.
joueur_qg
[
self
.
pion_select_num
-
1
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
if
self
.
dernier_bouton
==
'sortir'
:
self
.
pion_select
.
setPos
(
0
,
0
)
l
=
6
if
self
.
joueur
==
self
.
rh
:
l
=
-
2
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
=
l
,
self
.
pion_select_num
-
1
self
.
liste_rh_qg
[
self
.
pion_select_num
-
1
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
if
self
.
dernier_bouton
==
'pousser'
:
...
...
@@ -493,6 +510,7 @@ class Window(QMainWindow):
if
piece
.
coords
[
0
]
<
0
:
print
(
'jeux terminé'
)
self
.
mont_sorti
=
piece
self
.
vainqueur
()
else
:
print
(
'vous ne pouvez pas effectuer cette poussée: vous navez pas assez de force de poussée'
)
...
...
@@ -540,6 +558,7 @@ class Window(QMainWindow):
if
piece
.
coords
[
0
]
>
4
:
print
(
'jeux terminé'
)
self
.
mont_sorti
=
piece
self
.
vainqueur
()
else
:
print
(
'vous ne pouvez pas effectuer cette poussée: vous navez pas assez de force de poussée'
)
...
...
@@ -584,6 +603,7 @@ class Window(QMainWindow):
if
piece
.
coords
[
1
]
<
0
:
print
(
'jeux terminé'
)
self
.
mont_sorti
=
piece
self
.
vainqueur
()
else
:
print
(
'vous ne pouvez pas effectuer cette poussée: vous navez pas assez de force de poussée'
)
...
...
@@ -630,8 +650,10 @@ class Window(QMainWindow):
if
piece
.
coords
[
1
]
>
4
:
print
(
'jeux terminé'
)
self
.
mont_sorti
=
piece
self
.
vainqueur
()
else
:
print
(
'vous ne pouvez pas effectuer cette poussée: vous navez pas assez de force de poussée'
)
self
.
joueur_qg
[
self
.
pion_select_num
-
1
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
if
self
.
dernier_bouton
==
'entrer en poussant'
:
if
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
in
[
0
,
1
,
2
,
3
,
4
]
and
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
1
]
in
[
0
,
1
,
2
,
3
,
4
]:
...
...
@@ -678,7 +700,7 @@ class Window(QMainWindow):
else
:
print
(
'pour rentrer en poussant, vous devez mettre la piece sur une case extérieure au plateau, la mettre dans la bonne orientation et pousser '
)
self
.
joueur_qg
[
self
.
pion_select_num
-
1
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
#print("votre pièce %c%i est entrée à la position %s, orientée vers %c" % (self. self.joueur[self.pion_select_num - 1].car(), self. self.joueur[self.pion_select_num - 1].numero, self. self.joueur[self.pion_select_num - 1].coords, self. self.joueur[self.pion_select_num - 1].orientation))
def
deplacer
(
self
):
...
...
@@ -808,6 +830,32 @@ class Window(QMainWindow):
print
(
"le rhino {}+1"
.
format
(
i
))
self
.
pion_select
=
self
.
liste_rh_qg
[
i
]
self
.
pion_select_num
=
i
+
1
def
vainqueur
(
self
):
mine_e
,
min_r
=
10
,
10
vect_e
,
vect_r
=
10
,
10
i
,
j
=
self
.
mont_sorti
.
coords
print
(
i
,
j
,
'i,j'
)
dic_i
=
{
-
1
:
'g'
,
5
:
'd'
}
dic_j
=
{
-
1
:
'h'
,
5
:
'b'
}
for
el
in
self
.
ele
:
print
(
el
.
orientation
,
dic_i
[
i
])
if
(
el
.
orientation
==
dic_i
[
i
])
or
(
el
.
orientation
==
dic_j
[
j
]):
vect_e
=
np
.
sqrt
((
el
.
coords
[
0
]
-
i
)
**
2
+
(
el
.
coords
[
1
]
-
j
)
**
2
)
if
mine
>
vect_e
:
mine
=
vect_e
for
rh
in
self
.
rh
:
if
(
rh
.
orientation
==
dic_i
[
i
])
or
(
rh
.
orientation
==
dic_j
[
j
]):
vect_r
=
np
.
sqrt
((
rh
.
coords
[
0
]
-
i
)
**
2
+
(
rh
.
coords
[
1
]
-
j
)
**
2
)
if
minr
>
vect_r
:
minr
=
vect_r
print
(
mine
,
minr
)
if
minr
<
mine
:
print
(
"les rhinos gagnent!"
)
else
:
print
(
"les éléphants gagnent"
)
def
showDialog
(
self
):
...
...
@@ -817,27 +865,7 @@ class Window(QMainWindow):
return
self
.
txt
def
showDialog_choixjoueur
(
self
):
self
.
txt
,
ok
=
QInputDialog
.
getText
(
self
,
'input dialog'
,
'êtes vous les rhino ou éléphants ?'
)
if
ok
:
self
.
le
.
setText
(
str
(
self
.
txt
))
return
self
.
txt
def
showDialog_choixpions
(
self
):
self
.
txt
,
ok
=
QInputDialog
.
getText
(
self
,
'input dialog'
,
'choisissez votre pion: 1, 2, 3, ou 4 ?'
)
if
ok
:
self
.
le
.
setText
(
str
(
self
.
txt
))
return
self
.
txt
def
showDialog_cliques
(
self
):
self
.
txt
,
self
.
ok
=
QInputDialog
.
getText
(
self
,
'input dialog'
,
'cliques sur la case ou tu veux aller'
)
if
self
.
ok
:
self
.
le
.
setText
(
str
(
self
.
txt
))
return
self
.
txt
def
mousePressEvent
(
self
,
e
):
i0
,
j0
=
self
.
i
,
self
.
j
...
...
@@ -856,37 +884,7 @@ class Window(QMainWindow):
# On réaffiche
print
(
self
.
i
,
self
.
j
,
i0
,
j0
,
self
.
test
)
# def mouseMoveEvent(self, event):
# # Store mouse coordinates so they can be drawn to the screen
# self.mouseX = event.x()
# self.mouseY = event.y()
# self.repaint()
# print(self.mouseX)
#return [i,j]
#super(self.scene, self).mousePressEvent(e)
# class Win_t(QMainWindow):
# def __init__(self):
# super().__init__()
#
# self.setWindowTitle("Jeu de Siam")
# self.setGeometry(900, 700, 640, 520)
#
# self.create_ui_tourne()
#
# self.show()
#
#
# def create_ui_tourne(self):
# button = QPushButton("à droite", self)
# button.setGeometry(200, 450, 100, 50)
# button.clicked.connect(self.tourne_droite)
# scenet = QGraphicsScene(self)
# self.viewt = QGraphicsView(scenet, self)
# self.viewt.setGeometry(0, 0, 640, 440)
# def tourne_droite(self):
# self.view.rotate(90)
if
__name__
==
"__main__"
:
app
=
QApplication
(
sys
.
argv
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment