예제 #1
0
        public void AddToRecentLog(Participant userA, Participant userB)
        {
            // HACK: This whole function is a bit of a hack. But it works for now :P
            string name = UserSocialLogName.Value.Format(userA.Id);

            SaveLoad.Load(name, out string log);
            if (log == null)
            {
                string json = JsonUtility.ToJson(new SerializedSocial()
                {
                    Recent = new Participant[0], Friends = new Participant[0]
                });
                SaveLoad.Save(json, name);
                AddToRecentLog(userA, userB);
                return;
            }

            SerializedSocial serializedSocial = JsonUtility.FromJson <SerializedSocial>(log);

            List <Participant> newRecent = new List <Participant>(serializedSocial.Recent);

            newRecent.Insert(0, userB);
            serializedSocial.Recent = newRecent.ToArray();

            string updatedLog = JsonUtility.ToJson(serializedSocial);

            SaveLoad.Save(updatedLog, name);
        }
        public void OnHistoryLogsRequested(Participant participant, string serializedIndex)
        {
            int index = int.Parse(serializedIndex);

            string[] ids = LoadUserLogs(participant.Id);


            int count = Mathf.Clamp(Mathf.Min(ChunkSize, ids.Length - index), 0, int.MaxValue);

            SerializedHistory serializedHistory = new SerializedHistory()
            {
                Index = index,
                SerializedHistoryLogs = new string[count]
            };

            for (int i = index; i < count; i++)
            {
                string id   = ids[i];
                string name = string.Format(CompleteEvaluationName.Value, id);
                SaveLoad.Load(name, out string log);

                if (log == null)
                {
                    Debug.LogWarning("Missing Evaluation Entry: " + id);
                    break;
                }

                CompleteCaseEvaluation caseEvaluation = JsonUtility.FromJson <CompleteCaseEvaluation>(log);

                char c = (char)124;

                string serializedCase = caseEvaluation.RoleplayDescription.Case.Module.ToString() + c
                                        + caseEvaluation.EvaluationUserA.User.Name + c
                                        + caseEvaluation.EvaluationUserB.User.Name + c
                                        + caseEvaluation.TimeStamp + c
                                        + caseEvaluation.RoleplayDescription.Id;

                serializedHistory.SerializedHistoryLogs[i - index] = serializedCase;
            }

            string         json    = JsonUtility.ToJson(serializedHistory);
            NetworkMessage message = new NetworkMessage(NetworkMessageType.RequestHistoryLogs, "", participant.Id, json);

            Manager.SendMessage(message, participant.IP);
        }
예제 #3
0
        public void OnRequestAcquired(Participant participant)
        {
            string name = UserSocialLogName.Value.Format(participant.Id);

            SaveLoad.Load(name, out string data);

            if (data == null)
            {
                data = JsonUtility.ToJson(new SerializedSocial()
                {
                    Friends = new Participant[0], Recent = new Participant[0]
                });
            }

            NetworkMessage message = new NetworkMessage(NetworkMessageType.RequestSocialLogs, "", participant.Id, data);

            Manager.SendMessage(message, participant.IP);
        }