mirror of
https://github.com/correl/mage.git
synced 2025-01-13 11:01:58 +00:00
- Fixed #6292
This commit is contained in:
parent
3047a8bd76
commit
39ea0ec65d
1 changed files with 48 additions and 43 deletions
|
@ -1,6 +1,5 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.mana.*;
|
||||
|
@ -9,8 +8,6 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
|
@ -19,6 +16,11 @@ public class BecomesAllBasicsControlledEffect extends ContinuousEffectImpl {
|
|||
public BecomesAllBasicsControlledEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||
this.staticText = "Lands you control are every basic land type in addition to their other types";
|
||||
dependencyTypes.add(DependencyType.BecomeMountain);
|
||||
dependencyTypes.add(DependencyType.BecomeForest);
|
||||
dependencyTypes.add(DependencyType.BecomeSwamp);
|
||||
dependencyTypes.add(DependencyType.BecomeIsland);
|
||||
dependencyTypes.add(DependencyType.BecomePlains);
|
||||
}
|
||||
|
||||
private BecomesAllBasicsControlledEffect(final BecomesAllBasicsControlledEffect effect) {
|
||||
|
@ -37,50 +39,53 @@ public class BecomesAllBasicsControlledEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
game.getState()
|
||||
.getBattlefield()
|
||||
.getAllActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), game)
|
||||
.stream()
|
||||
.forEach(land -> this.modifyLand(land, layer, source, game));
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, source.getControllerId(), game)) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (!permanent.hasSubtype(SubType.SWAMP, game)) {
|
||||
permanent.getSubtype(game).add(SubType.SWAMP);
|
||||
}
|
||||
if (!permanent.hasSubtype(SubType.MOUNTAIN, game)) {
|
||||
permanent.getSubtype(game).add(SubType.MOUNTAIN);
|
||||
}
|
||||
if (!permanent.hasSubtype(SubType.FOREST, game)) {
|
||||
permanent.getSubtype(game).add(SubType.FOREST);
|
||||
}
|
||||
if (!permanent.hasSubtype(SubType.ISLAND, game)) {
|
||||
permanent.getSubtype(game).add(SubType.ISLAND);
|
||||
}
|
||||
if (!permanent.hasSubtype(SubType.PLAINS, game)) {
|
||||
permanent.getSubtype(game).add(SubType.PLAINS);
|
||||
}
|
||||
if (permanent.hasSubtype(SubType.SWAMP, game)
|
||||
&& !permanent.getAbilities().containsRule(new BlackManaAbility())) {
|
||||
permanent.addAbility(new BlackManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (permanent.hasSubtype(SubType.MOUNTAIN, game)
|
||||
&& !permanent.getAbilities().containsRule(new RedManaAbility())) {
|
||||
permanent.addAbility(new RedManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (permanent.hasSubtype(SubType.FOREST, game)
|
||||
&& !permanent.getAbilities().containsRule(new GreenManaAbility())) {
|
||||
permanent.addAbility(new GreenManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (permanent.hasSubtype(SubType.ISLAND, game)
|
||||
&& !permanent.getAbilities().containsRule(new BlueManaAbility())) {
|
||||
permanent.addAbility(new BlueManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (permanent.hasSubtype(SubType.PLAINS, game)
|
||||
&& !permanent.getAbilities().containsRule(new WhiteManaAbility())) {
|
||||
permanent.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void modifyLand(Permanent land, Layer layer, Ability source, Game game) {
|
||||
if (layer == Layer.AbilityAddingRemovingEffects_6) {
|
||||
Mana mana = new Mana();
|
||||
land.getAbilities()
|
||||
.stream()
|
||||
.filter(BasicManaAbility.class::isInstance)
|
||||
.map(BasicManaAbility.class::cast)
|
||||
.map(basicManaAbility -> basicManaAbility.getNetMana(game))
|
||||
.flatMap(Collection::stream)
|
||||
.forEach(mana::add);
|
||||
if (mana.getGreen() == 0) {
|
||||
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (mana.getRed() == 0) {
|
||||
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (mana.getBlue() == 0) {
|
||||
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (mana.getWhite() == 0) {
|
||||
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
if (mana.getBlack() == 0) {
|
||||
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
if (layer == Layer.TypeChangingEffects_4) {
|
||||
SubType.getBasicLands()
|
||||
.stream()
|
||||
.filter(subType -> !land.hasSubtype(subType, game))
|
||||
.forEach(land.getSubtype(game)::add);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4;
|
||||
return layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue