Compare commits

...
Author SHA1 Message Date
Segfault Guy 9309c53a40 Added CanDynamaxInstruction for multi battles. 2024-08-20 23:12:48 -04:00
3 changed files with 43 additions and 0 deletions
@@ -117,6 +117,9 @@ object ShowdownInterpreter {
sideInstructionParser["error"] = { _, targetActor, _, message -> ErrorInstruction(targetActor, message) }
sideInstructionParser["request"] = { _, targetActor, _, message -> RequestInstruction(targetActor, message) }
splitInstructionParser["-candynamax"] = { _, targetActor, instructionSet, publicMessage, privateMessage, _ ->
CanDynamaxInstruction(instructionSet, targetActor, publicMessage, privateMessage)
}
splitInstructionParser["-damage"] = { _, targetActor, instructionSet, publicMessage, privateMessage, _ ->
DamageInstruction(instructionSet, targetActor, publicMessage, privateMessage)
}
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.battles.interpreter.instructions
import com.cobblemon.mod.common.api.battles.interpreter.BattleMessage
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.text.yellow
import com.cobblemon.mod.common.battles.dispatch.InstructionSet
import com.cobblemon.mod.common.battles.dispatch.InterpreterInstruction
import com.cobblemon.mod.common.util.battleLang
/**
* Format: |-candynamax|SIDE
*
* SIDE can choose to dynamax this turn.
* In multi battles, actors on a team are alternatively given the option to dynamax each turn.
* On turn 1, the actors on their team's respective left have the first chance (p1 and p2; in multi battles, each actor is their own side).
* @author Segfault Guy
* @since July 16th, 2024
*/
class CanDynamaxInstruction(val instructionSet: InstructionSet, val battleActor: BattleActor, val publicMessage: BattleMessage, val privateMessage: BattleMessage): InterpreterInstruction {
override fun invoke(battle: PokemonBattle) {
battle.dispatchWaiting {
val side = privateMessage.argumentAt(0) ?: return@dispatchWaiting
battle.getActor(side)?.let {
it.canDynamax = true
battle.broadcastChatMessage(battleLang("candynamax", it.getName()).yellow())
}
}
}
}
@@ -1533,6 +1533,8 @@
"cobblemon.battle.mega": "%1$s has Mega Evolved!",
"cobblemon.battle.candynamax": "%1$s can Dynamax now!",
"cobblemon.experience.gained": "%1$s received %2$s experience.",
"cobblemon.experience.level_up": "%1$s is now level %2$s!",
"cobblemon.experience.learned_move": "%1$s has learned %2$s.",