Skip to content

Commit 23b085f

Browse files
authored
Merge pull request #129 from hlam9/1.7-port exp all fix
exp all fix
2 parents 201633d + 6c4d0e0 commit 23b085f

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

common/src/main/generated/resources/assets/generations_core/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,7 @@
19151915
"item.generations_core.eterna_city_disc": "Eterna City Disc",
19161916
"item.generations_core.event_ribbon": "Event Ribbon",
19171917
"item.generations_core.exp_all": "Exp All",
1918-
"item.generations_core.exp_all.desc": "Not currently implemented",
1918+
"item.generations_core.exp_all.desc": "Shares battle Exp. Points with all party members.",
19191919
"item.generations_core.exp_charm": "Exp Charm",
19201920
"item.generations_core.expert_battler_ribbon": "Expert Battler Ribbon",
19211921
"item.generations_core.explorer_kit": "Explorer Kit",

common/src/main/java/generations/gg/generations/core/generationscore/common/battle/GenerationsInstructionProcessor.kt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.cobblemon.mod.common.api.battles.model.PokemonBattle
99
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
1010
import com.cobblemon.mod.common.api.events.battles.BattleStartedEvent
1111
import com.cobblemon.mod.common.api.events.battles.instruction.TerastallizationEvent
12+
import com.cobblemon.mod.common.api.pokemon.experience.BattleExperienceSource
1213
import com.cobblemon.mod.common.api.pokemon.feature.FlagSpeciesFeature
1314
import com.cobblemon.mod.common.api.pokemon.feature.SpeciesFeature
1415
import com.cobblemon.mod.common.api.pokemon.feature.StringSpeciesFeature
@@ -277,21 +278,30 @@ fun grantExp(battle: PokemonBattle, actor: BattleActor) {
277278

278279

279280
fun grantExpAll(battle: PokemonBattle, opponent: BattleActor, faintedPokemonList: List<BattlePokemon>) {
280-
val opponentNonFaintedPokemonList = opponent.pokemonList.filter {it.health > 0}
281+
val player = opponent.uuid.getPlayer() ?: return
282+
val opponentNonFaintedPokemonList = opponent.pokemonList.filter { it.health > 0 }
281283

282284
faintedPokemonList.forEach { faintedPokemon ->
283285
for (opponentPokemon in opponentNonFaintedPokemonList) {
284-
val multiplier = opponentPokemon.calculateMultiplier()
285286
val facedFainted = opponentPokemon.facedOpponents.contains(faintedPokemon)
287+
288+
// Skip participants — Cobblemon's own system already handled them
289+
if (facedFainted) continue
290+
291+
val multiplier = 0.5 // non-participant multiplier
286292
val experience = Cobblemon.experienceCalculator.calculate(opponentPokemon, faintedPokemon, multiplier)
287293
val grantedEvs = Cobblemon.evYieldCalculator.calculate(opponentPokemon, faintedPokemon)
288294

289295
if (experience > 0) {
290-
opponent.awardExperience(opponentPokemon, experience)
291-
if (!facedFainted) {
292-
grantedEvs.forEach { stat, value -> opponentPokemon.effectedPokemon.evs.add(stat, value,
293-
BattleEvSource(battle, listOf(faintedPokemon), opponentPokemon.effectedPokemon))
294-
} //TODO: Decide how to handle
296+
// Bypass awardExperience — use faintedPokemon as source so Cobblemon accepts it
297+
val source = BattleExperienceSource(battle, listOf(faintedPokemon))
298+
opponentPokemon.effectedPokemon.addExperienceWithPlayer(player, source, experience)
299+
300+
grantedEvs.forEach { stat, value ->
301+
opponentPokemon.effectedPokemon.evs.add(
302+
stat, value,
303+
BattleEvSource(battle, listOf(faintedPokemon), opponentPokemon.effectedPokemon)
304+
)
295305
}
296306
}
297307
}

0 commit comments

Comments
 (0)