use of mage.game.command.Plane in project mage by magefree.
the class FieldsOfSummerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_FIELDS_OF_SUMMER)) {
return false;
}
Player owner = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (owner != null && owner.canRespond() && owner.chooseUse(Outcome.Benefit, "Gain 2 life?", source, game)) {
Effect effect = new GainLifeTargetEffect(2);
effect.setTargetPointer(new FixedTarget(owner.getId())).apply(game, source);
return true;
}
return false;
}
use of mage.game.command.Plane in project mage by magefree.
the class PanopticonTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_PANOPTICON)) {
return false;
}
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
getEffects().setTargetPointer(new FixedTarget(activePlayer.getId()));
return true;
}
return false;
}
use of mage.game.command.Plane in project mage by magefree.
the class TheGreatForestCombatDamageRuleEffect method apply.
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null) {
return false;
}
if (!cPlane.getPlaneType().equals(Planes.PLANE_THE_GREAT_FOREST)) {
return false;
}
// Change the rule
game.getCombat().setUseToughnessForDamage(true);
game.getCombat().addUseToughnessForDamageFilter(StaticFilters.FILTER_PERMANENT_CREATURES);
return true;
}
use of mage.game.command.Plane in project mage by magefree.
the class TurriIslandEffect method applies.
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null) {
return false;
}
if (!cPlane.getPlaneType().equals(Planes.PLANE_TURRI_ISLAND)) {
return false;
}
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
if (spellCard != null) {
return filter.match(spellCard, game) && selectedByRuntimeData(spellCard, source, game);
}
}
return false;
}
use of mage.game.command.Plane in project mage by magefree.
the class MageBook method loadTokens.
public List<Object> loadTokens() {
List<Object> res = new ArrayList<>();
// tokens
List<CardDownloadData> allTokens = getTokenCardUrls();
for (CardDownloadData token : allTokens) {
if (token.getSet().equals(currentSet)) {
try {
String className = token.getName();
className = className.replaceAll("[^a-zA-Z0-9]", "");
className = "mage.game.permanent.token." + className + "Token";
if (token.getTokenClassName() != null && token.getTokenClassName().length() > 0) {
if (token.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*token.*")) {
className = token.getTokenClassName();
className = "mage.game.permanent.token." + className;
} else if (token.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*emblem.*")) {
continue;
}
}
Class<?> c = Class.forName(className);
Constructor<?> cons = c.getConstructor();
Object newToken = cons.newInstance();
if (newToken instanceof Token) {
((Token) newToken).setOriginalExpansionSetCode(currentSet);
((Token) newToken).setExpansionSetCodeForImage(currentSet);
((Token) newToken).setTokenType(token.getType());
res.add(newToken);
}
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
// Swallow exception
}
}
}
// emblems
List<CardDownloadData> allEmblems = getTokenCardUrls();
for (CardDownloadData emblem : allEmblems) {
if (emblem.getSet().equals(currentSet)) {
try {
String className = emblem.getName();
if (emblem.getTokenClassName() != null && emblem.getTokenClassName().length() > 0) {
if (emblem.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*emblem.*")) {
className = emblem.getTokenClassName();
className = "mage.game.command.emblems." + className;
}
} else {
continue;
}
Class<?> c = Class.forName(className);
Constructor<?> cons = c.getConstructor();
Object newEmblem = cons.newInstance();
if (newEmblem instanceof Emblem) {
((Emblem) newEmblem).setExpansionSetCodeForImage(currentSet);
res.add(newEmblem);
}
} catch (ClassNotFoundException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | SecurityException | NoSuchMethodException ex) {
// Swallow exception
}
}
}
// planes
List<CardDownloadData> allPlanes = getTokenCardUrls();
for (CardDownloadData plane : allPlanes) {
if (plane.getSet().equals(currentSet)) {
try {
String className = plane.getName();
if (plane.getTokenClassName() != null && plane.getTokenClassName().length() > 0) {
if (plane.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*plane.*")) {
className = plane.getTokenClassName();
className = "mage.game.command.planes." + className;
}
} else {
continue;
}
Class<?> c = Class.forName(className);
Constructor<?> cons = c.getConstructor();
Object newPlane = cons.newInstance();
if (newPlane instanceof Plane) {
((Plane) newPlane).setExpansionSetCodeForImage(currentSet);
res.add(newPlane);
}
} catch (ClassNotFoundException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | SecurityException | NoSuchMethodException ex) {
// Swallow exception
}
}
}
// dungeons
List<CardDownloadData> allDungeons = getTokenCardUrls();
for (CardDownloadData dungeon : allDungeons) {
if (dungeon.getSet().equals(currentSet)) {
try {
String className = dungeon.getName();
if (dungeon.getTokenClassName() != null && dungeon.getTokenClassName().length() > 0) {
if (dungeon.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*dungeon.*")) {
className = dungeon.getTokenClassName();
className = "mage.game.command.dungeons." + className;
}
} else {
continue;
}
Class<?> c = Class.forName(className);
Constructor<?> cons = c.getConstructor();
Object newDungeon = cons.newInstance();
if (newDungeon instanceof Dungeon) {
((Dungeon) newDungeon).setExpansionSetCodeForImage(currentSet);
res.add(newDungeon);
}
} catch (ClassNotFoundException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | SecurityException | NoSuchMethodException ex) {
// Swallow exception
}
}
}
return res;
}
Aggregations