Merge pull request #5131 from NoahGleason/thick-skinned-goblin

Implement Thick-Skinned Goblin
This commit is contained in:
LevelX2 2018-07-14 10:40:10 +02:00 committed by GitHub
commit c29bb86ea0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 176 additions and 77 deletions

View file

@ -0,0 +1,76 @@
package mage.cards.t;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.*;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author noahg
*/
public final class ThickSkinnedGoblin extends CardImpl {
public ThickSkinnedGoblin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
this.subtype.add(SubType.GOBLIN);
this.subtype.add(SubType.SHAMAN);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// You may pay {0} rather than pay the echo cost for permanents you control.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ThickSkinnedGoblinCostModificationEffect()));
// {R}: Thick-Skinned Goblin gains protection from red until end of turn.
this.addAbility(new SimpleActivatedAbility(new GainAbilitySourceEffect(ProtectionAbility.from(ObjectColor.RED), Duration.EndOfTurn), new ManaCostsImpl("{R}")));
}
public ThickSkinnedGoblin(final ThickSkinnedGoblin card) {
super(card);
}
@Override
public ThickSkinnedGoblin copy() {
return new ThickSkinnedGoblin(this);
}
}
class ThickSkinnedGoblinCostModificationEffect extends AsThoughEffectImpl {
public ThickSkinnedGoblinCostModificationEffect(){
super(AsThoughEffectType.PAY_0_ECHO, Duration.WhileOnBattlefield, Outcome.Benefit);
this.staticText = "You may pay {0} rather than pay the echo cost for permanents you control.";
}
public ThickSkinnedGoblinCostModificationEffect(ThickSkinnedGoblinCostModificationEffect effect) {
super(effect);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
Permanent sourcePermanent = game.getPermanent(sourceId);
return sourcePermanent != null && sourcePermanent.isControlledBy(source.getControllerId());
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public ThickSkinnedGoblinCostModificationEffect copy() {
return new ThickSkinnedGoblinCostModificationEffect(this);
}
}

View file

@ -288,6 +288,7 @@ public final class TimeSpiral extends ExpansionSet {
cards.add(new SetCardInfo("Thallid Shell-Dweller", 226, Rarity.COMMON, mage.cards.t.ThallidShellDweller.class)); cards.add(new SetCardInfo("Thallid Shell-Dweller", 226, Rarity.COMMON, mage.cards.t.ThallidShellDweller.class));
cards.add(new SetCardInfo("Thelonite Hermit", 228, Rarity.RARE, mage.cards.t.TheloniteHermit.class)); cards.add(new SetCardInfo("Thelonite Hermit", 228, Rarity.RARE, mage.cards.t.TheloniteHermit.class));
cards.add(new SetCardInfo("Thelon of Havenwood", 227, Rarity.RARE, mage.cards.t.ThelonOfHavenwood.class)); cards.add(new SetCardInfo("Thelon of Havenwood", 227, Rarity.RARE, mage.cards.t.ThelonOfHavenwood.class));
cards.add(new SetCardInfo("Thick-Skinned Goblin", 182, Rarity.UNCOMMON, mage.cards.t.ThickSkinnedGoblin.class));
cards.add(new SetCardInfo("Think Twice", 86, Rarity.COMMON, mage.cards.t.ThinkTwice.class)); cards.add(new SetCardInfo("Think Twice", 86, Rarity.COMMON, mage.cards.t.ThinkTwice.class));
cards.add(new SetCardInfo("Thrill of the Hunt", 229, Rarity.COMMON, mage.cards.t.ThrillOfTheHunt.class)); cards.add(new SetCardInfo("Thrill of the Hunt", 229, Rarity.COMMON, mage.cards.t.ThrillOfTheHunt.class));
cards.add(new SetCardInfo("Thunder Totem", 265, Rarity.UNCOMMON, mage.cards.t.ThunderTotem.class)); cards.add(new SetCardInfo("Thunder Totem", 265, Rarity.UNCOMMON, mage.cards.t.ThunderTotem.class));

View file

@ -0,0 +1,94 @@
package mage.abilities.effects.keyword;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.AsThoughEffectType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.Locale;
public class EchoEffect extends OneShotEffect {
protected Cost cost;
protected DynamicValue amount;
public EchoEffect(Cost costs) {
super(Outcome.Sacrifice);
this.cost = costs;
this.amount = null;
}
public EchoEffect(DynamicValue amount) {
super(Outcome.Sacrifice);
this.amount = amount;
this.cost = null;
}
public EchoEffect(final EchoEffect effect) {
super(effect);
this.cost = effect.cost;
this.amount = effect.amount;
}
@Override
public boolean apply(Game game, Ability source) {
if (cost == null) {
cost = new ManaCostsImpl(Integer.toString(amount.calculate(game, source, this)));
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null
&& source.getSourceObjectIfItStillExists(game) != null) {
if (game.getContinuousEffects().asThough(source.getSourceId(), AsThoughEffectType.PAY_0_ECHO, source, source.getControllerId(), game) != null) {
Cost altCost = new ManaCostsImpl("{0}");
if (controller.chooseUse(Outcome.Benefit, "Pay {0} instead of the echo cost?", source, game)) {
altCost.clearPaid();
if (altCost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ECHO_PAID, source.getSourceId(), source.getSourceId(), source.getControllerId()));
return true;
}
}
}
if (controller.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ECHO_PAID, source.getSourceId(), source.getSourceId(), source.getControllerId()));
return true;
}
}
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
}
return true;
}
return false;
}
@Override
public EchoEffect copy() {
return new EchoEffect(this);
}
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
String costText = cost.getText();
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")) {
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));
sb.append(costText.substring(1));
} else {
sb.append("pay ").append(costText);
}
return sb.toString();
}
}

