Skip to content

Update example for MAKE_MOVE JSON payload#361

Open
josephgeis wants to merge 1 commit intosoftwareconstruction240:mainfrom
josephgeis:patch-2
Open

Update example for MAKE_MOVE JSON payload#361
josephgeis wants to merge 1 commit intosoftwareconstruction240:mainfrom
josephgeis:patch-2

Conversation

@josephgeis
Copy link
Contributor

The example on line 130 was inconsistent with what the passoff tests were expecting for the MAKE_MOVE command

The example on line 130 was inconsistent with what the passoff tests were expecting for the MAKE_MOVE command
@leesjensen
Copy link
Contributor

I'm trying to validate the assertion that the passoff tests require a specific serialized format. The starter code specifies the constructor and getters, but not the field names.

public class ChessMove {

    public ChessMove(ChessPosition startPosition, ChessPosition endPosition,
                     ChessPiece.PieceType promotionPiece) {
    }

    /**
     * @return ChessPosition of starting location
     */
    public ChessPosition getStartPosition() {
        throw new RuntimeException("Not implemented");
    }

    /**
     * @return ChessPosition of ending location
     */
    public ChessPosition getEndPosition() {
        throw new RuntimeException("Not implemented");
    }

    /**
     * Gets the type of piece to promote a pawn to if pawn promotion is part of this
     * chess move
     *
     * @return Type of piece to promote a pawn to, or null if no promotion
     */
    public ChessPiece.PieceType getPromotionPiece() {
        throw new RuntimeException("Not implemented");
    }
}

Can you point to which specific test you found that requires a specific serialization format for ChessMove?

@leesjensen
Copy link
Contributor

I modified my implementation of ChessMove to include both representations of long and shortened field names. This gets reflected in the serialization when pushing the object through GSON. All tests passed successfully.

public class ChessMove {

    private final ChessPosition start;
    private final ChessPosition endPosition;
    private final ChessPiece.PieceType promotionPiece;

    public ChessMove(ChessPosition startPosition, ChessPosition endPosition,
                     ChessPiece.PieceType promotionPiece) {
        this.start = startPosition;
        this.endPosition = endPosition;
        this.promotionPiece = promotionPiece;
    }

...

Is it possible that you are serializing in a way that couples the field names is some way that isn't necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants