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

Pokedex: bulk operations #5

Closed manueldidonna closed 3 years ago

manueldidonna commented 4 years ago
// to catch all -> pokedex.catch(species = 1..pokemonCounts)
fun Pokedex.catch(species: IntRange) {
    val reusableEntry = object : Pokedex.Entry {
        override val isSeen: Boolean = true
        override val isOwned: Boolean = true
        override var speciesId: Int = 0
    }
    for (i in species) {
        reusableEntry.speciesId = i
        setEntry(reusableEntry)
    }
}

// to see all -> pokedex.see(species = 1..pokemonCounts)
fun Pokedex.see(species: IntRange) {
    val reusableEntry = object : Pokedex.Entry {
        override val isSeen: Boolean = true
        override var isOwned: Boolean = false
        override var speciesId: Int = 0
    }
    for (i in species) {
        reusableEntry.speciesId = i
        reusableEntry.isOwned = getEntry(i).isOwned
        setEntry(reusableEntry)
    }
}