generated from y9vad9/kotlin-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.2.0: Type-safe battles, Brawlify Stats API support, bug fixes (#9)
* fix (closes #4): `createOr` now uses CreationFailure in its lambda * feat: type-safe battles (closes #8) * feat: add support for showdown matches (closes #6), add support for friendly matches (closes #5), add support for map-maker (closes #7) * fix: unnecessary macos system usage * feat: added ability to change the base url of brawl stars API client
- Loading branch information
Showing
44 changed files
with
2,846 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
|
||
jobs: | ||
build: | ||
runs-on: macos-latest | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
brawlify/src/commonMain/kotlin/com/y9vad9/brawlifyapi/types/stats/BrawlifyTeamStat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.y9vad9.brawlifyapi.types.stats | ||
|
||
import com.y9vad9.brawlifyapi.types.common.value.BrawlifyHash | ||
import com.y9vad9.brawlifyapi.types.common.value.BrawlifyRate | ||
import com.y9vad9.bsapi.types.brawler.value.BrawlerId | ||
import com.y9vad9.bsapi.types.common.value.Count | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.Transient | ||
|
||
@Serializable | ||
public data class BrawlifyTeamStat( | ||
val name: BrawlifyBrawlerStat, | ||
val hash: BrawlifyHash, | ||
val brawler1: BrawlerId, | ||
val brawler2: BrawlerId, | ||
val brawler3: BrawlerId? = null, | ||
val brawler4: BrawlerId? = null, | ||
val brawler5: BrawlerId? = null, | ||
val data: Data, | ||
) { | ||
@Transient | ||
public val brawlers: List<BrawlerId> = listOfNotNull(brawler1, brawler2, brawler3, brawler4, brawler5) | ||
|
||
@Serializable | ||
public data class Data( | ||
val winRate: BrawlifyRate, | ||
val useRate: BrawlifyRate, | ||
val wins: Count, | ||
val losses: Count, | ||
val draws: Count, | ||
val total: Count, | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
brawlify/src/commonMain/kotlin/com/y9vad9/brawlifyapi/types/stats/value/BrawlifyTeamName.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.y9vad9.brawlifyapi.types.stats.value | ||
|
||
import com.y9vad9.bsapi.types.ValueConstructor | ||
import com.y9vad9.bsapi.types.exception.CreationFailure | ||
import kotlinx.serialization.Serializable | ||
import kotlin.jvm.JvmInline | ||
|
||
@Serializable | ||
@JvmInline | ||
public value class BrawlifyTeamName private constructor(public val raw: String) { | ||
public companion object : ValueConstructor<BrawlifyTeamName, String> { | ||
override fun create(value: String): Result<BrawlifyTeamName> { | ||
if (value.isBlank()) return Result.failure(CreationFailure.ofBlank()) | ||
return Result.success(BrawlifyTeamName(value)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/src/commonMain/kotlin/com/y9vad9/bsapi/internal/EntityTagSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.y9vad9.bsapi.internal | ||
|
||
import com.y9vad9.bsapi.types.ValueConstructor | ||
import com.y9vad9.bsapi.types.createUnsafe | ||
import com.y9vad9.bsapi.types.player.value.BotTag | ||
import com.y9vad9.bsapi.types.player.value.EntityTag | ||
import com.y9vad9.bsapi.types.player.value.PlayerTag | ||
import com.y9vad9.bsapi.types.player.value.withHashTag | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
internal object EntityTagSerializer : KSerializer<EntityTag> { | ||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("EntityTag", PrimitiveKind.STRING) | ||
|
||
@OptIn(ValueConstructor.Unsafe::class) | ||
override fun deserialize(decoder: Decoder): EntityTag { | ||
val value = decoder.decodeString().replace("#", "") | ||
|
||
return when (value.length) { | ||
// bot's tags are 3 symbols (or four if with hashtag) | ||
3 -> BotTag.createUnsafe(value) | ||
else -> PlayerTag.createUnsafe(value) | ||
} | ||
} | ||
|
||
override fun serialize(encoder: Encoder, value: EntityTag) { | ||
encoder.encodeString(value.withHashTag) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.