Skip to content

Commit abf78ce

Browse files
authored
Merge pull request #23 from khlebobul/new_levels_51
New levels 51
2 parents f17a499 + 25ca744 commit abf78ce

18 files changed

Lines changed: 207 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [1.4.0]
2+
3+
#### New Features
4+
5+
- Added 10 new game levels (51–60).
6+
7+
#### Bug Fixes
8+
9+
- Improved detection and cleanup of corrupted game saves for affected levels.
10+
- Enhanced rendering performance on Android devices.
11+
- Improved touch responsiveness and tap detection.
12+
113
## [1.3.8]
214

315
#### Bug Fixes
@@ -30,7 +42,6 @@
3042

3143
- Improved and optimized work with the database for saving
3244

33-
3445
## [1.3.5]
3546

3647
#### Bug Fixes
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
package com.khlebobul.pegma
22

3+
import android.os.Bundle
34
import io.flutter.embedding.android.FlutterActivity
45

5-
class MainActivity : FlutterActivity()
6+
class MainActivity : FlutterActivity() {
7+
override fun onCreate(savedInstanceState: Bundle?) {
8+
super.onCreate(savedInstanceState)
9+
// Force hardware acceleration for better rendering performance
10+
window.setFlags(
11+
android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
12+
android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
13+
)
14+
}
15+
}

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@
495495
buildSettings = {
496496
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
497497
CLANG_ENABLE_MODULES = YES;
498-
CURRENT_PROJECT_VERSION = 25;
498+
CURRENT_PROJECT_VERSION = 26;
499499
DEVELOPMENT_TEAM = G4KB5U6326;
500500
ENABLE_BITCODE = NO;
501501
INFOPLIST_FILE = Runner/Info.plist;
@@ -505,7 +505,7 @@
505505
"$(inherited)",
506506
"@executable_path/Frameworks",
507507
);
508-
MARKETING_VERSION = 1.3.8;
508+
MARKETING_VERSION = 1.4.0;
509509
PRODUCT_BUNDLE_IDENTIFIER = com.khlebobul.pegma;
510510
PRODUCT_NAME = "$(TARGET_NAME)";
511511
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -683,7 +683,7 @@
683683
buildSettings = {
684684
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
685685
CLANG_ENABLE_MODULES = YES;
686-
CURRENT_PROJECT_VERSION = 25;
686+
CURRENT_PROJECT_VERSION = 26;
687687
DEVELOPMENT_TEAM = G4KB5U6326;
688688
ENABLE_BITCODE = NO;
689689
INFOPLIST_FILE = Runner/Info.plist;
@@ -693,7 +693,7 @@
693693
"$(inherited)",
694694
"@executable_path/Frameworks",
695695
);
696-
MARKETING_VERSION = 1.3.8;
696+
MARKETING_VERSION = 1.4.0;
697697
PRODUCT_BUNDLE_IDENTIFIER = com.khlebobul.pegma;
698698
PRODUCT_NAME = "$(TARGET_NAME)";
699699
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -709,7 +709,7 @@
709709
buildSettings = {
710710
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
711711
CLANG_ENABLE_MODULES = YES;
712-
CURRENT_PROJECT_VERSION = 25;
712+
CURRENT_PROJECT_VERSION = 26;
713713
DEVELOPMENT_TEAM = G4KB5U6326;
714714
ENABLE_BITCODE = NO;
715715
INFOPLIST_FILE = Runner/Info.plist;
@@ -719,7 +719,7 @@
719719
"$(inherited)",
720720
"@executable_path/Frameworks",
721721
);
722-
MARKETING_VERSION = 1.3.8;
722+
MARKETING_VERSION = 1.4.0;
723723
PRODUCT_BUNDLE_IDENTIFIER = com.khlebobul.pegma;
724724
PRODUCT_NAME = "$(TARGET_NAME)";
725725
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

