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.GamePointId,
|
||||||
gp.GameRoundId,
|
gp.GameRoundId,
|
||||||
gp.GameRoundRegNr,
|
gp.GameRoundRegNr,
|
||||||
gp.GameRegPoints,
|
latest.totPoints as GameRegPoints,
|
||||||
gr.GameRoundStartDate,
|
gr.GameRoundStartDate,
|
||||||
gr.GameStatus AS Status,
|
gr.GameStatus AS Status,
|
||||||
p.ParticipantId,
|
p.ParticipantId,
|
||||||
(p.LastName || ' ' || p.FirstName) AS ParticipantName
|
(p.LastName || ' ' || p.FirstName) AS ParticipantName
|
||||||
FROM GamePoints gp
|
FROM GamePoints gp
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId
|
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId, sum(GameRegPoints) AS totPoints
|
||||||
FROM GamePoints
|
FROM GamePoints
|
||||||
GROUP BY ParticipantId, GameRoundId
|
GROUP BY ParticipantId, GameRoundId
|
||||||
) latest ON gp.GamePointId = latest.MaxGamePointId
|
) latest ON gp.GamePointId = latest.MaxGamePointId
|
||||||
|
|||||||
@ -5,5 +5,7 @@ public enum GamePointStatus
|
|||||||
New = 0,
|
New = 0,
|
||||||
InProgress = 1,
|
InProgress = 1,
|
||||||
Completed = 2,
|
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.Title)] = "Deltagar bildens infopopup",
|
||||||
[nameof(InfoPopupViewModel.Message)] = "Deltagare laddade",
|
[nameof(InfoPopupViewModel.Message)] = "Deltagare laddade",
|
||||||
[nameof(InfoPopupViewModel.Name)] = "Urban",
|
[nameof(InfoPopupViewModel.Name)] = " ",
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
|
using CommunityToolkit.Maui;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using GreadyPoang.DataLayer;
|
using GreadyPoang.DataLayer;
|
||||||
@ -24,7 +25,9 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
IRepository<GamePoint> pointsRepo,
|
IRepository<GamePoint> pointsRepo,
|
||||||
IMethodSharingService<Participant> sharingService,
|
IMethodSharingService<Participant> sharingService,
|
||||||
ICombinedRepository combined,
|
ICombinedRepository combined,
|
||||||
IObjectMessageService objectMessage
|
IObjectMessageService objectMessage,
|
||||||
|
IPopupService popupService,
|
||||||
|
IPopupEventHub popupEvent
|
||||||
) : base()
|
) : base()
|
||||||
{
|
{
|
||||||
_roundsRepo = roundsRepo;
|
_roundsRepo = roundsRepo;
|
||||||
@ -32,8 +35,12 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
_sharingService = sharingService;
|
_sharingService = sharingService;
|
||||||
_combined = combined;
|
_combined = combined;
|
||||||
_objectMessage = objectMessage;
|
_objectMessage = objectMessage;
|
||||||
|
_popupService = popupService;
|
||||||
|
_popupEvent = popupEvent;
|
||||||
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
||||||
BuilderObject = new();
|
BuilderObject = new();
|
||||||
|
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
||||||
|
PopupVisad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IRepository<GameRound>? _roundsRepo;
|
private readonly IRepository<GameRound>? _roundsRepo;
|
||||||
@ -41,6 +48,8 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
private readonly IMethodSharingService<Participant> _sharingService;
|
private readonly IMethodSharingService<Participant> _sharingService;
|
||||||
private readonly ICombinedRepository _combined;
|
private readonly ICombinedRepository _combined;
|
||||||
private readonly IObjectMessageService _objectMessage;
|
private readonly IObjectMessageService _objectMessage;
|
||||||
|
private readonly IPopupService _popupService;
|
||||||
|
private readonly IPopupEventHub _popupEvent;
|
||||||
|
|
||||||
//private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
//private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||||
//private ObservableCollection<Participant> _ParticipantList = new();
|
//private ObservableCollection<Participant> _ParticipantList = new();
|
||||||
@ -52,6 +61,9 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private RoundBuilderElement builderObject;
|
private RoundBuilderElement builderObject;
|
||||||
|
|
||||||
|
public bool PopupVisad { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void TriggerRebuild()
|
public void TriggerRebuild()
|
||||||
{
|
{
|
||||||
// Trigga eventet
|
// Trigga eventet
|
||||||
@ -164,6 +176,30 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
return -1;
|
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)
|
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
|
||||||
@ -199,7 +235,27 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
if (element.GameRegPoints > 0)
|
if (element.GameRegPoints > 0)
|
||||||
{
|
{
|
||||||
player.Values.Add(element.GameRegPoints.ToString());
|
player.Values.Add(element.GameRegPoints.ToString());
|
||||||
|
var playerPointsOld = player.PlayerPoints;
|
||||||
player.PlayerPoints += element.GameRegPoints;
|
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;
|
//oldPart = element.ParticipantId;
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,9 @@
|
|||||||
x:DataType="viewModels:InfoPopupViewModel"
|
x:DataType="viewModels:InfoPopupViewModel"
|
||||||
BackgroundColor="Transparent">
|
BackgroundColor="Transparent">
|
||||||
<VerticalStackLayout BackgroundColor="Aquamarine" Padding="5" Margin="0">
|
<VerticalStackLayout BackgroundColor="Aquamarine" Padding="5" Margin="0">
|
||||||
<Label TextColor="BlueViolet" Text="{Binding Title}" Style="{StaticResource Headline}" />
|
<Label HorizontalOptions="Center" TextColor="BlueViolet" Text="{Binding Title}" Style="{StaticResource Headline}" />
|
||||||
<Label Text="{Binding Message}" Style="{StaticResource SubHeadline}"/>
|
<Label HorizontalOptions="Center" Text="{Binding Name}" Style="{StaticResource SubHeadline}"/>
|
||||||
|
<Label HorizontalOptions="Center" Text="{Binding Message}" Style="{StaticResource StatusLabelStyle}"/>
|
||||||
<!--<Label Text="What is your name?" />
|
<!--<Label Text="What is your name?" />
|
||||||
<Entry Text="{Binding Name}" />
|
<Entry Text="{Binding Name}" />
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,12 @@
|
|||||||
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Cancelled">
|
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Cancelled">
|
||||||
<Setter Property="BackgroundColor" Value="LightCoral" />
|
<Setter Property="BackgroundColor" Value="LightCoral" />
|
||||||
</DataTrigger>
|
</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.Triggers>
|
||||||
</Style>
|
</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