Пример #1
0
 @Override
 public void addWatcher(Watcher watcher) {
   if (watchers == null) {
     watchers = new ArrayList<>();
   }
   watcher.setSourceId(this.sourceId);
   watcher.setControllerId(this.controllerId);
   watchers.add(watcher);
 }
Пример #2
0
 @Override
 public boolean isAvailable(Game game, Ability source) {
   Watcher watcher =
       game.getState()
           .getWatchers()
           .get("noncreature permanent destroyed", source.getControllerId());
   if (watcher != null && watcher.conditionMet()) {
     return true;
   }
   return false;
 }
Пример #3
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent p = game.getPermanent(source.getSourceId());
   if (p != null) {
     Watcher watcher = game.getState().getWatchers().get("CastCreature", source.getSourceId());
     if (watcher != null && !watcher.conditionMet()) {
       return true;
     }
   }
   return false;
 }
Пример #4
0
 @Override
 public void setControllerId(UUID controllerId) {
   this.controllerId = controllerId;
   if (watchers != null) {
     for (Watcher watcher : watchers) {
       watcher.setControllerId(controllerId);
     }
   }
   if (subAbilities != null) {
     for (Ability subAbility : subAbilities) {
       subAbility.setControllerId(controllerId);
     }
   }
 }
Пример #5
0
 public void addCard(Card card) {
   setZone(card.getId(), Zone.OUTSIDE);
   for (Watcher watcher : card.getWatchers()) {
     watcher.setControllerId(card.getOwnerId());
     watcher.setSourceId(card.getId());
     watchers.add(watcher);
   }
   for (Ability ability : card.getAbilities()) {
     addAbility(ability, card);
   }
   if (card.isSplitCard()) {
     addCard(((SplitCard) card).getLeftHalfCard());
     addCard(((SplitCard) card).getRightHalfCard());
   }
 }
Пример #6
0
 @Override
 public void setSourceId(UUID sourceId) {
   if (this.sourceId == null) {
     this.sourceId = sourceId;
   } else if (!(this instanceof MageSingleton)) {
     this.sourceId = sourceId;
   }
   if (subAbilities != null) {
     for (Ability subAbility : subAbilities) {
       subAbility.setSourceId(sourceId);
     }
   }
   if (watchers != null) {
     for (Watcher watcher : watchers) {
       watcher.setSourceId(sourceId);
     }
   }
 }
Пример #7
0
 public AbilityImpl(final AbilityImpl ability) {
   this.id = ability.id;
   this.originalId = ability.originalId;
   this.abilityType = ability.abilityType;
   this.controllerId = ability.controllerId;
   this.sourceId = ability.sourceId;
   this.zone = ability.zone;
   this.name = ability.name;
   this.usesStack = ability.usesStack;
   this.manaCosts = ability.manaCosts;
   this.manaCostsToPay = ability.manaCostsToPay.copy();
   this.costs = ability.costs.copy();
   this.optionalCosts = ability.optionalCosts.copy();
   if (ability.watchers != null) {
     this.watchers = new ArrayList<>();
     for (Watcher watcher : ability.watchers) {
       watchers.add(watcher.copy());
     }
   }
   if (ability.subAbilities != null) {
     this.subAbilities = new ArrayList<>();
     for (Ability subAbility : ability.subAbilities) {
       subAbilities.add(subAbility.copy());
     }
   }
   this.modes = ability.getModes().copy();
   this.ruleAtTheTop = ability.ruleAtTheTop;
   this.ruleVisible = ability.ruleVisible;
   this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
   this.costModificationActive = ability.costModificationActive;
   this.worksFaceDown = ability.worksFaceDown;
   this.abilityWord = ability.abilityWord;
   this.sourceObject = ability.sourceObject;
   this.sourceObjectZoneChangeCounter = ability.sourceObjectZoneChangeCounter;
   this.canFizzle = ability.canFizzle;
 }
Пример #8
0
 @Override
 public void reset() {
   super.reset();
   spells.clear();
 }
Пример #9
0
 @Override
 public boolean isAvailable(Game game, Ability source) {
   Watcher watcher =
       game.getState().getWatchers().get("CreatureSpellCountered", source.getControllerId());
   return watcher != null && watcher.conditionMet();
 }
Пример #10
0
 @Override
 public void reset() {
   super.reset();
   damagingObjects.clear();
   damagedObjects.clear();
 }
Пример #11
0
 @Override
 public void reset() {
   super.reset();
   damageSources.clear();
 }
Пример #12
0
 @Override
 public void reset() {
   super.reset();
   creaturesCount = 0;
 }