You may play an additional land - added card hint to all lands about played count and max limit (#13216)

This commit is contained in:
Oleg Agafonov 2025-01-10 22:04:21 +04:00
parent 0505f5159e
commit a5c354f960
4 changed files with 60 additions and 24 deletions

View file

@ -1,14 +1,13 @@
package mage.abilities; package mage.abilities;
import mage.ApprovingObject; import mage.ApprovingObject;
import mage.abilities.hint.common.CanPlayAdditionalLandsHint;
import mage.cards.Card; import mage.cards.Card;
import mage.constants.AbilityType; import mage.constants.AbilityType;
import mage.constants.AsThoughEffectType; import mage.constants.AsThoughEffectType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
import java.util.HashMap;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -21,6 +20,8 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
super(AbilityType.PLAY_LAND, Zone.HAND); super(AbilityType.PLAY_LAND, Zone.HAND);
this.usesStack = false; this.usesStack = false;
this.name = "Play " + cardName; this.name = "Play " + cardName;
this.addHint(CanPlayAdditionalLandsHint.instance);
} }
protected PlayLandAbility(final PlayLandAbility ability) { protected PlayLandAbility(final PlayLandAbility ability) {
@ -43,7 +44,7 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
} }
//20091005 - 114.2a //20091005 - 114.2a
if(!game.isActivePlayer(playerId) if (!game.isActivePlayer(playerId)
|| !game.getPlayer(playerId).canPlayLand() || !game.getPlayer(playerId).canPlayLand()
|| !game.canPlaySorcery(playerId)) { || !game.canPlaySorcery(playerId)) {
return ActivationStatus.getFalse(); return ActivationStatus.getFalse();
@ -54,16 +55,15 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
if (!approvingObjects.isEmpty()) { if (!approvingObjects.isEmpty()) {
Card card = game.getCard(sourceId); Card card = game.getCard(sourceId);
Zone zone = game.getState().getZone(sourceId); Zone zone = game.getState().getZone(sourceId);
if(card != null && card.isOwnedBy(playerId) && Zone.HAND.match(zone)) { if (card != null && card.isOwnedBy(playerId) && Zone.HAND.match(zone)) {
// Regular casting, to be an alternative to the AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE from hand (e.g. One with the Multiverse): // Regular casting, to be an alternative to the AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE from hand (e.g. One with the Multiverse):
approvingObjects.add(new ApprovingObject(this, game)); approvingObjects.add(new ApprovingObject(this, game));
} }
} }
if(approvingObjects.isEmpty()) { if (approvingObjects.isEmpty()) {
return ActivationStatus.withoutApprovingObject(true); return ActivationStatus.withoutApprovingObject(true);
} } else {
else {
return new ActivationStatus(approvingObjects); return new ActivationStatus(approvingObjects);
} }
} }
@ -87,5 +87,4 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
public PlayLandAbility copy() { public PlayLandAbility copy() {
return new PlayLandAbility(this); return new PlayLandAbility(this);
} }
} }

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -9,6 +8,7 @@ import mage.constants.Outcome;
import mage.constants.SubLayer; import mage.constants.SubLayer;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
/** /**
* Each player may play an additional land on each of their turns. * Each player may play an additional land on each of their turns.
@ -49,14 +49,10 @@ public class PlayAdditionalLandsAllEffect extends ContinuousEffectImpl {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId()); Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) { if (player == null) {
if (numExtraLands == Integer.MAX_VALUE) { return false;
player.setLandsPerTurn(Integer.MAX_VALUE);
} else {
player.setLandsPerTurn(player.getLandsPerTurn() + numExtraLands);
}
return true;
} }
player.setLandsPerTurn(CardUtil.overflowInc(player.getLandsPerTurn(), numExtraLands));
return true; return true;
} }
} }

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -37,14 +36,11 @@ public class PlayAdditionalLandsControllerEffect extends ContinuousEffectImpl {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player == null) {
if (player.getLandsPerTurn() == Integer.MAX_VALUE || this.additionalCards == Integer.MAX_VALUE) { return false;
player.setLandsPerTurn(Integer.MAX_VALUE);
} else {
player.setLandsPerTurn(player.getLandsPerTurn() + this.additionalCards);
}
return true;
} }
player.setLandsPerTurn(CardUtil.overflowInc(player.getLandsPerTurn(), additionalCards));
return true; return true;
} }

View file

@ -0,0 +1,45 @@
package mage.abilities.hint.common;
import mage.abilities.Ability;
import mage.abilities.hint.Hint;
import mage.abilities.hint.HintUtils;
import mage.game.Game;
import mage.players.Player;
/**
* Global hint for all lands
*
* @author JayDi85
*/
public enum CanPlayAdditionalLandsHint implements Hint {
instance;
@Override
public String getText(Game game, Ability ability) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller == null) {
return "";
}
// hide hint on default 1 land settings (useless to show)
if (controller.getLandsPerTurn() == 1) {
return "";
}
String stats = String.format(" (played %d of %s)",
controller.getLandsPlayed(),
(controller.getLandsPerTurn() == Integer.MAX_VALUE ? "any" : String.valueOf(controller.getLandsPerTurn()))
);
if (controller.canPlayLand()) {
return HintUtils.prepareText("Can play more lands" + stats, null, HintUtils.HINT_ICON_GOOD);
} else {
return HintUtils.prepareText("Can't play lands" + stats, null, HintUtils.HINT_ICON_BAD);
}
}
@Override
public Hint copy() {
return instance;
}
}