mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
refactor: improved Aladdin's Lamp
This commit is contained in:
parent
36cec8961e
commit
6cf1f4af3d
3 changed files with 48 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ package mage.cards.a;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
import mage.abilities.costs.CostAdjuster;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
|
|
@ -35,8 +36,8 @@ public final class AladdinsLamp extends CardImpl {
|
||||||
// {X}, {T}: The next time you would draw a card this turn, instead look at the top X cards of your library, put all but one of them on the bottom of your library in a random order, then draw a card. X can't be 0.
|
// {X}, {T}: The next time you would draw a card this turn, instead look at the top X cards of your library, put all but one of them on the bottom of your library in a random order, then draw a card. X can't be 0.
|
||||||
Ability ability = new SimpleActivatedAbility(new AladdinsLampEffect(), new ManaCostsImpl<>("{X}"));
|
Ability ability = new SimpleActivatedAbility(new AladdinsLampEffect(), new ManaCostsImpl<>("{X}"));
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
ability.setVariableCostsMinMax(1, Integer.MAX_VALUE);
|
ability.setCostAdjuster(AladdinsLampCostAdjuster.instance);
|
||||||
// TODO: add costAdjuster for min/max values due library size
|
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,3 +97,17 @@ class AladdinsLampEffect extends ReplacementEffectImpl {
|
||||||
return source.isControlledBy(event.getPlayerId());
|
return source.isControlledBy(event.getPlayerId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum AladdinsLampCostAdjuster implements CostAdjuster {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareX(Ability ability, Game game) {
|
||||||
|
Player controller = game.getPlayer(ability.getControllerId());
|
||||||
|
if (controller == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ability.setVariableCostsMinMax(1, Math.max(1, controller.getLibrary().size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.cards.a;
|
package mage.cards.a;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -26,7 +25,7 @@ public final class Archivist extends CardImpl {
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
//{T}: Draw a card.
|
// {T}: Draw a card.
|
||||||
this.addAbility(new SimpleActivatedAbility(new DrawCardSourceControllerEffect(1), new TapSourceCost()));
|
this.addAbility(new SimpleActivatedAbility(new DrawCardSourceControllerEffect(1), new TapSourceCost()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -467,6 +467,36 @@ public class AdjusterCostTest extends CardTestPlayerBaseWithAIHelps {
|
||||||
assertLife(playerB, 20 - 3);
|
assertLife(playerB, 20 - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_prepareX_AladdinsLamp() {
|
||||||
|
skipInitShuffling();
|
||||||
|
|
||||||
|
// {X}, {T}: The next time you would draw a card this turn, instead look at the top X cards of your library,
|
||||||
|
// put all but one of them on the bottom of your library in a random order, then draw a card. X can't be 0.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Aladdin's Lamp");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
|
||||||
|
// {T}: Draw a card.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Archivist");
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Island", 1);
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Grizzly Bears", 1);
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Island", 3);
|
||||||
|
|
||||||
|
// prepare effect
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{X}, {T}: The next time");
|
||||||
|
setChoice(playerA, "X=5");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
|
||||||
|
// improved draw
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw");
|
||||||
|
setChoice(playerA, "Grizzly Bears"); // keep on top and draw
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertHandCount(playerA, "Grizzly Bears", 1);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_modifyCost_Fireball() {
|
public void test_modifyCost_Fireball() {
|
||||||
// This spell costs {1} more to cast for each target beyond the first.
|
// This spell costs {1} more to cast for each target beyond the first.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue