Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Echecs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Elarouti Adam
Echecs
Commits
9e9e3962
"TD02/code/test_pile.py" did not exist on "088e24ffbced7fc7284fd9d9401f37359abbbb65"
Commit
9e9e3962
authored
4 months ago
by
Elarouti Adam
Browse files
Options
Downloads
Patches
Plain Diff
mange piece
parent
96a3e90b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/chess.js
+6
-60
6 additions, 60 deletions
htdocs/chess.js
with
6 additions
and
60 deletions
htdocs/chess.js
+
6
−
60
View file @
9e9e3962
...
@@ -116,67 +116,14 @@ function highlightMoves(piece, row, col) {
...
@@ -116,67 +116,14 @@ function highlightMoves(piece, row, col) {
if
(
board
[
row
+
direction
]
&&
board
[
row
+
direction
][
col
]
===
""
)
{
if
(
board
[
row
+
direction
]
&&
board
[
row
+
direction
][
col
]
===
""
)
{
moves
.
push
({
row
:
row
+
direction
,
col
});
moves
.
push
({
row
:
row
+
direction
,
col
});
}
}
// Prises diagonales
if
(
noirs
.
includes
(
board
[
row
+
direction
][
col
+
direction
])){
let
possibleCaptures
=
[
col
-
1
,
col
+
1
];
moves
.
push
({
row
:
row
+
direction
,
col
:
col
+
direction
})
for
(
let
newCol
of
possibleCaptures
)
{
if
(
newCol
>=
0
&&
newCol
<
8
&&
board
[
row
+
direction
]
&&
noirs
.
has
(
board
[
row
+
direction
][
newCol
]))
{
moves
.
push
({
row
:
row
+
direction
,
col
:
newCol
});
}
}
if
(
piece
.
toLowerCase
()
===
"
t
"
)
{
// Déplacements vers le haut
for
(
let
r
=
row
-
1
;
r
>=
0
;
r
--
)
{
if
(
board
[
r
][
col
]
===
""
)
{
moves
.
push
({
row
:
r
,
col
});
}
else
{
if
(
noirs
.
includes
(
board
[
r
][
col
]))
{
moves
.
push
({
row
:
r
,
col
});
// Capture possible
}
if
(
blancs
.
includes
(
board
[
r
][
col
]))
{
break
}
break
;
// Bloqué par une pièce
}
}
// Déplacements vers le bas
for
(
let
r
=
row
+
1
;
r
<
8
;
r
++
)
{
if
(
board
[
r
][
col
]
===
""
)
{
moves
.
push
({
row
:
r
,
col
});
}
else
{
if
(
noirs
.
includes
(
board
[
r
][
col
]))
{
moves
.
push
({
row
:
r
,
col
});
}
break
;
}
}
// Déplacements vers la gauche
for
(
let
c
=
col
-
1
;
c
>=
0
;
c
--
)
{
if
(
board
[
row
][
c
]
===
""
)
{
moves
.
push
({
row
,
col
:
c
});
}
else
{
if
(
noirs
.
includes
(
board
[
r
][
col
]))
{
moves
.
push
({
row
,
col
:
c
});
}
break
;
}
}
if
(
noirs
.
includes
(
board
[
row
+
direction
][
col
-
direction
])){
moves
.
push
({
row
:
row
+
direction
,
col
:
col
-
direction
})
}
}
// Déplacements vers la droite
for
(
let
c
=
col
+
1
;
c
<
8
;
c
++
)
{
if
(
board
[
row
][
c
]
===
""
)
{
moves
.
push
({
row
,
col
:
c
});
}
else
{
if
(
noirs
.
includes
(
board
[
r
][
col
]))
{
moves
.
push
({
row
,
col
:
c
});
}
break
;
}
}
}
}
return
moves
;
return
moves
;
}
}
...
@@ -222,4 +169,3 @@ function movePiece(newRow, newCol) {
...
@@ -222,4 +169,3 @@ function movePiece(newRow, newCol) {
selectedPiece
=
null
;
selectedPiece
=
null
;
}
}
}
}
\ No newline at end of file
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment