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
926a90eb
Commit
926a90eb
authored
Jun 10, 2021
by
Pauline LEYRIT
Browse files
ok
parent
9ddffa02
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
appli-test.py
0 → 100644
View file @
926a90eb
This diff is collapsed.
Click to expand it.
appli2.py
View file @
926a90eb
...
...
@@ -404,6 +404,7 @@ class Window(QMainWindow):
else
:
self
.
tourne
()
# si le changement de position était valide, le joueur peut aussi tourner son pion
# la fonction tourne indiquera que le tour est terminé
print
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
)
self
.
joueur_qg
[
self
.
pion_select_num
-
1
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
...
...
@@ -541,7 +542,9 @@ class Window(QMainWindow):
if
piece
.
coords
[
0
]
==
i
:
V
.
append
(
piece
)
# de même pour la colonne
#on fait maintenant les mêmes cas (selon l'oorientation) que dans la fonction pousser de la classe pièce
if
orientation
==
'g'
and
i
in
[
0
,
1
,
2
,
3
,
4
]
and
j
in
[
0
,
1
,
2
,
3
,
4
]:
print
(
i
,
j
)
if
orientation
==
'g'
:
piece_gauche
=
self
.
joueur
[
self
.
pion_select_num
-
1
]
for
k
in
range
(
len
(
H
)):
# pour etre sur de ne pas louper une piece qui serait à gauche
for
piece
in
H
:
...
...
@@ -561,28 +564,29 @@ class Window(QMainWindow):
for
piece
in
Hab
:
piece
.
coords
=
piece
.
coords
[
0
]
-
1
,
piece
.
coords
[
1
]
num
,
car
=
piece
.
numero
,
piece
.
car
()
if
piece
.
coords
[
0
]
in
[
0
,
1
,
2
,
3
,
4
,
5
]
and
piece
.
coords
[
1
]
in
[
0
,
1
,
2
,
3
,
4
]:
#ce qu'on ajoute au code de la classe pièce :
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
# nouvelles absisses quand on a changé les coordonnées
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
#même ordonnées car il n'a pas changé
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
<
0
:
#la pièce sort par la gauche
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
#elle reprend sa position initiale sur le plateau
piece
.
coords
=
6
,
num
#et ses coordonnées suivent
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
<
0
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
<
0
:
#une montagne est sortie du plateau : le jeu est terminé
self
.
mont_sorti
=
piece
#on enregistre quelle montagne est sorti (pour connaitre sa position)
self
.
vainqueur
()
#on appelle la fonction qui nous indiquera le gagnant
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
# nouvelles absisses quand on a changé les coordonnées
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
#même ordonnées car il n'a pas changé
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
<
0
:
#la pièce sort par la gauche
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
#elle reprend sa position initiale sur le plateau
piece
.
coords
=
6
,
num
#et ses coordonnées suivent
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
<
0
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
<
0
:
#une montagne est sortie du plateau : le jeu est terminé
self
.
mont_sorti
=
piece
#on enregistre quelle montagne est sorti (pour connaitre sa position)
self
.
vainqueur
()
#on appelle la fonction qui nous indiquera le gagnant
self
.
texte
=
QGraphicsTextItem
(
"Vous avez poussé, au tour des {0}"
.
format
(
self
.
prochain
[
0
].
car
()))
self
.
zone_txt
.
addItem
(
self
.
texte
)
...
...
@@ -599,7 +603,7 @@ class Window(QMainWindow):
self
.
pousse
=
False
# si entrer en poussant n'a pas fonctionné, cette variable permet de le savoir
# pour en déduire si il faudra remettre la pièce à sa place
#on réitère pour les trois autres orientations
if
orientation
==
'd'
and
i
in
[
0
,
1
,
2
,
3
,
4
]
and
j
in
[
0
,
1
,
2
,
3
,
4
]
:
if
orientation
==
'd'
:
piece_droite
=
self
.
joueur
[
self
.
pion_select_num
-
1
]
for
k
in
range
(
len
(
H
)):
for
piece
in
H
:
...
...
@@ -619,27 +623,28 @@ class Window(QMainWindow):
for
piece
in
Hab
:
piece
.
coords
=
piece
.
coords
[
0
]
+
1
,
piece
.
coords
[
1
]
num
,
car
=
piece
.
numero
,
piece
.
car
()
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
>
4
:
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
6
,
num
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
>
4
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
>
4
:
self
.
mont_sorti
=
piece
self
.
vainqueur
()
if
piece
.
coords
[
0
]
in
[
-
1
,
0
,
1
,
2
,
3
,
4
]
and
piece
.
coords
[
1
]
in
[
0
,
1
,
2
,
3
,
4
]:
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
>
4
:
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
6
,
num
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
>
4
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
0
]
>
4
:
self
.
mont_sorti
=
piece
self
.
vainqueur
()
self
.
texte
=
QGraphicsTextItem
(
"Vous avez poussé, au tour des {0}"
.
format
(
self
.
prochain
[
0
].
car
()))
self
.
zone_txt
.
addItem
(
self
.
texte
)
...
...
@@ -655,7 +660,7 @@ class Window(QMainWindow):
self
.
texte
.
setPos
(
0
,
150
)
self
.
pousse
=
False
if
orientation
==
'h'
and
i
in
[
0
,
1
,
2
,
3
,
4
]
and
j
in
[
0
,
1
,
2
,
3
,
4
]
:
if
orientation
==
'h'
:
piece_haut
=
self
.
joueur
[
self
.
pion_select_num
-
1
]
for
k
in
range
(
len
(
V
)):
for
piece
in
V
:
...
...
@@ -675,27 +680,28 @@ class Window(QMainWindow):
for
piece
in
Vab
:
piece
.
coords
=
piece
.
coords
[
0
],
piece
.
coords
[
1
]
-
1
num
,
car
=
piece
.
numero
,
piece
.
car
()
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
<
0
:
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
6
,
num
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
<
0
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
<
0
:
self
.
mont_sorti
=
piece
self
.
vainqueur
()
if
piece
.
coords
[
0
]
in
[
0
,
1
,
2
,
3
,
4
]
and
piece
.
coords
[
1
]
in
[
0
,
1
,
2
,
3
,
4
,
5
]:
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
<
0
:
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
6
,
num
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
<
0
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
<
0
:
self
.
mont_sorti
=
piece
self
.
vainqueur
()
self
.
texte
=
QGraphicsTextItem
(
"Vous avez poussé, au tour des {0}"
.
format
(
self
.
prochain
[
0
].
car
()))
self
.
zone_txt
.
addItem
(
self
.
texte
)
...
...
@@ -711,7 +717,7 @@ class Window(QMainWindow):
self
.
texte
.
setPos
(
0
,
150
)
self
.
pousse
=
False
if
orientation
==
'b'
and
i
in
[
0
,
1
,
2
,
3
,
4
]
and
j
in
[
0
,
1
,
2
,
3
,
4
]
:
if
orientation
==
'b'
:
piece_haut
=
self
.
joueur
[
self
.
pion_select_num
-
1
]
for
k
in
range
(
len
(
V
)):
for
piece
in
V
:
...
...
@@ -731,27 +737,28 @@ class Window(QMainWindow):
for
piece
in
Vab
:
piece
.
coords
=
piece
.
coords
[
0
],
piece
.
coords
[
1
]
+
1
num
,
car
=
piece
.
numero
,
piece
.
car
()
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
>
4
:
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
6
,
num
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
>
4
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
>
4
:
self
.
mont_sorti
=
piece
self
.
vainqueur
()
if
piece
.
coords
[
0
]
in
[
0
,
1
,
2
,
3
,
4
]
and
piece
.
coords
[
1
]
in
[
-
1
,
0
,
1
,
2
,
3
,
4
]:
if
car
==
'E'
:
x
=
65.5
*
(
self
.
ele
[
num
].
coords
[
0
]
-
(
6
))
y
=
(
self
.
ele
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_el_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
>
4
:
self
.
liste_el_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
6
,
num
if
car
==
'R'
:
x
=
65.5
*
(
self
.
rh
[
num
].
coords
[
0
]
-
(
-
2
))
y
=
(
self
.
rh
[
num
].
coords
[
1
]
-
(
num
))
*
65.5
self
.
liste_rh_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
>
4
:
self
.
liste_rh_qg
[
num
].
setPos
(
0
,
0
)
piece
.
coords
=
-
2
,
num
if
car
==
'M'
:
x
=
65.5
*
(
self
.
mont
[
num
].
coords
[
0
]
-
(
2
))
y
=
(
self
.
mont
[
num
].
coords
[
1
]
-
(
num
+
1
))
*
65.5
self
.
liste_mont_qg
[
num
].
setPos
(
x
,
y
)
if
piece
.
coords
[
1
]
>
4
:
self
.
mont_sorti
=
piece
self
.
vainqueur
()
self
.
texte
=
QGraphicsTextItem
(
"Vous avez poussé, au tour des {0}"
.
format
(
self
.
prochain
[
0
].
car
()))
self
.
zone_txt
.
addItem
(
self
.
texte
)
...
...
@@ -766,7 +773,7 @@ class Window(QMainWindow):
self
.
zone_txt
.
addItem
(
self
.
texte
)
self
.
texte
.
setPos
(
0
,
150
)
self
.
pousse
=
False
else
:
if
i
in
[
-
2
,
6
]
or
(
i
in
[
-
1
,
5
]
and
j
in
[
-
1
,
5
])
:
self
.
texte
=
QGraphicsTextItem
(
"vous devez être sur le plateau pour pousser"'
\n
'
"Rejouez"
)
...
...
@@ -774,6 +781,8 @@ class Window(QMainWindow):
self
.
texte
.
setPos
(
0
,
150
)
self
.
pousse
=
False
print
(
self
.
pousse
)
if
self
.
dernier_bouton
==
'entrer en poussant'
:
l
=
6
...
...
@@ -822,9 +831,12 @@ class Window(QMainWindow):
print
(
i
,
j
)
if
i
==
-
1
or
i
==
5
or
j
==
-
1
or
j
==
5
:
#la pièce doit être placée sur une case extérieure, en
#face de la pièce à pousser
print
(
'jy v'
)
self
.
pousser
()
self
.
ok
()
if
self
.
pousse
==
False
:
print
(
'et'
)
self
.
pion_select
.
setPos
(
0
,
0
)
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
=
[
l
,
self
.
pion_select_num
-
1
]
...
...
@@ -839,6 +851,10 @@ class Window(QMainWindow):
self
.
texte
.
setPos
(
0
,
150
)
self
.
pion_select
.
setPos
(
0
,
0
)
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
=
[
l
,
self
.
pion_select_num
-
1
]
if
self
.
pousse
==
False
:
print
(
'et'
)
self
.
pion_select
.
setPos
(
0
,
0
)
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
=
[
l
,
self
.
pion_select_num
-
1
]
self
.
joueur_qg
[
self
.
pion_select_num
-
1
].
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
enabled
=
False
)
...
...
@@ -954,6 +970,7 @@ class Window(QMainWindow):
'd'
:
'g'
}
if
self
.
joueur
[
self
.
pion_select_num
-
1
].
coords
[
0
]
not
in
[
-
2
,
6
]:
print
(
'tourne if'
)
if
self
.
txt
==
'droite'
:
#on change l'orientation de la pièce dans la liste joueur
self
.
joueur
[
self
.
pion_select_num
-
1
].
orientation
=
tourner_droite
[
str
(
self
.
joueur
[
self
.
pion_select_num
-
1
].
orientation
)]
...
...
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