Fixed soft locking after a switch event

This commit is contained in:
JazzMcNade committed 2024-03-09 18:01:49 -06:00
1 parent adcccfee02
commit 01ac831c24
2 files changed
+14 -16

No files matched your search

@@ -22,22 +22,9 @@ class SingleActionRequest(
val singleActionRequests = mutableListOf<SingleActionRequest>()
singleActionRequests.addAll(
request.iterate(actor.activePokemon) { targetable, moveSet, forceSwitch ->
val singleRequest = SingleActionRequest(targetable, request.side, moveSet, forceSwitch, !request.noCancel)
// Known quirk of Showdown. It'll ask for actions on fainted slots
// Also during a forced switch in doubles/triples it'll ask for actions on non-switching slots
// Need to find better place to fix this
// Probably should find a way to fix this serverside so clients don't
// need to deal with this silliness.
val pokemon = request.side?.pokemon?.firstOrNull {
it.uuid == targetable.battlePokemon?.uuid
}
if((pokemon != null && pokemon.condition.contains("fnt")) || (moveSet == null && !forceSwitch)) {
singleRequest.response = PassActionResponse
}
singleRequest
SingleActionRequest(targetable, request.side, moveSet, forceSwitch, !request.noCancel)
}
)
return singleActionRequests
}
}
@@ -8,6 +8,7 @@
package com.cobblemon.mod.common.client.gui.battle
import com.cobblemon.mod.common.battles.PassActionResponse
import com.cobblemon.mod.common.battles.ShowdownActionResponse
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.client.battle.ClientBattleActor
@@ -130,11 +131,21 @@ class BattleGUI : Screen(battleLang("gui.title")) {
queuedActions.clear()
}
fun deriveRootActionSelection(actor: ClientBattleActor, request: SingleActionRequest): BattleActionSelection {
fun deriveRootActionSelection(actor: ClientBattleActor, request: SingleActionRequest): BattleActionSelection? {
return if (request.forceSwitch) {
BattleSwitchPokemonSelection(this, request)
} else {
BattleGeneralActionSelection(this, request)
// Known quirk of Showdown. It'll ask for actions on fainted slots
// Also during a forced switch in doubles/triples it'll ask for actions on non-switching slots
val pokemon = request.side?.pokemon?.firstOrNull { it.uuid === request.activePokemon.battlePokemon?.uuid }
if((pokemon != null && pokemon.condition.contains("fnt")) || (request.moveSet == null)) {
request.response = PassActionResponse
null
} else {
BattleGeneralActionSelection(this, request)
}
}
}