Små ändringar i roundrunning
This commit is contained in:
@ -90,30 +90,15 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
RoundElements.Add(item);
|
RoundElements.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Räkna ut vem som är nästa spelare
|
|
||||||
var nxt = nextPlayerElement();
|
|
||||||
|
|
||||||
// Aktuell spelare sätts som BuilderObject
|
|
||||||
BuilderObject.ParticipantName = _objectMessage.CurrentGroup.Elements[nxt].ParticipantName;
|
|
||||||
BuilderObject.GameRoundId = _objectMessage.CurrentGroup.GameRoundId;
|
|
||||||
BuilderObject.ParticipantId = _objectMessage.CurrentGroup.Elements[nxt].ParticipantId;
|
|
||||||
BuilderObject.Status = _objectMessage.CurrentGroup.Status;
|
BuilderObject.Status = _objectMessage.CurrentGroup.Status;
|
||||||
|
|
||||||
// Alla poängposter från samtliga spelare i rundan samlas ihop och fördelas per deltagare
|
UpdateAndShow();
|
||||||
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
|
|
||||||
|
|
||||||
FillupResultTable(localElements);
|
|
||||||
foreach (var col in PlayerColumns)
|
|
||||||
{
|
|
||||||
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
|
||||||
}
|
|
||||||
//TriggerRebuild();
|
|
||||||
BuildScore(playerColumns);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void StoreAndHandlePointsAsync()
|
private void StoreAndHandlePointsAsync()
|
||||||
{
|
{
|
||||||
@ -149,21 +134,8 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
RoundElements.Add(item);
|
RoundElements.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uppdatera spelaren som skall spela nästa
|
|
||||||
var nxt = nextPlayerElement();
|
|
||||||
BuilderObject.GameRegPoints = 0;
|
BuilderObject.GameRegPoints = 0;
|
||||||
BuilderObject.ParticipantName = RoundElements[nxt].ParticipantName;
|
UpdateAndShow();
|
||||||
BuilderObject.ParticipantId = RoundElements[nxt].ParticipantId;
|
|
||||||
BuilderObject.GameRoundId = RoundElements[0].GameRoundId;
|
|
||||||
|
|
||||||
var localElements = _combined.roundBuilderElementsTotalById(BuilderObject.GameRoundId);
|
|
||||||
FillupResultTable(localElements);
|
|
||||||
foreach (var col in PlayerColumns)
|
|
||||||
{
|
|
||||||
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
|
||||||
}
|
|
||||||
// TriggerRebuild();
|
|
||||||
BuildScore(playerColumns);
|
|
||||||
Shell.Current.GoToAsync("..").GetAwaiter().GetResult();
|
Shell.Current.GoToAsync("..").GetAwaiter().GetResult();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -180,6 +152,34 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateAndShow()
|
||||||
|
{
|
||||||
|
// Räkna ut vem som är nästa spelare
|
||||||
|
var nxt = nextPlayerElement();
|
||||||
|
|
||||||
|
// Aktuell spelare sätts som BuilderObject
|
||||||
|
BuilderObject.ParticipantName = _objectMessage.CurrentGroup.Elements[nxt].ParticipantName;
|
||||||
|
BuilderObject.ParticipantId = _objectMessage.CurrentGroup.Elements[nxt].ParticipantId;
|
||||||
|
BuilderObject.GameRoundId = _objectMessage.CurrentGroup.GameRoundId;
|
||||||
|
|
||||||
|
|
||||||
|
// Alla poängposter från samtliga spelare i rundan samlas ihop och fördelas per deltagare
|
||||||
|
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
|
||||||
|
|
||||||
|
FillupResultTable(localElements);
|
||||||
|
// Fix for CS8602: Add null check before dereferencing FirstOrDefault result
|
||||||
|
foreach (var col in PlayerColumns)
|
||||||
|
{
|
||||||
|
var roundElement = RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId);
|
||||||
|
if (roundElement != null)
|
||||||
|
{
|
||||||
|
roundElement.GameRegPoints = col.PlayerPoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fix for MVVMTK0034: Use the generated property 'PlayerColumns' instead of the backing field 'playerColumns'
|
||||||
|
BuildScore(PlayerColumns);
|
||||||
|
}
|
||||||
|
|
||||||
private void Show_a_Popup(string ppName, string ppTitle, string ppMessage)
|
private void Show_a_Popup(string ppName, string ppTitle, string ppMessage)
|
||||||
{
|
{
|
||||||
//if (!PopupVisad)
|
//if (!PopupVisad)
|
||||||
@ -296,7 +296,14 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
|
|
||||||
var nextPlayer = RoundElements[AfterNext()].ParticipantName;
|
var nextPlayer = RoundElements[AfterNext()].ParticipantName;
|
||||||
Debug.WriteLine($"Spelare {nextPlayer} samma som {player.PlayerName} ???.");
|
Debug.WriteLine($"Spelare {nextPlayer} samma som {player.PlayerName} ???.");
|
||||||
|
if (existingWinning != null && existingWinning.ParticipantId != player.PlayerId)
|
||||||
|
{
|
||||||
|
// Det finns redan en vinnare, sätt dennes status tillbaka till InProgress
|
||||||
|
existingWinning.Status = GamePointStatus.InProgress;
|
||||||
|
}
|
||||||
|
|
||||||
// Om det redan finns en vinnare, sätt dennes status tillbaka till InProgress, kanske
|
// Om det redan finns en vinnare, sätt dennes status tillbaka till InProgress, kanske
|
||||||
|
|
||||||
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
|
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
|
||||||
var oldStatus = winner.Status;
|
var oldStatus = winner.Status;
|
||||||
winner.Status = GamePointStatus.Winning;
|
winner.Status = GamePointStatus.Winning;
|
||||||
|
|||||||
Reference in New Issue
Block a user