Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
chess
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9611046
chess
Commits
3ae97982
Commit
3ae97982
authored
May 16, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made Pawn class
parent
f2b5d1a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
Pawn.java
src/pieces/Pawn.java
+53
-0
No files found.
src/pieces/Pawn.java
0 → 100644
View file @
3ae97982
package
pieces
;
import
game.Square
;
import
java.util.ArrayList
;
public
class
Pawn
extends
Piece
{
public
Pawn
(
String
ID
,
String
imagePath
,
String
color
){
setPieceId
(
ID
);
setImage
(
imagePath
);
setPieceColor
(
color
);
}
public
ArrayList
<
Square
>
move
(
Square
[][]
boardSquares
,
int
x
,
int
y
){
//The java.util.ArrayList.clear() method removes all of the elements from this list.The list will be empty after this call returns.
possibleSquares
.
clear
();
if
(
getPieceColor
().
equals
(
"w"
)){
if
(
x
==
0
){
return
possibleSquares
;
}
if
(
boardSquares
[
x
-
1
][
y
].
getPiece
()==
null
)
{
possibleSquares
.
add
(
boardSquares
[
x
-
1
][
y
]);
if
(
x
==
6
)
{
if
(
boardSquares
[
4
][
y
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
4
][
y
]);
}
}
if
((
y
>
0
)
&&
(
boardSquares
[
x
-
1
][
y
-
1
].
getPiece
()
!=
null
)
&&
(
boardSquares
[
x
-
1
][
y
-
1
].
getPiece
().
getPieceColor
()
!=
this
.
getPieceColor
()))
possibleSquares
.
add
(
boardSquares
[
x
-
1
][
y
-
1
]);
if
((
y
<
7
)
&&
(
boardSquares
[
x
-
1
][
y
+
1
].
getPiece
()
!=
null
)
&&
(
boardSquares
[
x
-
1
][
y
+
1
].
getPiece
().
getPieceColor
()
!=
this
.
getPieceColor
()))
possibleSquares
.
add
(
boardSquares
[
x
-
1
][
y
+
1
]);
}
else
if
(
getPieceColor
().
equals
(
"b"
))
{
if
(
x
==
8
)
return
possibleSquares
;
if
(
boardSquares
[
x
+
1
][
y
].
getPiece
()
==
null
)
{
possibleSquares
.
add
(
boardSquares
[
x
+
1
][
y
]);
if
(
x
==
1
)
{
if
(
boardSquares
[
3
][
y
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
3
][
y
]);
}
}
if
((
y
>
0
)
&&
(
boardSquares
[
x
+
1
][
y
-
1
].
getPiece
()
!=
null
)
&&
(
boardSquares
[
x
+
1
][
y
-
1
].
getPiece
().
getPieceColor
()
!=
this
.
getPieceColor
()))
possibleSquares
.
add
(
boardSquares
[
x
+
1
][
y
-
1
]);
if
((
y
<
7
)
&&
(
boardSquares
[
x
+
1
][
y
+
1
].
getPiece
()
!=
null
)
&&
(
boardSquares
[
x
+
1
][
y
+
1
].
getPiece
().
getPieceColor
()
!=
this
.
getPieceColor
()))
possibleSquares
.
add
(
boardSquares
[
x
+
1
][
y
+
1
]);
}
return
possibleSquares
;
}
}
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