mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Implement Brand
This commit is contained in:
parent
991fee9da8
commit
2c5083b85d
3 changed files with 135 additions and 43 deletions
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fenhl
|
||||
*/
|
||||
public class GainControlAllEffect extends ContinuousEffectImpl {
|
||||
|
||||
final FilterPermanent filter;
|
||||
|
||||
public GainControlAllEffect(Duration duration, FilterPermanent filter) {
|
||||
super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public GainControlAllEffect(final GainControlAllEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainControlAllEffect copy() {
|
||||
return new GainControlAllEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (permanent != null) {
|
||||
permanent.changeControllerId(source.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Gain control of " + filter;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue