import 'package:equatable/equatable.dart'; class Gem extends Equatable { final int type; final int row; final int col; final bool isMatched; final bool isSpecial; const Gem({ required this.type, required this.row, required this.col, this.isMatched = false, this.isSpecial = false, }); Gem copyWith({ int? type, int? row, int? col, bool? isMatched, bool? isSpecial, }) { return Gem( type: type ?? this.type, row: row ?? this.row, col: col ?? this.col, isMatched: isMatched ?? this.isMatched, isSpecial: isSpecial ?? this.isSpecial, ); } get name { switch (type) { case 0: return 'red'; case 1: return 'blue'; case 2: return 'green'; case 3: return 'yellow'; case 4: return 'purple'; case 5: return 'orange'; default: return 'unknown'; } } @override List get props => [type, row, col, isMatched, isSpecial]; // equals @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is Gem && other.type == type && other.row == row && other.col == col && other.isMatched == isMatched && other.isSpecial == isSpecial; } @override int get hashCode { return type.hashCode ^ row.hashCode ^ col.hashCode ^ isMatched.hashCode ^ isSpecial.hashCode; } }