Select Git revision
-
Benoît Harrault authoredBenoît Harrault authored
board.dart 911 B
import 'package:awale/utils/tools.dart';
typedef BoardCells = List<int>;
class Board {
Board({
required this.cells,
});
BoardCells cells = const [];
factory Board.createNull() {
return Board(
cells: [],
);
}
factory Board.createNew({
required BoardCells cells,
}) {
return Board(
cells: cells,
);
}
void dump() {
printlog('');
printlog(' $Board:');
const List<List<int>> indexes = [
[11, 10, 9, 8, 7, 6],
[0, 1, 2, 3, 4, 5],
];
for (List<int> line in indexes) {
String row = ' ';
for (int index in line) {
row += '[${cells[index].toString().padLeft(2, ' ')}]';
}
printlog(row);
}
printlog('');
}
@override
String toString() {
return '$Board(${toJson()})';
}
Map<String, dynamic>? toJson() {
return <String, dynamic>{
'cells': cells,
};
}
}