use of mage.MageObjectReference in project mage by magefree.
the class VisionCharmEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceLandType();
if (!controller.choose(outcome, choice, game)) {
discard();
return;
}
targetLandType = choice.getChoice();
choice = new ChoiceBasicLandType();
if (!controller.choose(outcome, choice, game)) {
discard();
return;
}
targetBasicLandType = SubType.byDescription(choice.getChoice());
if (targetLandType == null || targetBasicLandType == null) {
this.discard();
return;
}
} else {
this.discard();
return;
}
FilterPermanent filter = new FilterLandPermanent();
filter.add(SubType.byDescription(targetLandType).getPredicate());
if (this.affectedObjectsSet) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}
use of mage.MageObjectReference in project mage by magefree.
the class AddCardSubTypeSourceEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
}
use of mage.MageObjectReference in project mage by magefree.
the class BoostAllEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (this.affectedObjectsSet) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
// filter may not be used again, because object can have changed filter relevant attributes but still geets boost
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.addPower(power.calculate(game, source, this));
permanent.addToughness(toughness.calculate(game, source, this));
} else {
// no longer on the battlefield, remove reference to object
it.remove();
}
}
} else {
setRuntimeData(source, game);
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
perm.addPower(power.calculate(game, source, this));
perm.addToughness(toughness.calculate(game, source, this));
}
}
}
return true;
}
use of mage.MageObjectReference in project mage by magefree.
the class BoostControlledEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
if (this.affectedObjectsSet) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
}
if (this.lockedIn) {
power = StaticValue.get(power.calculate(game, source, this));
toughness = StaticValue.get(toughness.calculate(game, source, this));
}
}
use of mage.MageObjectReference in project mage by magefree.
the class BoostControlledEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (this.affectedObjectsSet) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.addPower(power.calculate(game, source, this));
permanent.addToughness(toughness.calculate(game, source, this));
} else {
// no longer on the battlefield, remove reference to object
it.remove();
}
}
} else {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
perm.addPower(power.calculate(game, source, this));
perm.addToughness(toughness.calculate(game, source, this));
}
}
}
return true;
}
Aggregations