diff --git a/unity-client/Assets/Scripts/Animation/CardController.cs b/unity-client/Assets/Scripts/Animation/CardController.cs index b7f9783..41896de 100644 --- a/unity-client/Assets/Scripts/Animation/CardController.cs +++ b/unity-client/Assets/Scripts/Animation/CardController.cs @@ -94,8 +94,8 @@ namespace CommanderAILab.Animation frontFaceImage.sprite = lowResPlaceholder; // Async load high-res from Scryfall - if (!string.IsNullOrEmpty(card.imageUrl)) - ImageCache.Instance.GetSprite(card.imageUrl, sprite => + if (!string.IsNullOrEmpty(card.imageUri)) + ImageCache.Instance.GetSprite(card.imageUri, sprite => { if (frontFaceImage != null) frontFaceImage.sprite = sprite; }); diff --git a/unity-client/Assets/Scripts/Models/CardModel.cs b/unity-client/Assets/Scripts/Models/CardModel.cs index c081b4c..3af49da 100644 --- a/unity-client/Assets/Scripts/Models/CardModel.cs +++ b/unity-client/Assets/Scripts/Models/CardModel.cs @@ -11,6 +11,7 @@ namespace CommanderAILab.Models [Serializable] public class CardModel { + [JsonProperty("id")] public string id; [JsonProperty("name")] public string name; [JsonProperty("oracle_id")] public string oracleId; [JsonProperty("scryfall_id")] public string scryfallId; diff --git a/unity-client/Assets/Scripts/Models/PreconListWrapper.cs b/unity-client/Assets/Scripts/Models/PreconListWrapper.cs new file mode 100644 index 0000000..5e7fa15 --- /dev/null +++ b/unity-client/Assets/Scripts/Models/PreconListWrapper.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace CommanderAILab.Models +{ + /// Wrapper for the precon list returned by /api/lab/precons. + [Serializable] + public class PreconListWrapper + { + [JsonProperty("precons")] public List precons; + } +} diff --git a/unity-client/Assets/Scripts/UI/CoachController.cs b/unity-client/Assets/Scripts/UI/CoachController.cs index 00e9456..c60e26c 100644 --- a/unity-client/Assets/Scripts/UI/CoachController.cs +++ b/unity-client/Assets/Scripts/UI/CoachController.cs @@ -395,7 +395,7 @@ namespace CommanderAILab.UI }; string body = JsonConvert.SerializeObject(payload); - StartCoroutine(ApiClient.Instance.PostRaw("/api/coach/chat", body, + ApiClient.Instance.PostRaw("/api/coach/chat", body, json => { _isWaiting = false; @@ -416,7 +416,7 @@ namespace CommanderAILab.UI sendButton.interactable = true; typingIndicator.gameObject.SetActive(false); ShowError($"Chat failed: {err}"); - })); + }); } private void AddUserBubble(string text) @@ -532,14 +532,14 @@ namespace CommanderAILab.UI preconCompareText.text = "Refreshing precon database..."; string body = JsonConvert.SerializeObject(new { }); - StartCoroutine(ApiClient.Instance.PostRaw("/api/lab/precons/refresh", body, + ApiClient.Instance.PostRaw("/api/lab/precons/refresh", body, json => { if (preconCompareText != null) preconCompareText.text = "Precon database refreshed!"; LoadPrecons(); }, - err => ShowError($"Precon refresh failed: {err}"))); + err => ShowError($"Precon refresh failed: {err}")); } // ── Export to Simulator ─────────────────────────────────────── diff --git a/unity-client/Assets/Scripts/UI/CollectionController.cs b/unity-client/Assets/Scripts/UI/CollectionController.cs index f020a01..d8233a6 100644 --- a/unity-client/Assets/Scripts/UI/CollectionController.cs +++ b/unity-client/Assets/Scripts/UI/CollectionController.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Text; using UnityEngine; +using UnityEngine.Networking; using UnityEngine.UI; using UnityEngine.SceneManagement; using TMPro; @@ -184,9 +185,9 @@ namespace CommanderAILab.UI _sortField = SortFieldFromDropdown(sortDropdown.value); string path = BuildQueryPath(page); - StartCoroutine(ApiClient.Instance.GetRaw(path, + ApiClient.Instance.GetRaw(path, json => OnPageLoaded(json, page), - errMsg => OnLoadError(errMsg))); + errMsg => OnLoadError(errMsg)); } private string BuildQueryPath(int page) @@ -257,9 +258,9 @@ namespace CommanderAILab.UI // Async image load var img = tile.GetComponentInChildren(); - if (img != null && !string.IsNullOrEmpty(card.imageUrl)) + if (img != null && !string.IsNullOrEmpty(card.imageUri)) { - ImageCache.Instance.GetSprite(card.imageUrl, sprite => + ImageCache.Instance.GetSprite(card.imageUri, sprite => { if (img != null) img.sprite = sprite; }); @@ -297,9 +298,9 @@ namespace CommanderAILab.UI detailQuantity.text = $"Owned: {card.ownedQty}"; // Load card art on front face - if (!string.IsNullOrEmpty(card.imageUrl)) + if (!string.IsNullOrEmpty(card.imageUri)) { - ImageCache.Instance.GetSprite(card.imageUrl, sprite => + ImageCache.Instance.GetSprite(card.imageUri, sprite => { if (detailCardFront != null) detailCardFront.sprite = sprite; }); diff --git a/unity-client/Assets/Scripts/UI/DeckBuilderController.cs b/unity-client/Assets/Scripts/UI/DeckBuilderController.cs index 630901d..fd9cd92 100644 --- a/unity-client/Assets/Scripts/UI/DeckBuilderController.cs +++ b/unity-client/Assets/Scripts/UI/DeckBuilderController.cs @@ -266,9 +266,9 @@ namespace CommanderAILab.UI if (!string.IsNullOrEmpty(color)) path += $"&colors={UnityWebRequest.EscapeURL(color)}"; - StartCoroutine(ApiClient.Instance.GetRaw(path, + ApiClient.Instance.GetRaw(path, json => PopulateCommanderResults(json), - err => ShowError($"Commander search failed:\n{err}"))); + err => ShowError($"Commander search failed:\n{err}")); } private void PopulateCommanderResults(string json) @@ -300,7 +300,7 @@ namespace CommanderAILab.UI { _commander = card; selectedCommanderText.text = $"Commander: {card.name}"; - if (_activeDeck != null) _activeDeck.commanderName = card.name; + if (_activeDeck != null) _activeDeck.commander = card.name; _isDirty = true; } @@ -322,17 +322,17 @@ namespace CommanderAILab.UI _activeDeck.cards = _deckCards; string json = JsonConvert.SerializeObject(_activeDeck); string path = $"/api/decks/{_activeDeck.id}"; - StartCoroutine(ApiClient.Instance.PatchRaw(path, json, + ApiClient.Instance.PatchRaw(path, json, _ => { _isDirty = false; LoadDecks(); }, - err => ShowError($"Save failed:\n{err}"))); + err => ShowError($"Save failed:\n{err}")); } private void OnDeleteDeck() { if (_activeDeck == null) return; - StartCoroutine(ApiClient.Instance.Delete($"/api/decks/{_activeDeck.id}", + ApiClient.Instance.Delete($"/api/decks/{_activeDeck.id}", _ => { _activeDeck = null; _deckCards.Clear(); LoadDecks(); }, - err => ShowError($"Delete failed:\n{err}"))); + err => ShowError($"Delete failed:\n{err}")); } // ── Charts ──────────────────────────────────────────────────────────── diff --git a/unity-client/Assets/Scripts/UI/DeckGeneratorController.cs b/unity-client/Assets/Scripts/UI/DeckGeneratorController.cs index 78049ab..ecbe1b5 100644 --- a/unity-client/Assets/Scripts/UI/DeckGeneratorController.cs +++ b/unity-client/Assets/Scripts/UI/DeckGeneratorController.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Networking; using UnityEngine.UI; using UnityEngine.SceneManagement; using TMPro; @@ -114,9 +115,9 @@ namespace CommanderAILab.UI string q = commanderSearchInput.text.Trim(); if (string.IsNullOrEmpty(q)) return; string path = $"/api/collection?search={UnityWebRequest.EscapeURL(q)}&type=Legendary+Creature&per_page=20"; - StartCoroutine(ApiClient.Instance.GetRaw(path, + ApiClient.Instance.GetRaw(path, json => PopulateCommanderResults(json), - err => ShowError($"Commander search failed:\n{err}"))); + err => ShowError($"Commander search failed:\n{err}")); } private void PopulateCommanderResults(string json) diff --git a/unity-client/Assets/Scripts/UI/PreconController.cs b/unity-client/Assets/Scripts/UI/PreconController.cs index cd4d75b..a87bfe9 100644 --- a/unity-client/Assets/Scripts/UI/PreconController.cs +++ b/unity-client/Assets/Scripts/UI/PreconController.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Networking; using UnityEngine.UI; using UnityEngine.SceneManagement; using TMPro; @@ -77,7 +78,7 @@ namespace CommanderAILab.UI public string colorIdentity; public int cardCount; public string theme; - public string imageUrl; + public string imageUri; } [Serializable] @@ -246,11 +247,11 @@ namespace CommanderAILab.UI btn.onClick.AddListener(() => ShowDetail(captured)); // Load commander image async - if (!string.IsNullOrEmpty(precon.imageUrl)) + if (!string.IsNullOrEmpty(precon.imageUri)) { var img = card.GetComponentInChildren(); if (img != null) - StartCoroutine(LoadImageAsync(precon.imageUrl, img)); + StartCoroutine(LoadImageAsync(precon.imageUri, img)); } } @@ -287,8 +288,8 @@ namespace CommanderAILab.UI detailInstallButton.GetComponentInChildren().text = installed ? "Installed" : "Install to Forge"; - if (!string.IsNullOrEmpty(precon.imageUrl)) - StartCoroutine(LoadImageAsync(precon.imageUrl, detailCommanderImage)); + if (!string.IsNullOrEmpty(precon.imageUri)) + StartCoroutine(LoadImageAsync(precon.imageUri, detailCommanderImage)); } // ======================================================== diff --git a/unity-client/Assets/Scripts/UI/ScannerController.cs b/unity-client/Assets/Scripts/UI/ScannerController.cs index a9b3943..fb99684 100644 --- a/unity-client/Assets/Scripts/UI/ScannerController.cs +++ b/unity-client/Assets/Scripts/UI/ScannerController.cs @@ -292,8 +292,8 @@ namespace CommanderAILab.UI resultSet.text = card.set; resultOracleText.text = card.oracleText; resultConfidence.text = $"Confidence: {confidence:P0}"; - if (!string.IsNullOrEmpty(card.imageUrl)) - ImageCache.Instance.GetSprite(card.imageUrl, s => { if (resultCardImage != null) resultCardImage.sprite = s; }); + if (!string.IsNullOrEmpty(card.imageUri)) + ImageCache.Instance.GetSprite(card.imageUri, s => { if (resultCardImage != null) resultCardImage.sprite = s; }); AddToHistory(card); } @@ -320,9 +320,9 @@ namespace CommanderAILab.UI { if (_scannedCard == null) return; var body = JsonConvert.SerializeObject(new { card_id = _scannedCard.id, qty = 1 }); - StartCoroutine(ApiClient.Instance.PostRaw("/api/collection/add", body, + ApiClient.Instance.PostRaw("/api/collection/add", body, _ => cameraStatusText.text = $"Added {_scannedCard.name} to collection", - err => ShowError($"Add to collection failed:\n{err}"))); + err => ShowError($"Add to collection failed:\n{err}")); } private void OnAddToDeck()