[SOI] Added Brain In A Jar and Biarbridge Patrol.

This commit is contained in:
LevelX2 2016-03-25 18:34:21 +01:00
parent 0a8ae65f15
commit 6429f4a4f2
5 changed files with 389 additions and 4 deletions

View file

@ -0,0 +1,155 @@
/*
* 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.shadowsoverinnistrad;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.common.FilterInstantOrSorceryCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
/**
*
* @author LevelX2
*/
public class BrainInAJar extends CardImpl {
public BrainInAJar(UUID ownerId) {
super(ownerId, 252, "Brain in a Jar", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "SOI";
// {1}, {T}: Put a charge counter on Brain in a Jar, then you may cast an instant or sorcery card with converted mana costs equal to the number of charge counters on Brain in a Jar from your hand without paying its mana cost.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), new GenericManaCost(1));
ability.addEffect(new BrainInAJarCastEffect());
ability.addCost(new TapSourceCost());
this.addAbility(ability);
// {3}, {T}, Remove X charge counters from Brain in a Jar: Scry X.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BrainInAJarScryEffect(), new GenericManaCost(3));
ability.addCost(new TapSourceCost());
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.CHARGE.createInstance()));
this.addAbility(ability);
}
public BrainInAJar(final BrainInAJar card) {
super(card);
}
@Override
public BrainInAJar copy() {
return new BrainInAJar(this);
}
}
class BrainInAJarCastEffect extends OneShotEffect {
public BrainInAJarCastEffect() {
super(Outcome.Benefit);
this.staticText = ", then you may cast an instant or sorcery card with converted mana costs equal to the number of charge counters on {this} from your hand without paying its mana cost";
}
public BrainInAJarCastEffect(final BrainInAJarCastEffect effect) {
super(effect);
}
@Override
public BrainInAJarCastEffect copy() {
return new BrainInAJarCastEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (controller != null && sourceObject != null) {
int counters = sourceObject.getCounters().getCount(CounterType.CHARGE);
FilterCard filter = new FilterInstantOrSorceryCard();
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, counters));
int cardsToCast = controller.getHand().count(filter, source.getControllerId(), source.getSourceId(), game);
if (cardsToCast > 0 && controller.chooseUse(outcome, "Cast an instant or sorcery card with converted mana costs of " + counters + " from your hand without paying its mana cost?", source, game)) {
TargetCardInHand target = new TargetCardInHand(filter);
controller.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.cast(card.getSpellAbility(), game, true);
}
}
return true;
}
return false;
}
}
class BrainInAJarScryEffect extends OneShotEffect {
public BrainInAJarScryEffect() {
super(Outcome.Benefit);
this.staticText = "Scry X";
}
public BrainInAJarScryEffect(final BrainInAJarScryEffect effect) {
super(effect);
}
@Override
public BrainInAJarScryEffect copy() {
return new BrainInAJarScryEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int x = new RemovedCountersForCostValue().calculate(game, source, this);
if (x > 0) {
return controller.scry(x, source, game);
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,112 @@
/*
* 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.shadowsoverinnistrad;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.DealsDamageToOneOrMoreCreaturesTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect;
import mage.abilities.effects.keyword.InvestigateEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.watchers.common.PermanentsSacrificedWatcher;
/**
*
* @author LevelX2
*/
public class BriarbridgePatrol extends CardImpl {
public BriarbridgePatrol(UUID ownerId) {
super(ownerId, 195, "Briarbridge Patrol", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.expansionSetCode = "SOI";
this.subtype.add("Human");
this.subtype.add("Warrior");
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Whenever Briarbridge Patrol deals damage to one or more creatures, investigate (Put a colorless Clue artifact token onto the battlefield with "2, Sacrifice this artifact: Draw a card.").
this.addAbility(new DealsDamageToOneOrMoreCreaturesTriggeredAbility(new InvestigateEffect(), false, false, false));
// At the beginning of each end step, if you sacrificed three or more Clues this turn, you may put a creature card from your hand onto the battlefield.
this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new PutPermanentOnBattlefieldEffect(new FilterCreatureCard("a creature card")), TargetController.ANY,
BriarbridgePatrolCondition.getInstance(), true), new PermanentsSacrificedWatcher());
}
public BriarbridgePatrol(final BriarbridgePatrol card) {
super(card);
}
@Override
public BriarbridgePatrol copy() {
return new BriarbridgePatrol(this);
}
}
class BriarbridgePatrolCondition implements Condition {
private static final BriarbridgePatrolCondition fInstance = new BriarbridgePatrolCondition();
public static Condition getInstance() {
return fInstance;
}
@Override
public boolean apply(Game game, Ability source) {
PermanentsSacrificedWatcher watcher = (PermanentsSacrificedWatcher) game.getState().getWatchers().get(PermanentsSacrificedWatcher.class.getName());
if (watcher != null) {
List<Permanent> sacrificedPermanents = watcher.getThisTurnSacrificedPermanents(source.getControllerId());
if (!sacrificedPermanents.isEmpty()) {
int amountOfClues = 0;
for (Permanent permanent : sacrificedPermanents) {
if (permanent.getSubtype().contains("Clue")) {
amountOfClues++;
}
}
return amountOfClues > 2;
}
}
return false;
}
@Override
public String toString() {
return "if you sacrificed three or more Clues this turn";
}
}

View file

@ -75,7 +75,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
case YOU: case YOU:
boolean yours = event.getPlayerId().equals(this.controllerId); boolean yours = event.getPlayerId().equals(this.controllerId);
if (yours) { if (yours) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -84,7 +84,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
return yours; return yours;
case OPPONENT: case OPPONENT:
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) { if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -94,7 +94,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
break; break;
case ANY: case ANY:
case NEXT: case NEXT:
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -105,7 +105,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
if (attachment != null && attachment.getAttachedTo() != null) { if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo()); Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) { if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }

View file

@ -0,0 +1,53 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.common;
import mage.abilities.effects.Effect;
import mage.constants.PhaseStep;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.turn.Step;
/**
*
* @author LevelX2
*/
public class DealsDamageToOneOrMoreCreaturesTriggeredAbility extends DealsDamageToACreatureTriggeredAbility {
public DealsDamageToOneOrMoreCreaturesTriggeredAbility(Effect effect, boolean combatOnly, boolean optional, boolean setTargetPointer) {
super(effect, combatOnly, optional, setTargetPointer);
}
public DealsDamageToOneOrMoreCreaturesTriggeredAbility(DealsDamageToOneOrMoreCreaturesTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
// check that combat damage does only once trigger also if multiple creatures were damaged because they block or were blocked by source
if (game.getTurn().getStepType().equals(PhaseStep.COMBAT_DAMAGE) || game.getTurn().getStepType().equals(PhaseStep.FIRST_COMBAT_DAMAGE)) {
Step step = (Step) game.getState().getValue("damageStep" + getOriginalId());
if (!game.getStep().equals(step)) {
// this ability did not trigger during this damage step
game.getState().setValue("damageStep" + getOriginalId(), game.getStep());
return true;
}
} else {
game.getState().setValue("damageStep" + getOriginalId(), null);
}
// TODO: check that if the source did non combat damage to multiple targets at the same time, it may only trigger one time
// I don't know currently how this can happen for a source creature that this has not already build in
}
return false;
}
@Override
public DealsDamageToOneOrMoreCreaturesTriggeredAbility copy() {
return new DealsDamageToOneOrMoreCreaturesTriggeredAbility(this);
}
}

View file

@ -0,0 +1,65 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.watchers.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
/**
*
* @author LevelX2
*/
public class PermanentsSacrificedWatcher extends Watcher {
private final HashMap<UUID, List<Permanent>> sacrificedPermanents = new HashMap<>();
public PermanentsSacrificedWatcher() {
super(PermanentsSacrificedWatcher.class.getName(), WatcherScope.GAME);
}
public PermanentsSacrificedWatcher(final PermanentsSacrificedWatcher watcher) {
super(watcher);
}
@Override
public PermanentsSacrificedWatcher copy() {
return new PermanentsSacrificedWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT) {
Permanent perm = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (perm != null) {
List<Permanent> permanents;
if (!sacrificedPermanents.containsKey(perm.getControllerId())) {
permanents = new ArrayList<>();
sacrificedPermanents.put(perm.getControllerId(), permanents);
} else {
permanents = sacrificedPermanents.get(perm.getControllerId());
}
permanents.add(perm);
}
}
}
@Override
public void reset() {
super.reset();
sacrificedPermanents.clear();
}
public List<Permanent> getThisTurnSacrificedPermanents(UUID playerId) {
return sacrificedPermanents.get(playerId);
}
}