View file

@ -1,23 +1,18 @@
package mage.abilities.keyword; package mage.abilities.keyword;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs; import mage.abilities.costs.Costs;
import mage.abilities.costs.CostsImpl; import mage.abilities.costs.CostsImpl;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.keyword.EchoEffect;
import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player; import java.util.UUID;
/** /**
* *
@ -82,7 +77,7 @@ public class EchoAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
// reset the echo paid state back, if creature enteres the battlefield // reset the echo paid state back, if creature enters the battlefield
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
&& event.getTargetId().equals(this.getSourceId())) { && event.getTargetId().equals(this.getSourceId())) {
@ -128,70 +123,3 @@ public class EchoAbility extends TriggeredAbilityImpl {
} }
} }
class EchoEffect extends OneShotEffect {
protected Cost cost;
protected DynamicValue amount;
public EchoEffect(Cost costs) {
super(Outcome.Sacrifice);
this.cost = costs;
this.amount = null;
}
public EchoEffect(DynamicValue amount) {
super(Outcome.Sacrifice);
this.amount = amount;
this.cost = null;
}
public EchoEffect(final EchoEffect effect) {
super(effect);
this.cost = effect.cost;
this.amount = effect.amount;
}
@Override
public boolean apply(Game game, Ability source) {
if (amount != null) {
cost = new ManaCostsImpl(Integer.toString(amount.calculate(game, source, this)));
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null
&& source.getSourceObjectIfItStillExists(game) != null) {
if (controller.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ECHO_PAID, source.getSourceId(), source.getSourceId(), source.getControllerId()));
return true;
}
}
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
}
return true;
}
return false;
}
@Override
public EchoEffect copy() {
return new EchoEffect(this);
}
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
String costText = cost.getText();
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")) {
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));
sb.append(costText.substring(1));
} else {
sb.append("pay ").append(costText);
}
return sb.toString();
}
}

View file

@ -26,7 +26,7 @@ public enum AsThoughEffectType {
DAMAGE, DAMAGE,
SHROUD, SHROUD,
HEXPROOF, HEXPROOF,
PAY, PAY_0_ECHO,
LOOK_AT_FACE_DOWN, LOOK_AT_FACE_DOWN,
SPEND_OTHER_MANA, SPEND_OTHER_MANA,
SPEND_ONLY_MANA, SPEND_ONLY_MANA,