Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GCompris
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
27
Issues
27
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
GCompris
Commits
7e60bf27
Commit
7e60bf27
authored
Jun 20, 2020
by
Johnny Jazeix
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chess, add en passant move
parent
59f9857d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
src/activities/chess/Chess.qml
src/activities/chess/Chess.qml
+16
-0
src/activities/chess/chess.js
src/activities/chess/chess.js
+3
-3
No files found.
src/activities/chess/Chess.qml
View file @
7e60bf27
...
...
@@ -507,6 +507,22 @@ ActivityBase {
movesCount
++
var
fromPiece
=
getPieceAt
(
from
)
var
toPiece
=
getPieceAt
(
to
)
// Specific case for en passant move. It is a case where
// we capture without having the pawn to the "to" position.
// To know if we captured, we browse the whole board to look
// for missing pawn
var
state
=
Activity
.
simplifiedState
(
Activity
.
state
.
board
)
for
(
var
i
=
0
;
i
<
state
.
length
;
++
i
)
{
var
pos
=
state
[
i
].
pos
var
pawnPiece
=
getPieceAt
(
pos
)
if
(
pos
!=
from
&&
state
[
i
].
img
===
""
&&
pawnPiece
.
img
!==
''
)
{
toPiece
=
pawnPiece
break
}
}
if
(
toPiece
.
img
!==
''
)
{
items
.
audioEffects
.
play
(
'
qrc:/gcompris/src/core/resource/sounds/smudge.wav
'
)
if
(
toPiece
.
isWhite
)
{
...
...
src/activities/chess/chess.js
View file @
7e60bf27
...
...
@@ -57,7 +57,7 @@ function initLevel() {
}
function
nextLevel
()
{
if
(
numberOfLevel
<=
++
currentLevel
)
{
if
(
numberOfLevel
<=
++
currentLevel
)
{
currentLevel
=
0
}
initLevel
();
...
...
@@ -295,7 +295,7 @@ function randomMove() {
return
}
// Get all possible moves
var
moves
=
Engine
.
p4_parse
(
state
,
state
.
to_play
,
0
,
0
)
var
moves
=
Engine
.
p4_parse
(
state
,
state
.
to_play
,
state
.
enpassant
,
0
)
moves
=
Core
.
shuffle
(
moves
)
var
move
=
state
.
move
(
moves
[
0
][
1
],
moves
[
0
][
2
])
if
(
move
.
ok
)
{
...
...
@@ -315,7 +315,7 @@ function clearAcceptMove() {
// Highlight the possible moves for the piece at position 'from'
function
showPossibleMoves
(
from
)
{
var
result
=
Engine
.
p4_parse
(
state
,
state
.
to_play
,
0
,
0
)
var
result
=
Engine
.
p4_parse
(
state
,
state
.
to_play
,
state
.
enpassant
,
0
)
clearAcceptMove
()
var
fromEngine
=
viewPosToEngine
(
from
)
for
(
var
i
=
0
;
i
<
result
.
length
;
++
i
)
{
...
...
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