generateHighlights function
Map<int, HighlightType>
generateHighlights({
- int? selection,
- int? target,
- required BoardState state,
- PlayState playState = PlayState.observing,
Implementation
Map<int, HighlightType> generateHighlights({
int? selection,
int? target,
required BoardState state,
PlayState playState = PlayState.observing,
}) {
HighlightType selectionColour = playState != PlayState.theirTurn
? HighlightType.selected
: HighlightType.premove;
Map<int, HighlightType> highlights = {
if (selection != null) selection: selectionColour,
if (target != null) target: selectionColour,
if (state.lastFrom != null &&
state.lastFrom != selection &&
state.lastFrom != target)
state.lastFrom!: HighlightType.previous,
if (state.lastTo != null &&
state.lastTo != selection &&
state.lastTo != target)
state.lastTo!: HighlightType.previous,
if (state.checkSquare != null &&
state.checkSquare != selection &&
state.checkSquare != target)
state.checkSquare!: playState == PlayState.finished
? HighlightType.checkmate
: HighlightType.check,
};
return highlights;
}