Ordning på spelarnas poängsummor + popup i participant och i RoundRunning när någon är på väg att vinna
This commit is contained in:
@ -52,14 +52,14 @@ public class CombinedRepository : ICombinedRepository
|
||||
gp.GamePointId,
|
||||
gp.GameRoundId,
|
||||
gp.GameRoundRegNr,
|
||||
gp.GameRegPoints,
|
||||
latest.totPoints as GameRegPoints,
|
||||
gr.GameRoundStartDate,
|
||||
gr.GameStatus AS Status,
|
||||
p.ParticipantId,
|
||||
(p.LastName || ' ' || p.FirstName) AS ParticipantName
|
||||
FROM GamePoints gp
|
||||
INNER JOIN (
|
||||
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId
|
||||
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId, sum(GameRegPoints) AS totPoints
|
||||
FROM GamePoints
|
||||
GROUP BY ParticipantId, GameRoundId
|
||||
) latest ON gp.GamePointId = latest.MaxGamePointId
|
||||
|
||||
@ -5,5 +5,7 @@ public enum GamePointStatus
|
||||
New = 0,
|
||||
InProgress = 1,
|
||||
Completed = 2,
|
||||
Cancelled = 3
|
||||
Cancelled = 3,
|
||||
Winning = 4,
|
||||
Winner = 5
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public partial class ParticipantViewModel : BaseViewModel
|
||||
{
|
||||
[nameof(InfoPopupViewModel.Title)] = "Deltagar bildens infopopup",
|
||||
[nameof(InfoPopupViewModel.Message)] = "Deltagare laddade",
|
||||
[nameof(InfoPopupViewModel.Name)] = "Urban",
|
||||
[nameof(InfoPopupViewModel.Name)] = " ",
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Maui;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using GreadyPoang.DataLayer;
|
||||
@ -24,7 +25,9 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
IRepository<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage
|
||||
IObjectMessageService objectMessage,
|
||||
IPopupService popupService,
|
||||
IPopupEventHub popupEvent
|
||||
) : base()
|
||||
{
|
||||
_roundsRepo = roundsRepo;
|
||||
@ -32,8 +35,12 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
_sharingService = sharingService;
|
||||
_combined = combined;
|
||||
_objectMessage = objectMessage;
|
||||
_popupService = popupService;
|
||||
_popupEvent = popupEvent;
|
||||
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
BuilderObject = new();
|
||||
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
||||
PopupVisad = false;
|
||||
}
|
||||
|
||||
private readonly IRepository<GameRound>? _roundsRepo;
|
||||
@ -41,6 +48,8 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
private readonly IPopupService _popupService;
|
||||
private readonly IPopupEventHub _popupEvent;
|
||||
|
||||
//private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
//private ObservableCollection<Participant> _ParticipantList = new();
|
||||
@ -52,6 +61,9 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private RoundBuilderElement builderObject;
|
||||
|
||||
public bool PopupVisad { get; set; }
|
||||
|
||||
|
||||
public void TriggerRebuild()
|
||||
{
|
||||
// Trigga eventet
|
||||
@ -164,6 +176,30 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void Show_a_Popup(string ppName, string ppTitle, string ppMessage)
|
||||
{
|
||||
if (!PopupVisad)
|
||||
{
|
||||
var queryAttributes = new Dictionary<string, object>
|
||||
{
|
||||
[nameof(InfoPopupViewModel.Title)] = ppTitle,
|
||||
[nameof(InfoPopupViewModel.Message)] = ppMessage,
|
||||
[nameof(InfoPopupViewModel.Name)] = ppName,
|
||||
|
||||
};
|
||||
|
||||
_popupService.ShowPopup<InfoPopupViewModel>(
|
||||
Shell.Current,
|
||||
options: PopupOptions.Empty,
|
||||
shellParameters: queryAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
private async void infoPopupViewModel_ClosePopupRequested(object? sender, EventArgs e)
|
||||
{
|
||||
PopupVisad = true;
|
||||
await _popupService.ClosePopupAsync(Shell.Current);
|
||||
}
|
||||
|
||||
|
||||
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
|
||||
@ -199,7 +235,27 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
if (element.GameRegPoints > 0)
|
||||
{
|
||||
player.Values.Add(element.GameRegPoints.ToString());
|
||||
var playerPointsOld = player.PlayerPoints;
|
||||
player.PlayerPoints += element.GameRegPoints;
|
||||
if (player.PlayerPoints > 10000)
|
||||
{
|
||||
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
|
||||
winner.Status = GamePointStatus.Winning;
|
||||
if (playerPointsOld < 10000)
|
||||
{
|
||||
Show_a_Popup(
|
||||
player.PlayerName,
|
||||
"Se upp för denne spelare !",
|
||||
$"Du har nått en poängnivå över 10000 ({player.PlayerPoints})\r" +
|
||||
$"Alla övriga får nu en chans att överträffa\r" +
|
||||
$"om någon kommer till samma poäng som\r" +
|
||||
$"{player.PlayerName}\r" +
|
||||
$"får hen försvara sig med nytt kast\r" +
|
||||
$"Om kastet inte blir godkänt (ger poäng)\r" +
|
||||
$"Vinner den upphinnande spelaren"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
//oldPart = element.ParticipantId;
|
||||
|
||||
|
||||
@ -10,8 +10,9 @@
|
||||
x:DataType="viewModels:InfoPopupViewModel"
|
||||
BackgroundColor="Transparent">
|
||||
<VerticalStackLayout BackgroundColor="Aquamarine" Padding="5" Margin="0">
|
||||
<Label TextColor="BlueViolet" Text="{Binding Title}" Style="{StaticResource Headline}" />
|
||||
<Label Text="{Binding Message}" Style="{StaticResource SubHeadline}"/>
|
||||
<Label HorizontalOptions="Center" TextColor="BlueViolet" Text="{Binding Title}" Style="{StaticResource Headline}" />
|
||||
<Label HorizontalOptions="Center" Text="{Binding Name}" Style="{StaticResource SubHeadline}"/>
|
||||
<Label HorizontalOptions="Center" Text="{Binding Message}" Style="{StaticResource StatusLabelStyle}"/>
|
||||
<!--<Label Text="What is your name?" />
|
||||
<Entry Text="{Binding Name}" />
|
||||
|
||||
|
||||
@ -55,6 +55,12 @@
|
||||
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Cancelled">
|
||||
<Setter Property="BackgroundColor" Value="LightCoral" />
|
||||
</DataTrigger>
|
||||
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Winning">
|
||||
<Setter Property="BackgroundColor" Value="Yellow" />
|
||||
</DataTrigger>
|
||||
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Winner">
|
||||
<Setter Property="BackgroundColor" Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
|
||||
@ -90,6 +90,12 @@ public partial class RoundRunningView : ContentPage
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
ViewModel.PopupVisad = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user