Commit 186b5415 by liulongfei

修复排名

parent e05b1ca2
...@@ -169,6 +169,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -169,6 +169,7 @@ namespace VIZ.TVP.Golf.Module
int score = this.realDataService.GetGroupRoundScore(group.Key, player1, player2, this.SelectedRound); int score = this.realDataService.GetGroupRoundScore(group.Key, player1, player2, this.SelectedRound);
temp_model.PlayersScore = this.realDataService.GetScoreString(score); temp_model.PlayersScore = this.realDataService.GetScoreString(score);
temp_model.PlayerScoreValue = score;
groupTempModels.Add(temp_model); groupTempModels.Add(temp_model);
} }
......
...@@ -109,7 +109,7 @@ namespace VIZ.TVP.Golf.Service ...@@ -109,7 +109,7 @@ namespace VIZ.TVP.Golf.Service
if (team1.Score == null && team2.Score == null) if (team1.Score == null && team2.Score == null)
return 0; return 0;
if (team1.Score != null && team2.Score != null) if (team1.Score != null && team2.Score == null)
return -1; return -1;
if (team1.Score == null && team2.Score != null) if (team1.Score == null && team2.Score != null)
......
...@@ -322,22 +322,16 @@ namespace VIZ.TVP.Golf.Service ...@@ -322,22 +322,16 @@ namespace VIZ.TVP.Golf.Service
data.Player1 = player1; data.Player1 = player1;
RoundRealModel real_round = player1.Rounds.FirstOrDefault(p => p.No == round); RoundRealModel real_round = player1.Rounds.FirstOrDefault(p => p.No == round);
if (this.IsPlayerHoleFinished(real_round, hole))
{
real_score1 = real_round?.Scores.FirstOrDefault(p => p.Hole == hole); real_score1 = real_round?.Scores.FirstOrDefault(p => p.Hole == hole);
} }
}
if (player2 != null) if (player2 != null)
{ {
data.Player2 = player2; data.Player2 = player2;
RoundRealModel real_round = player2.Rounds.FirstOrDefault(p => p.No == round); RoundRealModel real_round = player2.Rounds.FirstOrDefault(p => p.No == round);
if (this.IsPlayerHoleFinished(real_round, hole))
{
real_score2 = real_round?.Scores.FirstOrDefault(p => p.Hole == hole); real_score2 = real_round?.Scores.FirstOrDefault(p => p.Hole == hole);
} }
}
if (round == 1) if (round == 1)
{ {
...@@ -383,50 +377,6 @@ namespace VIZ.TVP.Golf.Service ...@@ -383,50 +377,6 @@ namespace VIZ.TVP.Golf.Service
} }
/// <summary> /// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="player">球员</param>
/// <param name="round">轮次</param>
/// <param name="hole">洞嗯呢</param>
/// <returns>是否已经完成该洞</returns>
public bool IsPlayerHoleFinished(PlayerRealModel player, int round, int hole)
{
if (player == null || player.Rounds == null)
return false;
RoundRealModel real_round = player.Rounds.FirstOrDefault(p => p.No == hole);
return this.IsPlayerHoleFinished(real_round, hole);
}
/// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="real_round">轮次真实数据</param>
/// <param name="hole">洞</param>
/// <returns>是否已经完成该洞</returns>
public bool IsPlayerHoleFinished(RoundRealModel real_round, int hole)
{
if (real_round == null)
return false;
int total_hole = ApplicationDomainEx.HoleInfos.Count;
int thru = real_round.Thru ?? 0;
if (hole >= real_round.StartingTee && hole < real_round.StartingTee + thru)
{
return true;
}
if ((real_round.StartingTee + thru > total_hole) && (hole < (real_round.StartingTee + thru) % total_hole))
{
return true;
}
return false;
}
/// <summary>
/// 更新队伍排名值 /// 更新队伍排名值
/// </summary> /// </summary>
/// <param name="teams">已经完成排序的队伍</param> /// <param name="teams">已经完成排序的队伍</param>
...@@ -445,14 +395,11 @@ namespace VIZ.TVP.Golf.Service ...@@ -445,14 +395,11 @@ namespace VIZ.TVP.Golf.Service
continue; continue;
} }
if (teams[i].TotalScoreValue == teams[i - 1].TotalScoreValue) ++position;
{
teams[i].Position = $"T{position}"; if (teams[i].TotalScoreValue != teams[i - 1].TotalScoreValue)
}
else
{ {
teams[i].Position = $"{position}"; teams[i].Position = $"{position}";
++position;
} }
} }
} }
...@@ -495,14 +442,11 @@ namespace VIZ.TVP.Golf.Service ...@@ -495,14 +442,11 @@ namespace VIZ.TVP.Golf.Service
continue; continue;
} }
if (groups[i].PlayerScoreValue == groups[i - 1].PlayerScoreValue) ++position;
{
groups[i].Position = $"T{position}"; if (groups[i].PlayerScoreValue != groups[i - 1].PlayerScoreValue)
}
else
{ {
groups[i].Position = $"{position}"; groups[i].Position = $"{position}";
++position;
} }
} }
} }
......
...@@ -109,23 +109,6 @@ namespace VIZ.TVP.Golf.Service ...@@ -109,23 +109,6 @@ namespace VIZ.TVP.Golf.Service
GroupHoleStatisticsData GetGroupHoleStatisticsData(string group, PlayerRealModel player1, PlayerRealModel player2, int round, int hole); GroupHoleStatisticsData GetGroupHoleStatisticsData(string group, PlayerRealModel player1, PlayerRealModel player2, int round, int hole);
/// <summary> /// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="player">球员</param>
/// <param name="round">轮次</param>
/// <param name="hole">洞嗯呢</param>
/// <returns>是否已经完成该洞</returns>
bool IsPlayerHoleFinished(PlayerRealModel player, int round, int hole);
/// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="real_round">轮次真实数据</param>
/// <param name="hole">洞</param>
/// <returns>是否已经完成该洞</returns>
bool IsPlayerHoleFinished(RoundRealModel real_round, int hole);
/// <summary>
/// 更新队伍排名值 /// 更新队伍排名值
/// </summary> /// </summary>
/// <param name="teams">已经完成排序的队伍</param> /// <param name="teams">已经完成排序的队伍</param>
......
...@@ -75,12 +75,12 @@ namespace VIZ.TVP.Golf.Storage ...@@ -75,12 +75,12 @@ namespace VIZ.TVP.Golf.Storage
public void FromXElement(XElement element) public void FromXElement(XElement element)
{ {
this.hole = element.GetAttributeValue<int>("hole"); this.hole = element.GetAttributeValue<int>("hole");
this.strokes = element.GetAttributeValue<int>("strokes"); this.strokes = element.GetAttributeValue<int?>("strokes");
this.par = element.GetAttributeValue<int>("par"); this.par = element.GetAttributeValue<int>("par");
this.bunkers = element.GetAttributeValue<int>("bunkers"); this.bunkers = element.GetAttributeValue<int?>("bunkers");
this.putts = element.GetAttributeValue<int>("putts"); this.putts = element.GetAttributeValue<int?>("putts");
this.drive = element.GetAttributeValue<int>("drive"); this.drive = element.GetAttributeValue<int?>("drive");
this.fairway = element.GetAttributeValue<int>("fairway"); this.fairway = element.GetAttributeValue<int?>("fairway");
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment