use of mage.abilities.mana.BlueManaAbility 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;
}
Aggregations