mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
[NPH] Bludgeon Brawl
This commit is contained in:
parent
77fbc9cae2
commit
7badc7ff96
1 changed files with 227 additions and 0 deletions
227
Mage.Sets/src/mage/sets/newphyrexia/BludgeonBrawl.java
Normal file
227
Mage.Sets/src/mage/sets/newphyrexia/BludgeonBrawl.java
Normal file
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* 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.newphyrexia;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Layer;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.SubLayer;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.BoostEquippedEffect;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterArtifactPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public class BludgeonBrawl extends CardImpl<BludgeonBrawl> {
|
||||
|
||||
public BludgeonBrawl(UUID ownerId) {
|
||||
super(ownerId, 80, "Bludgeon Brawl", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}");
|
||||
this.expansionSetCode = "NPH";
|
||||
|
||||
this.color.setRed(true);
|
||||
|
||||
this.addAbility(new BludgeonBrawlAbility());
|
||||
this.addAbility(new BludgeonBrawlTriggeredAbility());
|
||||
}
|
||||
|
||||
public BludgeonBrawl(final BludgeonBrawl card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BludgeonBrawl copy() {
|
||||
return new BludgeonBrawl(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BludgeonBrawlAbility extends StaticAbility<BludgeonBrawlAbility> {
|
||||
|
||||
public BludgeonBrawlAbility() {
|
||||
super(Zone.BATTLEFIELD, new BludgeonBrawlAddSubtypeEffect());
|
||||
this.addEffect(new BludgeonBrawlGainAbilityEffect());
|
||||
}
|
||||
|
||||
public BludgeonBrawlAbility(BludgeonBrawlAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BludgeonBrawlAbility copy() {
|
||||
return new BludgeonBrawlAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Each noncreature, non-Equipment artifact is an Equipment with equip {X} and \"Equipped creature gets +X/+0,\" where X is that artifact's converted mana cost.";
|
||||
}
|
||||
}
|
||||
|
||||
class BludgeonBrawlAddSubtypeEffect extends ContinuousEffectImpl<BludgeonBrawlAddSubtypeEffect> {
|
||||
|
||||
public BludgeonBrawlAddSubtypeEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
|
||||
}
|
||||
|
||||
public BludgeonBrawlAddSubtypeEffect(final BludgeonBrawlAddSubtypeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterArtifactPermanent filter = new FilterArtifactPermanent("noncreature, non-Equipment artifact");
|
||||
filter.getNotCardType().add(CardType.CREATURE);
|
||||
filter.getSubtype().add("Equipment");
|
||||
filter.setNotSubtype(true);
|
||||
|
||||
List<UUID> affectedPermanents = new ArrayList<UUID>();
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
for (Permanent permanent : permanents) {
|
||||
if (permanent != null) {
|
||||
permanent.getSubtype().add("Equipment");
|
||||
affectedPermanents.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
game.getState().setValue(source.getSourceId() + "BludgeonBrawlAffectedPermanents", affectedPermanents);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BludgeonBrawlAddSubtypeEffect copy() {
|
||||
return new BludgeonBrawlAddSubtypeEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BludgeonBrawlGainAbilityEffect extends ContinuousEffectImpl<BludgeonBrawlGainAbilityEffect> {
|
||||
|
||||
public BludgeonBrawlGainAbilityEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
}
|
||||
|
||||
public BludgeonBrawlGainAbilityEffect(final BludgeonBrawlGainAbilityEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BludgeonBrawlGainAbilityEffect copy() {
|
||||
return new BludgeonBrawlGainAbilityEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<UUID> permanents = (List<UUID>) game.getState().getValue(source.getSourceId() + "BludgeonBrawlAffectedPermanents");
|
||||
if (permanents != null) {
|
||||
for (UUID permanentId : permanents) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
int convertedManaCost = permanent.getManaCost().convertedManaCost();
|
||||
permanent.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(convertedManaCost)));
|
||||
permanent.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(convertedManaCost, 0)));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class BludgeonBrawlTriggeredAbility<T extends BludgeonBrawlTriggeredAbility<T>> extends TriggeredAbilityImpl<T> {
|
||||
|
||||
public BludgeonBrawlTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new BludgeonBrawlExitEffect(), false);
|
||||
}
|
||||
|
||||
public BludgeonBrawlTriggeredAbility(BludgeonBrawlTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T copy() {
|
||||
return (T) new BludgeonBrawlTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class BludgeonBrawlExitEffect extends OneShotEffect<BludgeonBrawlExitEffect> {
|
||||
|
||||
public BludgeonBrawlExitEffect() {
|
||||
super(Outcome.Neutral);
|
||||
}
|
||||
|
||||
public BludgeonBrawlExitEffect(final BludgeonBrawlExitEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BludgeonBrawlExitEffect copy() {
|
||||
return new BludgeonBrawlExitEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game);
|
||||
for (Permanent permanent : permanents) {
|
||||
if (permanent != null && permanent.getAttachedTo() != null) {
|
||||
Permanent other = game.getPermanent(permanent.getAttachedTo());
|
||||
if (other != null && !other.hasSubtype("Equipment") && !other.hasSubtype("Aura")) {
|
||||
other.getAttachments().remove(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue