Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xdecor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
xdecor
Commits
70277d42
Commit
70277d42
authored
6 years ago
by
Jean-Patrick Guerrero
Browse files
Options
Downloads
Patches
Plain Diff
Chess cleanup
parent
5e4704ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/chess.lua
+6
-6
6 additions, 6 deletions
src/chess.lua
with
6 additions
and
6 deletions
src/chess.lua
+
6
−
6
View file @
70277d42
...
...
@@ -27,7 +27,7 @@ local rookThreats = {false, true, false, true, true, false, true, false}
local
queenThreats
=
{
true
,
true
,
true
,
true
,
true
,
true
,
true
,
true
}
local
kingThreats
=
{
true
,
true
,
true
,
true
,
true
,
true
,
true
,
true
}
local
function
king_
attack
(
color
,
idx
,
inv
)
local
function
attack
ed
(
color
,
idx
,
inv
)
local
threatDetected
=
false
local
kill
=
color
==
"white"
local
pawnThreats
=
{
kill
,
false
,
kill
,
false
,
false
,
not
kill
,
false
,
not
kill
}
...
...
@@ -683,7 +683,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player
meta
:
set_int
(
"castlingWhiteL"
,
0
)
meta
:
set_int
(
"castlingWhiteR"
,
0
)
local
whiteAttacked
=
king_
attack
(
"white"
,
to_index
,
inv
)
local
whiteAttacked
=
attack
ed
(
"white"
,
to_index
,
inv
)
if
whiteAttacked
then
return
0
end
...
...
@@ -692,7 +692,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player
meta
:
set_int
(
"castlingBlackL"
,
0
)
meta
:
set_int
(
"castlingBlackR"
,
0
)
local
blackAttacked
=
king_
attack
(
"black"
,
to_index
,
inv
)
local
blackAttacked
=
attack
ed
(
"black"
,
to_index
,
inv
)
if
blackAttacked
then
return
0
end
...
...
@@ -773,12 +773,12 @@ end
function
realchess
.
on_move
(
pos
,
from_list
,
from_index
)
local
meta
=
minetest
.
get_meta
(
pos
)
local
inv
=
m
inetest
.
get_meta
(
pos
)
:
get_inventory
()
local
inv
=
m
eta
:
get_inventory
()
inv
:
set_stack
(
from_list
,
from_index
,
''
)
local
black_king_idx
,
white_king_idx
=
locate_kings
(
inv
)
local
black_king_attacked
=
king_
attack
(
"black"
,
black_king_idx
,
inv
)
local
white_king_attacked
=
king_
attack
(
"white"
,
white_king_idx
,
inv
)
local
black_king_attacked
=
attack
ed
(
"black"
,
black_king_idx
,
inv
)
local
white_king_attacked
=
attack
ed
(
"white"
,
white_king_idx
,
inv
)
local
playerWhite
=
meta
:
get_string
(
"playerWhite"
)
local
playerBlack
=
meta
:
get_string
(
"playerBlack"
)
...
...
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