- Add Level model with constraints, objectives, and star ratings - Create LevelService for loading levels from JSON configuration - Implement LevelSelectionScreen with visual progress tracking - Update GameBloc to handle level-based gameplay - Add 10 predefined levels with varying difficulty and objectives - Integrate level progression system into game flow
82 lines
1.5 KiB
Dart
82 lines
1.5 KiB
Dart
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 {
|
|
return getName(type);
|
|
}
|
|
|
|
@override
|
|
List<Object?> 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;
|
|
}
|
|
|
|
static String getName(int type) {
|
|
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';
|
|
}
|
|
}
|
|
}
|