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:
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;
|
||||
|
||||
// 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;
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
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 ───────────────────────────────────────
|
||||
|
||||
@@ -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<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;
|
||||
});
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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 ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<Image>();
|
||||
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 =
|
||||
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));
|
||||
}
|
||||
|
||||
// ========================================================
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user