Implemented Biomancer's Familiar

This commit is contained in:
Evan Kranzler 2019-01-03 17:35:43 -05:00
parent 965fa971a3
commit ee00ce34da
3 changed files with 170 additions and 16 deletions

View file

@ -0,0 +1,159 @@
package mage.cards.b;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class BiomancersFamiliar extends CardImpl {
public BiomancersFamiliar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{U}");
this.subtype.add(SubType.MUTANT);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Activated abilities of creatures you control cost {2} less to activate. This effect can't reduce the amount of mana an ability costs to activate to less than one mana.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BiomancersFamiliarCostReductionEffect()));
// {T}: The next time target creature adapts this turn, it adapts as though it had no +1/+1 counters on it.
Ability ability = new SimpleActivatedAbility(
new BiomancersFamiliarReplacementEffect(), new TapSourceCost()
);
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
private BiomancersFamiliar(final BiomancersFamiliar card) {
super(card);
}
@Override
public BiomancersFamiliar copy() {
return new BiomancersFamiliar(this);
}
}
class BiomancersFamiliarCostReductionEffect extends CostModificationEffectImpl {
private static final String effectText = "Activated abilities of creatures you control cost {2} less to activate. " +
"This effect can't reduce the amount of mana an ability costs to activate to less than one mana";
BiomancersFamiliarCostReductionEffect() {
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = effectText;
}
private BiomancersFamiliarCostReductionEffect(final BiomancersFamiliarCostReductionEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
Player controller = game.getPlayer(abilityToModify.getControllerId());
if (controller != null) {
Mana mana = abilityToModify.getManaCostsToPay().getMana();
int reduceMax = mana.getGeneric();
if (reduceMax > 0 && mana.count() == mana.getGeneric()) {
reduceMax--;
}
if (reduceMax > 2) {
reduceMax = 2;
}
if (reduceMax > 0) {
ChoiceImpl choice = new ChoiceImpl(true);
Set<String> set = new LinkedHashSet<>();
for (int i = 0; i <= reduceMax; i++) {
set.add(String.valueOf(i));
}
choice.setChoices(set);
choice.setMessage("Reduce ability cost");
if (!controller.choose(Outcome.Benefit, choice, game)) {
return false;
}
int reduce = Integer.parseInt(choice.getChoice());
CardUtil.reduceCost(abilityToModify, reduce);
}
return true;
}
return false;
}
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED
|| (abilityToModify.getAbilityType() == AbilityType.MANA && abilityToModify instanceof ActivatedAbility)) {
//Activated abilities of creatures you control
Permanent permanent = game.getPermanent(abilityToModify.getSourceId());
if (permanent != null && permanent.isControlledBy(source.getControllerId())) {
return true;
}
}
return false;
}
@Override
public BiomancersFamiliarCostReductionEffect copy() {
return new BiomancersFamiliarCostReductionEffect(this);
}
}
class BiomancersFamiliarReplacementEffect extends ReplacementEffectImpl {
BiomancersFamiliarReplacementEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
staticText = "The next time target creature adapts this turn, " +
"it adapts as though it had no +1/+1 counters on it.";
}
private BiomancersFamiliarReplacementEffect(final BiomancersFamiliarReplacementEffect effect) {
super(effect);
}
@Override
public BiomancersFamiliarReplacementEffect copy() {
return new BiomancersFamiliarReplacementEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ADAPT;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getTargetId().equals(targetPointer.getFirst(game, source));
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setFlag(true);
discard();
return false;
}
}

View file

@ -1,9 +1,6 @@
package mage.cards.t;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
@ -12,20 +9,17 @@ import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceImpl;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author maurer.it_at_gmail.com
*/
public final class TrainingGrounds extends CardImpl {
@ -49,15 +43,15 @@ public final class TrainingGrounds extends CardImpl {
class TrainingGroundsEffect extends CostModificationEffectImpl {
private static final String effectText = "Activated abilities of creatures you control cost up to {2} less to activate. This effect can't reduce the amount of mana an ability costs to activate to less than one mana";
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
private static final String effectText = "Activated abilities of creatures you control cost {2} less to activate. " +
"This effect can't reduce the amount of mana an ability costs to activate to less than one mana";
public TrainingGroundsEffect() {
TrainingGroundsEffect() {
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = effectText;
}
public TrainingGroundsEffect(final TrainingGroundsEffect effect) {
private TrainingGroundsEffect(final TrainingGroundsEffect effect) {
super(effect);
}
@ -100,7 +94,7 @@ class TrainingGroundsEffect extends CostModificationEffectImpl {
|| (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) {
//Activated abilities of creatures you control
Permanent permanent = game.getPermanent(abilityToModify.getSourceId());
if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
if (permanent != null && permanent.isControlledBy(source.getControllerId())) {
return true;
}
}

View file

@ -38,6 +38,7 @@ public final class RavnicaAllegiance extends ExpansionSet {
cards.add(new SetCardInfo("Azorius Guildgate", 244, Rarity.COMMON, mage.cards.a.AzoriusGuildgate.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Azorius Locket", 231, Rarity.COMMON, mage.cards.a.AzoriusLocket.class));
cards.add(new SetCardInfo("Bedevil", 157, Rarity.RARE, mage.cards.b.Bedevil.class));
cards.add(new SetCardInfo("Biomancer's Familiar", 158, Rarity.RARE, mage.cards.b.BiomancersFamiliar.class));
cards.add(new SetCardInfo("Blood Crypt", 245, Rarity.RARE, mage.cards.b.BloodCrypt.class));
cards.add(new SetCardInfo("Bolrac-Clan Crusher", 159, Rarity.UNCOMMON, mage.cards.b.BolracClanCrusher.class));
cards.add(new SetCardInfo("Breeding Pool", 246, Rarity.RARE, mage.cards.b.BreedingPool.class));