马梓彭 8e66cd293b 修复花样跳绳 计分规则与显示
- 修正个人及同步花样表现分失误重复计算
- 合并表现裁判与主裁失误计算得分系数 M
- 修正车轮跳规定元素数量及 Q 系数
- 修正同步花样规定元素等级和小数缺失量
- 统一 D/P/Q/M 舍入精度及总分计算
- 统一平板、后端、工作台和投屏显示口径
- 增加计分回归用例和上线规则迁移脚本
2026-09-29 17:19:03 +08:00

36 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace YD_Event.Application.Scoring;
/// <summary>从已保存的计算快照读取展示值,不能在查询时静默重算历史成绩。</summary>
public static class ScoreDisplayService
{
/// <summary>按角色格式化本人得分,主裁系数保留三位。</summary>
public static string JudgeText(EventJudgeScoreSheet sheet, bool isFactorTotal) =>
sheet.IsDisqualified ? "DQ" : JudgeValue(sheet, isFactorTotal).ToString(
isFactorTotal && JudgeRoleSchemaService.NormalizeRoleType(sheet.JudgeRoleType) == "T" ? "F3" : "F2",
System.Globalization.CultureInfo.InvariantCulture);
/// <summary>本裁判分值;主裁为本人的系数预览,综合M以成绩快照为准。</summary>
public static decimal JudgeValue(EventJudgeScoreSheet sheet, bool isFactorTotal)
{
if (!isFactorTotal) return sheet.TotalScore;
var role = JudgeRoleSchemaService.NormalizeRoleType(sheet.JudgeRoleType);
if (role == "T") return Math.Max(0m, 1m - sheet.DeductionScore);
if (role == "P") return sheet.PerformanceScore;
return role.StartsWith("D", StringComparison.OrdinalIgnoreCase) ? sheet.DifficultyScore : sheet.TotalScore;
}
/// <summary>花样得分系数 M;非花样或缺少计算快照时不推断数值。</summary>
public static decimal? DeductionFactor(string? calculationJson)
{
if (string.IsNullOrWhiteSpace(calculationJson)) return null;
try
{
return JObject.Parse(calculationJson)["factors"]?["m"]?.Value<decimal?>();
}
catch (Exception ex) when (ex is JsonException or FormatException or InvalidCastException or OverflowException)
{
return null;
}
}
}