foul-magics/Mage/src/main/java/mage/abilities/keyword/IngestAbility.java
Susucre f75b1c9f0a
Code cleanup: protect all copy constructors (#10750)
* apply regex to change public copy constructors to protected
* cleanup code using now protected constructors
* fix manaBuilder weird casting of Mana into ConditionalMana
2023-08-04 19:34:58 -04:00

65 lines
1.7 KiB
Java

package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
/**
* @author LevelX2
*/
public class IngestAbility extends DealsCombatDamageToAPlayerTriggeredAbility {
public IngestAbility() {
super(new IngestEffect(), false, true);
}
public IngestAbility(IngestAbility ability) {
super(ability);
}
@Override
public String getRule() {
return "Ingest <i>(Whenever this creature deals combat damage to a player, that player exiles the top card of their library.)</i>";
}
@Override
public IngestAbility copy() {
return new IngestAbility(this);
}
}
class IngestEffect extends OneShotEffect {
public IngestEffect() {
super(Outcome.Exile);
this.staticText = "that player exiles the top card of their library";
}
protected IngestEffect(final IngestEffect effect) {
super(effect);
}
@Override
public IngestEffect copy() {
return new IngestEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
targetPlayer.moveCards(card, Zone.EXILED, source, game);
}
return true;
}
return false;
}
}