Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jacobsapps/811b27731d38812940a24d39548f6b3b to your computer and use it in GitHub Desktop.

Select an option

Save jacobsapps/811b27731d38812940a24d39548f6b3b to your computer and use it in GitHub Desktop.
extension CardEntity {
func toCard() -> Card? {
// eagerly create UIImage from the data
guard let image = UIImage(data: imageData) else { return nil }
let cardStats = CardStats(
title: title,
type: ElementalType(emoji: emoji, hexClor: hexColor),
stats: stats.map { Stat(name: $0.name, value: $0.value) },
rarity: Rarity(rawValue: rarity) ?? .rare
)
return Card(id: id, image: image, stats: cardStats, createdAt: createdAt)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment