added game status

This commit is contained in:
2024-02-04 19:14:41 +05:30
parent eda5f77e2d
commit 494b27bf9e
16 changed files with 691 additions and 137 deletions

View File

@ -14,6 +14,7 @@ import 'package:rogapp/model/gps_data.dart';
import 'package:rogapp/pages/camera/camera_page.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/DatabaseService.dart';
import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/services/external_service.dart';
import 'package:rogapp/services/location_service.dart';
@ -77,6 +78,7 @@ class DestinationController extends GetxController {
final IndexController indexController = Get.find<IndexController>();
final LocationController locationController = Get.put(LocationController());
final DatabaseService dbService = DatabaseService();
int _start = 0;
int chekcs = 0;
@ -433,6 +435,7 @@ class DestinationController extends GetxController {
lastGoalAt = DateTime.fromMicrosecondsSinceEpoch(latgoal);
//print("===== last goal : $last_goal_at =====");
}
dbService.updateDatabase();
}
void deleteAllDestinations() {
@ -564,6 +567,7 @@ class DestinationController extends GetxController {
Future<void> checkForCheckin() async {
//print("--- Start of checkForCheckin function ---");
dbService.updateDatabase();
await Future.delayed(const Duration(milliseconds: 3000));
game_started = true;
@ -718,15 +722,16 @@ class DestinationController extends GetxController {
// print("------Ext service check point $value ------");
});
}
dbService.updateDatabase();
}
Future<void> removeCheckin(int cp) {
dbService.updateDatabase();
return ExternalService().removeCheckin(cp);
}
Future<void> startGame() async {
//print("------ starting game ------");
if (game_started == false) {
await checkForCheckin();
}
@ -776,6 +781,9 @@ class DestinationController extends GetxController {
}
double distanceToStart() {
if (indexController.locations.isEmpty) {
return 1000000000;
}
//print("=== gfs len == ${indexController.locations[0].collection.length}");
double distanceToDest = double.infinity;
if (indexController.locations[0].features.isEmpty) {
@ -959,6 +967,7 @@ class DestinationController extends GetxController {
db.deleteDestination(d.location_id!).then((value) {
populateDestinations();
});
dbService.updateDatabase();
}
void deleteDBDestinations() {
@ -966,6 +975,7 @@ class DestinationController extends GetxController {
db.deleteAllDestinations().then((value) {
populateDestinations();
});
dbService.updateDatabase();
}
// ---------- database ------------------///
@ -988,6 +998,7 @@ class DestinationController extends GetxController {
});
}
});
dbService.updateDatabase();
}
void toggleSelection(Destination dest) async {