Fix: hand cards use ContentCache def for full art + stats
CardInstanceDto lacks the `assets` array, so card art never loaded. Look up the full CardDefinitionDto from ContentCache (which has assets, genus, abilitiesJson, and all base stats) and pass it as the `def` argument to widget.setup(). Also remove the old "compact" code that was hiding the stats grid and shrinking the art area — the full CardWidget now shows as intended. Field alias retained: maxMp → movementPoints for CardWidget._load_stats. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -2280,26 +2280,24 @@ func _rebuild_hand(hand: Array) -> void:
|
||||
|
||||
|
||||
func _make_hand_card(card: Dictionary) -> Control:
|
||||
var iid : String = card.get("instanceId", "")
|
||||
var iid : String = card.get("instanceId", "")
|
||||
var def_id : String = str(card.get("cardDefinitionId", ""))
|
||||
|
||||
# Instantiate the shared CardWidget scene used by the collection UI.
|
||||
# Build a def dict from the live card data. CardWidget reads "movementPoints"
|
||||
# but the CardInstanceDto field is "maxMp", so alias it here.
|
||||
var widget : PanelContainer = _CARD_WIDGET_SCENE.instantiate()
|
||||
widget.set_meta("card_instance_id", iid)
|
||||
var def := card.duplicate()
|
||||
def["movementPoints"] = card.get("maxMp", null)
|
||||
widget.setup(card, def)
|
||||
|
||||
# Compact the card for the hand area: shrink art and hide the detailed
|
||||
# stats grid (HP/ATK/DEF/MP/range). Name, SP/ST cost, genus, and type
|
||||
# remain visible; long-press context popup shows full unit stats.
|
||||
var art_area := widget.get_node_or_null("Margin/VBox/ArtArea")
|
||||
if art_area is Control:
|
||||
(art_area as Control).custom_minimum_size = Vector2(0, 80)
|
||||
var stats_grid := widget.get_node_or_null("Margin/VBox/StatsGrid")
|
||||
if stats_grid is CanvasItem:
|
||||
(stats_grid as CanvasItem).visible = false
|
||||
# Use the full CardDefinitionDto from ContentCache so CardWidget gets the
|
||||
# assets array (Art2D cdnUrl) and can load card art. Fall back to the
|
||||
# instance data if the definition hasn't been synced yet.
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
if def.is_empty():
|
||||
def = card.duplicate()
|
||||
|
||||
# CardWidget._load_stats reads "movementPoints"; the CardInstanceDto calls
|
||||
# it "maxMp", so alias it into the def dict before passing.
|
||||
def["movementPoints"] = card.get("maxMp", def.get("movementPoints", null))
|
||||
|
||||
widget.setup(card, def)
|
||||
|
||||
# CardWidget emits card_pressed(definition_id); forward as hand-card click.
|
||||
widget.card_pressed.connect(func(_def_id: String) -> void:
|
||||
|
||||
Reference in New Issue
Block a user