Преглед изворни кода

Fix bugg fel svar fortsätt.
Större tillbaka knapp inne i spel.
Fix bugg, om man inte öppnat val av kategorier.
Små grafik justeringar

Axel Nordh пре 5 година
родитељ
комит
f0796ffb78

+ 13 - 6
Assets/NewDropZoneScript.cs

@@ -107,7 +107,7 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
             GameObject.Find("GameManager").GetComponent<GameManagerScript>().StopTimer();
             // TODO Check win condition, if met show Congratulations and send loss message to others
             GameObject.Find("GameManager").GetComponent<GameManagerScript>().CheckWin(AnswerLine.GetComponentsInChildren<QuestionCard>().ToList());
-            
+
             draggedQuestion.GetComponentInParent<NewQuestionCardController>().GenerateNewQuestion();
         } else { // Wrong answer
             GameObject.Find("GameManager").GetComponent<GameManagerScript>().StopTimer();
@@ -120,10 +120,9 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
             string message = LocalizationManager.Instance.GetText("DROPPED_QUESTION_WRONG_ANSWER_MESSAGE");
             dialog.SetMessage(String.Format(message, GameObject.Find("GameManager").GetComponent<GameManagerScript>().GetUnlockedQuestionsCount()));
             dialog.SetOnAccept(LocalizationManager.Instance.GetText("OK"), () => {
-
+                dialog.Hide();
                 GameObject.Find("GameManager").GetComponent<GameManagerScript>().RemoveUnlockedQuestions();
                 GameObject.Find("GameManager").GetComponent<GameManagerScript>().NextRound();
-                dialog.Hide();
             });
             dialog.SetOnDecline("", () => dialog.Hide());
             dialog.Show();
@@ -132,8 +131,12 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
     
     private void CreateLeftSpacer(GameObject AnswerLine, float width)
     {
-        GameObject newSpacerLeft = Instantiate(gameObject);     
-        newSpacerLeft.GetComponent<LayoutElement>().preferredWidth = width;
+        GameObject newSpacerLeft = Instantiate(gameObject);
+        if (width < 50f) {
+            newSpacerLeft.GetComponent<LayoutElement>().preferredWidth = 50f;
+        } else {
+            newSpacerLeft.GetComponent<LayoutElement>().preferredWidth = width;
+        }
         newSpacerLeft.name = "LeftDropZone";
         newSpacerLeft.GetComponent<NewDropZoneScript>().LeftmostSpacer = true;
         newSpacerLeft.transform.SetParent(AnswerLine.transform);
@@ -144,7 +147,11 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
     private void CreateRightSpacer(GameObject AnswerLine, float width)
     {
         GameObject newSpacerRight = Instantiate(gameObject);     
-        newSpacerRight.GetComponent<LayoutElement>().preferredWidth = width;
+        if (width < 50f) {
+            newSpacerRight.GetComponent<LayoutElement>().preferredWidth = 50f;
+        } else {
+            newSpacerRight.GetComponent<LayoutElement>().preferredWidth = width;
+        }
         newSpacerRight.name = "RightDropZone";
         newSpacerRight.GetComponent<NewDropZoneScript>().RightmostSpacer = true;
         newSpacerRight.transform.SetParent(AnswerLine.transform);

+ 3 - 3
Assets/Prefab/AnswerlineQuestion.prefab

@@ -141,14 +141,14 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 0.92156863}
+  m_Color: {r: 0.11725702, g: 0.8018868, b: 0.13107431, a: 0.79607844}
   m_RaycastTarget: 1
   m_Maskable: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
-  m_Type: 2
+  m_Type: 1
   m_PreserveAspect: 0
   m_FillCenter: 0
   m_FillMethod: 4
@@ -156,7 +156,7 @@ MonoBehaviour:
   m_FillClockwise: 1
   m_FillOrigin: 0
   m_UseSpriteMesh: 0
-  m_PixelsPerUnitMultiplier: 1
+  m_PixelsPerUnitMultiplier: 0.75
 --- !u!114 &5052258110911877697
 MonoBehaviour:
   m_ObjectHideFlags: 0

+ 12 - 14
Assets/Prefab/StatsLine.prefab

@@ -35,7 +35,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 20}
+  m_SizeDelta: {x: 0, y: 30}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &5385695372056896213
 CanvasRenderer:
@@ -54,17 +54,16 @@ MonoBehaviour:
   m_GameObject: {fileID: 1110996546943796457}
   m_Enabled: 1
   m_EditorHideFlags: 0
-  m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_FontSize: 14
@@ -115,7 +114,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 20}
+  m_SizeDelta: {x: 0, y: 30}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &2579321090774548123
 CanvasRenderer:
