2024-01-27 18:58:02 +00:00
|
|
|
using System;
|
2024-01-27 09:19:32 +00:00
|
|
|
using System.Collections.Generic;
|
2024-01-27 18:54:06 +00:00
|
|
|
using Newtonsoft.Json;
|
2024-01-27 09:19:32 +00:00
|
|
|
|
2024-01-27 18:58:02 +00:00
|
|
|
[Serializable]
|
2024-01-27 19:05:24 +00:00
|
|
|
[JsonObject]
|
2024-01-27 09:19:32 +00:00
|
|
|
public class Room
|
|
|
|
{
|
|
|
|
public string code;
|
2024-01-27 18:54:06 +00:00
|
|
|
public Dictionary<string, Question> questions;
|
|
|
|
public Dictionary<string, Player> players;
|
2024-01-27 09:19:32 +00:00
|
|
|
public int currentQuestion;
|
2024-01-27 14:08:12 +00:00
|
|
|
public double creationDate;
|
2024-01-27 21:26:23 +00:00
|
|
|
public int currentState;
|
2024-01-27 14:08:12 +00:00
|
|
|
|
|
|
|
public Room(string _code)
|
|
|
|
{
|
2024-01-27 18:58:02 +00:00
|
|
|
code = _code;
|
|
|
|
creationDate = DateTime.Now.ToOADate();
|
2024-01-27 18:59:51 +00:00
|
|
|
players = new Dictionary<string, Player>();
|
|
|
|
questions = new Dictionary<string, Question>();
|
2024-01-27 18:58:02 +00:00
|
|
|
currentQuestion = 0;
|
2024-01-27 23:06:23 +00:00
|
|
|
currentState = 1; //default by PC
|
2024-01-27 14:08:12 +00:00
|
|
|
}
|
2024-01-27 18:54:06 +00:00
|
|
|
|
|
|
|
public List<Player> GetPlayerList()
|
|
|
|
{
|
|
|
|
return new List<Player>(players.Values);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Question> GetQuestionList()
|
|
|
|
{
|
|
|
|
return new List<Question>(questions.Values);
|
|
|
|
}
|
2024-01-27 21:26:23 +00:00
|
|
|
|
2024-01-28 01:26:57 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-01-27 21:26:23 +00:00
|
|
|
public void setPlayersAreReady(int _state)
|
|
|
|
{
|
|
|
|
currentState = _state;
|
|
|
|
}
|
2024-01-27 09:19:32 +00:00
|
|
|
}
|
2024-01-27 18:54:06 +00:00
|
|
|
|