From 6014f5d2735063509bdb536d35868a0a4c2051b7 Mon Sep 17 00:00:00 2001 From: Drew Heavner Date: Tue, 6 Feb 2018 10:56:38 -0500 Subject: [PATCH] Added missing 'Ability' field to the card model object --- README.md | 5 +++-- build.gradle | 2 +- gradle.properties | 2 +- .../kotlin/io/pokemontcg/internal/api/ModelMapper.kt | 8 +++++++- .../main/kotlin/io/pokemontcg/internal/api/models.kt | 10 +++++++++- library/src/main/kotlin/io/pokemontcg/model/Ability.kt | 8 ++++++++ library/src/main/kotlin/io/pokemontcg/model/Card.kt | 3 ++- 7 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 library/src/main/kotlin/io/pokemontcg/model/Ability.kt diff --git a/README.md b/README.md index daf9874..0fbf993 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,12 @@ This is the Pokémon TCG SDK Kotlin implementation. It is a wrapper around the Pokémon TCG API of [pokemontcg.io](http://pokemontcg.io) -## Installation +## Installation [![Download](https://api.bintray.com/packages/r0adkll/pokemon-tcg-sdk-kotlin/pokemon-tcg-sdk-kotlin/images/download.svg) ](https://bintray.com/r0adkll/pokemon-tcg-sdk-kotlin/pokemon-tcg-sdk-kotlin/_latestVersion) + Add this line to your `dependencies {...}` block in your `build.gradle` file ```groovy -compile 'io.pokemontcg:pokemon-tcg-sdk-kotlin:1.0.8' +compile 'io.pokemontcg:pokemon-tcg-sdk-kotlin:{latest}' ``` ## Usage diff --git a/build.gradle b/build.gradle index 1fd65e2..c7c8929 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ apply from: 'tools/dependencies.gradle' buildscript { - ext.kotlin_version = '1.1.51' + ext.kotlin_version = '1.2.21' repositories { google() jcenter() diff --git a/gradle.properties b/gradle.properties index 7ed7a05..52b7d9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1536m GROUP=io.pokemontcg -VERSION_NAME=1.0.8 +VERSION_NAME=1.0.9 VERSION_DESC="Kotlin PokemonTCG SDK" POM_YEAR=2017 diff --git a/library/src/main/kotlin/io/pokemontcg/internal/api/ModelMapper.kt b/library/src/main/kotlin/io/pokemontcg/internal/api/ModelMapper.kt index b1aa72b..459ce76 100644 --- a/library/src/main/kotlin/io/pokemontcg/internal/api/ModelMapper.kt +++ b/library/src/main/kotlin/io/pokemontcg/internal/api/ModelMapper.kt @@ -28,11 +28,17 @@ internal object ModelMapper { model.text, model.attacks?.map { to(it) }, model.weaknesses?.map { to(it) }, - model.resistances?.map { to(it) } + model.resistances?.map { to(it) }, + model.ability?.let { to(it) } ) } + fun to(model: AbilityModel): Ability { + return Ability(model.name, model.text, model.type) + } + + fun to(model: AttackModel): Attack { return Attack( model.cost?.map { Type.find(it) }, diff --git a/library/src/main/kotlin/io/pokemontcg/internal/api/models.kt b/library/src/main/kotlin/io/pokemontcg/internal/api/models.kt index 4de0753..a223a1b 100644 --- a/library/src/main/kotlin/io/pokemontcg/internal/api/models.kt +++ b/library/src/main/kotlin/io/pokemontcg/internal/api/models.kt @@ -33,7 +33,8 @@ internal class CardModel( val text: List?, val attacks: List?, val weaknesses: List?, - val resistances: List? + val resistances: List?, + val ability: AbilityModel? ) @@ -51,6 +52,13 @@ internal class CardSetModel( ) +internal class AbilityModel( + val name: String, + val text: String, + val type: String +) + + internal class AttackModel( val cost: List?, val name: String, diff --git a/library/src/main/kotlin/io/pokemontcg/model/Ability.kt b/library/src/main/kotlin/io/pokemontcg/model/Ability.kt new file mode 100644 index 0000000..df5b766 --- /dev/null +++ b/library/src/main/kotlin/io/pokemontcg/model/Ability.kt @@ -0,0 +1,8 @@ +package io.pokemontcg.model + + +data class Ability( + val name: String, + val text: String, + val type: String +) \ No newline at end of file diff --git a/library/src/main/kotlin/io/pokemontcg/model/Card.kt b/library/src/main/kotlin/io/pokemontcg/model/Card.kt index 6dd63db..642344a 100644 --- a/library/src/main/kotlin/io/pokemontcg/model/Card.kt +++ b/library/src/main/kotlin/io/pokemontcg/model/Card.kt @@ -22,5 +22,6 @@ data class Card( val text: List?, val attacks: List?, val weaknesses: List?, - val resistances: List? + val resistances: List?, + val ability: Ability? ) \ No newline at end of file