mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
* Affinity abilities - added support of other cost modification effects like combo with commander tax (#5856);
* Affinity abilities - added artifact/land count hints to card;
This commit is contained in:
parent
6157187f07
commit
6e5ba7a446
7 changed files with 181 additions and 21 deletions
|
|
@ -0,0 +1,35 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public enum ArtifactsYouControlCount implements DynamicValue {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArtifactsYouControlCount copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "artifacts you control";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package mage.abilities.hint.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.ArtifactsYouControlCount;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public enum ArtifactsYouControlHint implements Hint {
|
||||
|
||||
instance;
|
||||
private static final Hint hint = new ValueHint("Artifacts you control", ArtifactsYouControlCount.instance);
|
||||
|
||||
@Override
|
||||
public String getText(Game game, Ability ability) {
|
||||
return hint.getText(game, ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hint copy() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,19 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.AdjustingSourceCosts;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.common.AffinityEffect;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class AffinityForLandTypeAbility extends SimpleStaticAbility implements AdjustingSourceCosts {
|
||||
public class AffinityForLandTypeAbility extends SimpleStaticAbility {
|
||||
|
||||
private final FilterControlledPermanent filter;
|
||||
|
||||
|
|
@ -26,14 +21,16 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A
|
|||
SubType landType;
|
||||
|
||||
public AffinityForLandTypeAbility(SubType landType, String text) {
|
||||
super(Zone.OUTSIDE, new AffinityEffect(getFilter(landType)));
|
||||
super(Zone.ALL, new AffinityEffect(getFilter(landType)));
|
||||
this.filter = getFilter(landType);
|
||||
setRuleAtTheTop(true);
|
||||
this.text = text;
|
||||
this.landType = landType;
|
||||
|
||||
this.addHint(new ValueHint(landType + " you control", new PermanentsOnBattlefieldCount(filter)));
|
||||
}
|
||||
|
||||
private static FilterControlledPermanent getFilter(SubType landType) {
|
||||
private static FilterControlledPermanent getFilter(SubType landType) {
|
||||
FilterControlledPermanent affinityfilter = new FilterControlledPermanent();
|
||||
affinityfilter.add(new SubtypePredicate(landType));
|
||||
return affinityfilter;
|
||||
|
|
@ -55,14 +52,4 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A
|
|||
public String getRule() {
|
||||
return "Affinity for " + text + " <i>(This spell costs 1 less to cast for each " + landType + " you control.)</i>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
int count = game.getBattlefield().getAllActivePermanents(filter, ability.getControllerId(), game).size();
|
||||
if (count > 0) {
|
||||
CardUtil.adjustCost((SpellAbility)ability, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue