Checkar in innan funktionen är klar
This commit is contained in:
@ -42,7 +42,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
BuilderObject = new();
|
||||
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
||||
PopupVisad = false;
|
||||
//PopupVisad = false;
|
||||
OnLoadedCommand = new AsyncRelayCommand(OnLoadedAsync, () => true);
|
||||
|
||||
}
|
||||
@ -67,7 +67,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
|
||||
private string _activePopupId;
|
||||
|
||||
public bool PopupVisad { get; set; }
|
||||
//public bool PopupVisad { get; set; }
|
||||
|
||||
private async Task OnLoadedAsync()
|
||||
{
|
||||
@ -182,8 +182,8 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
|
||||
private void Show_a_Popup(string ppName, string ppTitle, string ppMessage)
|
||||
{
|
||||
if (!PopupVisad)
|
||||
{
|
||||
//if (!PopupVisad)
|
||||
//{
|
||||
var queryAttributes = new Dictionary<string, object>
|
||||
{
|
||||
[nameof(InfoPopupViewModel.Title)] = ppTitle,
|
||||
@ -199,7 +199,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
|
||||
_activePopupId = LatestPopup.valueGuid;
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
private async void infoPopupViewModel_ClosePopupRequested(object? sender, PopupCloseEventArgs e)
|
||||
@ -208,7 +208,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
{
|
||||
return;
|
||||
}
|
||||
PopupVisad = true;
|
||||
//PopupVisad = true;
|
||||
await _popupService.ClosePopupAsync(Shell.Current);
|
||||
}
|
||||
|
||||
@ -229,10 +229,12 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
{
|
||||
PlayerColumn player = new PlayerColumn();
|
||||
|
||||
var regMax = elements.Max(e => e.GameRoundRegNr);
|
||||
var existingWinning = elements.FirstOrDefault(e => e.Status == GamePointStatus.Winning);
|
||||
|
||||
foreach (var element in elements)
|
||||
{
|
||||
player = PlayerColumns.FirstOrDefault(p => p.PlayerId == element.ParticipantId);
|
||||
|
||||
player = PlayerColumns.FirstOrDefault(p => p.PlayerId == element.ParticipantId)!;
|
||||
if (player == null)
|
||||
{
|
||||
player = new PlayerColumn
|
||||
@ -250,23 +252,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
player.PlayerPoints += element.GameRegPoints;
|
||||
if (player.PlayerPoints > 10000)
|
||||
{
|
||||
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
|
||||
var oldStatus = winner.Status;
|
||||
winner.Status = GamePointStatus.Winning;
|
||||
if (playerPointsOld < 10000 && oldStatus != winner.Status)
|
||||
{
|
||||
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"
|
||||
);
|
||||
}
|
||||
HandlePlayerReachedWinningThreshold(player, regMax, element, playerPointsOld, existingWinning);
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,6 +285,47 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
private void HandlePlayerReachedWinningThreshold(
|
||||
PlayerColumn player,
|
||||
int regMax,
|
||||
RoundBuilderElement element,
|
||||
int playerPointsOld,
|
||||
RoundBuilderElement existingWinning
|
||||
)
|
||||
{
|
||||
|
||||
var nextPlayer = RoundElements[AfterNext()].ParticipantName;
|
||||
Debug.WriteLine($"Spelare {nextPlayer} samma som {player.PlayerName} ???.");
|
||||
// Om det redan finns en vinnare, sätt dennes status tillbaka till InProgress, kanske
|
||||
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
|
||||
var oldStatus = winner.Status;
|
||||
winner.Status = GamePointStatus.Winning;
|
||||
if (playerPointsOld < 10000 && oldStatus != winner.Status && regMax == element.GameRoundRegNr)
|
||||
{
|
||||
//PopupVisad = false;
|
||||
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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private int AfterNext()
|
||||
{
|
||||
var comingUp = nextPlayerElement();
|
||||
if (RoundElements.Count - 1 == comingUp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return comingUp;
|
||||
}
|
||||
|
||||
public void BuildScore(IEnumerable<PlayerColumn> columns)
|
||||
{
|
||||
|
||||
@ -33,10 +33,10 @@ public static class MauiProgram
|
||||
builder.Services.AddDbContext<DataContext>(options =>
|
||||
{
|
||||
var MauiDataPath = FileSystem.Current.AppDataDirectory;
|
||||
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))) ;
|
||||
{
|
||||
File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"), MauiDataPath);
|
||||
}
|
||||
//if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))) ;
|
||||
//{
|
||||
// File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"), MauiDataPath);
|
||||
//}
|
||||
var dbPath = Path.Combine(MauiDataPath, "PoangDB.db");
|
||||
options.UseSqlite($"Data Source={dbPath}");
|
||||
});
|
||||
|
||||
@ -8,10 +8,6 @@
|
||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
x:DataType="vm:RoundRunningViewModel"
|
||||
Title="RoundRunningView">
|
||||
<!--xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"-->
|
||||
<!--<ContentPage.Behaviors>
|
||||
<behaviors:LoadedBehavior Command="{Binding OnLoadedCommand}" />
|
||||
</ContentPage.Behaviors>-->
|
||||
<Border
|
||||
behaviors:LoadedBehavior.Command="{Binding OnLoadedCommand}"
|
||||
Style="{StaticResource Border.Page}" StrokeThickness="4">
|
||||
@ -31,6 +27,7 @@
|
||||
<CollectionView Grid.Row="1"
|
||||
ItemsSource="{Binding RoundElements}"
|
||||
ItemsLayout="HorizontalList"
|
||||
HeightRequest="110"
|
||||
Margin="2">
|
||||
<CollectionView.ItemTemplate>
|
||||
<DataTemplate x:DataType="model:RoundBuilderElement">
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
ViewDescription="Välj deltagare och initiera spel" />
|
||||
<Border Grid.Row="1" Stroke="Gold" StrokeThickness="2" BackgroundColor="LemonChiffon" >
|
||||
<ScrollView Orientation="Horizontal">
|
||||
<StackLayout x:Name="ResponsiveStack" Spacing="5" Style="{StaticResource ResponsiveStackStyle}" >
|
||||
<StackLayout x:Name="ResponsiveStack" Spacing="5" HeightRequest="125" Style="{StaticResource ResponsiveStackStyle}" >
|
||||
<Border Stroke="Gray"
|
||||
StrokeThickness="2"
|
||||
BackgroundColor="LightGray"
|
||||
@ -119,6 +119,7 @@
|
||||
ItemsLayout="HorizontalList"
|
||||
x:Name="InnerList"
|
||||
Margin="0,10,0,10"
|
||||
HeightRequest="90"
|
||||
ItemSizingStrategy="MeasureAllItems">
|
||||
<CollectionView.ItemTemplate>
|
||||
<DataTemplate x:DataType="model:RoundBuilderElement">
|
||||
|
||||
Reference in New Issue
Block a user