manueldidonna / pokemon-save-editor-android

A work-in-progress pokémon save editor for Android
GNU General Public License v3.0
0 stars 0 forks source link

Support Pokérus #6

Closed manueldidonna closed 4 years ago

manueldidonna commented 4 years ago

Pokerus has been introduced in Gen 2 games. See #2

Pokerus info is stored in a byte. The upper 4 bits of the byte represent the specific strain of the Pokérus. The lower 4 bits represent the number of days remaining before the infected Pokémon is cured of the virus.


data class Pokerus (val strain: Int, val days: Int) {
    val isCured: Boolean = strain != 0 && days == 0

    companion object {
        val StrainValues: IntRange = 1..15 // 0 means never infected
        fun maxAllowedDays(strain: Int): Int = strain rem 4 + 1
        val NeverInfected = Pokerus(strain = 0, days = 0)
    }
}

interface Pokemon {
    val pokerus: Pokerus
}

interface Mutator {
    fun pokerus(value: Pokerus): Mutator
}