mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
remove redundant null checks before instanceof
This commit is contained in:
parent
d3aea0270c
commit
f04d7c9b03
72 changed files with 184 additions and 186 deletions
|
@ -538,7 +538,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
// Always hide not hidden popup window or enlarged card view if a frame is set to active
|
// Always hide not hidden popup window or enlarged card view if a frame is set to active
|
||||||
try {
|
try {
|
||||||
ActionCallback callback = Plugins.instance.getActionCallback();
|
ActionCallback callback = Plugins.instance.getActionCallback();
|
||||||
if (callback != null && callback instanceof MageActionCallback) {
|
if (callback instanceof MageActionCallback) {
|
||||||
((MageActionCallback) callback).hideEnlargedCard();
|
((MageActionCallback) callback).hideEnlargedCard();
|
||||||
}
|
}
|
||||||
Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||||
|
|
|
@ -319,7 +319,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||||
j = (JComponent) getComponentAt(e.getX(), e.getY());
|
j = (JComponent) getComponentAt(e.getX(), e.getY());
|
||||||
|
|
||||||
if (j != null && j instanceof DialogContainer) {
|
if (j instanceof DialogContainer) {
|
||||||
rec = j.getBounds();
|
rec = j.getBounds();
|
||||||
bDragged = true;
|
bDragged = true;
|
||||||
mx = e.getX();
|
mx = e.getX();
|
||||||
|
|
|
@ -530,7 +530,7 @@ public class MageBook extends JComponent {
|
||||||
Class<?> c = Class.forName(className);
|
Class<?> c = Class.forName(className);
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object newToken = cons.newInstance();
|
Object newToken = cons.newInstance();
|
||||||
if (newToken != null && newToken instanceof mage.game.permanent.token.Token) {
|
if (newToken instanceof Token) {
|
||||||
((Token) newToken).setExpansionSetCodeForImage(set);
|
((Token) newToken).setExpansionSetCodeForImage(set);
|
||||||
((Token) newToken).setOriginalExpansionSetCode(set);
|
((Token) newToken).setOriginalExpansionSetCode(set);
|
||||||
((Token) newToken).setTokenType(token.getType());
|
((Token) newToken).setTokenType(token.getType());
|
||||||
|
@ -580,7 +580,7 @@ public class MageBook extends JComponent {
|
||||||
Class<?> c = Class.forName(className);
|
Class<?> c = Class.forName(className);
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object newEmblem = cons.newInstance();
|
Object newEmblem = cons.newInstance();
|
||||||
if (newEmblem != null && newEmblem instanceof mage.game.command.Emblem) {
|
if (newEmblem instanceof Emblem) {
|
||||||
((Emblem) newEmblem).setExpansionSetCodeForImage(set);
|
((Emblem) newEmblem).setExpansionSetCodeForImage(set);
|
||||||
|
|
||||||
emblems.add((Emblem) newEmblem);
|
emblems.add((Emblem) newEmblem);
|
||||||
|
@ -637,7 +637,7 @@ public class MageBook extends JComponent {
|
||||||
Class<?> c = Class.forName(className);
|
Class<?> c = Class.forName(className);
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object newPlane = cons.newInstance();
|
Object newPlane = cons.newInstance();
|
||||||
if (newPlane != null && newPlane instanceof mage.game.command.Plane) {
|
if (newPlane instanceof Plane) {
|
||||||
((Plane) newPlane).setExpansionSetCodeForImage(set);
|
((Plane) newPlane).setExpansionSetCodeForImage(set);
|
||||||
|
|
||||||
planes.add((Plane) newPlane);
|
planes.add((Plane) newPlane);
|
||||||
|
|
|
@ -369,7 +369,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
||||||
if (!card.getId().equals(bigCard.getCardId())) {
|
if (!card.getId().equals(bigCard.getCardId())) {
|
||||||
if (!MageFrame.isLite()) {
|
if (!MageFrame.isLite()) {
|
||||||
Image image = Plugins.instance.getOriginalImage(card);
|
Image image = Plugins.instance.getOriginalImage(card);
|
||||||
if (image != null && image instanceof BufferedImage) {
|
if (image instanceof BufferedImage) {
|
||||||
// XXX: scaled to fit width
|
// XXX: scaled to fit width
|
||||||
bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<>(), false);
|
bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<>(), false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -617,7 +617,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) {
|
private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) {
|
||||||
if (image != null && image instanceof BufferedImage) {
|
if (image instanceof BufferedImage) {
|
||||||
// XXX: scaled to fit width
|
// XXX: scaled to fit width
|
||||||
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules(), mageCard.getOriginal().isToRotate());
|
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules(), mageCard.getOriginal().isToRotate());
|
||||||
// if it's an ability, show only the ability text as overlay
|
// if it's an ability, show only the ability text as overlay
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class CountryItemEditor extends BasicComboBoxEditor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItem(Object item) {
|
public void setItem(Object item) {
|
||||||
if (item == null || !(item instanceof String[])) {
|
if (!(item instanceof String[])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -800,7 +800,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
||||||
// this update removes the isChoosable mark from targetCardsInLibrary
|
// this update removes the isChoosable mark from targetCardsInLibrary
|
||||||
// so only done for permanents because it's needed to redraw counters in different size, if window size was changed
|
// so only done for permanents because it's needed to redraw counters in different size, if window size was changed
|
||||||
// no perfect solution yet (maybe also other not wanted effects for PermanentView objects)
|
// no perfect solution yet (maybe also other not wanted effects for PermanentView objects)
|
||||||
if (updateCard != null && (updateCard instanceof PermanentView)) {
|
if ((updateCard instanceof PermanentView)) {
|
||||||
update(updateCard);
|
update(updateCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ public class Connection {
|
||||||
for (InterfaceAddress addr : iface.getInterfaceAddresses()) {
|
for (InterfaceAddress addr : iface.getInterfaceAddresses()) {
|
||||||
if (addr != null) {
|
if (addr != null) {
|
||||||
InetAddress iaddr = addr.getAddress();
|
InetAddress iaddr = addr.getAddress();
|
||||||
if (iaddr != null && iaddr instanceof Inet4Address) {
|
if (iaddr instanceof Inet4Address) {
|
||||||
return iaddr;
|
return iaddr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public final class CompressUtil {
|
||||||
* @return Decompressed object
|
* @return Decompressed object
|
||||||
*/
|
*/
|
||||||
public static Object decompress(Object data) {
|
public static Object decompress(Object data) {
|
||||||
if (data == null || !(data instanceof ZippedObject)) {
|
if (!(data instanceof ZippedObject)) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
return ((ZippedObject) data).unzip();
|
return ((ZippedObject) data).unzip();
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class LevelUpOptimizer extends BaseTreeOptimizer {
|
||||||
for (Ability ability : actions) {
|
for (Ability ability : actions) {
|
||||||
if (ability instanceof LevelUpAbility) {
|
if (ability instanceof LevelUpAbility) {
|
||||||
Permanent permanent = game.getPermanent(ability.getSourceId());
|
Permanent permanent = game.getPermanent(ability.getSourceId());
|
||||||
if (permanent != null && permanent instanceof PermanentCard) {
|
if (permanent instanceof PermanentCard) {
|
||||||
PermanentCard leveler = (PermanentCard) permanent;
|
PermanentCard leveler = (PermanentCard) permanent;
|
||||||
// check already existing Level counters and compare to maximum that make sense
|
// check already existing Level counters and compare to maximum that make sense
|
||||||
if (permanent.getCounters(game).getCount(CounterType.LEVEL) >= leveler.getMaxLevelCounters()) {
|
if (permanent.getCounters(game).getCount(CounterType.LEVEL) >= leveler.getMaxLevelCounters()) {
|
||||||
|
|
|
@ -408,7 +408,7 @@ public final class SystemUtil {
|
||||||
Class<?> c = Class.forName("mage.game.permanent.token." + command.cardName);
|
Class<?> c = Class.forName("mage.game.permanent.token." + command.cardName);
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object token = cons.newInstance();
|
Object token = cons.newInstance();
|
||||||
if (token != null && token instanceof mage.game.permanent.token.Token) {
|
if (token instanceof mage.game.permanent.token.Token) {
|
||||||
((mage.game.permanent.token.Token) token).putOntoBattlefield(command.Amount, game, null, player.getId(), false, false);
|
((mage.game.permanent.token.Token) token).putOntoBattlefield(command.Amount, game, null, player.getId(), false, false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ public final class SystemUtil {
|
||||||
Class<?> c = Class.forName("mage.game.command.emblems." + command.cardName);
|
Class<?> c = Class.forName("mage.game.command.emblems." + command.cardName);
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object emblem = cons.newInstance();
|
Object emblem = cons.newInstance();
|
||||||
if (emblem != null && emblem instanceof mage.game.command.Emblem) {
|
if (emblem instanceof mage.game.command.Emblem) {
|
||||||
((mage.game.command.Emblem) emblem).setControllerId(player.getId());
|
((mage.game.command.Emblem) emblem).setControllerId(player.getId());
|
||||||
game.addEmblem((mage.game.command.Emblem) emblem, null, player.getId());
|
game.addEmblem((mage.game.command.Emblem) emblem, null, player.getId());
|
||||||
continue;
|
continue;
|
||||||
|
@ -427,7 +427,7 @@ public final class SystemUtil {
|
||||||
Class<?> c = Class.forName("mage.game.command.planes." + command.cardName);
|
Class<?> c = Class.forName("mage.game.command.planes." + command.cardName);
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object plane = cons.newInstance();
|
Object plane = cons.newInstance();
|
||||||
if (plane != null && plane instanceof mage.game.command.Plane) {
|
if (plane instanceof mage.game.command.Plane) {
|
||||||
((mage.game.command.Plane) plane).setControllerId(player.getId());
|
((mage.game.command.Plane) plane).setControllerId(player.getId());
|
||||||
game.addPlane((mage.game.command.Plane) plane, null, player.getId());
|
game.addPlane((mage.game.command.Plane) plane, null, player.getId());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -171,7 +171,7 @@ class BerserkDelayedDestroyEffect extends OneShotEffect {
|
||||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
if (watcher instanceof AttackedThisTurnWatcher) {
|
||||||
if (((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
|
if (((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
|
||||||
return permanent.destroy(source.getSourceId(), game, false);
|
return permanent.destroy(source.getSourceId(), game, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ class WhackCondition extends IntCompareCondition {
|
||||||
@Override
|
@Override
|
||||||
protected int getInputValue(Game game, Ability source) {
|
protected int getInputValue(Game game, Ability source) {
|
||||||
Object object = game.getState().getValue("whack" + source.getSourceId());
|
Object object = game.getState().getValue("whack" + source.getSourceId());
|
||||||
if (object != null && object instanceof Boolean && (Boolean) object) {
|
if (object instanceof Boolean && (Boolean) object) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -157,7 +157,7 @@ class DoodleCondition extends IntCompareCondition {
|
||||||
@Override
|
@Override
|
||||||
protected int getInputValue(Game game, Ability source) {
|
protected int getInputValue(Game game, Ability source) {
|
||||||
Object object = game.getState().getValue("doodle" + source.getSourceId());
|
Object object = game.getState().getValue("doodle" + source.getSourceId());
|
||||||
if (object != null && object instanceof Boolean && (Boolean) object) {
|
if (object instanceof Boolean && (Boolean) object) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -178,7 +178,7 @@ class BuzzCondition extends IntCompareCondition {
|
||||||
@Override
|
@Override
|
||||||
protected int getInputValue(Game game, Ability source) {
|
protected int getInputValue(Game game, Ability source) {
|
||||||
Object object = game.getState().getValue("buzz" + source.getSourceId());
|
Object object = game.getState().getValue("buzz" + source.getSourceId());
|
||||||
if (object != null && object instanceof Boolean && (Boolean) object) {
|
if (object instanceof Boolean && (Boolean) object) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -81,7 +81,7 @@ class ChainOfSilenceEffect extends OneShotEffect {
|
||||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true);
|
StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true);
|
||||||
if (newStackObject != null && newStackObject instanceof Spell) {
|
if (newStackObject instanceof Spell) {
|
||||||
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
||||||
if (activateMessage.startsWith(" casts ")) {
|
if (activateMessage.startsWith(" casts ")) {
|
||||||
activateMessage = activateMessage.substring(6);
|
activateMessage = activateMessage.substring(6);
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ChainOfVaporEffect extends OneShotEffect {
|
||||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true);
|
StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true);
|
||||||
if (newStackObject != null && newStackObject instanceof Spell) {
|
if (newStackObject instanceof Spell) {
|
||||||
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
||||||
if (activateMessage.startsWith(" casts ")) {
|
if (activateMessage.startsWith(" casts ")) {
|
||||||
activateMessage = activateMessage.substring(6);
|
activateMessage = activateMessage.substring(6);
|
||||||
|
|
|
@ -80,7 +80,7 @@ class ChainStasisEffect extends OneShotEffect {
|
||||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true);
|
StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true);
|
||||||
if (newStackObject != null && newStackObject instanceof Spell) {
|
if (newStackObject instanceof Spell) {
|
||||||
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
||||||
if (activateMessage.startsWith(" casts ")) {
|
if (activateMessage.startsWith(" casts ")) {
|
||||||
activateMessage = activateMessage.substring(6);
|
activateMessage = activateMessage.substring(6);
|
||||||
|
|
|
@ -98,7 +98,7 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl {
|
||||||
// save the x value to be available for ETB replacement effect
|
// save the x value to be available for ETB replacement effect
|
||||||
Object object = game.getState().getValue("spellX" + source.getSourceId());
|
Object object = game.getState().getValue("spellX" + source.getSourceId());
|
||||||
Map<String, Integer> spellX;
|
Map<String, Integer> spellX;
|
||||||
if (object != null && object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
spellX = (Map<String, Integer>) object;
|
spellX = (Map<String, Integer>) object;
|
||||||
} else {
|
} else {
|
||||||
spellX = new HashMap<>();
|
spellX = new HashMap<>();
|
||||||
|
|
|
@ -70,7 +70,7 @@ class EngineeredExplosivesEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject engineeredExplosives = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
MageObject engineeredExplosives = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||||
if(engineeredExplosives != null && engineeredExplosives instanceof Permanent){
|
if(engineeredExplosives instanceof Permanent){
|
||||||
int count = ((Permanent)engineeredExplosives).getCounters(game).getCount(CounterType.CHARGE);
|
int count = ((Permanent)engineeredExplosives).getCounters(game).getCount(CounterType.CHARGE);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||||
if(permanent.getConvertedManaCost() == count){
|
if(permanent.getConvertedManaCost() == count){
|
||||||
|
|
|
@ -77,7 +77,7 @@ class EssenceFluxEffect extends OneShotEffect {
|
||||||
cardsToBattlefield.add(targetId);
|
cardsToBattlefield.add(targetId);
|
||||||
} else {
|
} else {
|
||||||
Card card = game.getCard(targetId);
|
Card card = game.getCard(targetId);
|
||||||
if (card != null && card instanceof MeldCard) {
|
if (card instanceof MeldCard) {
|
||||||
MeldCard meldCard = (MeldCard) card;
|
MeldCard meldCard = (MeldCard) card;
|
||||||
Card topCard = meldCard.getTopHalfCard();
|
Card topCard = meldCard.getTopHalfCard();
|
||||||
Card bottomCard = meldCard.getBottomHalfCard();
|
Card bottomCard = meldCard.getBottomHalfCard();
|
||||||
|
|
|
@ -87,7 +87,7 @@ class FiresongAndSunspeakerTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (object != null && object instanceof Spell) {
|
if (object instanceof Spell) {
|
||||||
if (event.getTargetId().equals(this.getControllerId())
|
if (event.getTargetId().equals(this.getControllerId())
|
||||||
&& object.getColor(game).contains(ObjectColor.WHITE)
|
&& object.getColor(game).contains(ObjectColor.WHITE)
|
||||||
&& (object.isInstant()
|
&& (object.isInstant()
|
||||||
|
|
|
@ -151,7 +151,7 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
|
||||||
Card card = game.getCard(event.getTargetId());
|
Card card = game.getCard(event.getTargetId());
|
||||||
if (card != null && card.isOwnedBy(source.getControllerId())) {
|
if (card != null && card.isOwnedBy(source.getControllerId())) {
|
||||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||||
if (permanent == null || !(permanent instanceof PermanentToken)) {
|
if (!(permanent instanceof PermanentToken)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ class ForsakenWastesTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
||||||
if (eventSourceObject != null && event.getTargetId().equals(this.getSourceId())&& eventSourceObject instanceof Spell ) {
|
if (event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) {
|
||||||
getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
|
getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ class GoToJailUpkeepEffect extends OneShotEffect {
|
||||||
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
|
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
|
||||||
|
|
||||||
|
|
||||||
if (sourceObject != null && sourceObject instanceof Permanent && permanent != null) {
|
if (sourceObject instanceof Permanent && permanent != null) {
|
||||||
UUID opponentId = (UUID) game.getState().getValue(sourceObject.getId().toString() + ChooseOpponentEffect.VALUE_KEY);
|
UUID opponentId = (UUID) game.getState().getValue(sourceObject.getId().toString() + ChooseOpponentEffect.VALUE_KEY);
|
||||||
Player opponent = game.getPlayer(opponentId);
|
Player opponent = game.getPlayer(opponentId);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class GenesisHydraPutOntoBattlefieldEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY);
|
Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY);
|
||||||
if (controller != null && obj != null && obj instanceof SpellAbility) {
|
if (controller != null && obj instanceof SpellAbility) {
|
||||||
int count = ((SpellAbility) obj).getManaCostsToPay().getX();
|
int count = ((SpellAbility) obj).getManaCostsToPay().getX();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count));
|
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count));
|
||||||
|
|
|
@ -184,7 +184,7 @@ class HopeOfGhirapurCombatDamageWatcher extends Watcher {
|
||||||
public boolean playerGotCombatDamage(UUID objectId, UUID playerId, Game game) {
|
public boolean playerGotCombatDamage(UUID objectId, UUID playerId, Game game) {
|
||||||
StackObject stackObject = game.getState().getStack().getStackObject(objectId);
|
StackObject stackObject = game.getState().getStack().getStackObject(objectId);
|
||||||
MageObjectReference mor;
|
MageObjectReference mor;
|
||||||
if (stackObject != null && stackObject instanceof StackAbility) {
|
if (stackObject instanceof StackAbility) {
|
||||||
// This is neccessary because the source object was sacrificed as cost and the correct zone change counter for target calid check can only be get from stack
|
// This is neccessary because the source object was sacrificed as cost and the correct zone change counter for target calid check can only be get from stack
|
||||||
mor = new MageObjectReference(objectId, ((StackAbility) stackObject).getSourceObjectZoneChangeCounter(), game);
|
mor = new MageObjectReference(objectId, ((StackAbility) stackObject).getSourceObjectZoneChangeCounter(), game);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -265,7 +265,7 @@ class IceCauldronManaCondition implements Condition {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (source instanceof SpellAbility) {
|
if (source instanceof SpellAbility) {
|
||||||
Card card = game.getCard(source.getSourceId());
|
Card card = game.getCard(source.getSourceId());
|
||||||
if (card != null && exiledCard != null && card.equals(exiledCard)) {
|
if (card != null && card.equals(exiledCard)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class LabyrinthGuardianTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
||||||
if (eventSourceObject != null && event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) {
|
if (event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) {
|
||||||
getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
|
getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class MeletisCharlatanCopyTargetSpellEffect extends OneShotEffect {
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
StackObject newStackObject = spell.createCopyOnStack(game, source, spell.getControllerId(), true);
|
StackObject newStackObject = spell.createCopyOnStack(game, source, spell.getControllerId(), true);
|
||||||
Player player = game.getPlayer(spell.getControllerId());
|
Player player = game.getPlayer(spell.getControllerId());
|
||||||
if (player != null && newStackObject != null && newStackObject instanceof Spell) {
|
if (player != null && newStackObject instanceof Spell) {
|
||||||
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
||||||
if (activateMessage.startsWith(" casts ")) {
|
if (activateMessage.startsWith(" casts ")) {
|
||||||
activateMessage = activateMessage.substring(6);
|
activateMessage = activateMessage.substring(6);
|
||||||
|
|
|
@ -91,7 +91,7 @@ class MetzaliTowerOfTriumphEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
if (watcher instanceof AttackedThisTurnWatcher) {
|
||||||
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||||
List<Permanent> available = new ArrayList<>();
|
List<Permanent> available = new ArrayList<>();
|
||||||
for (MageObjectReference mor : attackedThisTurn) {
|
for (MageObjectReference mor : attackedThisTurn) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ class PawnOfUlamogTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
UUID targetId = event.getTargetId();
|
UUID targetId = event.getTargetId();
|
||||||
MageObject card = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
|
MageObject card = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
|
||||||
if (card != null && card instanceof Permanent && !(card instanceof PermanentToken)) {
|
if (card instanceof Permanent && !(card instanceof PermanentToken)) {
|
||||||
Permanent permanent = (Permanent) card;
|
Permanent permanent = (Permanent) card;
|
||||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD
|
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD
|
||||||
|
|
|
@ -99,7 +99,7 @@ class PhyrexianProcessorCreateTokenEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game);
|
String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game);
|
||||||
Object object = game.getState().getValue(key);
|
Object object = game.getState().getValue(key);
|
||||||
if(object != null && object instanceof Integer) {
|
if(object instanceof Integer) {
|
||||||
int lifePaid = (int) object;
|
int lifePaid = (int) object;
|
||||||
MinionToken token = new MinionToken();
|
MinionToken token = new MinionToken();
|
||||||
token.getPower().modifyBaseValue(lifePaid);
|
token.getPower().modifyBaseValue(lifePaid);
|
||||||
|
|
|
@ -85,7 +85,7 @@ class PsychicRebuttalEffect extends OneShotEffect {
|
||||||
&& controller.chooseUse(Outcome.PlayForFree, "Copy " + spell.getName() + " (you may choose new targets for the copy)?", source, game)) {
|
&& controller.chooseUse(Outcome.PlayForFree, "Copy " + spell.getName() + " (you may choose new targets for the copy)?", source, game)) {
|
||||||
|
|
||||||
StackObject newStackObject = spell.createCopyOnStack(game, source, source.getControllerId(), true);
|
StackObject newStackObject = spell.createCopyOnStack(game, source, source.getControllerId(), true);
|
||||||
if (newStackObject != null && newStackObject instanceof Spell) {
|
if (newStackObject instanceof Spell) {
|
||||||
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
||||||
if (activateMessage.startsWith(" casts ")) {
|
if (activateMessage.startsWith(" casts ")) {
|
||||||
activateMessage = activateMessage.substring(6);
|
activateMessage = activateMessage.substring(6);
|
||||||
|
|
|
@ -62,7 +62,7 @@ class PyromancersGauntletReplacementEffect extends ReplacementEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (object != null && object instanceof Spell) {
|
if (object instanceof Spell) {
|
||||||
if (((Spell) object).isControlledBy(source.getControllerId())
|
if (((Spell) object).isControlledBy(source.getControllerId())
|
||||||
&& (object.isInstant()
|
&& (object.isInstant()
|
||||||
|| object.isSorcery())){
|
|| object.isSorcery())){
|
||||||
|
|
|
@ -73,7 +73,7 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect {
|
||||||
Map<String, UUID> exileIds;
|
Map<String, UUID> exileIds;
|
||||||
String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game);
|
String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game);
|
||||||
Object object = game.getState().getValue(valueKey);
|
Object object = game.getState().getValue(valueKey);
|
||||||
if (object != null && object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
exileIds = (Map<String, UUID>) object;
|
exileIds = (Map<String, UUID>) object;
|
||||||
} else {
|
} else {
|
||||||
exileIds = new HashMap<>();
|
exileIds = new HashMap<>();
|
||||||
|
@ -123,7 +123,7 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect {
|
||||||
Map<String, UUID> exileIds;
|
Map<String, UUID> exileIds;
|
||||||
String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game);
|
String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game);
|
||||||
Object object = game.getState().getValue(valueKey);
|
Object object = game.getState().getValue(valueKey);
|
||||||
if (object != null && object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
exileIds = (Map<String, UUID>) object;
|
exileIds = (Map<String, UUID>) object;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -77,7 +77,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null && permanent.isControlledBy(this.controllerId) && (permanent.hasSubtype(SubType.WOLF, game) || permanent.hasSubtype(SubType.WEREWOLF, game))) {
|
if (permanent != null && permanent.isControlledBy(this.controllerId) && (permanent.hasSubtype(SubType.WOLF, game) || permanent.hasSubtype(SubType.WEREWOLF, game))) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (object != null && object instanceof Spell) {
|
if (object instanceof Spell) {
|
||||||
Card c = (Spell) object;
|
Card c = (Spell) object;
|
||||||
if (c.isInstant() || c.isSorcery()) {
|
if (c.isInstant() || c.isSorcery()) {
|
||||||
if (getTargets().isEmpty()) {
|
if (getTargets().isEmpty()) {
|
||||||
|
|
|
@ -123,7 +123,7 @@ class SolemnityEffect2 extends ReplacementEffectImpl {
|
||||||
Permanent permanent2 = game.getPermanent(event.getTargetId());
|
Permanent permanent2 = game.getPermanent(event.getTargetId());
|
||||||
Permanent permanent3 = game.getPermanentEntering(event.getTargetId());
|
Permanent permanent3 = game.getPermanentEntering(event.getTargetId());
|
||||||
|
|
||||||
if (object != null && object instanceof Permanent) {
|
if (object instanceof Permanent) {
|
||||||
if (filter.match((Permanent) object, game)) {
|
if (filter.match((Permanent) object, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
MageObject mageObject = game.getObject(spellId);
|
MageObject mageObject = game.getObject(spellId);
|
||||||
if (mageObject == null || !(mageObject instanceof Spell) || ((Spell) mageObject).isCopiedSpell()) {
|
if (!(mageObject instanceof Spell) || ((Spell) mageObject).isCopiedSpell()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Card sourceCard = game.getCard(spellId);
|
Card sourceCard = game.getCard(spellId);
|
||||||
|
|
|
@ -69,7 +69,7 @@ class SparkFiendEffect extends OneShotEffect {
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int roll = controller.rollDice(game, 6) + controller.rollDice(game, 6);
|
int roll = controller.rollDice(game, 6) + controller.rollDice(game, 6);
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
if (mageObject != null && mageObject instanceof Permanent) {
|
if (mageObject instanceof Permanent) {
|
||||||
Permanent sourcePermanent = (Permanent) mageObject;
|
Permanent sourcePermanent = (Permanent) mageObject;
|
||||||
if (roll == 2 || roll == 3 || roll == 12) {
|
if (roll == 2 || roll == 3 || roll == 12) {
|
||||||
// sacrifice
|
// sacrifice
|
||||||
|
@ -114,7 +114,7 @@ class SparkFiendUpkeepEffect extends OneShotEffect {
|
||||||
&& (Integer) game.getState().getValue("SparkFiend" + source.getSourceId().toString()) != 0) {
|
&& (Integer) game.getState().getValue("SparkFiend" + source.getSourceId().toString()) != 0) {
|
||||||
int roll = controller.rollDice(game, 6) + controller.rollDice(game, 6);
|
int roll = controller.rollDice(game, 6) + controller.rollDice(game, 6);
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
if (mageObject != null && mageObject instanceof Permanent) {
|
if (mageObject instanceof Permanent) {
|
||||||
Permanent sourcePermanent = (Permanent) mageObject;
|
Permanent sourcePermanent = (Permanent) mageObject;
|
||||||
if (roll == 7) {
|
if (roll == 7) {
|
||||||
// sacrifice
|
// sacrifice
|
||||||
|
|
|
@ -80,7 +80,7 @@ class SpectralPrisonAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
||||||
if (eventSourceObject != null && eventSourceObject instanceof Spell) {
|
if (eventSourceObject instanceof Spell) {
|
||||||
Permanent enchantment = game.getPermanent(sourceId);
|
Permanent enchantment = game.getPermanent(sourceId);
|
||||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||||
if (event.getTargetId().equals(enchantment.getAttachedTo())) {
|
if (event.getTargetId().equals(enchantment.getAttachedTo())) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ class SpellShrivelCounterUnlessPaysEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
|
StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (spell != null && (spell instanceof Spell) && sourceObject != null) {
|
if ((spell instanceof Spell) && sourceObject != null) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int amount = 4;
|
int amount = 4;
|
||||||
|
|
|
@ -90,8 +90,7 @@ class SummoningTrapWatcher extends Watcher {
|
||||||
if (counteredSpell == null) {
|
if (counteredSpell == null) {
|
||||||
counteredSpell = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
|
counteredSpell = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
|
||||||
}
|
}
|
||||||
if (counteredSpell != null
|
if (counteredSpell instanceof Spell
|
||||||
&& counteredSpell instanceof Spell
|
|
||||||
&& !players.contains(counteredSpell.getControllerId())
|
&& !players.contains(counteredSpell.getControllerId())
|
||||||
&& counteredSpell.isCreature()) {
|
&& counteredSpell.isCreature()) {
|
||||||
StackObject counteringStackObject = game.getStack().getStackObject(event.getSourceId());
|
StackObject counteringStackObject = game.getStack().getStackObject(event.getSourceId());
|
||||||
|
|
|
@ -61,7 +61,7 @@ class SyncopateCounterUnlessPaysEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
|
StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (spell != null && (spell instanceof Spell) && sourceObject != null) {
|
if ((spell instanceof Spell) && sourceObject != null) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int amount = source.getManaCostsToPay().getX();
|
int amount = source.getManaCostsToPay().getX();
|
||||||
|
|
|
@ -137,7 +137,7 @@ class ThoughtPrisonTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||||
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
|
||||||
|
|
||||||
if (spell != null && spell instanceof Spell) {
|
if (spell instanceof Spell) {
|
||||||
if (sourcePermanent == null) {
|
if (sourcePermanent == null) {
|
||||||
sourcePermanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
|
sourcePermanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,7 @@ class TreacherousPitDwellerEffect extends ContinuousEffectImpl {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject permanent = source.getSourceObjectIfItStillExists(game); // it can also return Card object
|
MageObject permanent = source.getSourceObjectIfItStillExists(game); // it can also return Card object
|
||||||
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
||||||
if (permanent != null
|
if ((permanent instanceof Permanent)
|
||||||
&& (permanent instanceof Permanent)
|
|
||||||
&& targetOpponent != null) {
|
&& targetOpponent != null) {
|
||||||
return ((Permanent) permanent).changeControllerId(targetOpponent.getId(), game);
|
return ((Permanent) permanent).changeControllerId(targetOpponent.getId(), game);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class TritonTacticsUntapTargetEffect extends OneShotEffect {
|
||||||
// save the targets for the watcher in a map with zone change counter (as the card is recast during combat it's neccessary to save with zone change counter)
|
// save the targets for the watcher in a map with zone change counter (as the card is recast during combat it's neccessary to save with zone change counter)
|
||||||
Map<Integer, Set<String>> targetMap;
|
Map<Integer, Set<String>> targetMap;
|
||||||
Object object = game.getState().getValue("targets" + source.getSourceId());
|
Object object = game.getState().getValue("targets" + source.getSourceId());
|
||||||
if (object != null && object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
targetMap = (Map<Integer, Set<String>>) object;
|
targetMap = (Map<Integer, Set<String>>) object;
|
||||||
} else {
|
} else {
|
||||||
targetMap = new HashMap<>();
|
targetMap = new HashMap<>();
|
||||||
|
@ -155,7 +155,7 @@ class TritonTacticsEndOfCombatEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Map<Integer, Set<String>> attackerMap = null;
|
Map<Integer, Set<String>> attackerMap = null;
|
||||||
Object object = game.getState().getValue("blockedAttackers" + source.getSourceId());
|
Object object = game.getState().getValue("blockedAttackers" + source.getSourceId());
|
||||||
if (object != null && object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
attackerMap = (Map<Integer, Set<String>>) object;
|
attackerMap = (Map<Integer, Set<String>>) object;
|
||||||
for (Set<String> attackerSet : attackerMap.values()) {
|
for (Set<String> attackerSet : attackerMap.values()) {
|
||||||
List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
|
List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
|
||||||
|
@ -197,7 +197,7 @@ class BlockedCreaturesWatcher extends Watcher {
|
||||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
|
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
|
||||||
Map<Integer, Set<String>> targetMap;
|
Map<Integer, Set<String>> targetMap;
|
||||||
Object object = game.getState().getValue("targets" + this.getSourceId().toString());
|
Object object = game.getState().getValue("targets" + this.getSourceId().toString());
|
||||||
if (object != null && object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
Permanent blocker = game.getPermanent(event.getSourceId());
|
Permanent blocker = game.getPermanent(event.getSourceId());
|
||||||
if (blocker != null) {
|
if (blocker != null) {
|
||||||
targetMap = (Map<Integer, Set<String>>) object;
|
targetMap = (Map<Integer, Set<String>>) object;
|
||||||
|
@ -217,7 +217,7 @@ class BlockedCreaturesWatcher extends Watcher {
|
||||||
Set<String> attackers;
|
Set<String> attackers;
|
||||||
Map<Integer, Set<String>> attackerMap;
|
Map<Integer, Set<String>> attackerMap;
|
||||||
Object object = game.getState().getValue("blockedAttackers" + getSourceId());
|
Object object = game.getState().getValue("blockedAttackers" + getSourceId());
|
||||||
if (object != null && object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
attackerMap = (Map<Integer, Set<String>>) object;
|
attackerMap = (Map<Integer, Set<String>>) object;
|
||||||
} else {
|
} else {
|
||||||
attackerMap = new HashMap<>();
|
attackerMap = new HashMap<>();
|
||||||
|
|
|
@ -65,7 +65,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null && permanent.isControlledBy(this.controllerId) && permanent.isCreature()) {
|
if (permanent != null && permanent.isControlledBy(this.controllerId) && permanent.isCreature()) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (object != null && object instanceof Spell) {
|
if (object instanceof Spell) {
|
||||||
Card c = (Spell) object;
|
Card c = (Spell) object;
|
||||||
if (c.isInstant() || c.isSorcery()) {
|
if (c.isInstant() || c.isSorcery()) {
|
||||||
if (getTargets().isEmpty()) {
|
if (getTargets().isEmpty()) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ class WispweaverAngelEffect extends OneShotEffect {
|
||||||
cardsToBattlefield.add(targetId);
|
cardsToBattlefield.add(targetId);
|
||||||
} else {
|
} else {
|
||||||
Card card = game.getCard(targetId);
|
Card card = game.getCard(targetId);
|
||||||
if (card != null && card instanceof MeldCard) {
|
if (card instanceof MeldCard) {
|
||||||
MeldCard meldCard = (MeldCard) card;
|
MeldCard meldCard = (MeldCard) card;
|
||||||
Card topCard = meldCard.getTopHalfCard();
|
Card topCard = meldCard.getTopHalfCard();
|
||||||
Card bottomCard = meldCard.getBottomHalfCard();
|
Card bottomCard = meldCard.getBottomHalfCard();
|
||||||
|
|
|
@ -143,7 +143,7 @@ class UntapAttackingThisTurnEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
if (watcher instanceof AttackedThisTurnWatcher) {
|
||||||
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||||
for (MageObjectReference mor : attackedThisTurn) {
|
for (MageObjectReference mor : attackedThisTurn) {
|
||||||
Permanent permanent = mor.getPermanent(game);
|
Permanent permanent = mor.getPermanent(game);
|
||||||
|
|
|
@ -137,7 +137,7 @@ class YawgmothsAgendaReplacementEffect extends ReplacementEffectImpl {
|
||||||
Card card = game.getCard(event.getTargetId());
|
Card card = game.getCard(event.getTargetId());
|
||||||
if (card != null && card.isOwnedBy(source.getControllerId())) {
|
if (card != null && card.isOwnedBy(source.getControllerId())) {
|
||||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||||
if (permanent == null || !(permanent instanceof PermanentToken)) {
|
if (!(permanent instanceof PermanentToken)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ class YawgmothsWillReplacementEffect extends ReplacementEffectImpl {
|
||||||
Card card = game.getCard(event.getTargetId());
|
Card card = game.getCard(event.getTargetId());
|
||||||
if (card != null && card.isOwnedBy(source.getControllerId())) {
|
if (card != null && card.isOwnedBy(source.getControllerId())) {
|
||||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||||
if (permanent == null || !(permanent instanceof PermanentToken)) {
|
if (!(permanent instanceof PermanentToken)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class DealsDamageToOneOrMoreCreaturesTriggeredAbility extends DealsDamage
|
||||||
|| game.getTurn().getStepType() == PhaseStep.FIRST_COMBAT_DAMAGE) {
|
|| game.getTurn().getStepType() == PhaseStep.FIRST_COMBAT_DAMAGE) {
|
||||||
String stepHash = (String) game.getState().getValue("damageStep" + getOriginalId());
|
String stepHash = (String) game.getState().getValue("damageStep" + getOriginalId());
|
||||||
String newStepHash = game.getStep().getType().toString() + game.getTurnNum();
|
String newStepHash = game.getStep().getType().toString() + game.getTurnNum();
|
||||||
if (stepHash == null || !newStepHash.equals(stepHash)) {
|
if (!newStepHash.equals(stepHash)) {
|
||||||
// this ability did not trigger during this damage step
|
// this ability did not trigger during this damage step
|
||||||
game.getState().setValue("damageStep" + getOriginalId(), game.getStep().getType().toString() + game.getTurnNum());
|
game.getState().setValue("damageStep" + getOriginalId(), game.getStep().getType().toString() + game.getTurnNum());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,62 +1,62 @@
|
||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package mage.abilities.common;
|
package mage.abilities.common;
|
||||||
|
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.game.stack.StackObject;
|
import mage.game.stack.StackObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author fireshoes
|
* @author fireshoes
|
||||||
*/
|
*/
|
||||||
public class SpellCounteredControllerTriggeredAbility extends TriggeredAbilityImpl {
|
public class SpellCounteredControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
public SpellCounteredControllerTriggeredAbility(Effect effect) {
|
public SpellCounteredControllerTriggeredAbility(Effect effect) {
|
||||||
this(effect, false);
|
this(effect, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellCounteredControllerTriggeredAbility(Effect effect, boolean optional) {
|
public SpellCounteredControllerTriggeredAbility(Effect effect, boolean optional) {
|
||||||
super(Zone.BATTLEFIELD, effect, optional);
|
super(Zone.BATTLEFIELD, effect, optional);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellCounteredControllerTriggeredAbility(final SpellCounteredControllerTriggeredAbility ability) {
|
public SpellCounteredControllerTriggeredAbility(final SpellCounteredControllerTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpellCounteredControllerTriggeredAbility copy() {
|
public SpellCounteredControllerTriggeredAbility copy() {
|
||||||
return new SpellCounteredControllerTriggeredAbility(this);
|
return new SpellCounteredControllerTriggeredAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType() == EventType.COUNTERED;
|
return event.getType() == EventType.COUNTERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
StackObject stackObjectThatCountered = game.getStack().getStackObject(event.getSourceId());
|
StackObject stackObjectThatCountered = game.getStack().getStackObject(event.getSourceId());
|
||||||
if (stackObjectThatCountered == null) {
|
if (stackObjectThatCountered == null) {
|
||||||
stackObjectThatCountered = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
|
stackObjectThatCountered = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
|
||||||
}
|
}
|
||||||
if (stackObjectThatCountered != null && stackObjectThatCountered.isControlledBy(getControllerId())) {
|
if (stackObjectThatCountered != null && stackObjectThatCountered.isControlledBy(getControllerId())) {
|
||||||
StackObject counteredStackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
|
StackObject counteredStackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
|
||||||
return counteredStackObject != null && (counteredStackObject instanceof Spell);
|
return (counteredStackObject instanceof Spell);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return "Whenever a spell or ability you control counters a spell, " + super.getRule();
|
return "Whenever a spell or ability you control counters a spell, " + super.getRule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
|
|
||||||
package mage.abilities.condition.common;
|
package mage.abilities.condition.common;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.condition.Condition;
|
import mage.abilities.condition.Condition;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.NamePredicate;
|
import mage.filter.predicate.mageobject.NamePredicate;
|
||||||
import mage.filter.predicate.other.OwnerIdPredicate;
|
import mage.filter.predicate.other.OwnerIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
*/
|
*/
|
||||||
public class MeldCondition implements Condition {
|
public class MeldCondition implements Condition {
|
||||||
|
|
||||||
private final String meldWithName;
|
private final String meldWithName;
|
||||||
|
|
||||||
public MeldCondition(String meldWithName) {
|
public MeldCondition(String meldWithName) {
|
||||||
this.meldWithName = meldWithName;
|
this.meldWithName = meldWithName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject sourceMageObject = source.getSourceObjectIfItStillExists(game);
|
MageObject sourceMageObject = source.getSourceObjectIfItStillExists(game);
|
||||||
if (sourceMageObject != null && sourceMageObject instanceof Permanent) {
|
if (sourceMageObject instanceof Permanent) {
|
||||||
Permanent sourcePermanent = (Permanent) sourceMageObject;
|
Permanent sourcePermanent = (Permanent) sourceMageObject;
|
||||||
if (sourcePermanent.isControlledBy(source.getControllerId())
|
if (sourcePermanent.isControlledBy(source.getControllerId())
|
||||||
&& sourcePermanent.isOwnedBy(source.getControllerId())) {
|
&& sourcePermanent.isOwnedBy(source.getControllerId())) {
|
||||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
||||||
filter.add(new NamePredicate(this.meldWithName));
|
filter.add(new NamePredicate(this.meldWithName));
|
||||||
filter.add(new OwnerIdPredicate(source.getControllerId()));
|
filter.add(new OwnerIdPredicate(source.getControllerId()));
|
||||||
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0;
|
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class SunburstCount implements DynamicValue {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (!game.getStack().isEmpty()) {
|
if (!game.getStack().isEmpty()) {
|
||||||
StackObject spell = game.getStack().getFirst();
|
StackObject spell = game.getStack().getFirst();
|
||||||
if (spell != null && spell instanceof Spell && ((Spell) spell).getSourceId().equals(source.getSourceId())) {
|
if (spell instanceof Spell && ((Spell) spell).getSourceId().equals(source.getSourceId())) {
|
||||||
Mana mana = ((Spell) spell).getSpellAbility().getManaCostsToPay().getPayment();
|
Mana mana = ((Spell) spell).getSpellAbility().getManaCostsToPay().getPayment();
|
||||||
if (mana.getBlack() > 0) {
|
if (mana.getBlack() > 0) {
|
||||||
count++;
|
count++;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getSourceId().equals(this.getSourceId())) {
|
if (event.getSourceId().equals(this.getSourceId())) {
|
||||||
MageObject spellObject = game.getObject(sourceId);
|
MageObject spellObject = game.getObject(sourceId);
|
||||||
if (spellObject != null && (spellObject instanceof Spell)) {
|
if ((spellObject instanceof Spell)) {
|
||||||
Spell spell = (Spell) spellObject;
|
Spell spell = (Spell) spellObject;
|
||||||
if (spell.getSpellAbility() != null) {
|
if (spell.getSpellAbility() != null) {
|
||||||
for (Effect effect : getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class CopyTargetSpellEffect extends OneShotEffect {
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
StackObject newStackObject = spell.createCopyOnStack(game, source, useController ? spell.getControllerId() : source.getControllerId(), true);
|
StackObject newStackObject = spell.createCopyOnStack(game, source, useController ? spell.getControllerId() : source.getControllerId(), true);
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player != null && newStackObject != null && newStackObject instanceof Spell) {
|
if (player != null && newStackObject instanceof Spell) {
|
||||||
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
String activateMessage = ((Spell) newStackObject).getActivatedMessage(game);
|
||||||
if (activateMessage.startsWith(" casts ")) {
|
if (activateMessage.startsWith(" casts ")) {
|
||||||
activateMessage = activateMessage.substring(6);
|
activateMessage = activateMessage.substring(6);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ReturnToBattlefieldUnderOwnerControlAttachedEffect extends OneShotE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Object object = getValue("attachedTo");
|
Object object = getValue("attachedTo");
|
||||||
if (object != null && object instanceof Permanent) {
|
if (object instanceof Permanent) {
|
||||||
Card card = game.getCard(((Permanent) object).getId());
|
Card card = game.getCard(((Permanent) object).getId());
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null)) {
|
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null)) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Card card = game.getCard(targetId);
|
Card card = game.getCard(targetId);
|
||||||
if (card != null && card instanceof MeldCard) {
|
if (card instanceof MeldCard) {
|
||||||
MeldCard meldCard = (MeldCard) card;
|
MeldCard meldCard = (MeldCard) card;
|
||||||
Card topCard = meldCard.getTopHalfCard();
|
Card topCard = meldCard.getTopHalfCard();
|
||||||
Card bottomCard = meldCard.getBottomHalfCard();
|
Card bottomCard = meldCard.getBottomHalfCard();
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ReturnToBattlefieldUnderYourControlAttachedEffect extends OneShotEf
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Object object = getValue("attachedTo");
|
Object object = getValue("attachedTo");
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null && object != null && object instanceof Permanent) {
|
if (controller != null && object instanceof Permanent) {
|
||||||
Card card = game.getCard(((Permanent) object).getId());
|
Card card = game.getCard(((Permanent) object).getId());
|
||||||
// Move the card only, if it is still in the next zone after the battlefield
|
// Move the card only, if it is still in the next zone after the battlefield
|
||||||
if (card != null && card.getZoneChangeCounter(game) == ((Permanent) object).getZoneChangeCounter(game) + 1) {
|
if (card != null && card.getZoneChangeCounter(game) == ((Permanent) object).getZoneChangeCounter(game) + 1) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Card card = game.getCard(targetId);
|
Card card = game.getCard(targetId);
|
||||||
if (card != null && card instanceof MeldCard) {
|
if (card instanceof MeldCard) {
|
||||||
MeldCard meldCard = (MeldCard) card;
|
MeldCard meldCard = (MeldCard) card;
|
||||||
Card topCard = meldCard.getTopHalfCard();
|
Card topCard = meldCard.getTopHalfCard();
|
||||||
Card bottomCard = meldCard.getBottomHalfCard();
|
Card bottomCard = meldCard.getBottomHalfCard();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class ReturnToHandAttachedEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Object object = getValue("attachedTo");
|
Object object = getValue("attachedTo");
|
||||||
if (object != null && object instanceof Permanent) {
|
if (object instanceof Permanent) {
|
||||||
Card card = game.getCard(((Permanent)object).getId());
|
Card card = game.getCard(((Permanent)object).getId());
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) {
|
if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class TransformSourceEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject sourceObject = source.getSourceObjectIfItStillExists(game); // Transform only if it's the same object as the effect was put on the stack
|
MageObject sourceObject = source.getSourceObjectIfItStillExists(game); // Transform only if it's the same object as the effect was put on the stack
|
||||||
if (sourceObject != null && sourceObject instanceof Permanent) {
|
if (sourceObject instanceof Permanent) {
|
||||||
Permanent sourcePermanent = (Permanent) sourceObject;
|
Permanent sourcePermanent = (Permanent) sourceObject;
|
||||||
if (sourcePermanent.canTransform(source, game)) {
|
if (sourcePermanent.canTransform(source, game)) {
|
||||||
// check not to transform twice the same side
|
// check not to transform twice the same side
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class UntapAllThatAttackedEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
if (watcher instanceof AttackedThisTurnWatcher) {
|
||||||
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||||
for (MageObjectReference mor : attackedThisTurn) {
|
for (MageObjectReference mor : attackedThisTurn) {
|
||||||
Permanent permanent = mor.getPermanent(game);
|
Permanent permanent = mor.getPermanent(game);
|
||||||
|
|
|
@ -149,7 +149,7 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl {
|
||||||
// wants to do that in the future.
|
// wants to do that in the future.
|
||||||
UUID sourceId = source.getSourceId();
|
UUID sourceId = source.getSourceId();
|
||||||
Card sourceCard = game.getCard(source.getSourceId());
|
Card sourceCard = game.getCard(source.getSourceId());
|
||||||
if (sourceCard != null && sourceCard instanceof SplitCardHalf) {
|
if (sourceCard instanceof SplitCardHalf) {
|
||||||
sourceCard = ((SplitCardHalf) sourceCard).getParentCard();
|
sourceCard = ((SplitCardHalf) sourceCard).getParentCard();
|
||||||
sourceId = sourceCard.getId();
|
sourceId = sourceCard.getId();
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl {
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
UUID sourceId = source.getSourceId();
|
UUID sourceId = source.getSourceId();
|
||||||
Card sourceCard = game.getCard(source.getSourceId());
|
Card sourceCard = game.getCard(source.getSourceId());
|
||||||
if (sourceCard != null && sourceCard instanceof SplitCardHalf) {
|
if (sourceCard instanceof SplitCardHalf) {
|
||||||
sourceCard = ((SplitCardHalf) sourceCard).getParentCard();
|
sourceCard = ((SplitCardHalf) sourceCard).getParentCard();
|
||||||
sourceId = sourceCard.getId();
|
sourceId = sourceCard.getId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ class ConspireEffect extends OneShotEffect {
|
||||||
Card card = game.getCard(conspiredSpell.getSourceId());
|
Card card = game.getCard(conspiredSpell.getSourceId());
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
StackObject newStackObject = conspiredSpell.createCopyOnStack(game, source, source.getControllerId(), true);
|
StackObject newStackObject = conspiredSpell.createCopyOnStack(game, source, source.getControllerId(), true);
|
||||||
if (newStackObject != null && newStackObject instanceof Spell && !game.isSimulation()) {
|
if (newStackObject instanceof Spell && !game.isSimulation()) {
|
||||||
game.informPlayers(controller.getLogName() + ((Spell) newStackObject).getActivatedMessage(game));
|
game.informPlayers(controller.getLogName() + ((Spell) newStackObject).getActivatedMessage(game));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class HauntAbility extends TriggeredAbilityImpl {
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
String key = new StringBuilder("Haunting_").append(getSourceId().toString()).append('_').append(card.getZoneChangeCounter(game)).toString();
|
String key = new StringBuilder("Haunting_").append(getSourceId().toString()).append('_').append(card.getZoneChangeCounter(game)).toString();
|
||||||
Object object = game.getState().getValue(key);
|
Object object = game.getState().getValue(key);
|
||||||
if (object != null && object instanceof FixedTarget) {
|
if (object instanceof FixedTarget) {
|
||||||
FixedTarget target = (FixedTarget) object;
|
FixedTarget target = (FixedTarget) object;
|
||||||
if (target.getTarget() != null && target.getTarget().equals(event.getTargetId())) {
|
if (target.getTarget() != null && target.getTarget().equals(event.getTargetId())) {
|
||||||
usedFromExile = true;
|
usedFromExile = true;
|
||||||
|
|
|
@ -222,7 +222,7 @@ class ReplicateCopyEffect extends OneShotEffect {
|
||||||
// create the copies
|
// create the copies
|
||||||
for (int i = 0; i < replicateCount; i++) {
|
for (int i = 0; i < replicateCount; i++) {
|
||||||
StackObject newStackObject = spell.createCopyOnStack(game, source, source.getControllerId(), true);
|
StackObject newStackObject = spell.createCopyOnStack(game, source, source.getControllerId(), true);
|
||||||
if (newStackObject != null && newStackObject instanceof Spell && !game.isSimulation()) {
|
if (newStackObject instanceof Spell && !game.isSimulation()) {
|
||||||
game.informPlayers(controller.getLogName() + ((Spell) newStackObject).getActivatedMessage(game));
|
game.informPlayers(controller.getLogName() + ((Spell) newStackObject).getActivatedMessage(game));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ public class Plane implements CommandObject {
|
||||||
Class<?> c = Class.forName(planeName);
|
Class<?> c = Class.forName(planeName);
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object plane = cons.newInstance();
|
Object plane = cons.newInstance();
|
||||||
if (plane != null && plane instanceof mage.game.command.Plane) {
|
if (plane instanceof Plane) {
|
||||||
return (Plane) plane;
|
return (Plane) plane;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ class IllusionTokenTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
MageObject eventSourceObject = game.getObject(event.getSourceId());
|
||||||
if (eventSourceObject != null && event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) {
|
if (event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) {
|
||||||
getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
|
getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ public abstract class TargetImpl implements Target {
|
||||||
@Override
|
@Override
|
||||||
public boolean isRequired(UUID sourceId, Game game) {
|
public boolean isRequired(UUID sourceId, Game game) {
|
||||||
MageObject object = game.getObject(sourceId);
|
MageObject object = game.getObject(sourceId);
|
||||||
if (!requiredExplicitlySet && object != null && object instanceof Ability) {
|
if (!requiredExplicitlySet && object instanceof Ability) {
|
||||||
return isRequired((Ability) object);
|
return isRequired((Ability) object);
|
||||||
} else {
|
} else {
|
||||||
return isRequired();
|
return isRequired();
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class TargetSource extends TargetObject {
|
||||||
public void addTarget(UUID id, Ability source, Game game) {
|
public void addTarget(UUID id, Ability source, Game game) {
|
||||||
if (targets.size() < maxNumberOfTargets) {
|
if (targets.size() < maxNumberOfTargets) {
|
||||||
MageObject object = game.getObject(id);
|
MageObject object = game.getObject(id);
|
||||||
if (object != null && object instanceof StackObject) {
|
if (object instanceof StackObject) {
|
||||||
addTarget(((StackObject) object).getSourceId(), source, game, notTarget);
|
addTarget(((StackObject) object).getSourceId(), source, game, notTarget);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class CastSpellYourLastTurnWatcher extends Watcher {
|
||||||
lastActivePlayer = game.getActivePlayerId();
|
lastActivePlayer = game.getActivePlayerId();
|
||||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||||
UUID playerId = event.getPlayerId();
|
UUID playerId = event.getPlayerId();
|
||||||
if (playerId != null && lastActivePlayer != null && playerId.equals(lastActivePlayer)) {
|
if (playerId != null && playerId.equals(lastActivePlayer)) {
|
||||||
amountOfSpellsCastOnCurrentTurn.putIfAbsent(playerId, 0);
|
amountOfSpellsCastOnCurrentTurn.putIfAbsent(playerId, 0);
|
||||||
amountOfSpellsCastOnCurrentTurn.compute(playerId, (k, a) -> a + 1);
|
amountOfSpellsCastOnCurrentTurn.compute(playerId, (k, a) -> a + 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue