Ajout de l'algorithme pour gérer les sacs.

This commit is contained in:
2019-05-30 01:45:56 +02:00
parent 37e003f0e4
commit af79011d14
3 changed files with 47 additions and 26 deletions

View File

@@ -83,28 +83,26 @@
</ListView> </ListView>
<StackPanel Grid.Row="2" Grid.Column="2"> <DockPanel Grid.Row="2" Grid.Column="2" >
<TextBlock>Resultat :</TextBlock>
<StackPanel Orientation="Horizontal">
<TextBlock> First : </TextBlock>
<TextBlock Text="{Binding First,UpdateSourceTrigger=PropertyChanged}"> </TextBlock>
</StackPanel>
<StackPanel Orientation="Vertical">
<TextBlock> Result :</TextBlock>
<ListView Grid.Row="2" Grid.Column="1" ItemsSource="{Binding SelectedGameResult}" Margin="5,5,5,5"
IsTextSearchEnabled="True" TextSearch.TextPath="Name">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Player}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Point}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView> <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<TextBlock> Total :</TextBlock>
<TextBlock Text="{Binding SelectedGameResult.Count,UpdateSourceTrigger=PropertyChanged}"></TextBlock>
</StackPanel> </StackPanel>
</StackPanel> <ListView ItemsSource="{Binding SelectedGameResult}" Margin="5,5,5,5"
IsTextSearchEnabled="True" TextSearch.TextPath="Name">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Player}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Point}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DockPanel>
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -73,13 +73,20 @@ namespace LaDOSE.Business.Provider
var participentResults = await new ParticipantsQuery(){tournamentID = idTournament }.call(ApiCaller); var participentResults = await new ParticipantsQuery(){tournamentID = idTournament }.call(ApiCaller);
List<Participent> participants = new List<Participent>(); List<Participent> participants = new List<Participent>();
participentResults.ForEach(w => participants.Add(new Participent() participentResults.ForEach(w =>
{ {
Id = w.id, if (w.active)
Name = w.name, {
Rank = w.final_rank, participants.Add(new Participent()
IsMember = true, {
})); Id = w.id,
Name = w.name,
Rank = w.final_rank,
IsMember = false,
});
}
});
return participants; return participants;
} }

View File

@@ -22,6 +22,8 @@ namespace LaDOSE.Business.Service
public int Top8Point { get; set; } public int Top8Point { get; set; }
public int Top16Point { get; set; } public int Top16Point { get; set; }
public int Participation => 1;
public Rules(int playerMin, int playerMax, int firstPoint, int secondPoint, int thirdFourthPoint, int top8Point, int top16Point) public Rules(int playerMin, int playerMax, int firstPoint, int secondPoint, int thirdFourthPoint, int top8Point, int top16Point)
{ {
PlayerMin = playerMin; PlayerMin = playerMin;
@@ -31,6 +33,7 @@ namespace LaDOSE.Business.Service
ThirdFourthPoint = thirdFourthPoint; ThirdFourthPoint = thirdFourthPoint;
Top8Point = top8Point; Top8Point = top8Point;
Top16Point = top16Point; Top16Point = top16Point;
} }
} }
@@ -97,6 +100,10 @@ namespace LaDOSE.Business.Service
tournament.Game = game; tournament.Game = game;
var playerCount = tournament.Participents.Count; var playerCount = tournament.Participents.Count;
//Suppression des forfait
var lesSacs = tournament.Participents;
var currentRule = TournamentRules.FirstOrDefault(rules => var currentRule = TournamentRules.FirstOrDefault(rules =>
rules.PlayerMin < playerCount && rules.PlayerMax >= playerCount rules.PlayerMin < playerCount && rules.PlayerMax >= playerCount
); );
@@ -112,10 +119,19 @@ namespace LaDOSE.Business.Service
var Top16 = tournament.Participents.Where(p => p.Rank >9 && p.Rank<=16).ToList(); var Top16 = tournament.Participents.Where(p => p.Rank >9 && p.Rank<=16).ToList();
result.Results.Add(new Result(first.Name,tournament.Game.Id,currentRule.FirstPoint)); result.Results.Add(new Result(first.Name,tournament.Game.Id,currentRule.FirstPoint));
lesSacs.Remove(first);
result.Results.Add(new Result(second.Name,tournament.Game.Id,currentRule.SecondPoint)); result.Results.Add(new Result(second.Name,tournament.Game.Id,currentRule.SecondPoint));
lesSacs.Remove(second);
thirdFourth.ForEach(r=> result.Results.Add(new Result(r.Name, tournament.Game.Id, currentRule.ThirdFourthPoint))); thirdFourth.ForEach(r=> result.Results.Add(new Result(r.Name, tournament.Game.Id, currentRule.ThirdFourthPoint)));
thirdFourth.ForEach(p=>lesSacs.Remove(p));
Top8.ForEach(r=> result.Results.Add(new Result(r.Name, tournament.Game.Id, currentRule.Top8Point))); Top8.ForEach(r=> result.Results.Add(new Result(r.Name, tournament.Game.Id, currentRule.Top8Point)));
Top8.ForEach(p => lesSacs.Remove(p));
Top16.ForEach(r=> result.Results.Add(new Result(r.Name, tournament.Game.Id, currentRule.Top16Point))); Top16.ForEach(r=> result.Results.Add(new Result(r.Name, tournament.Game.Id, currentRule.Top16Point)));
Top16.ForEach(p => lesSacs.Remove(p));
lesSacs.ForEach(r => result.Results.Add(new Result(r.Name, tournament.Game.Id, currentRule.Participation)));
//
} }
result.Games = tournaments.Select(e => e.Game).ToList(); result.Games = tournaments.Select(e => e.Game).ToList();