mage.game.events.ZoneChangeEvent类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中mage.game.events.ZoneChangeEvent类的一些代码示例,展示了ZoneChangeEvent类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneChangeEvent类的具体详情如下:
包路径:mage.game.events.ZoneChangeEvent
类名称:ZoneChangeEvent

ZoneChangeEvent介绍

暂无

代码示例

代码示例来源:origin: magefree/mage

public Unmelded(ZoneChangeInfo info, Game game) {
    super(info.event);
    MeldCard meld = game.getMeldCard(info.event.getTargetId());
    if (meld != null) {
      if (meld.hasTopHalf(game)) {
        ZoneChangeEvent topEvent = new ZoneChangeEvent(meld.getTopHalfCard().getId(), event.getSourceId(),
            event.getPlayerId(), event.getFromZone(), event.getToZone(), event.getAppliedEffects());
        ZoneChangeInfo topInfo = info.copy();
        topInfo.event = topEvent;
        subInfo.add(topInfo);
      }
      if (meld.hasBottomHalf(game)) {
        ZoneChangeEvent bottomEvent = new ZoneChangeEvent(meld.getBottomHalfCard().getId(), event.getSourceId(),
            event.getPlayerId(), event.getFromZone(), event.getToZone(), event.getAppliedEffects());
        ZoneChangeInfo bottomInfo = info.copy();
        bottomInfo.event = bottomEvent;
        subInfo.add(bottomInfo);
      }
    }
  }
}

代码示例来源:origin: magefree/mage

@Override
public boolean checkTrigger(GameEvent event, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  if (zEvent.getToZone() == Zone.GRAVEYARD
      && zEvent.getFromZone() == Zone.BATTLEFIELD
      && zEvent.getTarget().isArtifact()
      && zEvent.getTarget().isOwnedBy(this.controllerId)) {
    this.getEffects().setTargetPointer(new FixedTarget(zEvent.getTargetId()));
    return true;
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean checkTrigger(GameEvent event, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  if (zEvent.isDiesEvent() && zEvent.getTarget() != null && StaticFilters.FILTER_PERMANENT_CREATURES.match(zEvent.getTarget(), sourceId, controllerId, game)) {
    return true;
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean checkTrigger(GameEvent event, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  return zEvent.getFromZone() == Zone.GRAVEYARD && zEvent.getToZone() == Zone.BATTLEFIELD;
}

代码示例来源:origin: magefree/mage

@Override
  public boolean applies(GameEvent event, Ability source, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    return zEvent.getToZone() == Zone.GRAVEYARD
        && zEvent.getTargetId().equals(this.cardId);
  }
}

代码示例来源:origin: magefree/mage

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  return zEvent.getTarget() != null
      && zEvent.getTarget().isCreature()
      && zEvent.getFromZone() == Zone.BATTLEFIELD
      && zEvent.getToZone() == Zone.GRAVEYARD;
}

代码示例来源:origin: magefree/mage

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  if (zEvent.getToZone() == Zone.BATTLEFIELD && (zEvent.getFromZone() == Zone.GRAVEYARD || zEvent.getFromZone() == Zone.LIBRARY)) {
    Card card = game.getCard(zEvent.getTargetId());
    if (card != null && card.isCreature()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: magefree/mage

MeldCard meld = game.getMeldCard(info.event.getTargetId());
  for (Iterator<ZoneChangeInfo> itr = unmelded.subInfo.iterator(); itr.hasNext();) {
    ZoneChangeInfo subInfo = itr.next();
    if (!maybeRemoveFromSourceZone(subInfo, game)) {
      itr.remove();
    } else if (Objects.equals(subInfo.event.getTargetId(), meld.getTopHalfCard().getId())) {
      meld.setTopLastZoneChangeCounter(meld.getTopHalfCard().getZoneChangeCounter(game));
    } else if (Objects.equals(subInfo.event.getTargetId(), meld.getBottomHalfCard().getId())) {
      meld.setBottomLastZoneChangeCounter(meld.getBottomHalfCard().getZoneChangeCounter(game));
Card card = getTargetCard(game, event.getTargetId());
if (card == null) {
  Zone fromZone = event.getFromZone();
  if (event.getToZone() == Zone.BATTLEFIELD) {
      permanent = new PermanentMeld(card, event.getPlayerId(), game);
    } else if (card instanceof Permanent) {
      permanent = new PermanentCard(card, event.getPlayerId(), game);
    if (permanent.entersBattlefield(event.getSourceId(), game, fromZone, true)
        && card.removeFromZone(game, fromZone, event.getSourceId())) {
      success = true;
      event.setTarget(permanent);
    } else {
  } else if (event.getTarget() != null) {
    card.setFaceDown(info.faceDown, game);

代码示例来源:origin: magefree/mage

public static boolean cast(ZoneChangeInfo info, Game game) {
  if (maybeRemoveFromSourceZone(info, game)) {
    placeInDestinationZone(info, game);
    // create a group zone change event if a card is moved to stack for casting (it's always only one card, but some effects check for group events (one or more xxx))
    Set<Card> cards = new HashSet<>();
    Card targetCard = getTargetCard(game, info.event.getTargetId());
    cards.add(targetCard);
    game.fireEvent(new ZoneChangeGroupEvent(cards, info.event.getSourceId(), info.event.getPlayerId(), info.event.getFromZone(), info.event.getToZone()));
    // normal movement
    game.fireEvent(info.event);
    return true;
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean checkTrigger(GameEvent event, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  if ((fromZone == null || zEvent.getFromZone() == fromZone)
      && (toZone == null || zEvent.getToZone() == toZone)) {
    Permanent permanentThatMoved = null;
    if (zEvent.getTarget() != null) {
      permanentThatMoved = zEvent.getTarget();
    }
    if (permanentThatMoved != null
        && filter.match(permanentThatMoved, sourceId, controllerId, game)
        && zEvent.getPlayerId().equals(controllerId)) { //The controller's hand is where the permanent moved to.
      return true;
    }
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public void watch(GameEvent event, Game game) {
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.isDiesEvent()
        && zEvent.getTarget() != null
        && zEvent.getTarget().isCreature()) {
      diedThisTurn.add(zEvent.getTargetId());
    }
  }
}

代码示例来源:origin: magefree/mage

@Override
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
  boolean skullBriarEffectApplied = false;
  if (event.getToZone() != Zone.HAND && event.getToZone() != Zone.LIBRARY) {
    for (StaticAbility ability : getAbilities(game).getStaticAbilities(event.getFromZone())) {
      for (Effect effect : ability.getEffects(game, EffectType.REPLACEMENT)) {
        if (effect instanceof SkullbriarEffect && event.getAppliedEffects().contains(effect.getId())) {
          skullBriarEffectApplied = true;
    if (event.getTarget() != null && event.getFromZone() == Zone.BATTLEFIELD) {
      copyFrom = new Counters(event.getTarget().getCounters(game));
    } else {
      copyFrom = new Counters(this.getCounters(game));
  if (event.getTarget() != null && event.getToZone() == Zone.BATTLEFIELD) {
    if (event.getFromZone() != Zone.BATTLEFIELD) {
      copyTo = event.getTarget().getCounters(game);

代码示例来源:origin: magefree/mage

@Override
public void watch(GameEvent event, Game game) {
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE
      && ((ZoneChangeEvent) event).isDiesEvent()) {
    //400.3 Intercept only the controller's events
    cards.add(event.getTargetId());
  }
}

代码示例来源:origin: magefree/mage

@Override
public boolean checkTrigger(GameEvent event, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getTarget() != null && zEvent.getTargetId().equals(getTargets().getFirstTarget())) {
    this.getTargets().clear(); // else spell fizzles because target creature died
    return true;
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean checkTrigger(GameEvent event, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  if (zEvent.getFromZone() == Zone.LIBRARY && zEvent.getToZone() == Zone.GRAVEYARD && game.getOpponents(this.getControllerId()).contains(zEvent.getPlayerId())) {
    Card card = game.getCard(event.getTargetId());
    if (card != null && card.isCreature()) {
      this.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId()));
      return true;
    }
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
  if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    if (permanent != null) {
      Player player = game.getPlayer(permanent.getOwnerId());
      if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", source, game)) {
        ((ZoneChangeEvent) event).setToZone(Zone.COMMAND);
        if (!game.isSimulation()) {
          game.informPlayers(player.getLogName() + " has moved their commander to the command zone");
    if (((ZoneChangeEvent) event).getFromZone() == Zone.STACK) {
      Spell spell = game.getStack().getSpell(event.getTargetId());
      if (spell != null) {
      Player player = game.getPlayer(card.getOwnerId());
      if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", source, game)) {
        ((ZoneChangeEvent) event).setToZone(Zone.COMMAND);
        if (!game.isSimulation()) {
          game.informPlayers(player.getLogName() + " has moved their commander to the command zone");

代码示例来源:origin: magefree/mage

@Override
public boolean checkTrigger(GameEvent event, Game game) {
  ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
  if (zEvent.getFromZone() == Zone.GRAVEYARD) {
    Card card = game.getCard(zEvent.getTargetId());
    Player controller = game.getPlayer(getControllerId());
    return card != null
        && card.isCreature()
        && controller != null
        && controller.hasOpponent(card.getOwnerId(), game);
  }
  return false;
}

代码示例来源:origin: magefree/mage

for (Card card : cards) {
  fromZone = game.getState().getZone(card.getId());
  ZoneChangeEvent event = new ZoneChangeEvent(card.getId(), source.getSourceId(), byOwner ? card.getOwnerId() : getId(), fromZone, Zone.BATTLEFIELD, appliedEffects);
  infoList.add(new ZoneChangeInfo.Battlefield(event, faceDown, tapped));
  Permanent permanent = game.getPermanent(info.event.getTargetId());
  if (permanent != null) {
    successfulMovedCards.add(permanent);
    if (!game.isSimulation()) {
      Player eventPlayer = game.getPlayer(info.event.getPlayerId());
      if (eventPlayer != null && fromZone != null) {
        game.informPlayers(eventPlayer.getLogName() + " puts "
  if (card instanceof Permanent) {
    game.getBattlefield().removePermanent(card.getId());
    ZoneChangeEvent event = new ZoneChangeEvent(card.getId(), (source == null ? null : source.getSourceId()),
        byOwner ? card.getOwnerId() : getId(), Zone.BATTLEFIELD, Zone.OUTSIDE, appliedEffects);
    game.fireEvent(event);

代码示例来源:origin: magefree/mage

@Override
public void watch(GameEvent event, Game game) {
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getToZone() == Zone.BATTLEFIELD
        && zEvent.getTarget().isPlaneswalker()) {
      players.add(zEvent.getTarget().getControllerId());
    }
  }
}

代码示例来源:origin: magefree/mage

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
  Permanent permanent = ((ZoneChangeEvent) event).getTarget();
  Player controller = game.getPlayer(source.getControllerId());
  if (controller != null && permanent != null) {
    return controller.moveCards(permanent, Zone.EXILED, source, game);
  }
  return false;
}

相关文章