Search in sources :

Example 1 with RedManaAbility

use of mage.abilities.mana.RedManaAbility in project mage by magefree.

the class ChooseTwoBasicLandTypesEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    SubType firstChoice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "firstChoice"));
    SubType secondChoice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "secondChoice"));
    List<Permanent> lands = game.getBattlefield().getAllActivePermanents(CardType.LAND, game);
    if (controller != null && firstChoice != null && secondChoice != null) {
        for (Permanent land : lands) {
            if (land.isBasic()) {
                switch(layer) {
                    case TypeChangingEffects_4:
                        // the land mana ability is intrinsic, so add it here, not layer 6
                        if (land.hasSubtype(firstChoice, game)) {
                            land.removeAllSubTypes(game, SubTypeSet.NonBasicLandType);
                            land.addSubType(game, secondChoice);
                            land.removeAllAbilities(source.getSourceId(), game);
                            if (land.hasSubtype(SubType.FOREST, game)) {
                                this.dependencyTypes.add(DependencyType.BecomeForest);
                                land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
                            }
                            if (land.hasSubtype(SubType.PLAINS, game)) {
                                this.dependencyTypes.add(DependencyType.BecomePlains);
                                land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
                            }
                            if (land.hasSubtype(SubType.MOUNTAIN, game)) {
                                this.dependencyTypes.add(DependencyType.BecomeMountain);
                                land.addAbility(new RedManaAbility(), source.getSourceId(), game);
                            }
                            if (land.hasSubtype(SubType.ISLAND, game)) {
                                this.dependencyTypes.add(DependencyType.BecomeIsland);
                                land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
                            }
                            if (land.hasSubtype(SubType.SWAMP, game)) {
                                this.dependencyTypes.add(DependencyType.BecomeSwamp);
                                land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
                            }
                        }
                        break;
                }
            }
        }
        return true;
    }
    return false;
}
Also used : RedManaAbility(mage.abilities.mana.RedManaAbility) Player(mage.players.Player) GreenManaAbility(mage.abilities.mana.GreenManaAbility) Permanent(mage.game.permanent.Permanent) BlueManaAbility(mage.abilities.mana.BlueManaAbility) BlackManaAbility(mage.abilities.mana.BlackManaAbility) WhiteManaAbility(mage.abilities.mana.WhiteManaAbility)

Aggregations

BlackManaAbility (mage.abilities.mana.BlackManaAbility)1 BlueManaAbility (mage.abilities.mana.BlueManaAbility)1 GreenManaAbility (mage.abilities.mana.GreenManaAbility)1 RedManaAbility (mage.abilities.mana.RedManaAbility)1 WhiteManaAbility (mage.abilities.mana.WhiteManaAbility)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1