diff --git a/.gitignore b/.gitignore index 0fa6b67..e2b8a2c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release +/ios/Runner \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index c505a86..3f328b5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.4.32' repositories { google() jcenter() diff --git a/lib/2048Screen.dart b/lib/2048Screen.dart index 1a17e6a..1cc8dc7 100644 --- a/lib/2048Screen.dart +++ b/lib/2048Screen.dart @@ -158,16 +158,17 @@ class _Game2048State extends State with TickerProviderStateMixin } + + //Save game progress void saveState(){ if(isGameRunning){ - //save columnSize, rowSize, score and values String saveGame = "$columnSize;$rowSize;$_score;" + values.join(','); Provider.of(context, listen: false).setValue(StatConst.KEY_GAME_2048, StatConst.KEY_SAVEGAME_1, saveGame); } //save moves done String movesDone = Provider.of(context, listen: false).getValue(StatConst.KEY_GAME_2048, StatConst.KEY_MOVES_PERFORMED); - //TODO update value here + int updatedMovesDone = int.parse(movesDone) + _movesPerformed; Provider.of(context, listen: false).setValue(StatConst.KEY_GAME_2048, StatConst.KEY_MOVES_PERFORMED, "$updatedMovesDone"); _movesPerformed = 0; @@ -226,7 +227,10 @@ class _Game2048State extends State with TickerProviderStateMixin values = valuesAfter; _isInAnimation = false; }); - + //save current game progress + if(isGameRunning){ + saveState(); + } startTimerAppearing(); @@ -291,6 +295,8 @@ class _Game2048State extends State with TickerProviderStateMixin } } + //Update strings for final stats on the screen and game stats in the key-value store + //Delete existing savegame void setGameOver(){ isGameRunning = false; //save stats @@ -605,7 +611,7 @@ class _Game2048State extends State with TickerProviderStateMixin } void onExitPressed(){ - saveState(); + saveState(); //save game progress Navigator.pop(context); } diff --git a/lib/ConnectFourScreen.dart b/lib/ConnectFourScreen.dart index 3075765..aa9d4e1 100644 --- a/lib/ConnectFourScreen.dart +++ b/lib/ConnectFourScreen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:audioplayers/audio_cache.dart'; import 'package:audioplayers/audioplayers.dart'; import 'dart:io'; import 'dart:math'; diff --git a/pubspec.lock b/pubspec.lock index 5351e7b..6d0aae3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -16,12 +16,19 @@ packages: source: hosted version: "2.0.0" async: - dependency: transitive + dependency: "direct main" description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" + audioplayers: + dependency: "direct main" + description: + name: audioplayers + url: "https://pub.dartlang.org" + source: hosted + version: "0.19.1" boolean_selector: dependency: transitive description: @@ -70,7 +77,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" fake_async: dependency: transitive description: @@ -84,14 +91,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -114,6 +121,20 @@ packages: description: flutter source: sdk version: "0.0.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.3" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" image: dependency: transitive description: @@ -163,13 +184,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" path_provider_platform_interface: dependency: transitive description: @@ -183,35 +218,42 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.3" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.0.2" + version: "4.1.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.3" provider: dependency: "direct main" description: @@ -225,28 +267,28 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_platform_interface: dependency: transitive description: @@ -260,14 +302,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" sky_engine: dependency: transitive description: flutter @@ -279,7 +321,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -314,7 +356,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" tuple: dependency: "direct main" description: @@ -329,6 +371,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + uuid: + dependency: transitive + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.4" vector_math: dependency: transitive description: @@ -342,7 +391,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.2.5" xdg_directories: dependency: transitive description: @@ -356,7 +405,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.0.2" + version: "5.1.2" yaml: dependency: transitive description: @@ -365,5 +414,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.20.0" + dart: ">=2.13.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6d97bb3..1207b16 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: provider: ^5.0.0 # json_annotation: ^4.0.0 shared_preferences: ^2.0.5 - audioplayers: any + audioplayers: ^0.19.0 page_transition: "^1.1.7+6" async: any