mchess-client/lib/api/move.dart

33 lines
845 B
Dart

class ApiMove {
final ApiCoordinate startSquare;
final ApiCoordinate endSquare;
const ApiMove({
required this.startSquare,
required this.endSquare,
});
factory ApiMove.fromJson(Map<String, dynamic> json) {
final startSquare = ApiCoordinate.fromJson(json['startSquare']);
final endSquare = ApiCoordinate.fromJson(json['endSquare']);
return ApiMove(startSquare: startSquare, endSquare: endSquare);
}
Map<String, dynamic> toJson() =>
{'startSquare': startSquare, 'endSquare': endSquare};
}
class ApiCoordinate {
final int col;
final int row;
const ApiCoordinate({required this.col, required this.row});
factory ApiCoordinate.fromJson(Map<String, dynamic> json) {
return ApiCoordinate(col: json['col'], row: json['row']);
}
Map<String, dynamic> toJson() => {'col': col, 'row': row};
}