Files
BlockSeasons/lib/game/models/season.dart
T
airkjw 41c18c8bdd Add AutoPlayer bot, stage generator CLI, and calibrated Season 1 (60 stages)
Greedy bot with tray-survival lookahead and gem-line steering; generator
samples layouts along a difficulty curve, probes bot moves-to-win, sets
adaptive move budgets targeting win-rate bands, and derives star
thresholds from spare-move quantiles. Season 1 pack bundled in assets
with per-stage difficulty report.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 13:56:54 +09:00

72 lines
2.1 KiB
Dart

import 'stage.dart';
class SeasonTheme {
const SeasonTheme({required this.tileSet, required this.background});
factory SeasonTheme.fromJson(Map<String, dynamic> json) => SeasonTheme(
tileSet: json['tileSet'] as String,
background: json['background'] as String,
);
final String tileSet;
final String background;
Map<String, dynamic> toJson() =>
{'tileSet': tileSet, 'background': background};
}
/// A season's full content: metadata, theme, and its stages. The unit of
/// remote (or bundled) delivery.
class SeasonPack {
const SeasonPack({
required this.schemaVersion,
required this.seasonId,
required this.version,
required this.title,
required this.theme,
required this.stages,
});
/// Bump when the pack format changes incompatibly; older app builds skip
/// packs with a newer schema instead of crashing.
static const int supportedSchema = 1;
factory SeasonPack.fromJson(Map<String, dynamic> json) {
final schema = json['schemaVersion'] as int;
if (schema > supportedSchema) {
throw FormatException('Unsupported pack schema: $schema');
}
return SeasonPack(
schemaVersion: schema,
seasonId: json['seasonId'] as String,
version: json['version'] as int,
title: (json['title'] as Map<String, dynamic>)
.map((k, v) => MapEntry(k, v as String)),
theme: SeasonTheme.fromJson(json['theme'] as Map<String, dynamic>),
stages: [
for (final stage in json['stages'] as List)
StageConfig.fromJson(stage as Map<String, dynamic>),
],
);
}
final int schemaVersion;
final String seasonId;
final int version;
final Map<String, String> title;
final SeasonTheme theme;
final List<StageConfig> stages;
String titleFor(String languageCode) =>
title[languageCode] ?? title['en'] ?? seasonId;
Map<String, dynamic> toJson() => {
'schemaVersion': schemaVersion,
'seasonId': seasonId,
'version': version,
'title': title,
'theme': theme.toJson(),
'stages': [for (final stage in stages) stage.toJson()],
};
}