forked from External/mage
Commiting changes to allow Dispense Justice to use common SacrificeEffect
Made SacrificeEffect accept a more generic filter and target, users will have to be more careful about the filter sent in than before. Added setters for FilterCreaturePermanent so that attackers/blockers can be easily filtered without creating yet another child class.
This commit is contained in:
parent
9384cc36e4
commit
85a72180be
2 changed files with 25 additions and 5 deletions
|
|
@ -31,11 +31,11 @@ import mage.Constants.Outcome;
|
|||
import mage.Constants.TargetController;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -43,11 +43,11 @@ import mage.target.common.TargetControlledPermanent;
|
|||
*/
|
||||
public class SacrificeEffect extends OneShotEffect<SacrificeEffect>{
|
||||
|
||||
private FilterControlledPermanent filter;
|
||||
private FilterPermanent filter;
|
||||
private String preText;
|
||||
private int count;
|
||||
|
||||
public SacrificeEffect ( FilterControlledPermanent filter, int count, String preText ) {
|
||||
public SacrificeEffect ( FilterPermanent filter, int count, String preText ) {
|
||||
super(Outcome.Sacrifice);
|
||||
this.filter = filter;
|
||||
this.count = count;
|
||||
|
|
@ -60,12 +60,16 @@ public class SacrificeEffect extends OneShotEffect<SacrificeEffect>{
|
|||
this.count = effect.count;
|
||||
this.preText = effect.preText;
|
||||
}
|
||||
|
||||
public void setCount ( int count ) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getTargets().getFirstTarget());
|
||||
filter.setTargetController(TargetController.YOU);
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(count, count, filter, false);
|
||||
TargetPermanent target = new TargetPermanent(count, count, filter, false);
|
||||
|
||||
//A spell or ability could have removed the only legal target this player
|
||||
//had, if thats the case this ability should fizzle.
|
||||
|
|
|
|||
|
|
@ -80,6 +80,22 @@ public class FilterCreaturePermanent<T extends FilterCreaturePermanent<T>> exten
|
|||
return !notFilter;
|
||||
}
|
||||
|
||||
public void setUseAttacking ( boolean useAttacking ) {
|
||||
this.useAttacking = useAttacking;
|
||||
}
|
||||
|
||||
public void setAttacking ( boolean attacking ) {
|
||||
this.attacking = attacking;
|
||||
}
|
||||
|
||||
public void setUseBlocking ( boolean useBlocking ) {
|
||||
this.useBlocking = useBlocking;
|
||||
}
|
||||
|
||||
public void setBlocking ( boolean blocking ) {
|
||||
this.blocking = blocking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterCreaturePermanent<T> copy() {
|
||||
if (this == defaultFilter)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue