mirror of
https://github.com/correl/mage.git
synced 2025-04-09 01:01:06 -09:00
Fix Bolas's Citadel and add test.
This commit is contained in:
parent
b17bf1ac9f
commit
b0bac1f751
2 changed files with 184 additions and 118 deletions
Mage.Sets/src/mage/cards/b
Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.b;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.Costs;
|
||||
|
@ -90,29 +91,32 @@ class BolassCitadelPlayTheTopCardEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return applies(objectId, null, source, game, affectedControllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {
|
||||
Card cardOnTop = game.getCard(objectId);
|
||||
if (cardOnTop == null) {
|
||||
return false;
|
||||
}
|
||||
if (affectedControllerId.equals(source.getControllerId())
|
||||
if (playerId.equals(source.getControllerId())
|
||||
&& cardOnTop.isOwnedBy(source.getControllerId())) {
|
||||
Player controller = game.getPlayer(cardOnTop.getOwnerId());
|
||||
if (controller != null
|
||||
&& cardOnTop.equals(controller.getLibrary().getFromTop(game))) {
|
||||
if (affectedAbility instanceof ActivatedAbility) {
|
||||
ActivatedAbility activatedAbility = (ActivatedAbility) affectedAbility;
|
||||
// add the life cost first
|
||||
PayLifeCost cost = new PayLifeCost(cardOnTop.getManaCost().convertedManaCost());
|
||||
PayLifeCost cost = new PayLifeCost(activatedAbility.getManaCosts().convertedManaCost());
|
||||
Costs costs = new CostsImpl();
|
||||
costs.add(cost);
|
||||
// check for additional costs that must be paid
|
||||
if (cardOnTop.getSpellAbility() != null) {
|
||||
for (Cost additionalCost : cardOnTop.getSpellAbility().getCosts()) {
|
||||
costs.add(additionalCost);
|
||||
}
|
||||
}
|
||||
controller.setCastSourceIdWithAlternateMana(cardOnTop.getId(), null, costs);
|
||||
costs.addAll(activatedAbility.getCosts());
|
||||
controller.setCastSourceIdWithAlternateMana(activatedAbility.getSourceId(), null, costs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package org.mage.test.cards.cost.alternate;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
public class BolassCitadelTest extends CardTestPlayerBase {
|
||||
@Test
|
||||
public void testCastEagerCadet() {
|
||||
/*
|
||||
* Eager Cadet
|
||||
* Creature — Human Soldier
|
||||
* 1/1
|
||||
*/
|
||||
setStrictChooseMode(true);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Bolas's Citadel");
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
addCard(Zone.LIBRARY, playerA, "Eager Cadet");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Eager Cadet");
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertAllCommandsUsed();
|
||||
assertHandCount(playerA, 0);
|
||||
assertPermanentCount(playerA, "Eager Cadet", 1);
|
||||
assertGraveyardCount(playerA,0);
|
||||
assertLife(playerA, 19);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCastTreatsToShare() {
|
||||
/*
|
||||
* Curious Pair {1}{G}
|
||||
* Creature — Human Peasant
|
||||
* 1/3
|
||||
* ----
|
||||
* Treats to Share {G}
|
||||
* Sorcery — Adventure
|
||||
* Create a Food token.
|
||||
*/
|
||||
setStrictChooseMode(true);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Bolas's Citadel");
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
addCard(Zone.LIBRARY, playerA, "Curious Pair");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertAllCommandsUsed();
|
||||
assertTapped("Forest", false);
|
||||
assertHandCount(playerA, 0);
|
||||
assertPermanentCount(playerA, "Food", 1);
|
||||
assertExileCount(playerA, "Curious Pair", 1);
|
||||
assertGraveyardCount(playerA,0);
|
||||
assertLife(playerA, 19);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue