* Added Brothers Yamazaki and Struggle for Sanity from Champions of Kamigawa.

This commit is contained in:
LevelX2 2016-04-16 12:33:29 +02:00
parent bac17fd390
commit 31e82d1dc4
4 changed files with 284 additions and 9 deletions

View file

@ -0,0 +1,136 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.championsofkamigawa;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.keyword.BushidoAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class BrothersYamazaki extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
filter.add(new NamePredicate("Brothers Yamazaki"));
}
public BrothersYamazaki(UUID ownerId) {
super(ownerId, 160, "Brothers Yamazaki", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.expansionSetCode = "CHK";
this.supertype.add("Legendary");
this.subtype.add("Human");
this.subtype.add("Samurai");
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// Bushido 1
this.addAbility(new BushidoAbility(1));
// If there are exactly two permanents named Brothers Yamazaki on the battlefield, the "legend rule" doesn't apply to them.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BrothersYamazakiIgnoreLegendRuleEffectEffect()));
// Each other creature named Brothers Yamazaki gets +2/+2 and has haste.
Effect effect = new BoostAllEffect(2, 2, Duration.WhileOnBattlefield, filter, true);
effect.setText("Each other creature named Brothers Yamazaki gets +2/+2");
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect);
effect = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield, filter);
effect.setText("and has haste");
ability.addEffect(effect);
this.addAbility(ability);
}
public BrothersYamazaki(final BrothersYamazaki card) {
super(card);
}
@Override
public BrothersYamazaki copy() {
return new BrothersYamazaki(this);
}
}
class BrothersYamazakiIgnoreLegendRuleEffectEffect extends ContinuousRuleModifyingEffectImpl {
private static final FilterPermanent filter = new FilterPermanent();
static {
filter.add(new NamePredicate("Brothers Yamazaki"));
}
public BrothersYamazakiIgnoreLegendRuleEffectEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment, false, false);
staticText = "If there are exactly two permanents named Brothers Yamazaki on the battlefield, the \"legend rule\" doesn't apply to them";
}
public BrothersYamazakiIgnoreLegendRuleEffectEffect(final BrothersYamazakiIgnoreLegendRuleEffectEffect effect) {
super(effect);
}
@Override
public BrothersYamazakiIgnoreLegendRuleEffectEffect copy() {
return new BrothersYamazakiIgnoreLegendRuleEffectEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DESTROY_PERMANENT_BY_LEGENDARY_RULE;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getName().equals("Brothers Yamazaki")) {
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 2;
}
return false;
}
}

View file

@ -0,0 +1,132 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.championsofkamigawa;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetOpponent;
/**
*
* @author LevelX2
*/
public class StruggleForSanity extends CardImpl {
public StruggleForSanity(UUID ownerId) {
super(ownerId, 145, "Struggle for Sanity", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
this.expansionSetCode = "CHK";
// Target opponent reveals his or her hand. That player exiles a card from it, then you exile a card from it. Repeat this process until all cards in that hand have been exiled. That player returns the cards he or she exiled this way to his or her hand and puts the rest into his or her graveyard.
this.getSpellAbility().addEffect(new StruggleForSanityEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
}
public StruggleForSanity(final StruggleForSanity card) {
super(card);
}
@Override
public StruggleForSanity copy() {
return new StruggleForSanity(this);
}
}
class StruggleForSanityEffect extends OneShotEffect {
public StruggleForSanityEffect() {
super(Outcome.Discard); // kind of
this.staticText = "Target opponent reveals his or her hand. That player exiles a card from it, then you exile a card from it. Repeat this process until all cards in that hand have been exiled. That player returns the cards he or she exiled this way to his or her hand and puts the rest into his or her graveyard";
}
public StruggleForSanityEffect(final StruggleForSanityEffect effect) {
super(effect);
}
@Override
public StruggleForSanityEffect copy() {
return new StruggleForSanityEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
Player controller = game.getPlayer(source.getControllerId());
if (targetPlayer == null || sourceObject == null || controller == null) {
return false;
}
targetPlayer.revealCards(sourceObject.getIdName(), targetPlayer.getHand(), game);
Cards cardsLeft = new CardsImpl(targetPlayer.getHand());
Cards exiledByController = new CardsImpl();
UUID exileZoneController = UUID.randomUUID();
Cards exiledByOpponent = new CardsImpl();
UUID exileZoneOpponent = UUID.randomUUID();
boolean opponentsChoice = true;
TargetCard target = new TargetCard(Zone.HAND, new FilterCard("a card to exile"));
while (!cardsLeft.isEmpty()) {
if (opponentsChoice) {
targetPlayer.choose(Outcome.ReturnToHand, cardsLeft, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
exiledByOpponent.add(card);
cardsLeft.remove(card);
targetPlayer.moveCardsToExile(card, source, game, true, exileZoneOpponent, sourceObject.getIdName() + " exiled by " + targetPlayer.getName());
}
} else {
controller.choose(Outcome.Discard, cardsLeft, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
exiledByController.add(card);
cardsLeft.remove(card);
controller.moveCardsToExile(card, source, game, true, exileZoneController, sourceObject.getIdName() + " exiled by " + controller.getName());
}
}
target.clearChosen();
opponentsChoice = !opponentsChoice;
}
targetPlayer.moveCards(exiledByOpponent, Zone.HAND, source, game);
targetPlayer.moveCards(exiledByController, Zone.GRAVEYARD, source, game);
return true;
}
}

View file

@ -1891,18 +1891,20 @@ public abstract class GameImpl implements Game, Serializable {
filterLegendName.add(new NamePredicate(legend.getName()));
filterLegendName.add(new ControllerIdPredicate(legend.getControllerId()));
if (getBattlefield().contains(filterLegendName, legend.getControllerId(), this, 2)) {
Player controller = this.getPlayer(legend.getControllerId());
if (controller != null) {
Target targetLegendaryToKeep = new TargetPermanent(filterLegendName);
targetLegendaryToKeep.setTargetName(legend.getName() + " to keep (Legendary Rule)?");
controller.chooseTarget(Outcome.Benefit, targetLegendaryToKeep, null, this);
for (Permanent dupLegend : getBattlefield().getActivePermanents(filterLegendName, legend.getControllerId(), this)) {
if (!targetLegendaryToKeep.getTargets().contains(dupLegend.getId())) {
movePermanentToGraveyardWithInfo(dupLegend);
if (!replaceEvent(GameEvent.getEvent(GameEvent.EventType.DESTROY_PERMANENT_BY_LEGENDARY_RULE, legend.getId(), legend.getControllerId()))) {
Player controller = this.getPlayer(legend.getControllerId());
if (controller != null) {
Target targetLegendaryToKeep = new TargetPermanent(filterLegendName);
targetLegendaryToKeep.setTargetName(legend.getName() + " to keep (Legendary Rule)?");
controller.chooseTarget(Outcome.Benefit, targetLegendaryToKeep, null, this);
for (Permanent dupLegend : getBattlefield().getActivePermanents(filterLegendName, legend.getControllerId(), this)) {
if (!targetLegendaryToKeep.getTargets().contains(dupLegend.getId())) {
movePermanentToGraveyardWithInfo(dupLegend);
}
}
}
return true;
}
return true;
}
}
}

View file

@ -210,6 +210,11 @@ public class GameEvent implements Serializable {
DAMAGE_CREATURE, DAMAGED_CREATURE,
DAMAGE_PLANESWALKER, DAMAGED_PLANESWALKER,
DESTROY_PERMANENT,
/* DESTROY_PERMANENT_BY_LEGENDARY_RULE
targetId id of the permanent to destroy
playerId controller of the permanent to detroy
*/
DESTROY_PERMANENT_BY_LEGENDARY_RULE,
/* DESTROYED_PERMANENT
targetId id of the destroyed creature
sourceId sourceId of the ability with the destroy effect