feat(game): stub wild battle flow with catch, bag, switching, field state, and flee

This commit is contained in:
Fiereu committed 2026-07-19 22:35:04 +02:00
1 parent 9732c9373c
commit d618cff20e
92 files changed
+1499 -272

No files matched your search

@@ -8,6 +8,7 @@ import java.time.LocalDateTime
data class Pokemon(
val id: Long,
val ownerId: Long,
val container: PokemonContainer,
val containerSlot: Short,
val dexId: Int,
@@ -26,9 +27,13 @@ data class Pokemon(
val isSecret: Boolean,
val isFatefulEncounter: Boolean,
val isRaidEncounter: Boolean,
val caughtAt: LocalDateTime
val caughtAt: LocalDateTime,
val isEgg: Boolean = false
) {
val nature: PokemonNature = PokemonNature.entries[seed % PokemonNature.entries.size]
// seed is an unsigned 32-bit value on the wire, so mask before the modulo to avoid a negative
// index when the high bit is set.
val nature: PokemonNature =
PokemonNature.entries[((seed.toLong() and 0xFFFFFFFFL) % PokemonNature.entries.size).toInt()]
init {
require(moves.size <= 4) { "A Pokemon can't have more than 4 moves" }
@@ -0,0 +1,13 @@
package de.fiereu.openmmo.common.enums
/** A player's battle-turn choice. */
enum class BattleAction(val id: Byte) {
MOVE(0),
ITEM(1),
SWITCH(2),
RUN(3);
companion object {
fun fromId(id: Byte): BattleAction? = entries.firstOrNull { it.id == id }
}
}
@@ -0,0 +1,15 @@
package de.fiereu.openmmo.common.enums
/** A rarity trait packed into a monster's flag short, one trait per bit. */
enum class PokemonRarityFlag(val bit: Int) {
SHINY(0),
HIDDEN_ABILITY(1),
ALPHA(2),
SECRET_SHINY(3),
FATEFUL_ENCOUNTER(4),
RAID_ENCOUNTER(5);
val mask: Int = 1 shl bit
fun isSet(bits: Int): Boolean = (bits and mask) != 0
}