mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 12:19:59 -08:00
Merge origin/master
This commit is contained in:
commit
4785ebd5f8
16 changed files with 420 additions and 138 deletions
|
|
@ -34,6 +34,7 @@ import mage.ConditionalMana;
|
|||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
|
|
@ -80,8 +81,9 @@ public class CavernOfSouls extends CardImpl {
|
|||
this.addAbility(new ColorlessManaAbility());
|
||||
|
||||
// {T}: Add one mana of any color to your mana pool. Spend this mana only to cast a creature spell of the chosen type, and that spell can't be countered.
|
||||
this.addAbility(new ConditionalAnyColorManaAbility(new TapSourceCost(), 1, new CavernOfSoulsManaBuilder(), true), new CavernOfSoulsWatcher());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new CavernOfSoulsCantCounterEffect()));
|
||||
Ability ability = new ConditionalAnyColorManaAbility(new TapSourceCost(), 1, new CavernOfSoulsManaBuilder(), true);
|
||||
this.addAbility(ability, new CavernOfSoulsWatcher(ability.getOriginalId()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new CavernOfSoulsCantCounterEffect()));
|
||||
}
|
||||
|
||||
public CavernOfSouls(final CavernOfSouls card) {
|
||||
|
|
@ -146,14 +148,12 @@ class CavernOfSoulsManaBuilder extends ConditionalManaBuilder {
|
|||
if (controller != null && sourceObject != null) {
|
||||
game.informPlayers(controller.getName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() +
|
||||
" (can only be spend to cast for creatures of type " + creatureType + " and that spell can't be countered)");
|
||||
}
|
||||
|
||||
}
|
||||
return super.setMana(mana, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionalMana build(Object... options) {
|
||||
this.mana.setFlag(true); // indicates that the mana is from second ability
|
||||
return new CavernOfSoulsConditionalMana(this.mana, creatureType);
|
||||
}
|
||||
|
||||
|
|
@ -196,15 +196,18 @@ class CavernOfSoulsManaCondition extends CreatureCastManaCondition {
|
|||
|
||||
class CavernOfSoulsWatcher extends Watcher {
|
||||
|
||||
public List<UUID> spells = new ArrayList<>();
|
||||
|
||||
public CavernOfSoulsWatcher() {
|
||||
super("ManaPaidFromCavernOfSoulsWatcher", WatcherScope.GAME);
|
||||
private List<UUID> spells = new ArrayList<>();
|
||||
private final String originalId;
|
||||
|
||||
public CavernOfSoulsWatcher(UUID originalId) {
|
||||
super("ManaPaidFromCavernOfSoulsWatcher", WatcherScope.CARD);
|
||||
this.originalId = originalId.toString();
|
||||
}
|
||||
|
||||
public CavernOfSoulsWatcher(final CavernOfSoulsWatcher watcher) {
|
||||
super(watcher);
|
||||
this.spells.addAll(watcher.spells);
|
||||
this.originalId = watcher.originalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -215,13 +218,15 @@ class CavernOfSoulsWatcher extends Watcher {
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
// TODO: Replace identification by name by better method that also works if ability is copied from other land with other name
|
||||
if (object != null && object.getName().equals("Cavern of Souls") && event.getFlag()) {
|
||||
if (event.getData() != null && event.getData().equals(originalId)) {
|
||||
spells.add(event.getTargetId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean spellCantBeCountered(UUID spellId) {
|
||||
return spells.contains(spellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
|
@ -267,8 +272,8 @@ class CavernOfSoulsCantCounterEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get("ManaPaidFromCavernOfSoulsWatcher");
|
||||
CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get("ManaPaidFromCavernOfSoulsWatcher", source.getSourceId());
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
return spell != null && watcher.spells.contains(spell.getId());
|
||||
return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.sets.betrayersofkamigawa;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -38,13 +36,10 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.PlayerCastCreatureWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -110,41 +105,3 @@ class GoblinCohortEffect extends RestrictionEffect {
|
|||
}
|
||||
}
|
||||
|
||||
class PlayerCastCreatureWatcher extends Watcher {
|
||||
|
||||
Set<UUID> playerIds = new HashSet<>();
|
||||
|
||||
public PlayerCastCreatureWatcher() {
|
||||
super("PlayerCastCreature", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {
|
||||
super(watcher);
|
||||
this.playerIds.addAll(watcher.playerIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell.getCardType().contains(CardType.CREATURE)) {
|
||||
playerIds.add(spell.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerCastCreatureWatcher copy() {
|
||||
return new PlayerCastCreatureWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playerIds.clear();
|
||||
}
|
||||
|
||||
public boolean playerDidCastCreatureThisTurn(UUID playerId) {
|
||||
return playerIds.contains(playerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,11 +52,6 @@ public class Progenitus extends CardImpl {
|
|||
this.subtype.add("Hydra");
|
||||
this.subtype.add("Avatar");
|
||||
|
||||
this.color.setRed(true);
|
||||
this.color.setBlue(true);
|
||||
this.color.setGreen(true);
|
||||
this.color.setBlack(true);
|
||||
this.color.setWhite(true);
|
||||
this.power = new MageInt(10);
|
||||
this.toughness = new MageInt(10);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,17 +106,23 @@ class GrindstoneEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
colorShared = false;
|
||||
Card card1 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card1 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card1, source.getSourceId(), game, Zone.LIBRARY);
|
||||
Card card2 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card2 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card2, source.getSourceId(), game, Zone.LIBRARY);
|
||||
Card card1 = null;
|
||||
Card card2 = null;
|
||||
if (targetPlayer.getLibrary().size() > 0) {
|
||||
card1 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (targetPlayer.getLibrary().size() > 0) {
|
||||
card2 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card1.getColor().hasColor() && card2.getColor().hasColor()) {
|
||||
colorShared = card1.getColor().shares(card2.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (card1 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card1, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
if (card2 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card2, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
} while (colorShared && targetPlayer.isInGame());
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.sets.tempest;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -38,13 +36,10 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.PlayerCastCreatureWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -107,42 +102,3 @@ class MoggConscriptsEffect extends RestrictionEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerCastCreatureWatcher extends Watcher {
|
||||
|
||||
Set<UUID> playerIds = new HashSet<>();
|
||||
|
||||
public PlayerCastCreatureWatcher() {
|
||||
super("PlayerCastCreature", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {
|
||||
super(watcher);
|
||||
this.playerIds.addAll(watcher.playerIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell.getCardType().contains(CardType.CREATURE)) {
|
||||
playerIds.add(spell.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerCastCreatureWatcher copy() {
|
||||
return new PlayerCastCreatureWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playerIds.clear();
|
||||
}
|
||||
|
||||
public boolean playerDidCastCreatureThisTurn(UUID playerId) {
|
||||
return playerIds.contains(playerId);
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,8 @@ import mage.abilities.common.SimpleStaticAbility;
|
|||
import mage.abilities.condition.common.CardsInControllerGraveCondition;
|
||||
import mage.abilities.costs.common.DiscardCardCost;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.decorator.ConditionalRestrictionEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.combat.CantBlockSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
|
|
@ -57,7 +59,6 @@ public class PutridImp extends CardImpl {
|
|||
this.subtype.add("Zombie");
|
||||
this.subtype.add("Imp");
|
||||
|
||||
this.color.setBlack(true);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
|
|
@ -68,8 +69,9 @@ public class PutridImp extends CardImpl {
|
|||
new BoostSourceEffect(1, 1, Duration.WhileOnBattlefield),
|
||||
new CardsInControllerGraveCondition(7),
|
||||
"<i>Threshold</i> - As long as seven or more cards are in your graveyard, {this} gets +1/+1"));
|
||||
ability.addEffect(new ConditionalContinuousEffect(new CantBlockSourceEffect(Duration.WhileOnBattlefield), new CardsInControllerGraveCondition(7),
|
||||
"and can't block"));
|
||||
Effect effect = new ConditionalRestrictionEffect(new CantBlockSourceEffect(Duration.WhileOnBattlefield), new CardsInControllerGraveCondition(7));
|
||||
effect.setText("and can't block");
|
||||
ability.addEffect(effect);
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue