Skip to content

Commit

Permalink
feat: create timed stats on get playerMatches
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharlock10 committed Mar 14, 2024
1 parent e3323b8 commit 3906c0e
Show file tree
Hide file tree
Showing 10 changed files with 329 additions and 150 deletions.
1 change: 1 addition & 0 deletions lib/data_classes/players/index.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export "./player_timed_stats.dart";
export "./players.dart";
27 changes: 19 additions & 8 deletions lib/data_classes/players/player_timed_stats.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "package:freezed_annotation/freezed_annotation.dart";
import "package:paladinsedge/models/index.dart" show BaseRank, MatchPlayerStats;
import "package:paladinsedge/models/index.dart" show Ranked, MatchPlayerStats;

part "player_timed_stats.freezed.dart";

Expand All @@ -21,20 +21,31 @@ abstract class TimedStatsValues {

@freezed
class PlayerTimedStats with _$PlayerTimedStats {
PlayerTimedStats._();

factory PlayerTimedStats({
// type of timed stats
required TimedStatsType timedStatsType,

// for calculating rank diff
required BaseRank startingRank,
required BaseRank endingRank,
required Ranked? rankedStart,
required Ranked? rankedEnd,

// per match data
required Map<String, int> matchesType,
// count of played things
required Map<String, int> queuesPlayed,
required List<int> mostPlayedChampions,

// average matches data
required int totalMatches,
// matches data
required int wins,
required int losses,
required MatchPlayerStats averageStats,
required Duration totalMatchesDuration,
required MatchPlayerStats totalStats,
}) = _PlayerTimedStats;

int get totalMatches => wins + losses;
num get damagePerMinute =>
totalStats.totalDamageDealt / totalMatchesDuration.inMinutes;
num get healingPerMinute =>
totalStats.healingDone / totalMatchesDuration.inMinutes;
MatchPlayerStats get averageStats => totalStats / totalMatches;
}
Loading

0 comments on commit 3906c0e

Please sign in to comment.