i bringed another changes to tetris io stats
This commit is contained in:
parent
67da831cd2
commit
e21ec84fc1
|
@ -340,10 +340,6 @@ class TetrioPlayer {
|
|||
return tlSeason1!.lessStrictCheck(other.tlSeason1!);
|
||||
}
|
||||
|
||||
TetrioPlayerFromLeaderboard convertToPlayerFromLeaderboard() => TetrioPlayerFromLeaderboard(
|
||||
userId, username, role, xp, country, state, gamesPlayed, gamesWon,
|
||||
tlSeason1!.tr, tlSeason1!.glicko??0, tlSeason1!.rd??noTrRd, tlSeason1!.rank, tlSeason1!.bestRank, tlSeason1!.apm??0, tlSeason1!.pps??0, tlSeason1!.vs??0, tlSeason1!.decaying);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "$username ($state)";
|
||||
|
@ -1453,6 +1449,10 @@ class TetraLeague {
|
|||
|
||||
double? get esttracc => (estTr != null) ? estTr!.esttr - tr : null;
|
||||
|
||||
TetrioPlayerFromLeaderboard convertToPlayerFromLeaderboard(String id) => TetrioPlayerFromLeaderboard(
|
||||
id, "", "user", -1, null, timestamp, gamesPlayed, gamesWon,
|
||||
tr, glicko??0, rd??noTrRd, rank, bestRank, apm??0, pps??0, vs??0, decaying);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (gamesPlayed > 0) data['gamesplayed'] = gamesPlayed;
|
||||
|
@ -2337,21 +2337,21 @@ class TetrioPlayersLeaderboard {
|
|||
}
|
||||
}
|
||||
|
||||
PlayerLeaderboardPosition? getLeaderboardPosition(TetrioPlayer user) {
|
||||
if (user.tlSeason1?.gamesPlayed == 0) return null;
|
||||
PlayerLeaderboardPosition? getLeaderboardPosition(Map<String, TetraLeague>league) {
|
||||
if (league.values.first.gamesPlayed == 0) return null;
|
||||
bool fakePositions = false;
|
||||
late List<TetrioPlayerFromLeaderboard> copyOfLeaderboard;
|
||||
if (leaderboard.indexWhere((element) => element.userId == user.userId) == -1){
|
||||
if (leaderboard.indexWhere((element) => element.userId == league.keys.first) == -1){
|
||||
fakePositions =true;
|
||||
copyOfLeaderboard = List.of(leaderboard);
|
||||
copyOfLeaderboard.add(user.convertToPlayerFromLeaderboard());
|
||||
copyOfLeaderboard.add(league.values.first.convertToPlayerFromLeaderboard(league.keys.first));
|
||||
}
|
||||
List<Stats> stats = [Stats.apm, Stats.pps, Stats.vs, Stats.gp, Stats.gw, Stats.wr,
|
||||
Stats.app, Stats.vsapm, Stats.dss, Stats.dsp, Stats.appdsp, Stats.cheese, Stats.gbe, Stats.nyaapp, Stats.area, Stats.eTR, Stats.acceTR];
|
||||
List<LeaderboardPosition?> results = [];
|
||||
for (Stats stat in stats) {
|
||||
List<TetrioPlayerFromLeaderboard> sortedLeaderboard = getStatRanking(fakePositions ? copyOfLeaderboard : leaderboard, stat, reversed: stat == Stats.cheese ? true : false);
|
||||
int position = sortedLeaderboard.indexWhere((element) => element.userId == user.userId) + 1;
|
||||
int position = sortedLeaderboard.indexWhere((element) => element.userId == league.keys.first) + 1;
|
||||
if (position == 0) {
|
||||
results.add(null);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class UserAgentClient extends http.BaseClient {
|
||||
|
@ -11,7 +12,7 @@ class UserAgentClient extends http.BaseClient {
|
|||
@override
|
||||
Future<http.StreamedResponse> send(http.BaseRequest request) {
|
||||
request.headers['user-agent'] = userAgent;
|
||||
request.headers['X-Session-ID'] = "${Random().nextInt(1<<32)}";
|
||||
if (!kIsWeb) request.headers['X-Session-ID'] = "${Random().nextInt(1<<32)}";
|
||||
return _inner.send(request);
|
||||
}
|
||||
}
|
|
@ -411,7 +411,7 @@ class TetrioService extends DB {
|
|||
Cutoffs? cached = _cache.get("", Cutoffs);
|
||||
if (cached != null) return cached;
|
||||
|
||||
Uri url = Uri.https('ts.dan63.by', 'beanserver_blaster/cutoffs.json', {"users": null});
|
||||
Uri url = Uri.https('ts.dan63.by', 'beanserver_blaster/cutoffs.json');
|
||||
|
||||
try{
|
||||
final response = await client.get(url);
|
||||
|
|
|
@ -199,7 +199,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
|
|||
everyone = teto.getCachedLeaderboard();
|
||||
everyone ??= await teto.fetchTLLeaderboard();
|
||||
if (meAmongEveryone == null && everyone!.leaderboard.isNotEmpty){
|
||||
meAmongEveryone = await compute(everyone!.getLeaderboardPosition, me);
|
||||
meAmongEveryone = await compute(everyone!.getLeaderboardPosition, {me.userId: summaries.league});
|
||||
if (meAmongEveryone != null) teto.cacheLeaderboardPositions(me.userId, meAmongEveryone!);
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
|
|||
// if (everyone != null && summaries.league.gamesPlayed > 9) rankAverages = everyone?.averages[summaries.league.percentileRank]?[0];
|
||||
|
||||
// Making list of Tetra League matches
|
||||
bool isTracking = await teto.isPlayerTracking(me.userId);
|
||||
//bool isTracking = await teto.isPlayerTracking(me.userId);
|
||||
List<TetrioPlayer> states = [];
|
||||
TetraLeague? compareWith;
|
||||
Set<TetraLeague> uniqueTL = {};
|
||||
|
@ -274,7 +274,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
|
|||
states.addAll(await teto.getPlayer(me.userId));
|
||||
for (var element in states) { // For graphs I need only unique entries
|
||||
if (element.tlSeason1 != null && uniqueTL.isNotEmpty && uniqueTL.last != element.tlSeason1) uniqueTL.add(element.tlSeason1!);
|
||||
if (uniqueTL.isEmpty) uniqueTL.add(element.tlSeason1!);
|
||||
if (uniqueTL.isEmpty) uniqueTL.add(summaries.league);
|
||||
}
|
||||
// Also i need previous Tetra League State for comparison if avaliable
|
||||
if (uniqueTL.length >= 2){
|
||||
|
|
|
@ -108,7 +108,7 @@ class RanksAverages extends State<RankAveragesView> {
|
|||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: Text(f2.format(snapshot.data!.gxe[rank]), textAlign: TextAlign.right, style: TextStyle(fontFamily: bigScreen ? "Eurostile Round" : "Eurostile Round Condensed", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white, shadows: textShadow)),
|
||||
child: Text(f3.format(snapshot.data!.gxe[rank]), textAlign: TextAlign.right, style: TextStyle(fontFamily: bigScreen ? "Eurostile Round" : "Eurostile Round Condensed", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white, shadows: textShadow)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
|
|
|
@ -2,7 +2,7 @@ name: tetra_stats
|
|||
description: Track your and other player stats in TETR.IO
|
||||
publish_to: 'none'
|
||||
|
||||
version: 1.6.4+30
|
||||
version: 1.6.5+31
|
||||
|
||||
environment:
|
||||
sdk: '>=3.0.0'
|
||||
|
|
Loading…
Reference in New Issue