이벤트 개발완료

This commit is contained in:
2025-10-23 22:04:03 +09:00
parent ce1aee67d6
commit cd0e139b5e
48 changed files with 7855 additions and 3459 deletions
+40 -1
View File
@@ -310,5 +310,44 @@ class TieBreakerUtil {
return ranks;
}
/// 재사용 가능한: 점수 리스트에 대한 순위 계산 (외부에서 쉽게 호출)
static Map<String, int> computeScoreRanks(
List<Score> scores, {
required bool includeHandicap,
List<TieBreakerOption>? options,
List<Member>? members,
}) {
return calculateRanks(
scores,
includeHandicap,
options: options,
members: members,
);
}
/// 재사용 가능한: 참가자 요약(Map) 리스트에 정렬/순위 부여
/// - summaries: 각 항목은 최소 'total'과 'totalH' 키를 포함해야 함
/// - includeHandicap: 어떤 합계를 정렬 기준으로 사용할지 결정
/// - totalKey/totalHKey: 키명이 다른 경우 오버라이드 가능
static List<Map<String, dynamic>> rankParticipantSummaries(
List<Map<String, dynamic>> summaries, {
required bool includeHandicap,
String totalKey = 'total',
String totalHKey = 'totalH',
}) {
final items = List<Map<String, dynamic>>.of(summaries);
items.sort((a, b) {
final at = includeHandicap ? (a[totalHKey] as int) : (a[totalKey] as int);
final bt = includeHandicap ? (b[totalHKey] as int) : (b[totalKey] as int);
return bt.compareTo(at); // desc
});
for (var i = 0; i < items.length; i++) {
items[i] = {
...items[i],
'rank': i + 1,
};
}
return items;
}
}