@@ -134,17 +133,16 @@ MonoBehaviour:
   m_GameObject: {fileID: 3520506932150161392}
   m_Enabled: 1
   m_EditorHideFlags: 0
-  m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_FontSize: 14
@@ -211,7 +209,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 20}
+  m_SizeDelta: {x: 0, y: 30}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &7830958166291710495
 CanvasRenderer:
@@ -230,17 +228,16 @@ MonoBehaviour:
   m_GameObject: {fileID: 4647862445024647967}
   m_Enabled: 1
   m_EditorHideFlags: 0
-  m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 0.392}
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Type: 1
   m_PreserveAspect: 0
@@ -250,6 +247,7 @@ MonoBehaviour:
   m_FillClockwise: 1
   m_FillOrigin: 0
   m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
 --- !u!114 &3481210091842867662
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -259,12 +257,12 @@ MonoBehaviour:
   m_GameObject: {fileID: 4647862445024647967}
   m_Enabled: 1
   m_EditorHideFlags: 0
-  m_Script: {fileID: -405508275, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
   m_Padding:
     m_Left: 5
-    m_Right: 5
+    m_Right: 10
     m_Top: 0
     m_Bottom: 0
   m_ChildAlignment: 0

+ 21 - 21
Assets/Scenes/narKampen.unity

@@ -414,12 +414,12 @@ RectTransform:
   m_Children:
   - {fileID: 1840953566}
   m_Father: {fileID: 1265518384}
-  m_RootOrder: 3
+  m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 1, y: 1}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: -130, y: 0}
-  m_SizeDelta: {x: 30, y: 30}
+  m_AnchoredPosition: {x: -226, y: 0}
+  m_SizeDelta: {x: 50, y: 50}
   m_Pivot: {x: 1, y: 1}
 --- !u!114 &44609805
 MonoBehaviour:
@@ -1018,7 +1018,7 @@ RectTransform:
   m_AnchorMax: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
-  m_Pivot: {x: 0, y: 0.5}
+  m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &432797765
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -1236,12 +1236,12 @@ RectTransform:
   m_Children:
   - {fileID: 36487288}
   m_Father: {fileID: 1265518384}
-  m_RootOrder: 4
+  m_RootOrder: 3
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 1, y: 1}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: -100, y: 0}
-  m_SizeDelta: {x: 30, y: 30}
+  m_AnchoredPosition: {x: -172.9, y: 0}
+  m_SizeDelta: {x: 50, y: 50}
   m_Pivot: {x: 1, y: 1}
 --- !u!114 &456354910
 MonoBehaviour:
@@ -1575,7 +1575,7 @@ RectTransform:
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 200, y: 30}
+  m_SizeDelta: {x: 250, y: 50}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &705148541
 MonoBehaviour:
@@ -1790,7 +1790,7 @@ MonoBehaviour:
     m_HorizontalOverflow: 0
     m_VerticalOverflow: 0
     m_LineSpacing: 1
-  m_Text: Quit
+  m_Text: Back
 --- !u!222 &877975419
 CanvasRenderer:
   m_ObjectHideFlags: 0
