Seperate challenges
This commit is contained in:
@@ -22,6 +22,9 @@ class Helpers{
|
||||
case "LTC":
|
||||
return CryptoFontIcons.LTC;
|
||||
break;
|
||||
case "BCH":
|
||||
return CryptoFontIcons.AUR;
|
||||
break;
|
||||
}
|
||||
|
||||
return CryptoFontIcons.BTC;
|
||||
@@ -54,4 +57,18 @@ class Helpers{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static double CryptoToDollars({required double amount, required String Crypto}){
|
||||
if(Hoarder.cryptoRates==null){Debug.Log("Crypto rates haven't been updated yet"); return 0;}
|
||||
Debug.Log(Hoarder.cryptoRates);
|
||||
if(Hoarder.cryptoRates[Crypto] == null){
|
||||
Debug.Log("$Crypto not found in ${Hoarder.cryptoRates}");
|
||||
return 0;
|
||||
}
|
||||
return amount * double.parse(Hoarder.cryptoRates[Crypto]);
|
||||
}
|
||||
|
||||
static double SatsToCoin(int sats){
|
||||
return sats.toDouble() * 0.00000001;
|
||||
}
|
||||
}
|
||||
@@ -56,16 +56,22 @@ class Hoarder{
|
||||
FetchChallenges();
|
||||
}
|
||||
static double currentEarnings = 0;
|
||||
static double previousEarnings = 0;
|
||||
static Map<String, int> ThisSeasonGamesEarnings = {};
|
||||
static Map<String, int> ThisSeasonCryptoEarnings = {};
|
||||
|
||||
static dynamic cryptoRates;
|
||||
static Future<void> FetchChallenges() async {
|
||||
var response = null;
|
||||
|
||||
List<List<dynamic>> _Challenges = [];
|
||||
double _currentEarnings = 0;
|
||||
Map<String,int> _ThisSeasonCryptoEarnings = {};
|
||||
Map<String,int> _ThisSeasonGamesEarnings = {};
|
||||
Map<String, int> _ThisSeasonCryptoEarnings = {};
|
||||
|
||||
var cryptoValuesResponse = await http.get(Uri.parse('http://vps.playpoolstudios.com:2009/'));
|
||||
dynamic cryptoValues = jsonDecode(cryptoValuesResponse.body.toString());
|
||||
cryptoRates = cryptoValues;
|
||||
Debug.Log(cryptoValues);
|
||||
for (var value in Brain.LinkedGamesJson) {
|
||||
try {
|
||||
@@ -91,6 +97,7 @@ class Hoarder{
|
||||
if(total <= current){
|
||||
_currentEarnings+= rewardInDollars;
|
||||
// Debug.Log(_ThisSeasonCryptoEarnings[GameJson['coin']]);
|
||||
_ThisSeasonGamesEarnings.update(GameJson['code'], (value) => value + reward, ifAbsent: ()=> reward);
|
||||
_ThisSeasonCryptoEarnings.update(GameJson['coin'], (value) => value + reward, ifAbsent: ()=> reward);
|
||||
// Debug.Log(_ThisSeasonCryptoEarnings[GameJson['coin']]);
|
||||
}
|
||||
@@ -103,11 +110,12 @@ class Hoarder{
|
||||
Debug.LogError("Error while fetching challenges $e");
|
||||
}
|
||||
}
|
||||
ThisSeasonGamesEarnings = _ThisSeasonGamesEarnings;
|
||||
ThisSeasonCryptoEarnings = _ThisSeasonCryptoEarnings;
|
||||
Challenges = _Challenges;
|
||||
currentEarnings = _currentEarnings;
|
||||
|
||||
Debug.Log(ThisSeasonCryptoEarnings);
|
||||
Debug.Log(ThisSeasonGamesEarnings);
|
||||
|
||||
// Debug.Log(Challenges);
|
||||
// Debug.Log("Challenge, " + (Hoarder.Challenges[0][0]['game']));
|
||||
|
||||
Reference in New Issue
Block a user