mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Fixed that sacrifice was handled targeted (because of using other method now with sourceId and controllerId).
This commit is contained in:
parent
7af34eb8b1
commit
e22174b148
3 changed files with 28 additions and 15 deletions
|
@ -82,25 +82,30 @@ class MomentousFallEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
|
||||
int power = 0;
|
||||
int toughness = 0;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
||||
for (Cost cost: source.getCosts()) {
|
||||
if (cost instanceof SacrificeTargetCost && ((SacrificeTargetCost)cost).getPermanents().size() > 0) {
|
||||
power = ((SacrificeTargetCost)cost).getPermanents().get(0).getPower().getValue();
|
||||
toughness = ((SacrificeTargetCost)cost).getPermanents().get(0).getToughness().getValue();
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (cost instanceof SacrificeTargetCost && ((SacrificeTargetCost) cost).getPermanents().size() > 0) {
|
||||
power = ((SacrificeTargetCost) cost).getPermanents().get(0).getPower().getValue();
|
||||
toughness = ((SacrificeTargetCost) cost).getPermanents().get(0).getToughness().getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (power > 0) {
|
||||
player.drawCards(power, game);
|
||||
controller.drawCards(power, game);
|
||||
}
|
||||
if (toughness > 0) {
|
||||
player.gainLife(toughness, game);
|
||||
controller.gainLife(toughness, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MomentousFallEffect copy() {
|
||||
|
|
|
@ -11,6 +11,13 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
*/
|
||||
public class MomentousFallTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Momentous Fall
|
||||
* Instant {2}{G}{G}
|
||||
* As an additional cost to cast Momentous Fall, sacrifice a creature.
|
||||
* You draw cards equal to the sacrificed creature's power, then you
|
||||
* gain life equal to its toughness.
|
||||
*/
|
||||
@Test
|
||||
public void testSacrificeCostAndLKI() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
|
||||
|
|
|
@ -48,6 +48,7 @@ public class SacrificeTargetCost extends CostImpl {
|
|||
|
||||
public SacrificeTargetCost(TargetControlledPermanent target) {
|
||||
this.addTarget(target);
|
||||
target.setNotTarget(true); // sacrifice is never targeted
|
||||
this.text = "Sacrifice " + target.getTargetName();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue