mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
rework MayhemLandAbility to work properly
This commit is contained in:
parent
37ade28c31
commit
d98d59cc55
3 changed files with 92 additions and 32 deletions
|
|
@ -20,7 +20,7 @@ import java.util.UUID;
|
|||
public final class OscorpIndustries extends CardImpl {
|
||||
|
||||
public OscorpIndustries(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, null);
|
||||
|
||||
|
||||
// This land enters tapped.
|
||||
|
|
@ -35,7 +35,7 @@ public final class OscorpIndustries extends CardImpl {
|
|||
this.addAbility(new RedManaAbility());
|
||||
|
||||
// Mayhem
|
||||
this.addAbility(new MayhemLandAbility(this));
|
||||
this.addAbility(new MayhemLandAbility());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class OscorpIndustriesTest extends CardTestPlayerBase {
|
|||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw");
|
||||
setChoice(playerA, oscorpIndustries);
|
||||
|
||||
playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, oscorpIndustries + " with Mayhem");
|
||||
playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, oscorpIndustries);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
|
@ -49,4 +49,56 @@ public class OscorpIndustriesTest extends CardTestPlayerBase {
|
|||
assertLife(playerA, 20 - 2);
|
||||
assertPermanentCount(playerA, oscorpIndustries, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOscorpIndustriesNoMayhem() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.HAND, playerA, oscorpIndustries);
|
||||
addCard(Zone.BATTLEFIELD, playerA, thoughtCourier);
|
||||
|
||||
playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, oscorpIndustries);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertPermanentCount(playerA, oscorpIndustries, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCantPlayWithoutDiscard() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.GRAVEYARD, playerA, oscorpIndustries);
|
||||
|
||||
checkPlayableAbility("Can't play without discard", 1, PhaseStep.PRECOMBAT_MAIN, playerA,
|
||||
"Play " + oscorpIndustries, false);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertPermanentCount(playerA, oscorpIndustries, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOscorpIndustriesNextTurn() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.HAND, playerA, oscorpIndustries);
|
||||
addCard(Zone.BATTLEFIELD, playerA, thoughtCourier);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw");
|
||||
setChoice(playerA, oscorpIndustries);
|
||||
|
||||
checkPlayableAbility("Can't play without discard", 3, PhaseStep.PRECOMBAT_MAIN, playerA,
|
||||
"Play " + oscorpIndustries, false);
|
||||
|
||||
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertPermanentCount(playerA, oscorpIndustries, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,22 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageIdentifier;
|
||||
import mage.abilities.PlayLandAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.effects.AsThoughEffect;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MayhemLandAbility extends PlayLandAbility {
|
||||
public class MayhemLandAbility extends StaticAbility {
|
||||
|
||||
private final String rule;
|
||||
|
||||
public MayhemLandAbility(Card card) {
|
||||
super(card.getName());
|
||||
this.zone = Zone.GRAVEYARD;
|
||||
public MayhemLandAbility() {
|
||||
super(AbilityType.STATIC, Zone.GRAVEYARD);
|
||||
this.newId();
|
||||
this.name += " with Mayhem";
|
||||
this.addEffect(new MayhemPlayEffect());
|
||||
this.addWatcher(new MayhemWatcher());
|
||||
this.setRuleAtTheTop(true);
|
||||
this.rule = "Mayhem " +
|
||||
|
|
@ -30,24 +29,6 @@ public class MayhemLandAbility extends PlayLandAbility {
|
|||
this.rule = ability.rule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
if (!Zone.GRAVEYARD.match(game.getState().getZone(getSourceId()))
|
||||
|| !MayhemWatcher.checkCard(getSourceId(), game)) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
return super.canActivate(playerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(Game game, Set<MageIdentifier> allowedIdentifiers, boolean noMana) {
|
||||
if (!super.activate(game, allowedIdentifiers, noMana)) {
|
||||
return false;
|
||||
}
|
||||
this.setCostsTag(MayhemAbility.MAYHEM_ACTIVATION_VALUE_KEY, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MayhemLandAbility copy() {
|
||||
return new MayhemLandAbility(this);
|
||||
|
|
@ -58,3 +39,30 @@ public class MayhemLandAbility extends PlayLandAbility {
|
|||
return rule;
|
||||
}
|
||||
}
|
||||
|
||||
class MayhemPlayEffect extends AsThoughEffectImpl {
|
||||
|
||||
public MayhemPlayEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileInGraveyard, Outcome.Neutral);
|
||||
}
|
||||
|
||||
public MayhemPlayEffect(final MayhemPlayEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return Zone.GRAVEYARD.match(game.getState().getZone(sourceId))
|
||||
&& MayhemWatcher.checkCard(sourceId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsThoughEffect copy() {
|
||||
return new MayhemPlayEffect(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue