use of mage.constants.Zone in project mage by magefree.
the class TraceUtil method traceForPermanent.
private static void traceForPermanent(Game game, Permanent permanent, String uuid, ContinuousEffectsList<RestrictionEffect> restrictionEffects) {
for (RestrictionEffect effect : restrictionEffects) {
log.error(uuid + " effect=" + effect.toString() + " id=" + effect.getId());
for (Ability ability : restrictionEffects.getAbility(effect.getId())) {
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, permanent, null)) {
log.error(uuid + " ability=" + ability + ", applies_to_attacker=" + effect.applies(permanent, ability, game));
} else {
boolean usable = ability.isInUseableZone(game, permanent, null);
log.error(uuid + " instanceof StaticAbility: " + (ability instanceof StaticAbility) + ", ability=" + ability);
log.error(uuid + " usable zone: " + usable + ", ability=" + ability);
if (!usable) {
Zone zone = ability.getZone();
log.error(uuid + " zone: " + zone);
MageObject object = game.getObject(ability.getSourceId());
log.error(uuid + " object: " + object);
if (object != null) {
log.error(uuid + " contains ability: " + object.getAbilities().contains(ability));
}
Zone test = game.getState().getZone(ability.getSourceId());
log.error(uuid + " test_zone: " + test);
}
}
}
}
}
use of mage.constants.Zone in project mage by magefree.
the class GhostlyFlickerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Set<Card> toExile = new HashSet<>();
for (UUID permanentId : targetPointer.getTargets(game, source)) {
Permanent target = game.getPermanent(permanentId);
if (target != null) {
toExile.add(target);
}
}
controller.moveCards(toExile, Zone.EXILED, source, game);
game.getState().processAction(game);
Set<Card> toBattlefield = new HashSet<>();
for (Card card : toExile) {
Zone currentZone = game.getState().getZone(card.getId());
if (Zone.BATTLEFIELD != currentZone && currentZone.isPublicZone()) {
toBattlefield.add(card);
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
return true;
}
return false;
}
use of mage.constants.Zone in project mage by magefree.
the class CantBeTargetedCardsGraveyardsEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Card targetCard = game.getCard(event.getTargetId());
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (targetCard != null && stackObject != null) {
Zone zone = game.getState().getZone(targetCard.getId());
if (zone != null && zone == Zone.GRAVEYARD) {
return true;
}
}
return false;
}
use of mage.constants.Zone in project mage by magefree.
the class Cards method layoutCards.
private void layoutCards() {
// get all the card panels
java.util.List<MageCard> cardsToLayout = new ArrayList<>();
for (Component component : cardArea.getComponents()) {
if (component instanceof MageCard) {
cardsToLayout.add((MageCard) component);
}
}
// WARNING, must be same sort code as MageActionCallback->sortLayout (if not then hand cards will be messed after drag)
// sort the cards
cardsToLayout.sort(Comparator.comparingInt(cp -> cp.getCardLocation().getCardX()));
// relocate the cards (support only horizontal style: hand and stack panels)
// TODO: add shrinking of cards list for too big amount (cards will be overlapped, use MageActionCallback.HAND_CARDS_BETWEEN_GAP_X to control it)
// starting position
int dx = MageActionCallback.getHandOrStackBetweenGapX(zone);
for (MageCard component : cardsToLayout) {
component.setCardLocation(dx, component.getCardLocation().getCardY());
dx += component.getCardLocation().getCardWidth() + MageActionCallback.getHandOrStackBetweenGapX(zone);
}
}
use of mage.constants.Zone in project mage by magefree.
the class DeadbridgeChantEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && !controller.getGraveyard().isEmpty()) {
Card card = controller.getGraveyard().getRandom(game);
if (card != null) {
Zone targetZone = Zone.HAND;
String text = " put into hand of ";
if (card.isCreature(game)) {
targetZone = Zone.BATTLEFIELD;
text = " put onto battlefield for ";
}
controller.moveCards(card, targetZone, source, game);
game.informPlayers("Deadbridge Chant: " + card.getName() + text + controller.getLogName());
return true;
}
}
return false;
}
Aggregations