Starlight-30036225 / ChessTCP

FILLMELATER
0 stars 0 forks source link

Create bass piece class #6

Closed Starlight-30036225 closed 9 months ago

Starlight-30036225 commented 9 months ago

I have defined some early framework for the piece class, this will be stored behind the scenes in the server.

`public class Piece {

protected int x;
protected int y;
protected boolean white;

Piece(int x, int y, boolean white){}

public boolean move(String NewLocation){
    return false;
}

public List<String> GetPossibleMoves() {
    return null;
}

public int getX() {
    return x;
}
public int getY() {
    return y;
}

} interface Diagonal{}

interface Straight{} `

The two interfaces at the bottom will be used for movement like rooks and bishops, and as a queen just uses a combination of these two it will eliminate any redundant code.

Starlight-30036225 commented 9 months ago

Get possible moves can be abstracted, as it will need to be refined for every single piece type.

Starlight-30036225 commented 9 months ago

I have also created a static factory method inside the bass piece class to create pieces of the correct class. This will help encapsulate piece definition. For now it only returns rooks as i test pieces, but will show when it is completed.

image