mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
[MH2] Implemented Tavern Scoundrel
This commit is contained in:
parent
8a5b9a6018
commit
e7adae42ef
4 changed files with 123 additions and 15 deletions
98
Mage.Sets/src/mage/cards/t/TavernScoundrel.java
Normal file
98
Mage.Sets/src/mage/cards/t/TavernScoundrel.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.FlipCoinEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.CoinFlippedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.token.TreasureToken;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class TavernScoundrel extends CardImpl {
|
||||
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("another permanent");
|
||||
|
||||
static {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
}
|
||||
|
||||
public TavernScoundrel(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
|
||||
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.ROGUE);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(3);
|
||||
|
||||
// Whenever you win a coin flip, create two Treasure tokens.
|
||||
this.addAbility(new TavernScoundrelTriggeredAbility());
|
||||
|
||||
// {1}, {T}, Sacrifice another permanent: Flip a coin.
|
||||
Ability ability = new SimpleActivatedAbility(new FlipCoinEffect(), new GenericManaCost(1));
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter)));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
private TavernScoundrel(final TavernScoundrel card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TavernScoundrel copy() {
|
||||
return new TavernScoundrel(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TavernScoundrelTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
TavernScoundrelTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new CreateTokenEffect(new TreasureToken(), 2), false);
|
||||
}
|
||||
|
||||
private TavernScoundrelTriggeredAbility(final TavernScoundrelTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TavernScoundrelTriggeredAbility copy() {
|
||||
return new TavernScoundrelTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.COIN_FLIPPED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
CoinFlippedEvent flipEvent = (CoinFlippedEvent) event;
|
||||
return isControlledBy(event.getPlayerId())
|
||||
&& flipEvent.isWinnable()
|
||||
&& flipEvent.wasWon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you win a coin flip, create two Treasure tokens.";
|
||||
}
|
||||
}
|
|
@ -210,6 +210,7 @@ public final class ModernHorizons2 extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Sylvan Anthem", 176, Rarity.RARE, mage.cards.s.SylvanAnthem.class));
|
||||
cards.add(new SetCardInfo("Sythis, Harvest's Hand", 214, Rarity.RARE, mage.cards.s.SythisHarvestsHand.class));
|
||||
cards.add(new SetCardInfo("Tanglepool Bridge", 257, Rarity.COMMON, mage.cards.t.TanglepoolBridge.class));
|
||||
cards.add(new SetCardInfo("Tavern Scoundrel", 144, Rarity.COMMON, mage.cards.t.TavernScoundrel.class));
|
||||
cards.add(new SetCardInfo("Terramorph", 177, Rarity.UNCOMMON, mage.cards.t.Terramorph.class));
|
||||
cards.add(new SetCardInfo("Territorial Kavu", 216, Rarity.RARE, mage.cards.t.TerritorialKavu.class));
|
||||
cards.add(new SetCardInfo("The Underworld Cookbook", 240, Rarity.UNCOMMON, mage.cards.t.TheUnderworldCookbook.class));
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
|
@ -13,7 +12,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class FlipCoinEffect extends OneShotEffect {
|
||||
|
@ -21,6 +19,10 @@ public class FlipCoinEffect extends OneShotEffect {
|
|||
protected Effects executingEffectsWon = new Effects();
|
||||
protected Effects executingEffectsLost = new Effects();
|
||||
|
||||
public FlipCoinEffect() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public FlipCoinEffect(Effect effectWon) {
|
||||
this(effectWon, null);
|
||||
}
|
||||
|
@ -58,19 +60,19 @@ public class FlipCoinEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && mageObject != null) {
|
||||
boolean result = true;
|
||||
for (Effect effect : controller.flipCoin(source, game, true) ? executingEffectsWon : executingEffectsLost) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
result &= effect.apply(game, source);
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
if (controller == null || mageObject == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
boolean result = true;
|
||||
for (Effect effect : controller.flipCoin(source, game, true) ? executingEffectsWon : executingEffectsLost) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
result &= effect.apply(game, source);
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +80,10 @@ public class FlipCoinEffect extends OneShotEffect {
|
|||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("Flip a coin. If you win the flip, ").append(executingEffectsWon.getText(mode));
|
||||
StringBuilder sb = new StringBuilder("flip a coin");
|
||||
if (!executingEffectsWon.isEmpty()) {
|
||||
sb.append(". If you win the flip, ").append(executingEffectsWon.getText(mode));
|
||||
}
|
||||
if (!executingEffectsLost.isEmpty()) {
|
||||
sb.append(" If you lose the flip, ").append(executingEffectsLost.getText(mode));
|
||||
}
|
||||
|
|
|
@ -40,4 +40,8 @@ public class CoinFlippedEvent extends GameEvent {
|
|||
public boolean isWinnable() {
|
||||
return winnable;
|
||||
}
|
||||
|
||||
public boolean wasWon() {
|
||||
return result == chosen;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue