Esempio n. 1
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent ThranWeaponry = game.getPermanent(source.getSourceId());
   if (ThranWeaponry != null) {
     if (ThranWeaponry.isTapped()) {
       super.apply(game, source);
       return true;
     } else {
       used = true;
     }
   }
   return false;
 }
Esempio n. 2
0
 @Override
 public boolean applies(Permanent permanent, Ability source, Game game) {
   Permanent rustTick = game.getPermanent(source.getSourceId());
   if (rustTick != null && rustTick.isTapped()) {
     if (rustTick.getConnectedCards("DesertersQuarters").size() > 0) {
       UUID target = rustTick.getConnectedCards("DesertersQuarters").get(0);
       if (target != null && target.equals(permanent.getId())) {
         return true;
       }
     }
   }
   return false;
 }
Esempio n. 3
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (super.applies(event, source, game)) {
     if (event.getTargetId().equals(source.getControllerId())) {
       Permanent sourcePermanent = game.getPermanent(source.getSourceId());
       if (sourcePermanent != null && !sourcePermanent.isTapped()) {
         Permanent damageSource = game.getPermanent(event.getSourceId());
         if (damageSource != null && filter.match(damageSource, game)) {
           return true;
         }
       }
     }
   }
   return false;
 }
Esempio n. 4
0
 @Override
 public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
   // check if all creatures of defender are able to block this permanent
   // permanent.canBlock() can't be used because causing recursive call
   for (Permanent permanent :
       game.getBattlefield().getAllActivePermanents(filter, blocker.getControllerId(), game)) {
     if (permanent.isTapped()
         && !game.getState()
             .getContinuousEffects()
             .asThough(
                 this.getId(),
                 AsThoughEffectType.BLOCK_TAPPED,
                 source,
                 blocker.getControllerId(),
                 game)) {
       return false;
     }
     // check blocker restrictions
     for (Map.Entry<RestrictionEffect, HashSet<Ability>> entry :
         game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).entrySet()) {
       for (Ability ability : entry.getValue()) {
         if (!entry.getKey().canBlock(attacker, permanent, ability, game)) {
           return false;
         }
       }
     }
     // check also attacker's restriction effects
     for (Map.Entry<RestrictionEffect, HashSet<Ability>> restrictionEntry :
         game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) {
       for (Ability ability : restrictionEntry.getValue()) {
         if (!(restrictionEntry.getKey() instanceof CantBeBlockedUnlessAllEffect)
             && !restrictionEntry.getKey().canBeBlocked(attacker, permanent, ability, game)) {
           return false;
         }
       }
     }
     if (attacker.hasProtectionFrom(permanent, game)) {
       return false;
     }
   }
   return true;
 }
Esempio n. 5
0
  public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) {
    super(permanent, game, permanent.getControllerId().equals(createdForPlayerId));
    this.controlled = permanent.getControllerId().equals(createdForPlayerId);
    this.rules = permanent.getRules(game);
    this.tapped = permanent.isTapped();
    this.flipped = permanent.isFlipped();
    this.phasedIn = permanent.isPhasedIn();
    this.summoningSickness = permanent.hasSummoningSickness();
    this.morphed = permanent.isMorphed();
    this.manifested = permanent.isManifested();
    this.damage = permanent.getDamage();
    if (permanent.getAttachments().size() > 0) {
      attachments = new ArrayList<>();
      attachments.addAll(permanent.getAttachments());
    }
    this.attachedTo = permanent.getAttachedTo();
    if (isToken()) {
      original = new CardView(((PermanentToken) permanent).getToken());
      original.expansionSetCode = permanent.getExpansionSetCode();
      tokenSetCode = original.getTokenSetCode();
    } else {
      if (card != null) {
        // original may not be face down
        original = new CardView(card);
      } else {
        original = null;
      }
    }
    this.transformed = permanent.isTransformed();
    this.copy = permanent.isCopy();

    // for fipped, transformed or copied cards, switch the names
    if (original != null && !original.getName().equals(this.getName())) {
      if (permanent.isCopy() && permanent.isFlipCard()) {
        this.alternateName = permanent.getFlipCardName();
        this.originalName = this.getName();
      } else {
        if (controlled // controller may always know
            || (!morphed && !manifested)) { // others don't know for morph or transformed cards
          this.alternateName = original.getName();
          this.originalName = this.getName();
        }
      }
    }
    if (!permanent.getOwnerId().equals(permanent.getControllerId())) {
      Player owner = game.getPlayer(permanent.getOwnerId());
      if (owner != null) {
        this.nameOwner = owner.getName();
      } else {
        this.nameOwner = "";
      }
    } else {
      this.nameOwner = "";
    }

    if (permanent.isFaceDown(game) && card != null) {
      if (controlled) {
        // must be a morphed or manifested card
        for (Ability permanentAbility : permanent.getAbilities()) {
          if (permanentAbility instanceof TurnFaceUpAbility && !permanentAbility.getRuleVisible()) {
            this.rules.add(permanentAbility.getRule(true));
          }
          if (permanentAbility.getWorksFaceDown()) {
            this.rules.add(permanentAbility.getRule());
          }
        }
        this.name = card.getName();
        this.displayName = card.getName();
        this.expansionSetCode = card.getExpansionSetCode();
        this.cardNumber = card.getCardNumber();
      } else {
        if (permanent.isManifested()) {
          this.rules.add(
              "A manifested creature card can be turned face up any time for it's mana cost."
                  + " A face-down card can also be turned face up for its morph cost.");
        } else if (permanent.isMorphed()) {
          this.rules.add(
              "If the controller has priority, he or she may turn this permanent face up."
                  + " This is a special action; it doesn’t use the stack. To do this he or she pays the morph costs,"
                  + " then turns this permanent face up.");
        }
      }
    }
    // determines if shown in it's own column
    if (permanent.getAttachedTo() != null) {
      attachedToPermanent = game.getPermanent(permanent.getAttachedTo()) != null;
    } else {
      attachedToPermanent = false;
    }
  }