feat: new algo questions

This commit is contained in:
Michel Roux 2024-01-28 12:54:57 +01:00
parent f254c044e8
commit 3625e36f88
2 changed files with 13 additions and 29 deletions

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994} m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.18018535, g: 0.22559482, b: 0.30677685, a: 1} m_IndirectSpecularColor: {r: 0.18028328, g: 0.22571328, b: 0.3069218, a: 1}
m_UseRadianceAmbientProbe: 0 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
@ -1395,7 +1395,7 @@ MonoBehaviour:
- {fileID: 1854893636} - {fileID: 1854893636}
- {fileID: 2065109614} - {fileID: 2065109614}
- {fileID: 1197279072} - {fileID: 1197279072}
promptList: {fileID: 0} promptList: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2}
votingTime: 20 votingTime: 20
--- !u!114 &375256413 --- !u!114 &375256413
MonoBehaviour: MonoBehaviour:

View File

@ -6,6 +6,7 @@
using UnityEngine; using UnityEngine;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Linq; using System.Linq;
using Google.MiniJSON;
public class RoomManager : MonoBehaviour public class RoomManager : MonoBehaviour
{ {
@ -298,43 +299,26 @@ public void HostHasStartedGame()
public void GeneratePrompts() public void GeneratePrompts()
{ {
System.Random rnd = new(); System.Random rnd = new();
List<Prompt> prompts = promptList.prompts.OrderBy(x => rnd.Next()).Take(myRoom.players.Count() * 2).ToList(); List<Prompt> prompts = promptList.prompts.OrderBy(x => rnd.Next()).Take(myRoom.players.Count()).ToList();
List<Player> fullPlayers = myRoom.players.Values.ToList().Concat(myRoom.players.Values.ToList()).OrderBy(x => rnd.Next()).ToList(); List<Player> players = myRoom.players.Values.ToList().OrderBy(x => rnd.Next()).ToList();
Dictionary<string, Question> questions = new(); Dictionary<string, Question> questions = new();
foreach (Prompt prompt in prompts) for (int i = 0; i < players.Count(); i++)
{ {
Dictionary<string, Proposition> propositions = new(); Dictionary<string, Proposition> propositions = new();
Player basePlayer = fullPlayers[0];
propositions.Add(Guid.NewGuid().ToString(), new Proposition() for (int j = 0; j < 2; j++)
{ {
owner = basePlayer, propositions.Add(j.ToString(), new Proposition()
{
owner = players[i + j < players.Count() ? i + j : 0],
creationDate = DateTime.Now.ToOADate() creationDate = DateTime.Now.ToOADate()
}); });
//fullPlayers.RemoveAt(0);
for (int i = 1; i < fullPlayers.Count(); i++)
{
Player secondPlayer = fullPlayers[i];
if (basePlayer.id != secondPlayer.id)
{
propositions.Add(Guid.NewGuid().ToString(), new Proposition()
{
owner = secondPlayer,
creationDate = DateTime.Now.ToOADate()
});
fullPlayers.RemoveAt(0);
break;
}
} }
questions.Add(Guid.NewGuid().ToString(), new Question() questions.Add(i.ToString(), new Question()
{ {
promptId = prompt.id, promptId = prompts[i].id,
propositions = propositions, propositions = propositions,
creationDate = DateTime.Now.ToOADate(), creationDate = DateTime.Now.ToOADate(),
}); });