mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
[CLB] Implemented Agent of the Shadow Thieves
This commit is contained in:
parent
00a82cda05
commit
a38c0bea3e
3 changed files with 121 additions and 0 deletions
|
|
@ -0,0 +1,61 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class AttacksOpponentWithMostLifeTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public AttacksOpponentWithMostLifeTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
}
|
||||
|
||||
private AttacksOpponentWithMostLifeTriggeredAbility(final AttacksOpponentWithMostLifeTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return game.getCombat().getAttackers().contains(this.getSourceId())
|
||||
&& game.getPlayer(game.getCombat().getDefenderId(this.getSourceId())) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkInterveningIfClause(Game game) {
|
||||
Player defender = game.getPlayer(game.getCombat().getDefenderId(getSourceId()));
|
||||
return defender != null
|
||||
&& game
|
||||
.getOpponents(getControllerId())
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.mapToInt(Player::getLife)
|
||||
.max()
|
||||
.orElse(Integer.MIN_VALUE)
|
||||
<= defender
|
||||
.getLife();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTriggerPhrase() {
|
||||
return "Whenever this creature attacks a player, if no opponent has more life than that player, ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttacksOpponentWithMostLifeTriggeredAbility copy() {
|
||||
return new AttacksOpponentWithMostLifeTriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue