package de.ladkau.deckinadash.ui

import android.content.Context
import androidx.annotation.DrawableRes

/**
 * Resolves a card slug (e.g. "fool", "wheel_of_fortune" - the same
 * strings engine/src/tarot_data.c's tarot_card_slug() returns) to its
 * generated drawable resource, produced by ../../scripts/gen_card_images.py
 * into res/drawable-nodpi/<slug>.webp at build time - see that script's
 * own comment. Slugs are already valid Android resource-name identifiers,
 * so no separate mapping table is needed, only a runtime resource lookup
 * (the resource ID isn't known at compile time from this module, since
 * the drawables are generated, not committed).
 */
@DrawableRes
fun cardDrawableRes(context: Context, cardSlug: String): Int {
    val id = context.resources.getIdentifier(cardSlug, "drawable", context.packageName)
    return if (id != 0) id else android.R.drawable.ic_menu_report_image
}
