use of mage.constants.SubType in project mage by magefree.
the class EmbalmEffect method setRule.
private String setRule(Cost cost, Card card) {
StringBuilder sb = new StringBuilder("Embalm ").append(cost.getText());
sb.append(" <i>(").append(cost.getText());
sb.append(", Exile this card from your graveyard: Create a token that's a copy of it, except it's a white Zombie ");
for (SubType subtype : card.getSubtype()) {
sb.append(subtype).append(" ");
}
sb.append(" with no mana cost. Embalm only as a sorcery.)</i>");
return sb.toString();
}
use of mage.constants.SubType in project mage by magefree.
the class EternalizeEffect method setRule.
private String setRule(Cost cost, Card card) {
StringBuilder sb = new StringBuilder("Eternalize ").append(cost.getText());
sb.append(" <i>(").append(cost.getText());
sb.append(", Exile this card from your graveyard: Create a token that's a copy of it, except it's a 4/4 black Zombie ");
for (SubType subtype : card.getSubtype()) {
sb.append(subtype).append(" ");
}
sb.append(" with no mana cost. Eternalize only as a sorcery.)</i>");
return sb.toString();
}
use of mage.constants.SubType in project mage by magefree.
the class CardCriteria method buildQuery.
public void buildQuery(QueryBuilder qb) throws SQLException {
optimize();
Where where = qb.where();
where.eq("nightCard", false);
where.eq("splitCardHalf", false);
int clausesCount = 2;
if (name != null) {
where.like("name", new SelectArg('%' + name + '%'));
clausesCount++;
}
if (nameExact != null) {
where.like("name", new SelectArg(nameExact));
clausesCount++;
}
if (rules != null) {
where.like("rules", new SelectArg('%' + rules + '%'));
clausesCount++;
}
if (doubleFaced != null) {
where.eq("doubleFaced", doubleFaced);
clausesCount++;
}
if (modalDoubleFaced != null) {
where.eq("modalDoubleFacesCard", modalDoubleFaced);
clausesCount++;
}
for (Rarity rarity : rarities) {
where.eq("rarity", rarity);
}
if (!rarities.isEmpty()) {
where.or(rarities.size());
clausesCount++;
}
for (String setCode : setCodes) {
where.eq("setCode", setCode);
}
if (!setCodes.isEmpty()) {
where.or(setCodes.size());
clausesCount++;
}
for (String ignoreSetCode : ignoreSetCodes) {
where.ne("setCode", ignoreSetCode);
}
if (!ignoreSetCodes.isEmpty()) {
where.or(ignoreSetCodes.size());
clausesCount++;
}
if (types.size() != 7) {
// if all types selected - no selection needed (Tribal and Conspiracy not selectable yet)
for (CardType type : types) {
where.like("types", new SelectArg('%' + type.name() + '%'));
}
if (!types.isEmpty()) {
where.or(types.size());
clausesCount++;
}
}
for (CardType type : notTypes) {
where.not().like("types", new SelectArg('%' + type.name() + '%'));
clausesCount++;
}
for (SuperType superType : supertypes) {
where.like("supertypes", new SelectArg('%' + superType.name() + '%'));
clausesCount++;
}
for (SuperType superType : notSupertypes) {
where.not().like("supertypes", new SelectArg('%' + superType.name() + '%'));
clausesCount++;
}
for (SubType subType : subtypes) {
where.like("subtypes", new SelectArg('%' + subType.toString() + '%'));
clausesCount++;
}
if (manaValue != null) {
where.eq("manaValue", manaValue);
clausesCount++;
}
int colorClauses = 0;
if (black) {
where.eq("black", true);
colorClauses++;
}
if (blue) {
where.eq("blue", true);
colorClauses++;
}
if (green) {
where.eq("green", true);
colorClauses++;
}
if (red) {
where.eq("red", true);
colorClauses++;
}
if (white) {
where.eq("white", true);
colorClauses++;
}
if (colorless) {
where.eq("black", false).eq("blue", false).eq("green", false).eq("red", false).eq("white", false);
where.and(5);
colorClauses++;
}
if (colorClauses > 0) {
where.or(colorClauses);
clausesCount++;
}
if (minCardNumber != Integer.MIN_VALUE) {
where.ge("cardNumberAsInt", minCardNumber);
clausesCount++;
}
if (maxCardNumber != Integer.MAX_VALUE) {
where.le("cardNumberAsInt", maxCardNumber);
clausesCount++;
}
if (clausesCount > 0) {
where.and(clausesCount);
} else {
where.eq("cardNumber", new SelectArg(0));
}
if (start != null) {
qb.offset(start);
}
if (count != null) {
qb.limit(count);
}
if (sortBy != null) {
qb.orderBy(sortBy, true);
}
}
use of mage.constants.SubType in project mage by magefree.
the class GlobalRuinDestroyLandEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Set<UUID> lands = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (SubType landName : Arrays.stream(SubType.values()).filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType).collect(Collectors.toSet())) {
FilterControlledLandPermanent filter = new FilterControlledLandPermanent(landName + " you control");
filter.add(landName.getPredicate());
Target target = new TargetControlledPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(outcome, target, source, game);
lands.add(target.getFirstTarget());
}
}
}
}
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LAND, game)) {
if (!lands.contains(permanent.getId())) {
permanent.sacrifice(source, game);
}
}
return true;
}
use of mage.constants.SubType in project mage by magefree.
the class KindredChargeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
if (subType != null) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control of the chosen type");
filter.add(subType.getPredicate());
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
if (permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
for (Permanent addedToken : effect.getAddedPermanents()) {
Effect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
}
}
}
return true;
}
}
return false;
}
Aggregations