mirror of
https://github.com/correl/mage.git
synced 2025-03-17 01:06:26 -09: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,24 +82,29 @@ class MomentousFallEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int power = 0;
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
int toughness = 0;
|
if (controller != null) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
|
||||||
|
|
||||||
for (Cost cost: source.getCosts()) {
|
int power = 0;
|
||||||
if (cost instanceof SacrificeTargetCost && ((SacrificeTargetCost)cost).getPermanents().size() > 0) {
|
int toughness = 0;
|
||||||
power = ((SacrificeTargetCost)cost).getPermanents().get(0).getPower().getValue();
|
|
||||||
toughness = ((SacrificeTargetCost)cost).getPermanents().get(0).getToughness().getValue();
|
for (Cost cost : source.getCosts()) {
|
||||||
break;
|
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) {
|
||||||
|
controller.drawCards(power, game);
|
||||||
|
}
|
||||||
|
if (toughness > 0) {
|
||||||
|
controller.gainLife(toughness, game);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (power > 0) {
|
return false;
|
||||||
player.drawCards(power, game);
|
|
||||||
}
|
|
||||||
if (toughness > 0) {
|
|
||||||
player.gainLife(toughness, game);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,6 +11,13 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
*/
|
*/
|
||||||
public class MomentousFallTest extends 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
|
@Test
|
||||||
public void testSacrificeCostAndLKI() {
|
public void testSacrificeCostAndLKI() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class SacrificeTargetCost extends CostImpl {
|
||||||
|
|
||||||
public SacrificeTargetCost(TargetControlledPermanent target) {
|
public SacrificeTargetCost(TargetControlledPermanent target) {
|
||||||
this.addTarget(target);
|
this.addTarget(target);
|
||||||
|
target.setNotTarget(true); // sacrifice is never targeted
|
||||||
this.text = "Sacrifice " + target.getTargetName();
|
this.text = "Sacrifice " + target.getTargetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue