-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab576d6
commit 5f21b97
Showing
7 changed files
with
194 additions
and
24 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
lib/algorithms/jumpers_ranking/country_team_ranking_creator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:sj_manager/models/simulation/flow/jumper_dynamic_params.dart'; | ||
import 'package:sj_manager/models/user_db/jumper/jumper.dart'; | ||
|
||
class CountryTeamRankingCreator { | ||
const CountryTeamRankingCreator({ | ||
required this.jumpers, | ||
required this.dynamicParams, | ||
}); | ||
|
||
final List<Jumper> jumpers; | ||
final Map<Jumper, JumperDynamicParams> dynamicParams; | ||
|
||
List<Jumper> create() { | ||
final ratings = { | ||
for (final jumper in jumpers) jumper: _calculateRating(jumper), | ||
}; | ||
final sorted = List.of(jumpers) | ||
..sort((first, second) { | ||
return ratings[second]!.compareTo(ratings[first]!); | ||
}); | ||
return sorted; | ||
} | ||
|
||
double _calculateRating(Jumper jumper) { | ||
return (jumper.skills.takeoffQuality / 1) + | ||
(jumper.skills.flightQuality / 1) + | ||
(jumper.skills.landingQuality / 10) + | ||
(dynamicParams[jumper]!.jumpsConsistency / 1.5) + | ||
(dynamicParams[jumper]!.form * 2); | ||
} | ||
} | ||
|
||
/* | ||
takeoff quality: 15 | ||
flight quality: 15 | ||
landing quality: 15 / 10 | ||
jumps consistency: 14 / 1.5 | ||
form: 10 * 2 | ||
*/ |
32 changes: 32 additions & 0 deletions
32
lib/ui/reusable_widgets/jumpers_ranking/jumper_in_ranking_tile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:sj_manager/models/user_db/jumper/jumper.dart'; | ||
import 'package:sj_manager/ui/screens/simulation/large/widgets/simulation_jumper_image.dart'; | ||
|
||
class JumperInRankingTile extends StatelessWidget { | ||
const JumperInRankingTile({ | ||
super.key, | ||
required this.jumper, | ||
required this.position, | ||
this.onTap, | ||
}); | ||
|
||
final Jumper jumper; | ||
final int position; | ||
final VoidCallback? onTap; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ListTile( | ||
leading: Text( | ||
position.toString(), | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
trailing: SimulationJumperImage( | ||
jumper: jumper, | ||
width: 25, | ||
), | ||
title: Text(jumper.nameAndSurname()), | ||
onTap: onTap, | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/ui/reusable_widgets/jumpers_ranking/team_jumpers_ranking_list.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:sj_manager/models/user_db/jumper/jumper.dart'; | ||
import 'package:sj_manager/ui/reusable_widgets/jumpers_ranking/jumper_in_ranking_tile.dart'; | ||
|
||
class TeamJumpersRankingList extends StatelessWidget { | ||
const TeamJumpersRankingList({ | ||
super.key, | ||
required this.jumpers, | ||
}); | ||
|
||
final List<Jumper> jumpers; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ListView( | ||
children: [ | ||
for (var i = 0; i < jumpers.length; i++) | ||
JumperInRankingTile( | ||
jumper: jumpers[i], | ||
position: i + 1, | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...tion/large/widgets/teams/country_team_profile/overview/country_team_profile_overview.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:sj_manager/algorithms/jumpers_ranking/country_team_ranking_creator.dart'; | ||
import 'package:sj_manager/bloc/simulation/simulation_database_cubit.dart'; | ||
import 'package:sj_manager/models/user_db/jumper/jumper.dart'; | ||
import 'package:sj_manager/models/user_db/team/country_team/country_team.dart'; | ||
import 'package:sj_manager/ui/reusable_widgets/card_with_title.dart'; | ||
import 'package:sj_manager/ui/reusable_widgets/jumpers_ranking/team_jumpers_ranking_list.dart'; | ||
|
||
class CountryTeamProfileOverview extends StatelessWidget { | ||
const CountryTeamProfileOverview({ | ||
super.key, | ||
required this.countryTeam, | ||
}); | ||
|
||
final CountryTeam countryTeam; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final database = context.watch<SimulationDatabaseCubit>().state; | ||
final subteams = database.subteamJumpers.keys.where( | ||
(subteam) => subteam.parentTeam == countryTeam, | ||
); | ||
final unorderedJumpers = <Jumper>[]; | ||
for (var subteam in subteams) { | ||
final jumperIds = database.subteamJumpers[subteam]!; | ||
unorderedJumpers.addAll( | ||
jumperIds.map((id) => database.idsRepo.get(id) as Jumper), | ||
); | ||
} | ||
final ranking = CountryTeamRankingCreator( | ||
jumpers: unorderedJumpers, dynamicParams: database.jumperDynamicParams) | ||
.create(); | ||
|
||
return Row( | ||
children: [ | ||
SizedBox( | ||
width: 250, | ||
child: CardWithTitle( | ||
title: Text( | ||
'Ranking', | ||
style: Theme.of(context).textTheme.headlineSmall, | ||
), | ||
child: TeamJumpersRankingList( | ||
jumpers: ranking, | ||
), | ||
), | ||
) | ||
], | ||
); | ||
} | ||
} | ||
|
||
// ranking skoczków | ||
// perspektywa | ||
// podstawowe rekordy (wygranych konkursow druż pś, wygranych konkursów ind pś) | ||
// gwiazdki | ||
// płeć na fladze | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters