Fixed #1
This commit is contained in:
parent
f337e72476
commit
9bba037c66
|
|
@ -17,6 +17,18 @@ class DataManager{
|
||||||
|
|
||||||
static dynamic UserJson;
|
static dynamic UserJson;
|
||||||
|
|
||||||
|
static dynamic cryptoRates;
|
||||||
|
static double currentEarnings =0;
|
||||||
|
static Map<String, int> GamesEarnings = {};
|
||||||
|
static Map<String, int> CryptoEarnings = {};
|
||||||
|
|
||||||
|
|
||||||
|
static void Reset(){
|
||||||
|
UserJson = LinkedGamesJson = NonLinkedGamesJson = Challenges = [];
|
||||||
|
currentEarnings = 0;
|
||||||
|
GamesEarnings = CryptoEarnings = {};
|
||||||
|
}
|
||||||
|
|
||||||
static Future<bool> Init() async{
|
static Future<bool> Init() async{
|
||||||
bool isSettingsDone = await GetSettings();
|
bool isSettingsDone = await GetSettings();
|
||||||
bool isGamesDone = await GetGames();
|
bool isGamesDone = await GetGames();
|
||||||
|
|
@ -43,31 +55,35 @@ class DataManager{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FilterLinkedGames(){
|
static void FilterLinkedGames(){
|
||||||
LinkedGamesJson = [];
|
Debug.Log("err044 : $UserJson");
|
||||||
NonLinkedGamesJson = [];
|
LinkedGamesJson = [];
|
||||||
if(UserJson['linkedGames'].toString().length < 3){
|
NonLinkedGamesJson = [];
|
||||||
NonLinkedGamesJson = AllGames;
|
if (UserJson['linkedGames']
|
||||||
return;
|
.toString()
|
||||||
}
|
.length < 3) {
|
||||||
List<Map<String, dynamic>> linkedGames = jsonDecode(
|
NonLinkedGamesJson = AllGames;
|
||||||
UserJson['linkedGames']).cast<Map<String, dynamic>>();
|
return;
|
||||||
|
}
|
||||||
|
List<Map<String, dynamic>> linkedGames = jsonDecode(
|
||||||
|
UserJson['linkedGames']).cast<Map<String, dynamic>>();
|
||||||
|
|
||||||
AllGames.forEach((element) {
|
AllGames.forEach((element) {
|
||||||
bool foundLink = false;
|
bool foundLink = false;
|
||||||
for (var linkedGame in linkedGames) {
|
for (var linkedGame in linkedGames) {
|
||||||
int gid = linkedGame["game_id"];
|
int gid = linkedGame["game_id"];
|
||||||
int id = int.parse(element['id']);
|
int id = int.parse(element['id']);
|
||||||
if (gid == id) {
|
if (gid == id) {
|
||||||
LinkedGamesJson.add(element);
|
LinkedGamesJson.add(element);
|
||||||
foundLink = true;
|
foundLink = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundLink) {
|
if (!foundLink) {
|
||||||
NonLinkedGamesJson.add(element);
|
NonLinkedGamesJson.add(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> GetSettings() async{
|
static Future<bool> GetSettings() async{
|
||||||
|
|
@ -143,10 +159,7 @@ class DataManager{
|
||||||
Challenges = _Challenges;
|
Challenges = _Challenges;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static dynamic cryptoRates;
|
|
||||||
static double currentEarnings =0;
|
|
||||||
static Map<String, int> GamesEarnings = {};
|
|
||||||
static Map<String, int> CryptoEarnings = {};
|
|
||||||
|
|
||||||
|
|
||||||
static void CalculateEarnings() async{
|
static void CalculateEarnings() async{
|
||||||
|
|
@ -215,4 +228,6 @@ class DataManager{
|
||||||
Debug.LogError(e);
|
Debug.LogError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -525,6 +525,7 @@ class _HomeState extends State<Home> {
|
||||||
|
|
||||||
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>
|
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>
|
||||||
MyHomePage()), (Route<dynamic> route) => false);
|
MyHomePage()), (Route<dynamic> route) => false);
|
||||||
|
DataManager.Reset();
|
||||||
},
|
},
|
||||||
child: GlassCard(child: Padding(
|
child: GlassCard(child: Padding(
|
||||||
padding: const EdgeInsets.all(15.0),
|
padding: const EdgeInsets.all(15.0),
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
int regResult = await LoginManager.Register(usernameController.text, passwordController.text);
|
int regResult = await LoginManager.Register(usernameController.text, passwordController.text);
|
||||||
|
|
||||||
if(regResult == 0){
|
if(regResult == 0){
|
||||||
|
await LoginManager.AutoLogin();
|
||||||
await DataManager.GetGamesProgress();
|
await DataManager.GetGamesProgress();
|
||||||
|
|
||||||
loadHome();
|
loadHome();
|
||||||
}else if(regResult == 5){
|
}else if(regResult == 5){
|
||||||
Dialogs.showAlertDialog(context, "Register Failed", "Username Already exists, Please try again with a different username");
|
Dialogs.showAlertDialog(context, "Register Failed", "Username Already exists, Please try again with a different username");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user