@@ -1978,7 +1978,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 200, y: 30}
+  m_SizeDelta: {x: 200, y: 50}
   m_Pivot: {x: 0, y: 1}
 --- !u!114 &1052864997
 MonoBehaviour:
@@ -2006,7 +2006,7 @@ MonoBehaviour:
     m_BestFit: 1
     m_MinSize: 10
     m_MaxSize: 40
-    m_Alignment: 0
+    m_Alignment: 3
     m_AlignByGeometry: 0
     m_RichText: 1
     m_HorizontalOverflow: 0
@@ -2395,16 +2395,16 @@ RectTransform:
   m_Children:
   - {fileID: 1052864996}
   - {fileID: 705148540}
-  - {fileID: 1848882435}
   - {fileID: 44609804}
   - {fileID: 456354909}
+  - {fileID: 1848882435}
   m_Father: {fileID: 329904626}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 1, y: 1}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 30}
+  m_SizeDelta: {x: 0, y: 50}
   m_Pivot: {x: 0.5, y: 1}
 --- !u!114 &1265518385
 MonoBehaviour:
@@ -2475,7 +2475,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 6ae6755aa613f534c8c5b5481c953a6d, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  quitButton: {fileID: 1848882436}
+  backButton: {fileID: 1848882436}
   loggedInPlayerText: {fileID: 1052864997}
   swedishButton: {fileID: 44609805}
   englishButton: {fileID: 456354910}
@@ -2643,8 +2643,8 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0, y: -15}
-  m_SizeDelta: {x: 0, y: -30}
+  m_AnchoredPosition: {x: 0, y: -25}
+  m_SizeDelta: {x: 0, y: -50}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1287173173
 MonoBehaviour:
@@ -3261,7 +3261,7 @@ GameObject:
   - component: {fileID: 1848882436}
   - component: {fileID: 1848882439}
   m_Layer: 5
-  m_Name: Quit
+  m_Name: BackButton
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
@@ -3280,12 +3280,12 @@ RectTransform:
   m_Children:
   - {fileID: 877975417}
   m_Father: {fileID: 1265518384}
-  m_RootOrder: 2
+  m_RootOrder: 4
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 1, y: 0.5}
   m_AnchorMax: {x: 1, y: 0.5}
-  m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 100, y: 30}
+  m_AnchoredPosition: {x: 0, y: 0.000030517578}
+  m_SizeDelta: {x: 171.59998, y: 49.99997}
   m_Pivot: {x: 1, y: 0.5}
 --- !u!114 &1848882436
 MonoBehaviour:
@@ -3379,7 +3379,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 78e7dcec242b8e54db8994e443fcf679, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  key: QUIT
+  key: BACK
 --- !u!1001 &1868330960
 PrefabInstance:
   m_ObjectHideFlags: 0

+ 1 - 0
Assets/Scripts/Database/OnlineDatabase.cs

@@ -274,6 +274,7 @@ public class OnlineDatabase : MonoBehaviour {
         }
     }
 
+//TODO Försök att ta bort alla utom 1 databas anrop i denna
     internal List<OnlineGameScript> GetOnlineGames(int userId, string userName, GameObject prefab) {
 
         WWWForm formData = new WWWForm();

+ 1 - 1
Assets/Scripts/GameManagerScript.cs

@@ -239,7 +239,7 @@ public class GameManagerScript : MonoBehaviour {
         }
         scrollViewScript.SetAllQuestionsLocked(true);
         scrollViewScript.RemoveEverythingFromAnswerline();
-        NewQuestionCard.GetComponent<NewQuestionCardController>().GenerateNewQuestion();
+        NewQuestionCard.GetComponent<NewQuestionCardController>().GenerateNewQuestion(); // Borde inte behövas
         NextPlayer();
     }
 

+ 1 - 1
Assets/Scripts/MainGame/CategoryPanel.cs

