All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.elderscrollslegends.Card.kt Maven / Gradle / Ivy

Go to download

A java wrapper around the Elder Scrolls: Legends API of https://elderscrollslegends.io

The newest version!
package io.elderscrollslegends

import com.fasterxml.jackson.annotation.JsonProperty

data class Card(
    val name: String,
    val rarity: String = "",
    val type: String = "",
    val subtypes: List = emptyList(),
    val cost: Int = -1,
    val power: Int = -1,
    val health: Int = -1,
    val set: CardSet = CardSet(),
    val collectible: Boolean = false,
    val soulSummon: String = "",
    val soulTrap: String = "",
    val text: String = "",
    val attributes: List = emptyList(),
    val keywords: List = emptyList(),
    val unique: Boolean = true,
    val imageUrl: String = "",
    val id: String = ""
) {
    companion object {
        private val queryBuilder = QueryBuilder()
        private const val RESOURCE_NAME = "cards"

        @JvmStatic
        fun all(): List {
            return where(emptyMap())
        }

        @JvmStatic
        fun find(id: String): Card? {
            return queryBuilder.find(resource = RESOURCE_NAME, id = id, cls = CardSingle::class.java)?.card
        }

        @JvmStatic
        fun where(predicates: Map): List {
            return queryBuilder.where(resource = RESOURCE_NAME, cls = Cards::class.java, predicates = predicates) { cards, cardList ->
                cardList.addAll(cards?.cards ?: emptyList())
            }
        }
    }
}

data class Cards(
    val cards: List,

    @JsonProperty("_pageSize")
    override val pageSize: Int,
    @JsonProperty("_totalCount")
    override val totalCount: Int
) : ResultCounters(pageSize, totalCount)

data class CardSingle(
    val card: Card
)

data class CardSet(
    val name: String = "",
    val id: String = "",
    @JsonProperty("_self")
    val self: String = ""
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy