From 3625e36f8810ff082e6a85120a8177ebd68bccd1 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 28 Jan 2024 12:54:57 +0100 Subject: [PATCH] feat: new algo questions --- Assets/Scenes/ComputerView.unity | 4 ++-- Assets/Scripts/RoomManager.cs | 38 +++++++++----------------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/Assets/Scenes/ComputerView.unity b/Assets/Scenes/ComputerView.unity index 7b35f82..fd08813 100644 --- a/Assets/Scenes/ComputerView.unity +++ b/Assets/Scenes/ComputerView.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} 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 --- !u!157 &3 LightmapSettings: @@ -1395,7 +1395,7 @@ MonoBehaviour: - {fileID: 1854893636} - {fileID: 2065109614} - {fileID: 1197279072} - promptList: {fileID: 0} + promptList: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2} votingTime: 20 --- !u!114 &375256413 MonoBehaviour: diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index 7c8cf36..7a013d6 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -6,6 +6,7 @@ using UnityEngine; using Newtonsoft.Json; using System.Linq; +using Google.MiniJSON; public class RoomManager : MonoBehaviour { @@ -298,43 +299,26 @@ public void HostHasStartedGame() public void GeneratePrompts() { System.Random rnd = new(); - List prompts = promptList.prompts.OrderBy(x => rnd.Next()).Take(myRoom.players.Count() * 2).ToList(); - List fullPlayers = myRoom.players.Values.ToList().Concat(myRoom.players.Values.ToList()).OrderBy(x => rnd.Next()).ToList(); + List prompts = promptList.prompts.OrderBy(x => rnd.Next()).Take(myRoom.players.Count()).ToList(); + List players = myRoom.players.Values.ToList().OrderBy(x => rnd.Next()).ToList(); Dictionary questions = new(); - foreach (Prompt prompt in prompts) + for (int i = 0; i < players.Count(); i++) { Dictionary propositions = new(); - Player basePlayer = fullPlayers[0]; - propositions.Add(Guid.NewGuid().ToString(), new Proposition() + for (int j = 0; j < 2; j++) { - owner = basePlayer, - 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(j.ToString(), new Proposition() { - propositions.Add(Guid.NewGuid().ToString(), new Proposition() - { - owner = secondPlayer, - creationDate = DateTime.Now.ToOADate() - }); - - fullPlayers.RemoveAt(0); - break; - } + owner = players[i + j < players.Count() ? i + j : 0], + creationDate = DateTime.Now.ToOADate() + }); } - questions.Add(Guid.NewGuid().ToString(), new Question() + questions.Add(i.ToString(), new Question() { - promptId = prompt.id, + promptId = prompts[i].id, propositions = propositions, creationDate = DateTime.Now.ToOADate(), });