mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Gather Specimens, simplified replacement effect, some other minor changes.
This commit is contained in:
parent
3d7c2c32bf
commit
5d13559ef1
5 changed files with 45 additions and 71 deletions
|
@ -37,15 +37,10 @@ import mage.constants.Duration;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import static mage.constants.Zone.EXILED;
|
||||
import static mage.constants.Zone.GRAVEYARD;
|
||||
import static mage.constants.Zone.HAND;
|
||||
import static mage.constants.Zone.LIBRARY;
|
||||
import static mage.constants.Zone.PICK;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -76,6 +71,8 @@ public class GatherSpecimens extends CardImpl<GatherSpecimens> {
|
|||
|
||||
class GatherSpecimensReplacementEffect extends ReplacementEffectImpl<GatherSpecimensReplacementEffect> {
|
||||
|
||||
private static final FilterCreatureCard filter = new FilterCreatureCard();
|
||||
|
||||
public GatherSpecimensReplacementEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.GainControl);
|
||||
staticText = "If a creature would enter the battlefield under an opponent's control this turn, it enters the battlefield under your control instead";
|
||||
|
@ -97,57 +94,12 @@ class GatherSpecimensReplacementEffect extends ReplacementEffectImpl<GatherSpeci
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
if (((ZoneChangeEvent) event).getFromZone() == Zone.HAND
|
||||
|| ((ZoneChangeEvent) event).getFromZone() == Zone.EXILED
|
||||
|| ((ZoneChangeEvent) event).getFromZone() == Zone.LIBRARY
|
||||
|| ((ZoneChangeEvent) event).getFromZone() == Zone.GRAVEYARD
|
||||
|| ((ZoneChangeEvent) event).getFromZone() == Zone.PICK) {
|
||||
Card card = game.getCard(((ZoneChangeEvent) event).getTargetId());
|
||||
game.replaceEvent(event);
|
||||
if (card != null) {
|
||||
Zone currentZone = game.getState().getZone(card.getId());
|
||||
ZoneChangeEvent event2 = new ZoneChangeEvent(card.getId(), source.getSourceId(), source.getControllerId(), currentZone, Zone.BATTLEFIELD);
|
||||
if (currentZone != null) {
|
||||
boolean removed = false;
|
||||
switch (currentZone) {
|
||||
case GRAVEYARD:
|
||||
removed = game.getPlayer(card.getOwnerId()).removeFromGraveyard(card, game);
|
||||
break;
|
||||
case HAND:
|
||||
removed = game.getPlayer(card.getOwnerId()).removeFromHand(card, game);
|
||||
break;
|
||||
case LIBRARY:
|
||||
removed = game.getPlayer(card.getOwnerId()).removeFromLibrary(card, game);
|
||||
break;
|
||||
case EXILED:
|
||||
game.getExile().removeCard(card, game);
|
||||
removed = true;
|
||||
break;
|
||||
case PICK:
|
||||
removed = true;
|
||||
break;
|
||||
default:
|
||||
System.out.println("putOntoBattlefield, not fully implemented: fromZone=" + currentZone);
|
||||
}
|
||||
game.rememberLKI(card.getId(), event2.getFromZone(), card);
|
||||
if (!removed) {
|
||||
System.out.println("Couldn't find card in fromZone, card=" + card.getName() + ", fromZone=" + currentZone);
|
||||
}
|
||||
}
|
||||
PermanentCard permanent = new PermanentCard(card, source.getControllerId());
|
||||
game.resetForSourceId(permanent.getId());
|
||||
game.addPermanent(permanent);
|
||||
game.setZone(card.getId(), Zone.BATTLEFIELD);
|
||||
game.setScopeRelevant(true);
|
||||
game.applyEffects();
|
||||
permanent.entersBattlefield(source.getSourceId(), game, currentZone, true);
|
||||
game.setScopeRelevant(false);
|
||||
game.applyEffects();
|
||||
game.fireEvent(new ZoneChangeEvent(permanent, source.getControllerId(), currentZone, Zone.BATTLEFIELD));
|
||||
return true;
|
||||
}
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
Card card = game.getCard(((ZoneChangeEvent) event).getTargetId());
|
||||
if (card != null) {
|
||||
card.putOntoBattlefield(game, zEvent.getFromZone(), zEvent.getSourceId(), source.getControllerId(), zEvent.comesIntoPlayTapped(), zEvent.getAppliedEffects());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,12 +107,12 @@ class GatherSpecimensReplacementEffect extends ReplacementEffectImpl<GatherSpeci
|
|||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
|
||||
&& ((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD) {
|
||||
Card card = game.getCard(((ZoneChangeEvent) event).getTargetId());
|
||||
if (card != null
|
||||
&& card.getCardType().contains(CardType.CREATURE)
|
||||
&& card.getOwnerId() != source.getControllerId()) {
|
||||
return true;
|
||||
if (card != null && filter.match(card, source.getSourceId(), source.getControllerId(), game)) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ public interface Card extends MageObject {
|
|||
boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId);
|
||||
boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId);
|
||||
boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped);
|
||||
boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, ArrayList<UUID> appliedEffects);
|
||||
List<Mana> getMana();
|
||||
|
||||
void build();
|
||||
|
|
|
@ -296,7 +296,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
case PICK:
|
||||
break;
|
||||
default:
|
||||
logger.fatal("invalid zone for card - " + fromZone);
|
||||
logger.fatal(new StringBuilder("Invalid from zone [").append(fromZone).append("] for card [").append(this.getName()).toString());
|
||||
break;
|
||||
}
|
||||
game.rememberLKI(objectId, event.getFromZone(), this);
|
||||
|
@ -342,7 +342,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
event.setTarget(permanent);
|
||||
break;
|
||||
default:
|
||||
logger.fatal("invalid zone for card - " + toZone);
|
||||
logger.fatal(new StringBuilder("Invalid from zone [").append(toZone).append("] for card [").append(this.getName()).toString());
|
||||
return false;
|
||||
}
|
||||
setControllerId(ownerId);
|
||||
|
@ -435,13 +435,18 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
|
||||
@Override
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId) {
|
||||
return putOntoBattlefield(game, fromZone, sourceId, controllerId, false);
|
||||
return this.putOntoBattlefield(game, fromZone, sourceId, controllerId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped){
|
||||
return this.putOntoBattlefield(game, fromZone, sourceId, controllerId, tapped, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped){
|
||||
ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, controllerId, fromZone, Zone.BATTLEFIELD);
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, ArrayList<UUID> appliedEffects){
|
||||
ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, controllerId, fromZone, Zone.BATTLEFIELD, appliedEffects, tapped);
|
||||
if (!game.replaceEvent(event)) {
|
||||
if (fromZone != null) {
|
||||
boolean removed = false;
|
||||
|
@ -476,7 +481,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
game.addPermanent(permanent);
|
||||
game.setZone(objectId, Zone.BATTLEFIELD);
|
||||
game.setScopeRelevant(true);
|
||||
game.applyEffects(); // magenoxx: this causes bugs - LevelX2: but it's neccessary for casting e.g. Kird Ape which must trigger evolve
|
||||
game.applyEffects();
|
||||
permanent.setTapped(tapped);
|
||||
permanent.entersBattlefield(sourceId, game, event.getFromZone(), true);
|
||||
game.setScopeRelevant(false);
|
||||
|
|
|
@ -67,12 +67,17 @@ public class ZoneChangeEvent extends GameEvent {
|
|||
}
|
||||
|
||||
public ZoneChangeEvent(UUID targetId, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone, ArrayList<UUID> appliedEffects) {
|
||||
this(targetId, sourceId, playerId, fromZone, toZone, appliedEffects, false);
|
||||
}
|
||||
|
||||
public ZoneChangeEvent(UUID targetId, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone, ArrayList<UUID> appliedEffects, boolean comesIntoPlayTapped) {
|
||||
super(EventType.ZONE_CHANGE, targetId, sourceId, playerId);
|
||||
this.fromZone = fromZone;
|
||||
this.toZone = toZone;
|
||||
if (appliedEffects != null) {
|
||||
this.appliedEffects = appliedEffects;
|
||||
}
|
||||
this.flag = comesIntoPlayTapped;
|
||||
}
|
||||
|
||||
public ZoneChangeEvent(Permanent target, UUID playerId, Zone fromZone, Zone toZone) {
|
||||
|
@ -106,4 +111,9 @@ public class ZoneChangeEvent extends GameEvent {
|
|||
public boolean isDiesEvent() {
|
||||
return (toZone == Zone.GRAVEYARD && fromZone == Zone.BATTLEFIELD);
|
||||
}
|
||||
|
||||
public boolean comesIntoPlayTapped() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -522,16 +522,22 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId) {
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, ArrayList<UUID> appliedEffects) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardNumber() {
|
||||
return card.getCardNumber();
|
||||
|
|
Loading…
Reference in a new issue