feat: room has now a function to list player and get propositions
This commit is contained in:
parent
39603d26dc
commit
a19f158828
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[Serializable]
|
||||
@ -28,6 +29,15 @@ public List<Player> GetPlayerList()
|
||||
return new List<Player>(players.Values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// return the list of player ordered by who joined first
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Player> GetOrderedPlayerList()
|
||||
{
|
||||
return players.Values.OrderBy(x => x.creationDate).ToList();
|
||||
}
|
||||
|
||||
public List<Question> GetQuestionList()
|
||||
{
|
||||
return new List<Question>(questions.Values);
|
||||
@ -37,5 +47,24 @@ public void setPlayersAreReady(int _state)
|
||||
{
|
||||
currentState = _state;
|
||||
}
|
||||
|
||||
public List<Proposition> GetPropositionsByPlayer(Player player)
|
||||
{
|
||||
List<Proposition> propositions = new();
|
||||
|
||||
foreach (Question question in GetQuestionList())
|
||||
{
|
||||
foreach (Proposition proposition in new List<Proposition>(question.propositions.Values))
|
||||
{
|
||||
if (proposition.owner.id == player.id)
|
||||
{
|
||||
propositions.Add(proposition);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return propositions;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user