@@ -45,7 +45,7 @@ public class CategoryPanel : MonoBehaviour
         newText.color = color;
         newText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
         newText.resizeTextForBestFit = true;
-        newText.resizeTextMaxSize = 18;
+        newText.resizeTextMaxSize = 40;
         newText.resizeTextMinSize = 8;
 
         newText.alignment = TextAnchor.MiddleCenter;

+ 3 - 3
Assets/Scripts/MainGame/InformationPanelScript.cs

@@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
 
 public class InformationPanelScript : MonoBehaviour
 {
-    public Button quitButton;
+    public Button backButton;
     public Text loggedInPlayerText;
 
     public Button swedishButton;
@@ -18,10 +18,10 @@ public class InformationPanelScript : MonoBehaviour
 
     // Start is called before the first frame update
     void Start() {
-        quitButton.onClick.AddListener(quitButtonAction);
+        backButton.onClick.AddListener(quitButtonAction);
         swedishButton.onClick.AddListener(() => SwitchLanguage(0));
         englishButton.onClick.AddListener(() => SwitchLanguage(1));
-        loggedInPlayerText.text = GameManagerScript.GetCurrentPlayer();
+        loggedInPlayerText.text = Database.Instance.GetSignedInUser().Value;
         if (logoutButton != null) {
             logoutButton.onClick.AddListener(() => {
                 Database.Instance.LogoutUser();

+ 11 - 12
Assets/Scripts/MainGame/ScrollViewScript.cs

@@ -73,7 +73,11 @@ public class ScrollViewScript : MonoBehaviour {
         ldz.transform.SetParent(contentPanel);
         ldz.transform.SetSiblingIndex(i++);
         ldz.transform.localScale = new Vector3(1,1,1);
-        ldz.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
+        if (newQuestionRect.rect.width < 50f) {
+            ldz.GetComponent<LayoutElement>().preferredWidth = 50f;
+        } else {
+            ldz.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
+        }
 
         KeyValuePair<int, string> signedInUser = Database.Instance.GetSignedInUser();
         foreach (NewQuestionData q in questions) {
@@ -110,8 +114,11 @@ public class ScrollViewScript : MonoBehaviour {
         rdz.transform.SetParent(contentPanel);
         rdz.transform.SetSiblingIndex(i);
         rdz.transform.localScale = new Vector3(1,1,1);
-        rdz.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
-
+        if (newQuestionRect.rect.width < 50f) {
+            rdz.GetComponent<LayoutElement>().preferredWidth = 50f;
+        } else {
+            rdz.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
+        }
         SetAllQuestionsLocked(false);
     }
 
@@ -124,20 +131,12 @@ public class ScrollViewScript : MonoBehaviour {
             q.GetComponent<LayoutElement>().preferredHeight = newQuestionRect.rect.height;
         }
 
-        if (questions[0].GetComponent<LayoutElement>().preferredWidth >= 0) {
+        if (questions.Count > 0 && questions[0].GetComponent<LayoutElement>().preferredWidth >= 0) {
             sizeUpdated = true;
         }
     }
 
     public int GetUnlockedQuestionCount() {
-        /*int unlockedQuestionCount = 0;
-        for (int i = 0; i < contentPanel.childCount; i++) {
-            QuestionCard qc = contentPanel.GetChild(i).GetComponent<QuestionCard>();
-            if (!qc.IsQuestionSafe()) {
-                unlockedQuestionCount++;
-            }
-        }
-        */
         return contentPanel.GetComponentsInChildren<QuestionCard>().Where(q => !q.IsQuestionSafe()).ToArray().Length;;
     }
 

BIN
Assets/narKampenLocal.db


+ 2 - 2
ProjectSettings/ProjectSettings.asset

@@ -121,7 +121,7 @@ PlayerSettings:
     16:10: 1
     16:9: 1
     Others: 1
-  bundleVersion: 0.48
+  bundleVersion: 0.49
   preloadedAssets: []
   metroInputSource: 0
   wsaTransparentSwapchain: 0
@@ -167,7 +167,7 @@ PlayerSettings:
   applicationIdentifier:
     Android: se.axelnordh.narkampen
   buildNumber: {}
-  AndroidBundleVersionCode: 18
+  AndroidBundleVersionCode: 19
   AndroidMinSdkVersion: 19
   AndroidTargetSdkVersion: 0
   AndroidPreferredInstallLocation: 1

+ 4 - 4
dbFiles/FCMMessageing.php

@@ -28,7 +28,7 @@
 	
 	if ($messageType === "FCMNextPlayer") {
 		$playerName = $conn->real_escape_string($_POST['playerName']);
-		$token = getToken($gameId, $playerName);
+		$token = getToken($conn, $gameId, $playerName);
 		
 		if ($token != null && $token != "") {
 			sendMessage($httpClient, $token, $title, $messageToSend);
@@ -36,19 +36,19 @@
 	} else if ($messageType === "InviteMessage") {
 		$i = 0;
 		while ($_POST['player' . $i] != null) {
-			$token = getToken($gameId, $conn->real_escape_string($_POST['player' . $i]));
+			$token = getToken($conn, $gameId, $conn->real_escape_string($_POST['player' . $i]));
 			sendMessage($httpClient, $token, $title, $messageToSend);
 		}
 
 	} else if ($messageType === "gameFinishedMessage") {
 		$i = 0;
 		while ($_POST['player' . $i] != null) {
-			$token = getToken($gameId, $conn->real_escape_string($_POST['player' . $i]));
+			$token = getToken($conn, $gameId, $conn->real_escape_string($_POST['player' . $i]));
 			sendMessage($httpClient, $token, $title, $messageToSend);
 		}
 	}
 	
-	function getToken($gameId, $playerName) {
+	function getToken($conn, $gameId, $playerName) {
 		$sql = "SELECT messageToken FROM `gamePlayers` INNER JOIN users ON users.id = playerId WHERE gameId = $gameId and users.username = '$playerName'";
 
 		$result = $conn->query($sql);

+ 7 - 3
dbFiles/NewOnlineGame.php

@@ -72,9 +72,13 @@
 	}
 
 	$categoryValues = "";
-	$categoryIdsArray = explode(",", $categoryIds);
-	foreach ($categoryIdsArray AS $catId) {
-		$categoryValues .= "($gameId, $catId),";
+	if (empty($categoryIds)) {
+		$categoryValues = "(SELECT $gameId, id FROM category)";
+	} else {
+		$categoryIdsArray = explode(",", $categoryIds);
+		foreach ($categoryIdsArray AS $catId) {
+			$categoryValues .= "($gameId, $catId),";
+		}
 	}
 	$categoryValues = rtrim($categoryValues, ",");
 	$categorySql = "INSERT INTO gameCategories(gameId, categoryId) VALUES $categoryValues";

+ 4 - 4
dbFiles/OnlineGames.php

@@ -18,10 +18,10 @@
 	$userId = $conn->query("SELECT id FROM users where username = '$userName'")->fetch_assoc()['id'];
 	
 	if ($callFunction === "list"){	
-		$sql = "SELECT game.*, users.username as playerToAct FROM game " +
-				"LEFT JOIN users on currentPlayer = users.id " +
-				"WHERE game.id IN (SELECT gameId FROM gamePlayers WHERE playerId = $userId) " + 
-				"AND game.status != 'FINISHED' "+
+		$sql = "SELECT game.*, users.username as playerToAct FROM game " .
+				"LEFT JOIN users on currentPlayer = users.id " .
+				"WHERE game.id IN (SELECT gameId FROM gamePlayers WHERE playerId = $userId) " .
+				"AND game.status != 'FINISHED' ".
 				"ORDER BY FIELD(PlayerToAct, '$userName') DESC, lastPlayedDate DESC";
 		$result = $conn->query($sql);