io.github.pidoveproject.showdown.battle.decoder.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-showdown-api_3 Show documentation
Show all versions of scala-showdown-api_3 Show documentation
A Scala wrapper of Pokemon Showdown's API
The newest version!
package io.github.pidoveproject.showdown.battle
import io.github.pidoveproject.showdown.protocol.MessageDecoder
import zio.json.JsonDecoder
given MessageDecoder[PlayerNumber] = MessageDecoder.string.mapEither(PlayerNumber.fromString)
given JsonDecoder[PlayerNumber] = JsonDecoder.string.mapOrFail(PlayerNumber.fromString(_).left.map(_.getMessage))
given MessageDecoder[PokemonSlot] = MessageDecoder.char.mapEither(PokemonSlot.fromCode)
given MessageDecoder[Health] = MessageDecoder.string.mapEither(Health.fromString)