feat: room has now a function to list player and get propositions

This commit is contained in:
Morgan - 6 Freedom 2024-01-28 02:40:38 +01:00
parent 39603d26dc
commit a19f158828

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
[Serializable] [Serializable]
@ -28,6 +29,15 @@ public List<Player> GetPlayerList()
return new List<Player>(players.Values); 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() public List<Question> GetQuestionList()
{ {
return new List<Question>(questions.Values); return new List<Question>(questions.Values);
@ -37,5 +47,24 @@ public void setPlayersAreReady(int _state)
{ {
currentState = _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;
}
} }