lib/core/database/database_helper.dart

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import 'package:path/path.dart';
55
class DatabaseHelper {
66
static final DatabaseHelper instance = DatabaseHelper._init();
77
static Database? _database;
8+
static Future<Database>? _initFuture;
89

910
DatabaseHelper._init();
1011

1112
Future<Database> get database async {
1213
if (_database != null) return _database!;
13-
_database = await _initDB('pegma.db');
14+
// Prevent race conditions by reusing the same initialization future
15+
_initFuture ??= _initDB('pegma.db');
16+
_database = await _initFuture;
1417
return _database!;
1518
}
1619

@@ -20,7 +23,7 @@ class DatabaseHelper {
2023

2124
return await openDatabase(
2225
path,
23-
version: 4,
26+
version: 5,
2427
onCreate: _createDB,
2528
onUpgrade: _upgradeDB,
2629
);
@@ -49,6 +52,16 @@ class DatabaseHelper {
4952
)
5053
''');
5154
}
55+
56+
if (oldVersion < 5) {
57+
// Delete saved games for levels that were modified (10, 45, 48)
58+
// This fixes incompatibility issues while preserving completed level progress
59+
await db.delete(
60+
'saved_games',
61+
where: 'level_id IN (?, ?, ?)',
62+
whereArgs: [10, 45, 48],
63+
);
64+
}
5265
}
5366

5467
Future<void> _createDB(Database db, int version) async {
@@ -126,11 +139,26 @@ class DatabaseHelper {
126139

127140
if (result.isEmpty) return null;
128141

129-
final row = result.first;
130-
return {
131-
'board': jsonDecode(row['board_state'] as String) as List<dynamic>,
132-
'moves_count': row['moves_count'] as int,
133-
};
142+
try {
143+
final row = result.first;
144+
final boardData = jsonDecode(row['board_state'] as String) as List<dynamic>;
145+
146+
// Validate board structure
147+
if (boardData.isEmpty || boardData.first is! List) {
148+
// Invalid board structure, delete corrupted save
149+
await deleteSavedGameState(levelId);
150+
return null;
151+
}
152+
153+
return {
154+
'board': boardData,
155+
'moves_count': row['moves_count'] as int,
156+
};
157+
} catch (e) {
158+
// If decoding fails, delete corrupted save and return null
159+
await deleteSavedGameState(levelId);
160+
return null;
161+
}
134162
}
135163

136164
Future<void> deleteSavedGameState(int levelId) async {
@@ -143,6 +171,18 @@ class DatabaseHelper {
143171
await db.delete('saved_games');
144172
}
145173

174+
/// Clear saved games for specific levels (useful after level modifications)
175+
Future<void> clearSavedGamesForLevels(List<int> levelIds) async {
176+
if (levelIds.isEmpty) return;
177+
final db = await database;
178+
final placeholders = List.filled(levelIds.length, '?').join(',');
179+
await db.delete(
180+
'saved_games',
181+
where: 'level_id IN ($placeholders)',
182+
whereArgs: levelIds,
183+
);
184+
}
185+
146186
Future<void> close() async {
147187
final db = await database;
148188
await db.close();

lib/data/levels/level_51.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"board": [
3+
["-1", "-1", "0", "1", "0", "-1", "-1"],
4+
["-1", "-1", "0", "1", "0", "-1", "-1"],
5+
["0", "0", "1", "1", "1", "0", "0"],
6+
["0", "1", "0", "1", "0", "1", "0"],
7+
["0", "0", "1", "0", "1", "0", "0"],
8+
["-1", "-1", "1", "1", "1", "-1", "-1"],
9+
["-1", "-1", "0", "0", "0", "-1", "-1"]
10+
]
11+
}

lib/data/levels/level_52.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"board": [
3+
["-1", "-1", "0", "0", "0", "-1", "-1"],
4+
["-1", "-1", "0", "1", "0", "-1", "-1"],
5+
["0", "0", "0", "1", "0", "0", "0"],
6+
["0", "0", "1", "1", "1", "0", "0"],
7+
["1", "1", "0", "0", "0", "1", "1"],
8+
["-1", "-1", "1", "0", "1", "-1", "-1"],
9+
["-1", "-1", "1", "0", "1", "-1", "-1"]
10+
]
11+
}

lib/data/levels/level_53.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"board": [
3+
["-1", "-1", "0", "0", "0", "-1", "-1"],
4+
["-1", "-1", "1", "1", "1", "-1", "-1"],
5+
["0", "0", "1", "1", "1", "0", "0"],
6+
["0", "1", "1", "0", "1", "1", "0"],
7+
["0", "0", "1", "0", "1", "0", "0"],
8+
["-1", "-1", "0", "1", "0", "-1", "-1"],
9+
["-1", "-1", "0", "0", "0", "-1", "-1"]
10+
]
11+
}

lib/data/levels/level_54.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"board": [
3+
["-1", "-1", "0", "0", "0", "-1", "-1"],
4+
["-1", "-1", "0", "1", "0", "-1", "-1"],
5+
["0", "0", "1", "1", "1", "0", "0"],
6+
["0", "1", "0", "1", "0", "1", "0"],
7+
["0", "1", "1", "0", "1", "1", "0"],
8+
["-1", "-1", "1", "0", "1", "-1", "-1"],
9+
["-1", "-1", "0", "0", "0", "-1", "-1"]
10+
]
11+
}

lib/data/levels/level_55.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"board": [
3+
["-1", "-1", "0", "1", "0", "-1", "-1"],
4+
["-1", "-1", "1", "1", "1", "-1", "-1"],
5+
["0", "0", "1", "0", "1", "0", "0"],
6+
["0", "0", "1", "1", "1", "0", "0"],
7+
["0", "0", "1", "0", "1", "0", "0"],
8+
["-1", "-1", "1", "1", "1", "-1", "-1"],
9+
["-1", "-1", "0", "1", "0", "-1", "-1"]
10+
]
11+
}

lib/data/levels/level_56.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"board": [
3+
["-1", "-1", "0", "0", "0", "-1", "-1"],
4+
["-1", "-1", "0", "0", "0", "-1", "-1"],
5+
["0", "0", "0", "0", "1", "1", "1"],
6+
["1", "1", "1", "1", "1", "1", "1"],
7+
["0", "0", "0", "1", "1", "0", "0"],
8+
["-1", "-1", "0", "1", "1", "-1", "-1"],
9+
["-1", "-1", "0", "1", "1", "-1", "-1"]
10+
]
11+
}

0 commit comments

Comments
 (0)