mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
* Some refactoring.
This commit is contained in:
parent
c41b59a006
commit
6693929557
55 changed files with 439 additions and 529 deletions
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
|
@ -43,8 +44,6 @@ import mage.filter.predicate.permanent.ControllerPredicate;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
*/
|
||||
|
@ -99,9 +98,9 @@ class AdaptiveAutomatonAddSubtypeEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type");
|
||||
if (subtype != null && !permanent.hasSubtype(subtype, game)) {
|
||||
permanent.getSubtype(game).add(subtype);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(permanent.getId(), game);
|
||||
if (subType != null && !permanent.hasSubtype(subType, game)) {
|
||||
permanent.getSubtype(game).add(subType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
|
@ -41,8 +42,6 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
|
@ -87,11 +86,9 @@ class AnZerrinRuinsDontUntapEffect extends DontUntapInControllersUntapStepAllEff
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
Permanent sourcePerm = game.getPermanent(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && sourcePerm != null) {
|
||||
SubType subtype = (SubType) game.getState().getValue(sourcePerm.getId() + "_type");
|
||||
if (permanent.hasSubtype(subtype, game)) {
|
||||
if (permanent != null) {
|
||||
if (permanent.hasSubtype(ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game), game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +98,6 @@ class AnZerrinRuinsDontUntapEffect extends DontUntapInControllersUntapStepAllEff
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Creatures of the chosen type don't untap during their controllers' untap steps.";
|
||||
return "Creatures of the chosen type don't untap during their controllers' untap steps";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
*/
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -43,10 +46,6 @@ import mage.game.stack.Spell;
|
|||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
|
@ -91,41 +90,41 @@ class ConspyEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
SubType choice = (SubType) game.getState().getValue(source.getSourceId().toString() + "_type");
|
||||
if (controller != null && choice != null) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (controller != null && subType != null) {
|
||||
// Creature cards you own that aren't on the battlefield
|
||||
// in graveyard
|
||||
for (UUID cardId : controller.getGraveyard()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card.isCreature() && !card.hasSubtype(choice, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice);
|
||||
if (card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
// on Hand
|
||||
for (UUID cardId : controller.getHand()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card.isCreature() && !card.hasSubtype(choice, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice);
|
||||
if (card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
// in Exile
|
||||
for (Card card : game.getState().getExile().getAllCards(game)) {
|
||||
if (card.isCreature() && !card.hasSubtype(choice, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice);
|
||||
if (card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
// in Library (e.g. for Mystical Teachings)
|
||||
for (Card card : controller.getLibrary().getCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId()) && card.isCreature() && !card.hasSubtype(choice, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice);
|
||||
if (card.getOwnerId().equals(controller.getId()) && card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
// commander in command zone
|
||||
for (UUID commanderId : controller.getCommandersIds()) {
|
||||
if (game.getState().getZone(commanderId) == Zone.COMMAND) {
|
||||
Card card = game.getCard(commanderId);
|
||||
if (card.isCreature() && !card.hasSubtype(choice, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice);
|
||||
if (card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,17 +134,17 @@ class ConspyEffect extends ContinuousEffectImpl {
|
|||
if (stackObject instanceof Spell
|
||||
&& stackObject.getControllerId().equals(source.getControllerId())
|
||||
&& stackObject.isCreature()
|
||||
&& !stackObject.hasSubtype(choice, game)) {
|
||||
&& !stackObject.hasSubtype(subType, game)) {
|
||||
Card card = ((Spell) stackObject).getCard();
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice);
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
// creatures you control
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(
|
||||
new FilterControlledCreaturePermanent(), source.getControllerId(), game);
|
||||
for (Permanent creature : creatures) {
|
||||
if (creature != null && !creature.hasSubtype(choice, game)) {
|
||||
creature.getSubtype(game).add(choice);
|
||||
if (creature != null && !creature.hasSubtype(subType, game)) {
|
||||
creature.getSubtype(game).add(subType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -40,8 +41,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
|
@ -84,12 +83,16 @@ class AshesOfTheFallenEffect extends ContinuousEffectImpl {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (controller != null && permanent != null) {
|
||||
SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type");
|
||||
for (UUID cardId : controller.getGraveyard()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null && card.isCreature() && !card.hasSubtype(subtype, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subtype);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(permanent.getId(), game);
|
||||
if (subType != null) {
|
||||
for (UUID cardId : controller.getGraveyard()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null && card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
discard();;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
*/
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.ConditionalMana;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
|
@ -50,10 +53,6 @@ import mage.game.stack.Spell;
|
|||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noxx
|
||||
|
@ -61,7 +60,7 @@ import java.util.UUID;
|
|||
public class CavernOfSouls extends CardImpl {
|
||||
|
||||
public CavernOfSouls(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||
|
||||
// As Cavern of Souls enters the battlefield, choose a creature type.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature)));
|
||||
|
@ -91,9 +90,9 @@ class CavernOfSoulsManaBuilder extends ConditionalManaBuilder {
|
|||
|
||||
@Override
|
||||
public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) {
|
||||
SubType value = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (value != null ) {
|
||||
creatureType = value;
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
creatureType = subType;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
|
|
|
@ -27,8 +27,12 @@
|
|||
*/
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
|
@ -43,10 +47,6 @@ import mage.game.stack.Spell;
|
|||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.util.SubTypeList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -92,33 +92,33 @@ class ConspiracyEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
SubType choice = (SubType) game.getState().getValue(source.getSourceId().toString() + "_type");
|
||||
if (controller != null && choice != null) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (controller != null && subType != null) {
|
||||
// Creature cards you own that aren't on the battlefield
|
||||
// in graveyard
|
||||
for (UUID cardId : controller.getGraveyard()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card.isCreature()) {
|
||||
setCreatureSubtype(card, choice, game);
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
// on Hand
|
||||
for (UUID cardId : controller.getHand()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card.isCreature()) {
|
||||
setCreatureSubtype(card, choice, game);
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
// in Exile
|
||||
for (Card card : game.getState().getExile().getAllCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId()) && card.isCreature()) {
|
||||
setCreatureSubtype(card, choice, game);
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
// in Library (e.g. for Mystical Teachings)
|
||||
for (Card card : controller.getLibrary().getCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId()) && card.isCreature()) {
|
||||
setCreatureSubtype(card, choice, game);
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
// commander in command zone
|
||||
|
@ -126,7 +126,7 @@ class ConspiracyEffect extends ContinuousEffectImpl {
|
|||
if (game.getState().getZone(commanderId) == Zone.COMMAND) {
|
||||
Card card = game.getCard(commanderId);
|
||||
if (card.isCreature()) {
|
||||
setCreatureSubtype(card, choice, game);
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,14 +137,14 @@ class ConspiracyEffect extends ContinuousEffectImpl {
|
|||
&& stackObject.getControllerId().equals(source.getControllerId())
|
||||
&& stackObject.isCreature()) {
|
||||
Card card = ((Spell) stackObject).getCard();
|
||||
setCreatureSubtype(card, choice, game);
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
// creatures you control
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(
|
||||
new FilterControlledCreaturePermanent(), source.getControllerId(), game);
|
||||
for (Permanent creature : creatures) {
|
||||
setCreatureSubtype(creature, choice, game);
|
||||
setCreatureSubtype(creature, subType, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
|
@ -39,8 +40,6 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
@ -48,8 +47,7 @@ import java.util.UUID;
|
|||
public class CoverOfDarkness extends CardImpl {
|
||||
|
||||
public CoverOfDarkness(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}");
|
||||
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}");
|
||||
|
||||
// As Cover of Darkness enters the battlefield, choose a creature type.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.AddAbility)));
|
||||
|
@ -68,29 +66,37 @@ public class CoverOfDarkness extends CardImpl {
|
|||
}
|
||||
|
||||
class FilterCoverOfDarkness extends FilterCreaturePermanent {
|
||||
|
||||
|
||||
private SubType subType = null;
|
||||
|
||||
public FilterCoverOfDarkness() {
|
||||
super("All creatures of the chosen type");
|
||||
}
|
||||
|
||||
|
||||
public FilterCoverOfDarkness(final FilterCoverOfDarkness filter) {
|
||||
super(filter);
|
||||
this.subType = filter.subType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FilterCoverOfDarkness copy() {
|
||||
return new FilterCoverOfDarkness(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) {
|
||||
if (super.match(permanent, sourceId, playerId, game)) {
|
||||
SubType subtype = (SubType) game.getState().getValue(sourceId + "_type");
|
||||
if (subtype != null && permanent.hasSubtype(subtype, game)) {
|
||||
if (subType == null) {
|
||||
subType = ChooseCreatureTypeEffect.getChoosenCreatureType(sourceId, game);
|
||||
if (subType == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (permanent.hasSubtype(subType, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ import mage.abilities.effects.common.DamageTargetEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
@ -55,7 +55,7 @@ import mage.target.common.TargetCreatureOrPlayer;
|
|||
public class DoomCannon extends CardImpl {
|
||||
|
||||
public DoomCannon(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{6}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}");
|
||||
|
||||
// As Doom Cannon enters the battlefield, choose a creature type.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.Sacrifice)));
|
||||
|
@ -79,29 +79,29 @@ public class DoomCannon extends CardImpl {
|
|||
}
|
||||
|
||||
class DoomCannonFilter extends FilterControlledCreaturePermanent {
|
||||
|
||||
|
||||
public DoomCannonFilter() {
|
||||
super("a creature of the chosen type");
|
||||
}
|
||||
|
||||
|
||||
public DoomCannonFilter(final DoomCannonFilter filter) {
|
||||
super(filter);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DoomCannonFilter copy() {
|
||||
return new DoomCannonFilter(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) {
|
||||
if (super.match(permanent, sourceId, playerId, game)) {
|
||||
SubType subtype = (SubType) game.getState().getValue(sourceId + "_type");
|
||||
if (subtype != null && permanent.hasSubtype(subtype, game)) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(sourceId, game);
|
||||
if (subType != null && permanent.hasSubtype(subType, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
|
@ -38,18 +39,13 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Plopman
|
||||
|
@ -57,13 +53,14 @@ import java.util.UUID;
|
|||
public class DoorOfDestinies extends CardImpl {
|
||||
|
||||
public DoorOfDestinies(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// As Door of Destinies enters the battlefield, choose a creature type.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature)));
|
||||
|
||||
// Whenever you cast a spell of the chosen type, put a charge counter on Door of Destinies.
|
||||
this.addAbility(new AddCounterAbility());
|
||||
|
||||
// Creatures you control of the chosen type get +1/+1 for each charge counter on Door of Destinies.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostCreatureEffectEffect()));
|
||||
}
|
||||
|
@ -100,17 +97,13 @@ class AddCounterAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent doorOfDestinies = game.getPermanent(getSourceId());
|
||||
if (doorOfDestinies != null) {
|
||||
SubType subtype = (SubType) game.getState().getValue(doorOfDestinies.getId() + "_type");
|
||||
if (subtype != null) {
|
||||
FilterSpell filter = new FilterSpell();
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
filter.add(new SubtypePredicate(subtype));
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(getSourceId(), game);
|
||||
if (subType != null) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null
|
||||
&& spell.getControllerId().equals(getControllerId())
|
||||
&& spell.hasSubtype(subType, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -124,7 +117,6 @@ class AddCounterAbility extends TriggeredAbilityImpl {
|
|||
|
||||
class BoostCreatureEffectEffect extends ContinuousEffectImpl {
|
||||
|
||||
|
||||
public BoostCreatureEffectEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
staticText = "Creatures you control of the chosen type get +1/+1 for each charge counter on {this}";
|
||||
|
|
|
@ -95,26 +95,24 @@ class KindredChargeEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
Object object = game.getState().getValue(sourceObject.getId() + "_type");
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
String creatureType = object.toString();
|
||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control of the chosen type");
|
||||
filter.add(new SubtypePredicate(SubType.byDescription(creatureType)));
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
|
||||
if (permanent != null) {
|
||||
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
effect.apply(game, source);
|
||||
for (Permanent addedToken : effect.getAddedPermanent()) {
|
||||
Effect exileEffect = new ExileTargetEffect();
|
||||
exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
|
||||
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control of the chosen type");
|
||||
filter.add(new SubtypePredicate(subType));
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
|
||||
if (permanent != null) {
|
||||
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
effect.apply(game, source);
|
||||
for (Permanent addedToken : effect.getAddedPermanent()) {
|
||||
Effect exileEffect = new ExileTargetEffect();
|
||||
exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
|
||||
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -28,14 +28,13 @@
|
|||
package mage.cards.k;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.abilities.effects.common.DestroyAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
|
@ -91,11 +90,13 @@ class KindredDominanceEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (controller != null & mageObject != null) {
|
||||
String creatureType = game.getState().getValue(mageObject.getId() + "_type").toString();
|
||||
FilterPermanent filter = new FilterCreaturePermanent("creatures");
|
||||
filter.add(Predicates.not(new SubtypePredicate(SubType.byDescription(creatureType))));
|
||||
return new DestroyAllEffect(filter).apply(game, source);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
FilterPermanent filter = new FilterCreaturePermanent("creatures");
|
||||
filter.add(Predicates.not(new SubtypePredicate(subType)));
|
||||
return new DestroyAllEffect(filter).apply(game, source);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,19 +98,18 @@ class KindredSummonsEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
Object object = game.getState().getValue(sourceObject.getId() + "_type");
|
||||
if (object == null) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType == null) {
|
||||
return false;
|
||||
}
|
||||
String creatureType = object.toString();
|
||||
FilterControlledCreaturePermanent filterPermanent = new FilterControlledCreaturePermanent("creature you control of the chosen type");
|
||||
filterPermanent.add(new SubtypePredicate(SubType.byDescription(creatureType)));
|
||||
filterPermanent.add(new SubtypePredicate(subType));
|
||||
int numberOfCards = game.getBattlefield().countAll(filterPermanent, source.getControllerId(), game);
|
||||
Cards revealed = new CardsImpl();
|
||||
Set<Card> chosenSubtypeCreatureCards = new LinkedHashSet<>();
|
||||
Cards otherCards = new CardsImpl();
|
||||
FilterCreatureCard filterCard = new FilterCreatureCard("creature card of the chosen type");
|
||||
filterCard.add(new SubtypePredicate(SubType.byDescription(creatureType)));
|
||||
filterCard.add(new SubtypePredicate(subType));
|
||||
while (chosenSubtypeCreatureCards.size() < numberOfCards && controller.getLibrary().hasCards()) {
|
||||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
revealed.add(card);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
|
@ -43,8 +44,6 @@ import mage.game.events.EntersTheBattlefieldEvent;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
|
@ -105,8 +104,8 @@ class MetallicMimicReplacementEffect extends ReplacementEffectImpl {
|
|||
&& enteringCreature.getControllerId().equals(source.getControllerId())
|
||||
&& enteringCreature.isCreature()
|
||||
&& !event.getTargetId().equals(source.getSourceId())) {
|
||||
SubType subtype = (SubType) game.getState().getValue(sourcePermanent.getId() + "_type");
|
||||
return subtype != null && enteringCreature.hasSubtype(subtype, game);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
return subType != null && enteringCreature.hasSubtype(subType, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.o;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -40,8 +41,6 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
|
@ -49,7 +48,7 @@ import java.util.UUID;
|
|||
public class ObeliskOfUrd extends CardImpl {
|
||||
|
||||
public ObeliskOfUrd(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{6}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}");
|
||||
|
||||
// Convoke
|
||||
this.addAbility(new ConvokeAbility());
|
||||
|
@ -93,14 +92,16 @@ class ObeliskOfUrdBoostEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type");
|
||||
if (subtype != null) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (perm.hasSubtype(subtype, game)) {
|
||||
if (perm.hasSubtype(subType, game)) {
|
||||
perm.addPower(2);
|
||||
perm.addToughness(2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -79,10 +79,7 @@ class PillarOfOriginsManaBuilder extends ConditionalManaBuilder {
|
|||
|
||||
@Override
|
||||
public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) {
|
||||
SubType value = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (value != null) {
|
||||
creatureType = value;
|
||||
}
|
||||
creatureType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.r;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
|
@ -44,15 +45,13 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
public class RidersOfGavony extends CardImpl {
|
||||
|
||||
public RidersOfGavony(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}");
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.KNIGHT);
|
||||
|
||||
|
@ -108,10 +107,12 @@ class RidersOfGavonyGainAbilityControlledEffect extends ContinuousEffectImpl {
|
|||
if (protectionFilter == null) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type");
|
||||
if (subtype != null) {
|
||||
protectionFilter = new FilterPermanent(subtype.getDescription() + 's');
|
||||
protectionFilter.add(new SubtypePredicate(subtype));
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(permanent.getId(), game);
|
||||
if (subType != null) {
|
||||
protectionFilter = new FilterPermanent(subType.getDescription() + 's');
|
||||
protectionFilter.add(new SubtypePredicate(subType));
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.r;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
|
@ -50,8 +51,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.token.RiptideReplicatorToken;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author HanClinto
|
||||
|
@ -106,9 +105,12 @@ class RiptideReplicatorEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
SubType type = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType == null) {
|
||||
return false;
|
||||
}
|
||||
int x = (new CountersSourceCount(CounterType.CHARGE)).calculate(game, source, this);
|
||||
Token token = new RiptideReplicatorToken(color, type, x);
|
||||
Token token = new RiptideReplicatorToken(color, subType, x);
|
||||
return token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
|
@ -39,8 +40,6 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author markedagain
|
||||
|
@ -48,7 +47,7 @@ import java.util.UUID;
|
|||
public class SteelyResolve extends CardImpl {
|
||||
|
||||
public SteelyResolve(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
|
||||
|
||||
// As Steely Resolve enters the battlefield, choose a creature type.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.AddAbility)));
|
||||
|
@ -65,30 +64,31 @@ public class SteelyResolve extends CardImpl {
|
|||
return new SteelyResolve(this);
|
||||
}
|
||||
}
|
||||
|
||||
class FilterSteelyResolve extends FilterCreaturePermanent {
|
||||
|
||||
|
||||
public FilterSteelyResolve() {
|
||||
super("All creatures of the chosen type");
|
||||
}
|
||||
|
||||
|
||||
public FilterSteelyResolve(final FilterSteelyResolve filter) {
|
||||
super(filter);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FilterSteelyResolve copy() {
|
||||
return new FilterSteelyResolve(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) {
|
||||
if (super.match(permanent, sourceId, playerId, game)) {
|
||||
SubType subtype = (SubType) game.getState().getValue(sourceId + "_type");
|
||||
if (subtype != null && permanent.hasSubtype(subtype, game)) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(sourceId, game);
|
||||
if (subType != null && permanent.hasSubtype(subType, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -83,9 +83,9 @@ class UnclaimedTerritoryManaBuilder extends ConditionalManaBuilder {
|
|||
|
||||
@Override
|
||||
public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) {
|
||||
SubType value = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (value != null) {
|
||||
creatureType = value;
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
creatureType = subType;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
|
|
|
@ -42,14 +42,11 @@ import mage.constants.Outcome;
|
|||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
/**
|
||||
|
@ -110,17 +107,14 @@ class DrawCardIfCreatureTypeAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent vanquishersBanner = game.getPermanent(getSourceId());
|
||||
if (vanquishersBanner != null) {
|
||||
SubType subtype = (SubType) game.getState().getValue(vanquishersBanner.getId() + "_type");
|
||||
if (subtype != null) {
|
||||
FilterSpell filter = new FilterSpell();
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
filter.add(new SubtypePredicate(subtype));
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(getSourceId(), game);
|
||||
if (subType != null) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null
|
||||
&& spell.isCreature()
|
||||
&& spell.hasSubtype(subType, game)
|
||||
&& spell.getControllerId().equals(getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.v;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
|
@ -47,8 +48,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.token.Token;
|
||||
import mage.game.permanent.token.VolrathsLaboratoryToken;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
|
@ -100,8 +99,8 @@ class VolrathsLaboratoryEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
SubType type = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
Token token = new VolrathsLaboratoryToken(color, type);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
Token token = new VolrathsLaboratoryToken(color, subType);
|
||||
return token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.cards.x;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -39,9 +41,6 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
|
@ -80,12 +79,12 @@ class XenograftAddSubtypeEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (subtype != null) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game);
|
||||
for (Permanent permanent : permanents) {
|
||||
if (permanent != null && !permanent.hasSubtype(subtype, game)) {
|
||||
permanent.getSubtype(game).add(subtype);
|
||||
if (permanent != null && !permanent.hasSubtype(subType, game)) {
|
||||
permanent.getSubtype(game).add(subType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -57,12 +57,9 @@ public class AllyEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
EntersTheBattlefieldEvent ebe = (EntersTheBattlefieldEvent) event;
|
||||
if (ebe.getTarget().getControllerId().equals(this.controllerId)
|
||||
return ebe.getTarget().getControllerId().equals(this.controllerId)
|
||||
&& (event.getTargetId().equals(this.getSourceId())
|
||||
|| (ebe.getTarget().hasSubtype(SubType.ALLY, game) && !event.getTargetId().equals(this.getSourceId())))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|| (ebe.getTarget().hasSubtype(SubType.ALLY, game) && !event.getTargetId().equals(this.getSourceId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,10 +32,7 @@ public class AttacksOrBlocksEnchantedTriggeredAbility extends TriggeredAbilityIm
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchantment = game.getPermanent(this.getSourceId());
|
||||
if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,72 +1,69 @@
|
|||
/*
|
||||
* 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.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class BecomesExertSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public BecomesExertSourceTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect, false);
|
||||
}
|
||||
|
||||
public BecomesExertSourceTriggeredAbility(final BecomesExertSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesExertSourceTriggeredAbility copy() {
|
||||
return new BecomesExertSourceTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.BECOMES_EXERTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getSourceId().equals(this.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When {this} becomes exerted, " + super.getRule();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class BecomesExertSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public BecomesExertSourceTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect, false);
|
||||
}
|
||||
|
||||
public BecomesExertSourceTriggeredAbility(final BecomesExertSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesExertSourceTriggeredAbility copy() {
|
||||
return new BecomesExertSourceTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.BECOMES_EXERTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getSourceId().equals(this.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When {this} becomes exerted, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,11 +61,8 @@ public class CycleAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return false;
|
||||
}
|
||||
StackObject item = game.getState().getStack().getFirst();
|
||||
if (item instanceof StackAbility
|
||||
&& item.getStackAbility() instanceof CyclingAbility) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return item instanceof StackAbility
|
||||
&& item.getStackAbility() instanceof CyclingAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,80 +1,77 @@
|
|||
/*
|
||||
* 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.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class EntersBattlefieldOrAttacksSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
}
|
||||
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility(final EntersBattlefieldOrAttacksSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility copy() {
|
||||
return new EntersBattlefieldOrAttacksSourceTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} enters the battlefield or attacks, " + super.getRule();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class EntersBattlefieldOrAttacksSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
}
|
||||
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility(final EntersBattlefieldOrAttacksSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntersBattlefieldOrAttacksSourceTriggeredAbility copy() {
|
||||
return new EntersBattlefieldOrAttacksSourceTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} enters the battlefield or attacks, " + super.getRule();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,10 +77,7 @@ public class OnEventTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (allPlayers || event.getPlayerId().equals(this.controllerId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return allPlayers || event.getPlayerId().equals(this.controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -74,10 +74,7 @@ public class SimpleTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!onlyController || event.getPlayerId().equals(this.controllerId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !onlyController || event.getPlayerId().equals(this.controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,10 +101,7 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
|
|||
}
|
||||
}
|
||||
if (correctEndPhase) {
|
||||
if (condition != null && !condition.apply(game, this)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(condition != null && !condition.apply(game, this));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -70,10 +70,7 @@ public class ExileSourceFromGraveCost extends CostImpl {
|
|||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && game.getState().getZone(sourceId) == Zone.GRAVEYARD) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return card != null && game.getState().getZone(sourceId) == Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,10 +64,7 @@ public class RemoveCountersSourceCost extends CostImpl {
|
|||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null && permanent.getCounters(game).getCount(name) >= amount) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return permanent != null && permanent.getCounters(game).getCount(name) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,10 +44,7 @@ public class AffinityEffect extends CostModificationEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,10 +26,7 @@ public class AttacksIfAbleTargetPlayerSourceEffect extends RequirementEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return permanent.getId().equals(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -86,4 +87,18 @@ public class ChooseCreatureTypeEffect extends OneShotEffect {
|
|||
return new ChooseCreatureTypeEffect(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param objectId sourceId the effect was exeuted under
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
public static SubType getChoosenCreatureType(UUID objectId, Game game) {
|
||||
SubType creatureType = null;
|
||||
Object savedCreatureType = game.getState().getValue(objectId + "_type");
|
||||
if (savedCreatureType != null) {
|
||||
creatureType = SubType.byDescription(savedCreatureType.toString());
|
||||
}
|
||||
return creatureType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,10 +159,7 @@ class DetainRestrictionEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (this.targetPointer.getTargets(game, source).contains(permanent.getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.targetPointer.getTargets(game, source).contains(permanent.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -123,10 +123,7 @@ public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!used && super.applies(event, source, game) && targetAmountMap.containsKey(event.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !used && super.applies(event, source, game) && targetAmountMap.containsKey(event.getTargetId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,10 +82,8 @@ public class RegenerateTargetEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
//20110204 - 701.11c - event.getAmount() is used to signal if regeneration is allowed
|
||||
if (event.getAmount() == 0 && event.getTargetId().equals(targetPointer.getFirst(game, source)) && !this.used) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return event.getAmount() == 0 && event.getTargetId().equals(targetPointer.getFirst(game, source)) && !this.used;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,10 +40,7 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect {
|
|||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null
|
||||
&& permanent.getId().equals(attachment.getAttachedTo())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return attachment != null && attachment.getAttachedTo() != null
|
||||
&& permanent.getId().equals(attachment.getAttachedTo());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,11 +51,8 @@ public class CantAttackBlockAttachedEffect extends RestrictionEffect {
|
|||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null
|
||||
&& permanent.getId().equals(attachment.getAttachedTo())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return attachment != null && attachment.getAttachedTo() != null
|
||||
&& permanent.getId().equals(attachment.getAttachedTo());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,10 +76,7 @@ public class CantAttackIfDefenderControlsPermanent extends RestrictionEffect {
|
|||
} else {
|
||||
defendingPlayerId = defenderId;
|
||||
}
|
||||
if (defendingPlayerId != null && game.getBattlefield().countAll(filter, defendingPlayerId, game) > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(defendingPlayerId != null && game.getBattlefield().countAll(filter, defendingPlayerId, game) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,10 +51,7 @@ public class CantAttackSourceEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return permanent.getId().equals(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,10 +63,7 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (filter.match(blocker, source.getSourceId(), source.getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,18 +58,12 @@ public class CantBeBlockedByTargetSourceEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (source.getSourceId().equals(permanent.getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return source.getSourceId().equals(permanent.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (this.getTargetPointer().getTargets(game, source).contains(blocker.getId())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !this.getTargetPointer().getTargets(game, source).contains(blocker.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,10 +54,7 @@ public class CantBlockSourceEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return permanent.getId().equals(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,59 +1,56 @@
|
|||
/*
|
||||
* 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.effects.common.continuous;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughEffectImpl {
|
||||
|
||||
private Class activatedAbility;
|
||||
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(Class activatedAbility, String activatedAbilityName) {
|
||||
super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
|
||||
this.activatedAbility = activatedAbility;
|
||||
staticText = "You may activate " + activatedAbilityName + " any time you could cast an instant";
|
||||
}
|
||||
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(final ActivateAbilitiesAnyTimeYouCouldCastInstantEffect effect) {
|
||||
super(effect);
|
||||
this.activatedAbility = effect.activatedAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect copy() {
|
||||
return new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
|
||||
if (affectedAbility.getControllerId().equals(source.getControllerId())
|
||||
&& activatedAbility.isInstance(affectedAbility)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return false; // Not used
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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.effects.common.continuous;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughEffectImpl {
|
||||
|
||||
private Class activatedAbility;
|
||||
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(Class activatedAbility, String activatedAbilityName) {
|
||||
super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
|
||||
this.activatedAbility = activatedAbility;
|
||||
staticText = "You may activate " + activatedAbilityName + " any time you could cast an instant";
|
||||
}
|
||||
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(final ActivateAbilitiesAnyTimeYouCouldCastInstantEffect effect) {
|
||||
super(effect);
|
||||
this.activatedAbility = effect.activatedAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect copy() {
|
||||
return new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
|
||||
return affectedAbility.getControllerId().equals(source.getControllerId())
|
||||
&& activatedAbility.isInstance(affectedAbility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return false; // Not used
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
@ -48,9 +49,9 @@ public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect {
|
|||
|
||||
@Override
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
SubType s = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (s != null) {
|
||||
subtype = s;
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
subtype = subType;
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
|
|
|
@ -96,10 +96,7 @@ public class CantCastMoreThanOneSpellEffect extends ContinuousRuleModifyingEffec
|
|||
}
|
||||
}
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterCard;
|
||||
|
@ -32,9 +33,9 @@ public class SpellsCostReductionAllOfChosenSubtypeEffect extends SpellsCostReduc
|
|||
|
||||
@Override
|
||||
protected boolean selectedByRuntimeData(Card card, Ability source, Game game) {
|
||||
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (subtype != null) {
|
||||
return card.hasSubtype(subtype, game);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
|
||||
if (subType != null) {
|
||||
return card.hasSubtype(subType, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -81,18 +81,12 @@ class FearEffect extends RestrictionEffect implements MageSingleton {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getAbilities().containsKey(FearAbility.getInstance().getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return permanent.getAbilities().containsKey(FearAbility.getInstance().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (blocker.isArtifact() || blocker.getColor(game).isBlack()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return blocker.isArtifact() || blocker.getColor(game).isBlack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,10 +44,7 @@ public class RippleAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.getSourceId().equals(this.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return spell != null && spell.getSourceId().equals(this.getSourceId());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -99,10 +99,7 @@ class TotemArmorEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null && event.getTargetId().equals(sourcePermanent.getAttachedTo())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return sourcePermanent != null && event.getTargetId().equals(sourcePermanent.getAttachedTo());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
*/
|
||||
package mage.filter.predicate.mageobject;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
|
@ -48,8 +48,8 @@ public class ChosenSubtypePredicate implements Predicate<MageObject> {
|
|||
|
||||
@Override
|
||||
public boolean apply(MageObject input, Game game) {
|
||||
SubType subtype = (SubType) game.getState().getValue(cardID + "_type");
|
||||
return input.hasSubtype(subtype, game);
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(cardID, game);
|
||||
return input.hasSubtype(subType, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -976,10 +976,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false);
|
||||
}
|
||||
|
||||
protected boolean canDamage(MageObject source, Game game) {
|
||||
|
|
|
@ -71,11 +71,8 @@ class CantBeEnchantedAbility extends StaticAbility {
|
|||
}
|
||||
|
||||
public boolean canTarget(MageObject source, Game game) {
|
||||
if (source.isEnchantment()
|
||||
&& source.hasSubtype(SubType.AURA, game)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(source.isEnchantment()
|
||||
&& source.hasSubtype(SubType.AURA, game));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue