diff --git a/lib/puzzle/bloc/puzzle_bloc.dart b/lib/puzzle/bloc/puzzle_bloc.dart index 71cc0c3..c45a22b 100644 --- a/lib/puzzle/bloc/puzzle_bloc.dart +++ b/lib/puzzle/bloc/puzzle_bloc.dart @@ -27,12 +27,14 @@ class PuzzleBloc extends Bloc { final PuzzlesRepository _puzzlesRepository; + final puzzleVersion = DateTime.now().difference(DateTime(2022, 3, 14)).inDays; + Future _onPuzzleFetched( PuzzleFetched event, Emitter emit, ) async { emit(state.copyWith(status: GameStatus.loading)); - final game = await _puzzlesRepository.getPuzzle(); + final game = await _puzzlesRepository.getPuzzle(puzzleVersion); emit(state.copyWith(status: GameStatus.setup, history: [game])); } @@ -88,13 +90,13 @@ class PuzzleBloc extends Bloc { void _onPuzzleShared(PuzzleShared event, Emitter emit) { if (!state.puzzle.isSolved) return; - sharePuzzle(state); + sharePuzzle(state, puzzleVersion); } } -void sharePuzzle(PuzzleState state) { +void sharePuzzle(PuzzleState state, int version) { final introMessage = ''' -https://flutter-rush.web.app/ (#${DateTime.now().difference(DateTime(2022, 2, 27)).inDays}) +https://flutter-rush.web.app/ (#$version) '''; final buffer = StringBuffer(); for (final state in state.history) { diff --git a/packages/puzzle_models/lib/src/models/position.dart b/packages/puzzle_models/lib/src/models/position.dart index 8b40330..41ff63b 100644 --- a/packages/puzzle_models/lib/src/models/position.dart +++ b/packages/puzzle_models/lib/src/models/position.dart @@ -1,10 +1,14 @@ import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'position.g.dart'; /// {@template position} /// 2-dimensional position model. /// /// (0, 0) is the top left corner of the board. /// {@endtemplate} +@JsonSerializable() class Position extends Equatable { /// {@macro position} const Position(this.x, this.y) @@ -18,7 +22,7 @@ class Position extends Equatable { ); /// A position with the same [value] offset for both axis - const Position.all(int value) + const Position.all(int value) : assert( value >= 0, 'value must be greater than or equal to 0.', @@ -26,6 +30,10 @@ class Position extends Equatable { x = value, y = value; + /// Converts a JSON [Map] into a [Position] instance + factory Position.fromJson(Map json) => + _$PositionFromJson(json); + /// A position with a zero offset in both axis static const Position zero = Position(0, 0); @@ -72,4 +80,7 @@ class Position extends Equatable { @override List get props => [x, y]; + + /// Converts this [Position] instance into a JSON [Map] + Map toJson() => _$PositionToJson(this); } diff --git a/packages/puzzle_models/lib/src/models/position.g.dart b/packages/puzzle_models/lib/src/models/position.g.dart new file mode 100644 index 0000000..09646c5 --- /dev/null +++ b/packages/puzzle_models/lib/src/models/position.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'position.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Position _$PositionFromJson(Map json) => Position( + json['x'] as int, + json['y'] as int, + ); + +Map _$PositionToJson(Position instance) => { + 'x': instance.x, + 'y': instance.y, + }; diff --git a/packages/puzzle_models/lib/src/models/rush_puzzle.dart b/packages/puzzle_models/lib/src/models/rush_puzzle.dart index c139247..e92e6b4 100644 --- a/packages/puzzle_models/lib/src/models/rush_puzzle.dart +++ b/packages/puzzle_models/lib/src/models/rush_puzzle.dart @@ -1,12 +1,16 @@ import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; import 'package:puzzle_models/puzzle_models.dart'; +part 'rush_puzzle.g.dart'; + /// {@template rush_puzzle} /// Represents a Rush Hour puzzle. /// /// For more information see: /// - https://en.wikipedia.org/wiki/Rush_Hour_(puzzle) /// {@endtemplate} +@JsonSerializable() class RushPuzzle extends Equatable { /// {@macro rush_puzzle} RushPuzzle({ @@ -36,6 +40,13 @@ class RushPuzzle extends Equatable { lastVehicleMoved = null, jammedVehicleId = ''; + /// Converts a JSON [Map] into a [Position] instance + factory RushPuzzle.fromJson(Map json) => + _$RushPuzzleFromJson(json); + + /// Converts this [Position] instance into a JSON [Map] + Map toJson() => _$RushPuzzleToJson(this); + /// The [Position] that the [jammedVehicleId] has to reach in order to solve /// the puzzle. static const Position exit = Position(6, 2); diff --git a/packages/puzzle_models/lib/src/models/rush_puzzle.g.dart b/packages/puzzle_models/lib/src/models/rush_puzzle.g.dart new file mode 100644 index 0000000..00e8796 --- /dev/null +++ b/packages/puzzle_models/lib/src/models/rush_puzzle.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'rush_puzzle.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +RushPuzzle _$RushPuzzleFromJson(Map json) => RushPuzzle( + difficulty: $enumDecode(_$PuzzleDifficultyEnumMap, json['difficulty']), + jammedVehicleId: json['jammedVehicleId'] as String, + vehicles: (json['vehicles'] as Map).map( + (k, e) => MapEntry(k, Vehicle.fromJson(e as Map)), + ), + lastVehicleMoved: json['lastVehicleMoved'] == null + ? null + : Vehicle.fromJson(json['lastVehicleMoved'] as Map), + ); + +Map _$RushPuzzleToJson(RushPuzzle instance) => + { + 'vehicles': instance.vehicles, + 'jammedVehicleId': instance.jammedVehicleId, + 'difficulty': _$PuzzleDifficultyEnumMap[instance.difficulty], + 'lastVehicleMoved': instance.lastVehicleMoved, + }; + +const _$PuzzleDifficultyEnumMap = { + PuzzleDifficulty.beginner: 'beginner', + PuzzleDifficulty.intermediate: 'intermediate', + PuzzleDifficulty.advanced: 'advanced', + PuzzleDifficulty.expert: 'expert', +}; diff --git a/packages/puzzle_models/lib/src/models/vehicle.dart b/packages/puzzle_models/lib/src/models/vehicle.dart index f4e9294..b959fc4 100644 --- a/packages/puzzle_models/lib/src/models/vehicle.dart +++ b/packages/puzzle_models/lib/src/models/vehicle.dart @@ -1,12 +1,16 @@ import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; import 'package:puzzle_models/puzzle_models.dart'; +part 'vehicle.g.dart'; + /// {@template vehicle} /// Representation of a [RushPuzzle] vehicle. /// /// [Vehicle] can have variable length, but the width is assumed to be one. /// The orientation of the vehicle is fixed and determined by [Steering]. /// {@endtemplate} +@JsonSerializable() class Vehicle extends Equatable { /// {@macro vehicle} Vehicle({ @@ -24,6 +28,13 @@ class Vehicle extends Equatable { ? Position(type.length - 1, 0) : Position(0, type.length - 1)); + /// Converts a JSON [Map] into a [Position] instance + factory Vehicle.fromJson(Map json) => + _$VehicleFromJson(json); + + /// Converts this [Position] instance into a JSON [Map] + Map toJson() => _$VehicleToJson(this); + /// Unique identifier for this vehicle. final String id; diff --git a/packages/puzzle_models/lib/src/models/vehicle.g.dart b/packages/puzzle_models/lib/src/models/vehicle.g.dart new file mode 100644 index 0000000..692de74 --- /dev/null +++ b/packages/puzzle_models/lib/src/models/vehicle.g.dart @@ -0,0 +1,38 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'vehicle.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Vehicle _$VehicleFromJson(Map json) => Vehicle( + id: json['id'] as String, + steering: $enumDecode(_$SteeringEnumMap, json['steering']), + firstPosition: + Position.fromJson(json['firstPosition'] as Map), + type: $enumDecode(_$VehicleTypeEnumMap, json['type']), + ); + +Map _$VehicleToJson(Vehicle instance) => { + 'id': instance.id, + 'type': _$VehicleTypeEnumMap[instance.type], + 'steering': _$SteeringEnumMap[instance.steering], + 'firstPosition': instance.firstPosition, + }; + +const _$SteeringEnumMap = { + Steering.horizontal: 'horizontal', + Steering.vertical: 'vertical', +}; + +const _$VehicleTypeEnumMap = { + VehicleType.taxi: 'taxi', + VehicleType.car: 'car', + VehicleType.police: 'police', + VehicleType.bus: 'bus', + VehicleType.secondaryBus: 'secondaryBus', + VehicleType.truck: 'truck', + VehicleType.secondaryTruck: 'secondaryTruck', + VehicleType.ambulance: 'ambulance', +}; diff --git a/packages/puzzle_models/pubspec.yaml b/packages/puzzle_models/pubspec.yaml index fb5eec1..ebd04ff 100644 --- a/packages/puzzle_models/pubspec.yaml +++ b/packages/puzzle_models/pubspec.yaml @@ -8,7 +8,12 @@ environment: dependencies: equatable: ^2.0.3 + json_annotation: ^4.4.0 + + dev_dependencies: + build_runner: ^2.1.8 + json_serializable: ^6.1.5 test: ^1.19.2 very_good_analysis: ^2.4.0 diff --git a/packages/puzzles_repository/assets/1.json b/packages/puzzles_repository/assets/1.json new file mode 100644 index 0000000..6ece050 --- /dev/null +++ b/packages/puzzles_repository/assets/1.json @@ -0,0 +1,79 @@ +{ + "jammedVehicleId": "X", + "difficulty": "beginner", + "minMoves": "8", + "vehicles": { + "A": { + "id": "A", + "type": "taxi", + "steering": "horizontal", + "firstPosition": { + "x": 0, + "y": 0 + } + }, + "P": { + "id": "P", + "type": "secondaryBus", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 1 + } + }, + "B": { + "id": "B", + "type": "car", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 4 + } + }, + "X": { + "id": "X", + "type": "ambulance", + "steering": "horizontal", + "firstPosition": { + "x": 1, + "y": 2 + } + }, + "Q": { + "id": "Q", + "type": "secondaryTruck", + "steering": "vertical", + "firstPosition": { + "x": 3, + "y": 1 + } + }, + "R": { + "id": "R", + "type": "bus", + "steering": "horizontal", + "firstPosition": { + "x": 2, + "y": 5 + } + }, + "C": { + "id": "C", + "type": "police", + "steering": "horizontal", + "firstPosition": { + "x": 4, + "y": 4 + } + }, + "O": { + "id": "O", + "type": "truck", + "steering": "vertical", + "firstPosition": { + "x": 5, + "y": 0 + } + } + } +} \ No newline at end of file diff --git a/packages/puzzles_repository/assets/2.json b/packages/puzzles_repository/assets/2.json new file mode 100644 index 0000000..aca5192 --- /dev/null +++ b/packages/puzzles_repository/assets/2.json @@ -0,0 +1,106 @@ +{ + "jammedVehicleId": "X", + "difficulty": "beginner", + "minMoves": "8", + "vehicles": { + "A": { + "id": "A", + "type": "taxi", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 0 + } + }, + "B": { + "id": "B", + "type": "car", + "steering": "vertical", + "firstPosition": { + "x": 3, + "y": 1 + } + }, + "C": { + "id": "C", + "type": "police", + "steering": "vertical", + "firstPosition": { + "x": 4, + "y": 2 + } + }, + "D": { + "id": "D", + "type": "taxi", + "steering": "vertical", + "firstPosition": { + "x": 2, + "y": 4 + } + }, + "E": { + "id": "E", + "type": "taxi", + "steering": "horizontal", + "firstPosition": { + "x": 4, + "y": 4 + } + }, + "F": { + "id": "F", + "type": "car", + "steering": "horizontal", + "firstPosition": { + "x": 0, + "y": 5 + } + }, + "G": { + "id": "G", + "type": "police", + "steering": "horizontal", + "firstPosition": { + "x": 3, + "y": 5 + } + }, + "O": { + "id": "O", + "type": "truck", + "steering": "horizontal", + "firstPosition": { + "x": 3, + "y": 0 + } + }, + "P": { + "id": "P", + "type": "secondaryBus", + "steering": "vertical", + "firstPosition": { + "x": 5, + "y": 1 + } + }, + "Q": { + "id": "Q", + "type": "secondaryTruck", + "steering": "horizontal", + "firstPosition": { + "x": 0, + "y": 3 + } + }, + "X": { + "id": "X", + "type": "ambulance", + "steering": "horizontal", + "firstPosition": { + "x": 0, + "y": 2 + } + } + } +} \ No newline at end of file diff --git a/packages/puzzles_repository/assets/3.json b/packages/puzzles_repository/assets/3.json new file mode 100644 index 0000000..8a3080b --- /dev/null +++ b/packages/puzzles_repository/assets/3.json @@ -0,0 +1,61 @@ +{ + "jammedVehicleId": "X", + "difficulty": "beginner", + "minMoves": "14", + "vehicles": { + "A": { + "id": "A", + "type": "taxi", + "steering": "vertic", + "firstPosition": { + "x": 1, + "y": 3 + } + }, + "B": { + "id": "B", + "type": "car", + "steering": "vertical", + "firstPosition": { + "x": 1, + "y": 4 + } + }, + "C": { + "id": "C", + "type": "police", + "steering": "horizontal", + "firstPosition": { + "x": 2, + "y": 5 + } + }, + "O": { + "id": "O", + "type": "truck", + "steering": "vertical", + "firstPosition": { + "x": 3, + "y": 2 + } + }, + "P": { + "id": "P", + "type": "bus", + "steering": "vertical", + "firstPosition": { + "x": 5, + "y": 3 + } + }, + "X": { + "id": "X", + "type": "ambulance", + "steering": "horizontal", + "firstPosition": { + "x": 1, + "y": 2 + } + } + } +} \ No newline at end of file diff --git a/packages/puzzles_repository/assets/4.json b/packages/puzzles_repository/assets/4.json new file mode 100644 index 0000000..1d40906 --- /dev/null +++ b/packages/puzzles_repository/assets/4.json @@ -0,0 +1,70 @@ +{ + "jammedVehicleId": "X", + "difficulty": "beginner", + "minMoves": "9", + "vehicles": { + "A": { + "id": "A", + "type": "taxi", + "steering": "vertical", + "firstPosition": { + "x": 2, + "y": 3 + } + }, + "B": { + "id": "B", + "type": "car", + "steering": "vertical", + "firstPosition": { + "x": 5, + "y": 4 + } + }, + "O": { + "id": "O", + "type": "truck", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 0 + } + }, + "P": { + "id": "P", + "type": "bus", + "steering": "vertical", + "firstPosition": { + "x": 3, + "y": 0 + } + }, + "Q": { + "id": "Q", + "type": "secondaryTruck", + "steering": "horizontal", + "firstPosition": { + "x": 3, + "y": 3 + } + }, + "R": { + "id": "R", + "type": "secondaryBus", + "steering": "horizontal", + "firstPosition": { + "x": 2, + "y": 5 + } + }, + "X": { + "id": "X", + "type": "ambulance", + "steering": "horizontal", + "firstPosition": { + "x": 1, + "y": 2 + } + } + } +} \ No newline at end of file diff --git a/packages/puzzles_repository/assets/5.json b/packages/puzzles_repository/assets/5.json new file mode 100644 index 0000000..7d3a0a8 --- /dev/null +++ b/packages/puzzles_repository/assets/5.json @@ -0,0 +1,106 @@ +{ + "jammedVehicleId": "X", + "difficulty": "beginner", + "minMoves": "9", + "vehicles": { + "A": { + "id": "A", + "type": "taxi", + "steering": "horizontal", + "firstPosition": { + "x": 0, + "y": 0 + } + }, + "B": { + "id": "B", + "type": "car", + "steering": "vertical", + "firstPosition": { + "x": 5, + "y": 0 + } + }, + "D": { + "id": "D", + "type": "taxi", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 4 + } + }, + "E": { + "id": "E", + "type": "taxi", + "steering": "horizontal", + "firstPosition": { + "x": 4, + "y": 4 + } + }, + "F": { + "id": "F", + "type": "car", + "steering": "horizontal", + "firstPosition": { + "x": 4, + "y": 5 + } + }, + "G": { + "id": "G", + "type": "police", + "steering": "vertical", + "firstPosition": { + "x": 5, + "y": 2 + } + }, + "O": { + "id": "O", + "type": "truck", + "steering": "vertical", + "firstPosition": { + "x": 3, + "y": 0 + } + }, + "P": { + "id": "P", + "type": "bus", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 1 + } + }, + "Q": { + "id": "Q", + "type": "secondaryTruck", + "steering": "vertical", + "firstPosition": { + "x": 4, + "y": 1 + } + }, + "R": { + "id": "R", + "type": "secondaryBus", + "steering": "horizontal", + "firstPosition": { + "x": 1, + "y": 3 + } + }, + "X": { + "id": "X", + "type": "ambulance", + "steering": "horizontal", + "firstPosition": { + "x": 1, + "y": 2 + } + } + } +} \ No newline at end of file diff --git a/packages/puzzles_repository/assets/base.json b/packages/puzzles_repository/assets/base.json new file mode 100644 index 0000000..79254c1 --- /dev/null +++ b/packages/puzzles_repository/assets/base.json @@ -0,0 +1,115 @@ +{ + "jammedVehicleId": "X", + "difficulty": "beginner", + "minMoves": "8", + "vehicles": { + "A": { + "id": "A", + "type": "taxi", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 0 + } + }, + "B": { + "id": "B", + "type": "car", + "steering": "vertical", + "firstPosition": { + "x": 3, + "y": 2 + } + }, + "C": { + "id": "C", + "type": "police", + "steering": "horizontal", + "firstPosition": { + "x": 4, + "y": 3 + } + }, + "D": { + "id": "D", + "type": "taxi", + "steering": "vertical", + "firstPosition": { + "x": 2, + "y": 4 + } + }, + "E": { + "id": "E", + "type": "taxi", + "steering": "horizontal", + "firstPosition": { + "x": 4, + "y": 4 + } + }, + "F": { + "id": "F", + "type": "car", + "steering": "horizontal", + "firstPosition": { + "x": 5, + "y": 0 + } + }, + "G": { + "id": "G", + "type": "police", + "steering": "horizontal", + "firstPosition": { + "x": 5, + "y": 3 + } + }, + "O": { + "id": "O", + "type": "truck", + "steering": "horizontal", + "firstPosition": { + "x": 3, + "y": 0 + } + }, + "P": { + "id": "P", + "type": "bus", + "steering": "vertical", + "firstPosition": { + "x": 0, + "y": 1 + } + }, + "Q": { + "id": "Q", + "type": "secondaryTruck", + "steering": "horizontal", + "firstPosition": { + "x": 0, + "y": 3 + } + }, + "R": { + "id": "R", + "type": "secondaryBus", + "steering": "horizontal", + "firstPosition": { + "x": 2, + "y": 5 + } + }, + "X": { + "id": "X", + "type": "ambulance", + "steering": "horizontal", + "firstPosition": { + "x": 1, + "y": 2 + } + } + } +} \ No newline at end of file diff --git a/packages/puzzles_repository/lib/src/puzzles_repository.dart b/packages/puzzles_repository/lib/src/puzzles_repository.dart index fe53187..7ec364b 100644 --- a/packages/puzzles_repository/lib/src/puzzles_repository.dart +++ b/packages/puzzles_repository/lib/src/puzzles_repository.dart @@ -1,6 +1,8 @@ import 'dart:async'; +import 'dart:convert'; import 'package:puzzle_models/puzzle_models.dart'; +import 'package:flutter/services.dart' show rootBundle; /// {@template puzzles_repository} /// A repository that handles [RushPuzzle]s related requests. @@ -12,79 +14,10 @@ class PuzzlesRepository { /// Retrieves a [RushPuzzle]. /// /// The [RushPuzzle] is expected to be on the initial state. - FutureOr getPuzzle() { - return _GamePuzzles.games.first; + FutureOr getPuzzle(int number) async { + final game = await rootBundle + .loadString('packages/puzzles_repository/assets/$number.json'); + final json = jsonDecode(game) as Map; + return RushPuzzle.fromJson(json); } } - -class _GamePuzzles { - static final games = [ - _SimpleRushPuzzle( - difficulty: PuzzleDifficulty.beginner, - vehicles: [ - Vehicle( - id: 'A', - type: VehicleType.taxi, - steering: Steering.horizontal, - firstPosition: Position.zero, - ), - Vehicle( - id: 'P', - type: VehicleType.secondaryBus, - steering: Steering.vertical, - firstPosition: const Position(0, 1), - ), - Vehicle( - id: 'B', - type: VehicleType.car, - steering: Steering.vertical, - firstPosition: const Position(0, 4), - ), - Vehicle( - id: 'X', - type: VehicleType.ambulance, - steering: Steering.horizontal, - firstPosition: const Position(1, 2), - ), - Vehicle( - id: 'Q', - type: VehicleType.secondaryTruck, - steering: Steering.vertical, - firstPosition: const Position(3, 1), - ), - Vehicle( - id: 'R', - type: VehicleType.bus, - steering: Steering.horizontal, - firstPosition: const Position(2, 5), - ), - Vehicle( - id: 'C', - type: VehicleType.police, - steering: Steering.horizontal, - firstPosition: const Position(4, 4), - ), - Vehicle( - id: 'O', - type: VehicleType.truck, - steering: Steering.vertical, - firstPosition: const Position(5, 0), - ), - ], - ), - ]; -} - -// TODO(alestiago): define another constructor. -class _SimpleRushPuzzle extends RushPuzzle { - _SimpleRushPuzzle({ - required PuzzleDifficulty difficulty, - required List vehicles, - }) : super( - difficulty: difficulty, - jammedVehicleId: 'X', - vehicles: { - for (final vehicle in vehicles) vehicle.id: vehicle, - }, - ); -} diff --git a/packages/puzzles_repository/pubspec.yaml b/packages/puzzles_repository/pubspec.yaml index e261b7d..b793454 100644 --- a/packages/puzzles_repository/pubspec.yaml +++ b/packages/puzzles_repository/pubspec.yaml @@ -7,9 +7,17 @@ environment: sdk: ">=2.14.0 <3.0.0" dependencies: + flutter: + sdk: flutter puzzle_models: path: ../puzzle_models dev_dependencies: + flutter_test: + sdk: flutter test: ^1.19.2 very_good_analysis: ^2.4.0 + +flutter: + assets: + - assets/ \ No newline at end of file diff --git a/packages/puzzles_repository/test/src/puzzles_repository_test.dart b/packages/puzzles_repository/test/src/puzzles_repository_test.dart index 4a83ec5..182d033 100644 --- a/packages/puzzles_repository/test/src/puzzles_repository_test.dart +++ b/packages/puzzles_repository/test/src/puzzles_repository_test.dart @@ -1,18 +1,24 @@ // ignore_for_file: prefer_const_constructors +import 'package:flutter_test/flutter_test.dart'; import 'package:puzzle_models/puzzle_models.dart'; import 'package:puzzles_repository/puzzles_repository.dart'; -import 'package:test/test.dart'; void main() { group('PuzzlesRepository', () { + TestWidgetsFlutterBinding.ensureInitialized(); test('can be constructed', () { expect(PuzzlesRepository(), isA()); }); test('gets a puzzle', () { final repository = PuzzlesRepository(); - expect(repository.getPuzzle(), isA()); + expect(repository.getPuzzle(1), completion(isA())); + }); + + test('3', () { + final repository = PuzzlesRepository(); + expect(repository.getPuzzle(1), completion(isA())); }); }); } diff --git a/packages/puzzles_repository/tool/verify.dart b/packages/puzzles_repository/tool/verify.dart new file mode 100644 index 0000000..5bbfae1 --- /dev/null +++ b/packages/puzzles_repository/tool/verify.dart @@ -0,0 +1,16 @@ +// ignore_for_file: prefer_const_constructors + +import 'dart:convert'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:puzzle_models/puzzle_models.dart'; + + +Future main() async { + final string = File('assets/1.json').readAsStringSync(); + + final json = jsonDecode(string) as Map; + final puzzle = RushPuzzle.fromJson(json); + inspect(puzzle.toJson()); +} diff --git a/pubspec.lock b/pubspec.lock index 06c9055..110c758 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -266,6 +266,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.4.0" logging: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 177bf01..bea908a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: rush_hour_puzzle description: Play a daily Rush Puzzle game -version: 0.0.12+12 +version: 0.0.13+13 publish_to: none environment: