isStructuralChange method

  1. @override
bool isStructuralChange(
  1. GridConfig oldConfig,
  2. GridConfig newConfig
)
override

奖品数量、行列或任何奖品和按钮的格子坐标变化均属于结构变化。

Implementation

@override
bool isStructuralChange(GridConfig oldConfig, GridConfig newConfig) {
  if (oldConfig.rows != newConfig.rows ||
      oldConfig.cols != newConfig.cols ||
      oldConfig.prizes.length != newConfig.prizes.length ||
      oldConfig.buttons.length != newConfig.buttons.length) {
    return true;
  }
  final oldCells = <GridCell>[...oldConfig.prizes, ...oldConfig.buttons];
  final newCells = <GridCell>[...newConfig.prizes, ...newConfig.buttons];
  for (var i = 0; i < oldCells.length; i++) {
    final old = oldCells[i];
    final next = newCells[i];
    if (old.x != next.x ||
        old.y != next.y ||
        old.col != next.col ||
        old.row != next.row) {
      return true;
    }
  }
  return false;
}