prettifyStats function
Map<String, dynamic>
prettifyStats(
- dynamic data
)
Implementation
Map<String, dynamic> prettifyStats(dynamic data) {
var s = data['stats'];
var h = data['homes'];
var characters = data['avatars'] ?? [];
Map<String, dynamic> results = {
'stats': {
'achievements': s['achievement_number'],
'active_days': s['active_day_number'],
'characters': s['avatar_number'],
'spiral_abyss': s['spiral_abyss'],
'anemoculi': s['anemoculus_number'],
'geoculi': s['geoculus_number'],
'electroculi': s['electroculus_number'],
'common_chests': s['common_chest_number'],
'exquisite_chests': s['exquisite_chest_number'],
'precious_chests': s['precious_chest_number'],
'luxurious_chests': s['luxurious_chest_number'],
'unlocked_waypoints': s['way_point_number'],
'unlocked_domains': s['domain_number'],
},
'teapot': null,
'characters': [],
'explorations': [],
};
for (var i = 0; i < characters.length; i++) {
var character = characters[i];
if (character['rarity'] > 100) {
character.rarity = character.rarity - 100;
}
results['characters'].add(character);
}
// print("homes $h");
if (h != null) {
for (var i = 0; i < h.length; i++) {}
results['teapot'] = {
'realms': [],
'level': h[0]['level'],
'comfort': h[0]['comfort_num'],
'comfort_name': h[0]['comfort_level_name'],
'comfort_icon': h[0]['comfort_level_icon'],
'items': h[0]['item_num'],
'visitors': h[0]['visit_num'],
};
for (var i = 0; i < h.length; i++) {
var realm = h[i];
results['teapot']['realms'].add(realm);
}
}
var explorations = data['world_explorations'] ?? [];
for (var i = 0; i < explorations.length; i++) {
var exploration = explorations[i];
results['explorations'].add({
'name': exploration['name'],
'explored': exploration['exploration_percentage'].round(),
'type': exploration['type'],
'icon': exploration['icon'],
'level': exploration['level'],
'offerings': exploration['offerings']
});
}
return results;
}