From 5a783cf452d96a0dde225fd31a790cff9e21e5f3 Mon Sep 17 00:00:00 2001
From: unknown <john.schihada@hotmail.com>
Date: Mon, 26 Oct 2020 17:20:00 +0100
Subject: [PATCH] Fetching Scrolls works again

---
 Assets/Scripts/InventoryStuff/Scroll.cs       | 28 ++++++++++++-------
 .../Scripts/InventoryStuff/ScrollDetails.cs   |  4 +--
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/Assets/Scripts/InventoryStuff/Scroll.cs b/Assets/Scripts/InventoryStuff/Scroll.cs
index c1e183d4..8ccdd976 100644
--- a/Assets/Scripts/InventoryStuff/Scroll.cs
+++ b/Assets/Scripts/InventoryStuff/Scroll.cs
@@ -4,6 +4,7 @@
 using System;
 using UnityEngine;
 using static JSONManager;
+using JsonSubTypes;
 using Newtonsoft.Json;
 
 
@@ -43,21 +44,16 @@ public class Scroll : LightScroll
     public string label;
     public string description;
     public List<ScrollFact> requiredFacts;
+    public List<ScrollFact> acquiredFacts;
 
     public static List<Scroll> FromJSON(string json)
     {
-        List<Scroll> scrolls = JsonConvert.DeserializeObject<List<Scroll>>(json, new JsonSerializerSettings
-        {
-            TypeNameHandling = TypeNameHandling.Auto
-        });
+        List<Scroll> scrolls = JsonConvert.DeserializeObject<List<Scroll>>(json);
         return scrolls;
     }
     public static string ToJSON(FilledScroll scroll)
     {
-        string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll, new JsonSerializerSettings
-        {
-            TypeNameHandling = TypeNameHandling.Auto
-        });
+        string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll);
         return json;
     }
 
@@ -133,14 +129,21 @@ public FilledScroll(LightScroll scroll, List<ScrollAssignment> assignments)
     }
 
 
-
+    [JsonConverter(typeof(JsonSubtypes), "kind")]
+    [JsonSubtypes.KnownSubType(typeof(ScrollSymbolFact), "general")]
+    [JsonSubtypes.KnownSubType(typeof(ScrollValueFact), "veq")]
     public class ScrollFact
     {
-        public string uri;
         public string kind;
+        public UriReference @ref;
         public string label;
     }
 
+    public class UriReference
+    {
+        public string uri;
+    }
+
     /**
     * Class used for deserializing incoming symbol-declarations from mmt
     */
@@ -164,6 +167,11 @@ public class ScrollValueFact : ScrollFact
 }
 
 public class LightScroll
+{
+    public ScrollTheoryReference @ref;
+}
+
+public class ScrollTheoryReference
 {
     public string problemTheory;
     public string solutionTheory;
diff --git a/Assets/Scripts/InventoryStuff/ScrollDetails.cs b/Assets/Scripts/InventoryStuff/ScrollDetails.cs
index 90ffaf97..f0840680 100644
--- a/Assets/Scripts/InventoryStuff/ScrollDetails.cs
+++ b/Assets/Scripts/InventoryStuff/ScrollDetails.cs
@@ -316,8 +316,8 @@ public bool isAngle()
     private string pushout(string view)
     {
         string path = "localhost:8081/pushout?";
-        path = path + "problem=" + this.scroll.problemTheory + "&";
-        path = path + "solution=" + this.scroll.solutionTheory + "&";
+        path = path + "problem=" + this.scroll.@ref.problemTheory + "&";
+        path = path + "solution=" + this.scroll.@ref.solutionTheory + "&";
         path = path + "view=" + view;
         UnityWebRequest www = UnityWebRequest.Get(path);
         var async = www.Send();
-- 
GitLab