mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
updated cost adjustment for Mobilized District, added test
This commit is contained in:
parent
4daaaddbb0
commit
439303882c
2 changed files with 85 additions and 51 deletions
|
@ -3,12 +3,12 @@ package mage.cards.m;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.CostAdjuster;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.abilities.mana.ColorlessManaAbility;
|
||||
|
@ -29,15 +29,6 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class MobilizedDistrict extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent();
|
||||
|
||||
static {
|
||||
filter.add(SuperType.LEGENDARY.getPredicate());
|
||||
filter.add(TargetController.YOU.getControllerPredicate());
|
||||
}
|
||||
|
||||
static final DynamicValue cardsCount = new PermanentsOnBattlefieldCount(filter);
|
||||
|
||||
public MobilizedDistrict(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||
|
||||
|
@ -45,17 +36,14 @@ public final class MobilizedDistrict extends CardImpl {
|
|||
this.addAbility(new ColorlessManaAbility());
|
||||
|
||||
// {4}: Mobilized District becomes a 3/3 Citizen creature with vigilance until end of turn. It's still a land. This ability costs {1} less to activate for each legendary creature and planeswalker you control.
|
||||
// TODO: Make ability properly copiable
|
||||
Ability ability = new SimpleActivatedAbility(new BecomesCreatureSourceEffect(
|
||||
new MobilizedDistrictToken(), "land", Duration.EndOfTurn
|
||||
).setText("{this} becomes a 3/3 Citizen creature with vigilance until end of turn. " +
|
||||
"It's still a land. This ability costs {1} less to activate " +
|
||||
"for each legendary creature and planeswalker you control."
|
||||
), new GenericManaCost(4));
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new SimpleStaticAbility(
|
||||
Zone.ALL, new MobilizedDistrictCostIncreasingEffect(ability.getOriginalId())
|
||||
).addHint(new ValueHint("Legendary creatures and planeswalkers you control", cardsCount)));
|
||||
ability.setCostAdjuster(MobilizedDistrictAdjuster.instance);
|
||||
this.addAbility(ability.addHint(MobilizedDistrictAdjuster.getHint()));
|
||||
}
|
||||
|
||||
private MobilizedDistrict(final MobilizedDistrict card) {
|
||||
|
@ -68,6 +56,33 @@ public final class MobilizedDistrict extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
enum MobilizedDistrictAdjuster implements CostAdjuster {
|
||||
instance;
|
||||
|
||||
private static final FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent();
|
||||
|
||||
static {
|
||||
filter.add(SuperType.LEGENDARY.getPredicate());
|
||||
filter.add(TargetController.YOU.getControllerPredicate());
|
||||
}
|
||||
|
||||
static final DynamicValue cardsCount = new PermanentsOnBattlefieldCount(filter);
|
||||
private static final Hint hint = new ValueHint("Legendary creatures and planeswalkers you control", cardsCount);
|
||||
|
||||
public static Hint getHint() {
|
||||
return hint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
Player controller = game.getPlayer(ability.getControllerId());
|
||||
if (controller != null) {
|
||||
int count = cardsCount.calculate(game, ability, null);
|
||||
CardUtil.reduceCost(ability, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MobilizedDistrictToken extends TokenImpl {
|
||||
|
||||
MobilizedDistrictToken() {
|
||||
|
@ -87,38 +102,3 @@ class MobilizedDistrictToken extends TokenImpl {
|
|||
return new MobilizedDistrictToken(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MobilizedDistrictCostIncreasingEffect extends CostModificationEffectImpl {
|
||||
|
||||
private final UUID originalId;
|
||||
|
||||
MobilizedDistrictCostIncreasingEffect(UUID originalId) {
|
||||
super(Duration.EndOfGame, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
private MobilizedDistrictCostIncreasingEffect(final MobilizedDistrictCostIncreasingEffect effect) {
|
||||
super(effect);
|
||||
this.originalId = effect.originalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int count = MobilizedDistrict.cardsCount.calculate(game, source, this);
|
||||
CardUtil.reduceCost(abilityToModify, count);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify.getOriginalId().equals(originalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobilizedDistrictCostIncreasingEffect copy() {
|
||||
return new MobilizedDistrictCostIncreasingEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package org.mage.test.cards.single.war;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author TheELk801
|
||||
*/
|
||||
public class MobilizedDistrictTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testActivate() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mobilized District");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Isamaru, Hound of Konda");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{4}");
|
||||
|
||||
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertPowerToughness(playerA, "Mobilized District", 3, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActivate2() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mobilized District");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Isamaru, Hound of Konda");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Rhys the Redeemed");
|
||||
addCard(Zone.HAND, playerA, "Wrath of God");
|
||||
|
||||
// Activating costs {2}, have enough to activate exactly twice
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{4}");
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{4}");
|
||||
|
||||
// Remove legends
|
||||
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Wrath of God");
|
||||
|
||||
// Activating costs {4} now
|
||||
activateAbility(5, PhaseStep.PRECOMBAT_MAIN, playerA, "{4}");
|
||||
|
||||
setStopAt(5, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertPowerToughness(playerA, "Mobilized District", 3, 3);
|
||||
assertTappedCount("Mobilized District", true, 1);
|
||||
assertTappedCount("Plains", true, 3);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue