mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
[CMR] Implemented Port Razer
This commit is contained in:
parent
e03d76cc46
commit
951d7da77d
2 changed files with 116 additions and 0 deletions
115
Mage.Sets/src/mage/cards/p/PortRazer.java
Normal file
115
Mage.Sets/src/mage/cards/p/PortRazer.java
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
package mage.cards.p;
|
||||||
|
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.RestrictionEffect;
|
||||||
|
import mage.abilities.effects.common.AdditionalCombatPhaseEffect;
|
||||||
|
import mage.abilities.effects.common.UntapAllControllerEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.WatcherScope;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.watchers.Watcher;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class PortRazer extends CardImpl {
|
||||||
|
|
||||||
|
public PortRazer(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{R}");
|
||||||
|
|
||||||
|
this.subtype.add(SubType.ORC);
|
||||||
|
this.subtype.add(SubType.PIRATE);
|
||||||
|
this.power = new MageInt(4);
|
||||||
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
|
// Whenever Port Razer deals combat damage to a player, untap each creature you control. After this combat phase, there is an additional combat phase.
|
||||||
|
Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(
|
||||||
|
new UntapAllControllerEffect(
|
||||||
|
StaticFilters.FILTER_CONTROLLED_CREATURES,
|
||||||
|
"untap all creatures you control"
|
||||||
|
), false
|
||||||
|
);
|
||||||
|
ability.addEffect(new AdditionalCombatPhaseEffect());
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// Port Razer can't attack a player it has already attacked this turn.
|
||||||
|
this.addAbility(new SimpleStaticAbility(new PortRazerEffect()), new PortRazerWatcher());
|
||||||
|
}
|
||||||
|
|
||||||
|
private PortRazer(final PortRazer card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PortRazer copy() {
|
||||||
|
return new PortRazer(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PortRazerEffect extends RestrictionEffect {
|
||||||
|
|
||||||
|
PortRazerEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield);
|
||||||
|
staticText = "{this} can't attack a player it has already attacked this turn";
|
||||||
|
}
|
||||||
|
|
||||||
|
private PortRazerEffect(final PortRazerEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PortRazerEffect copy() {
|
||||||
|
return new PortRazerEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
|
||||||
|
PortRazerWatcher watcher = game.getState().getWatcher(PortRazerWatcher.class);
|
||||||
|
return watcher != null && watcher.checkAttacker(attacker, defenderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PortRazerWatcher extends Watcher {
|
||||||
|
|
||||||
|
private final Map<UUID, Set<UUID>> attackMap = new HashMap<>();
|
||||||
|
|
||||||
|
PortRazerWatcher() {
|
||||||
|
super(WatcherScope.GAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void watch(GameEvent event, Game game) {
|
||||||
|
if (event.getType() != GameEvent.EventType.ATTACKER_DECLARED
|
||||||
|
|| game.getPlayer(event.getTargetId()) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
attackMap.computeIfAbsent(event.getSourceId(), x -> new HashSet<>()).add(event.getTargetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
attackMap.clear();
|
||||||
|
super.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean checkAttacker(Permanent permanent, UUID defenderId) {
|
||||||
|
return attackMap.computeIfAbsent(permanent.getId(), x -> new HashSet<>()).contains(defenderId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -150,6 +150,7 @@ public final class CommanderLegends extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Phyrexian Rager", 142, Rarity.COMMON, mage.cards.p.PhyrexianRager.class));
|
cards.add(new SetCardInfo("Phyrexian Rager", 142, Rarity.COMMON, mage.cards.p.PhyrexianRager.class));
|
||||||
cards.add(new SetCardInfo("Phyrexian Triniform", 331, Rarity.MYTHIC, mage.cards.p.PhyrexianTriniform.class));
|
cards.add(new SetCardInfo("Phyrexian Triniform", 331, Rarity.MYTHIC, mage.cards.p.PhyrexianTriniform.class));
|
||||||
cards.add(new SetCardInfo("Plague Reaver", 143, Rarity.RARE, mage.cards.p.PlagueReaver.class));
|
cards.add(new SetCardInfo("Plague Reaver", 143, Rarity.RARE, mage.cards.p.PlagueReaver.class));
|
||||||
|
cards.add(new SetCardInfo("Port Razer", 193, Rarity.MYTHIC, mage.cards.p.PortRazer.class));
|
||||||
cards.add(new SetCardInfo("Prava of the Steel Legion", 38, Rarity.UNCOMMON, mage.cards.p.PravaOfTheSteelLegion.class));
|
cards.add(new SetCardInfo("Prava of the Steel Legion", 38, Rarity.UNCOMMON, mage.cards.p.PravaOfTheSteelLegion.class));
|
||||||
cards.add(new SetCardInfo("Preordain", 84, Rarity.COMMON, mage.cards.p.Preordain.class));
|
cards.add(new SetCardInfo("Preordain", 84, Rarity.COMMON, mage.cards.p.Preordain.class));
|
||||||
cards.add(new SetCardInfo("Profane Transfusion", 145, Rarity.MYTHIC, mage.cards.p.ProfaneTransfusion.class));
|
cards.add(new SetCardInfo("Profane Transfusion", 145, Rarity.MYTHIC, mage.cards.p.ProfaneTransfusion.class));
|
||||||
|
|
Loading…
Reference in a new issue