fix(unity): resolve all 32 C# compilation errors

- CardModel: add missing `id` field
- CardModel: `imageUrl` → `imageUri` (match JSON property name)
- DeckModel: `commanderName` → `commander` (match JSON property name)
- PreconDeck: `imageUrl` → `imageUri`
- Add missing `PreconListWrapper` model class
- Add `using UnityEngine.Networking` to CollectionController,
  DeckGeneratorController, PreconController
- Remove double StartCoroutine() wrapping on ApiClient calls
  (GetRaw/PatchRaw/Delete/PostRaw already return Coroutine)
  Affected: CollectionController, DeckBuilderController,
  DeckGeneratorController, ScannerController, CoachController
This commit is contained in:
KoalaTrapLord committed 2026-03-19 05:13:00 +00:00
1 parent 2d8a55fdc6
commit a501a9755d
9 files changed
+47 -30

No files matched your search

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