Override Ability setters

This commit is contained in:
Noah Gleason 2018-06-24 10:51:48 -04:00
parent 65d67d48fd
commit 6ee4d4a217
No known key found for this signature in database
GPG key ID: 38D5F989A472EC21
2 changed files with 59 additions and 20 deletions

View file

@ -1,29 +1,28 @@
package mage.cards.o;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DamageAttachedControllerEffect;
import mage.abilities.effects.common.DestroyAttachedToEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.meta.OrTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.common.TargetLandPermanent;
import mage.abilities.Ability;
import mage.abilities.effects.common.AttachEffect;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.target.common.TargetLandPermanent;
import java.util.UUID;
/**
*

View file

@ -1,17 +1,26 @@
package mage.abilities.meta;
import mage.MageObject;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import java.util.UUID;
/**
* A triggered ability that combines several others and triggers whenever one or more of them would. The abilities
* passed in should have null as their effect, and should have their own targets set if necessary. All other information
* will be passed in from changes to this Ability.
* @author noahg
*/
public class OrTriggeredAbility extends TriggeredAbilityImpl {
private TriggeredAbility[] triggeredAbilities;
private final String ruleTrigger;
private TriggeredAbility[] triggeredAbilities;
public OrTriggeredAbility(Zone zone, Effect effect, TriggeredAbility... abilities) {
this(zone, effect, false, null, abilities);
@ -24,8 +33,6 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl {
for (TriggeredAbility ability : triggeredAbilities) {
//Remove useless data
ability.getEffects().clear();
ability.setSourceId(this.getSourceId());
ability.setControllerId(this.getControllerId());
}
}
@ -80,4 +87,37 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl {
sb.append(" or ").append(triggeredAbilities[triggeredAbilities.length - 1].getRule().toLowerCase());
return sb.toString() + super.getRule();
}
@Override
public void setControllerId(UUID controllerId) {
super.setControllerId(controllerId);
for (TriggeredAbility ability : triggeredAbilities) {
ability.setControllerId(controllerId);
}
}
@Override
public void setSourceId(UUID sourceId) {
super.setSourceId(sourceId);
for (TriggeredAbility ability : triggeredAbilities) {
ability.setSourceId(sourceId);
}
}
@Override
public void addWatcher(Watcher watcher) {
super.addWatcher(watcher);
for (TriggeredAbility ability : triggeredAbilities) {
ability.addWatcher(watcher);
}
}
@Override
public void setSourceObject(MageObject sourceObject, Game game) {
super.setSourceObject(sourceObject, game);
for (TriggeredAbility ability : triggeredAbilities) {
ability.setSourceObject(sourceObject, game);
}
}
}