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;
import mage.ApprovingObject;
import mage.abilities.hint.common.CanPlayAdditionalLandsHint;
import mage.cards.Card;
import mage.constants.AbilityType;
import mage.constants.AsThoughEffectType;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.HashMap;
import java.util.Set;
import java.util.UUID;
@ -21,6 +20,8 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
super(AbilityType.PLAY_LAND, Zone.HAND);
this.usesStack = false;
this.name = "Play " + cardName;
this.addHint(CanPlayAdditionalLandsHint.instance);
}
protected PlayLandAbility(final PlayLandAbility ability) {
@ -62,8 +63,7 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
if (approvingObjects.isEmpty()) {
return ActivationStatus.withoutApprovingObject(true);
}
else {
} else {
return new ActivationStatus(approvingObjects);
}
}
@ -87,5 +87,4 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
public PlayLandAbility copy() {
return new PlayLandAbility(this);
}
}

View file

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

View file

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