refactor: simpler processAction syntax (#12458)

* game.processAction() instead of game.getState().processAction(game)

* add simpler method name and docs

* find/replace to new method

* remove old method

* deprecate applyEffects
This commit is contained in:
xenohedron 2024-06-11 22:55:43 -04:00 committed by GitHub
parent e2b1d980b6
commit d61de05eb8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
163 changed files with 218 additions and 217 deletions

View file

@ -248,7 +248,7 @@ public abstract class AbilityImpl implements Ability {
* abilities with replacement effects deactivated too late Example:
* {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
*/
game.getState().processAction(game);
game.processAction();
}
return result;
}

View file

@ -190,7 +190,7 @@ class AnimateDeadPutOntoBattlefieldEffect extends OneShotEffect {
}
// Put card onto the battlefield under your control...
player.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null);
game.getState().processAction(game);
game.processAction();
Permanent creature = game.getPermanent(CardUtil.getDefaultCardSideForBattlefield(game, card).getId());
if (creature == null) {

View file

@ -114,7 +114,7 @@ public class DevourEffect extends ReplacementEffectImpl {
+ filterDevoured.getMessage() + (devouredCreatures > 1 ? "s" : "")
);
game.getState().processAction(game); // need for multistep effects
game.processAction(); // need for multistep effects
int amountCounters;
if (devourFactor == Integer.MAX_VALUE) {

View file

@ -62,7 +62,7 @@ public class ExileThenReturnTargetEffect extends OneShotEffect {
return false;
}
controller.moveCards(toFlicker, Zone.EXILED, source, game);
game.getState().processAction(game);
game.processAction();
for (Card card : toFlicker) {
putCards.moveCard(
yourControl ? controller : game.getPlayer(card.getOwnerId()),

View file

@ -47,14 +47,14 @@ public class LivingDeathEffect extends OneShotEffect {
}
}
}
game.getState().processAction(game);
game.processAction();
// Sacrifice all creatures
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
permanent.sacrifice(source, game);
}
game.getState().processAction(game);
game.processAction();
// Exiled cards are put onto the battlefield at the same time under their owner's control
Set<Card> cardsToReturnFromExile = new HashSet<>();

View file

@ -35,7 +35,7 @@ public class ShuffleHandIntoLibraryDrawThatManySourceEffect extends OneShotEffec
if (cardsHand > 0) {
controller.moveCards(controller.getHand(), Zone.LIBRARY, source, game);
controller.shuffleLibrary(source, game);
game.getState().processAction(game); // then
game.processAction(); // then
controller.drawCards(cardsHand, source, game);
}
return true;

View file

@ -48,7 +48,7 @@ public class GainControlAllUntapGainHasteEffect extends OneShotEffect {
FilterPermanent affectedFilter = new FilterPermanent();
affectedFilter.add(new PermanentReferenceInCollectionPredicate(affectedObjects, game));
new GainControlAllEffect(Duration.EndOfTurn, affectedFilter).apply(game, source);
game.getState().processAction(game);
game.processAction();
new UntapAllEffect(affectedFilter).apply(game, source);
game.addEffect(new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, affectedFilter), source);
return true;

View file

@ -68,7 +68,7 @@ public class DiscoverEffect extends OneShotEffect {
for (Card card : player.getLibrary().getCards(game)) {
cards.add(card);
player.moveCards(card, Zone.EXILED, source, game);
game.getState().processAction(game);
game.processAction();
if (filter.match(card, game)) {
return card;
}

View file

@ -116,7 +116,7 @@ public class ExploreSourceEffect extends OneShotEffect {
// the exploring creature receives a +1/+1 counter.
addCounter(game, permanent, source);
}
game.getState().processAction(game);
game.processAction();
// 701.40b A permanent explores after the process described in rule 701.40a is complete, even if some or all of
// those actions were impossible.
game.fireEvent(new ExploredEvent(permanent, source, card));

View file

@ -124,7 +124,7 @@ class CascadeEffect extends OneShotEffect {
cardsToExile.add(card);
// the card move is sequential, not all at once.
controller.moveCards(card, Zone.EXILED, source, game);
game.getState().processAction(game); // Laelia, the Blade Reforged
game.processAction(); // Laelia, the Blade Reforged
if (!card.isLand(game)
&& card.getManaValue() < sourceCost) {
cardToCast = card;

View file

@ -136,7 +136,7 @@ class MadnessReplacementEffect extends ReplacementEffectImpl {
}
// needed to add Madness ability to cards (e.g. by Falkenrath Gorger)
game.getState().processAction(game);
game.processAction();
GameEvent gameEvent = new MadnessCardExiledEvent(card.getId(), source, controller.getId());
game.fireEvent(gameEvent);