mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
Rework how Training events are handled (#11748)
* Replace training GameEvent with custom TriggeredAbility
This commit is contained in:
parent
079b78628a
commit
c4e0d64428
3 changed files with 22 additions and 36 deletions
|
|
@ -2,10 +2,8 @@ package mage.abilities.keyword;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
|
|
@ -20,7 +18,7 @@ import java.util.Objects;
|
|||
public class TrainingAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public TrainingAbility() {
|
||||
super(Zone.BATTLEFIELD, new TrainingAbilityEffect());
|
||||
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()));
|
||||
}
|
||||
|
||||
private TrainingAbility(final TrainingAbility ability) {
|
||||
|
|
@ -60,33 +58,3 @@ public class TrainingAbility extends TriggeredAbilityImpl {
|
|||
"with greater power, put a +1/+1 counter on this creature.)</i>";
|
||||
}
|
||||
}
|
||||
|
||||
class TrainingAbilityEffect extends OneShotEffect {
|
||||
|
||||
TrainingAbilityEffect() {
|
||||
super(Outcome.Neutral);
|
||||
}
|
||||
|
||||
private TrainingAbilityEffect(final TrainingAbilityEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrainingAbilityEffect copy() {
|
||||
return new TrainingAbilityEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
||||
game.fireEvent(GameEvent.getEvent(
|
||||
GameEvent.EventType.TRAINED_CREATURE,
|
||||
source.getSourceId(), source, source.getControllerId()
|
||||
));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -470,7 +470,6 @@ public class GameEvent implements Serializable {
|
|||
EVOLVED_CREATURE,
|
||||
EMBALMED_CREATURE,
|
||||
ETERNALIZED_CREATURE,
|
||||
TRAINED_CREATURE,
|
||||
ATTACH, ATTACHED,
|
||||
UNATTACH, UNATTACHED,
|
||||
/* ATTACH, ATTACHED,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue