Nu är det ordning på funktionaliteten när det gäller att hantera spelare nya spelronder och den poänghistorik som lagras
This commit is contained in:
@ -39,11 +39,12 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
|
||||
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
private Collection<PlayerColumn> _playerColumns;
|
||||
private RoundBuilderElement _builderObject;
|
||||
|
||||
public void TriggerRebuild()
|
||||
{
|
||||
@ -71,10 +72,6 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private RoundBuilderElement _builderObject;
|
||||
|
||||
public RoundBuilderElement BuilderObject
|
||||
{
|
||||
get { return _builderObject; }
|
||||
@ -103,14 +100,20 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
_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;
|
||||
|
||||
// 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);
|
||||
|
||||
FillupResultTable(localElements);
|
||||
TriggerRebuild();
|
||||
}
|
||||
return RoundElements;
|
||||
}
|
||||
@ -118,7 +121,18 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
|
||||
public void StoreAndHandlePoints()
|
||||
{
|
||||
var game = _roundsRepo.Get(BuilderObject.GameRoundId).GetAwaiter().GetResult();
|
||||
var regNr = RoundElements.Count > 0 ? RoundElements.Max(e => e.GameRoundRegNr) + 1 : 1;
|
||||
|
||||
if (game.GameStatus == GamePointStatus.New)
|
||||
{
|
||||
game.GameStatus = GamePointStatus.InProgress;
|
||||
regNr = regNr == 0 ? 1 : regNr;
|
||||
_roundsRepo.Save(game);
|
||||
|
||||
}
|
||||
|
||||
BuilderObject.Status = game.GameStatus;
|
||||
var points = BuilderObject.GameRegPoints;
|
||||
var newPoint = new GamePoint
|
||||
{
|
||||
@ -135,6 +149,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
RoundElements.Clear();
|
||||
foreach (var item in tmpElements)
|
||||
{
|
||||
item.Status = GamePointStatus.InProgress;
|
||||
RoundElements.Add(item);
|
||||
}
|
||||
|
||||
@ -179,7 +194,8 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
_playerColumns = new Collection<PlayerColumn>();
|
||||
}
|
||||
|
||||
if (elements.Any(g => g.GameRegPoints > 0))
|
||||
// if (elements.Any(g => g.GameRegPoints > 0))
|
||||
if (BuilderObject.Status == GamePointStatus.InProgress)
|
||||
{
|
||||
PlayerColumn player = new PlayerColumn();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user