mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
- Fixed #6127
This commit is contained in:
parent
0bbacc2a49
commit
5ed5bce718
1 changed files with 26 additions and 10 deletions
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.abilities.effects.keyword;
|
package mage.abilities.effects.keyword;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -21,19 +20,26 @@ import mage.players.Player;
|
||||||
*/
|
*/
|
||||||
public class ExploreSourceEffect extends OneShotEffect {
|
public class ExploreSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
// "it explores. <i>(Reveal the top card of your library. Put that card into your hand if it's a land. Otherwise, put a +1/+1 counter on this creature, then put the card back or put it into your graveyard.)</i>";
|
// "it explores. <i>(Reveal the top card of your library. Put that card into
|
||||||
|
// your hand if it's a land. Otherwise, put a +1/+1 counter on this creature,
|
||||||
|
// then put the card back or put it into your graveyard.)</i>";
|
||||||
private static final String RULE_TEXT_START = "explores.";
|
private static final String RULE_TEXT_START = "explores.";
|
||||||
private static final String RULE_TEXT_HINT = "<i>(Reveal the top card of your library. Put that card into your hand if it's a land. Otherwise, put a +1/+1 counter on this creature, then put the card back or put it into your graveyard.)</i>";
|
private static final String RULE_TEXT_HINT = "<i>(Reveal the top card of your library. "
|
||||||
|
+ "Put that card into your hand if it's a land. Otherwise, put a +1/+1 counter on "
|
||||||
|
+ "this creature, then put the card back or put it into your graveyard.)</i>";
|
||||||
|
|
||||||
public static String getRuleText(boolean showAbilityHint) {
|
public static String getRuleText(boolean showAbilityHint) {
|
||||||
return getRuleText(showAbilityHint, null);
|
return getRuleText(showAbilityHint, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRuleText(boolean showAbilityHint, String whosExplores) {
|
public static String getRuleText(boolean showAbilityHint, String whosExplores) {
|
||||||
|
|
||||||
String res = whosExplores;
|
String res = whosExplores;
|
||||||
if(res == null){ res = "it"; }
|
if (res == null) {
|
||||||
|
res = "it";
|
||||||
|
}
|
||||||
|
|
||||||
res += " " + RULE_TEXT_START;
|
res += " " + RULE_TEXT_START;
|
||||||
|
|
||||||
if (showAbilityHint) {
|
if (showAbilityHint) {
|
||||||
res += " " + RULE_TEXT_HINT;
|
res += " " + RULE_TEXT_HINT;
|
||||||
|
@ -55,7 +61,7 @@ public class ExploreSourceEffect extends OneShotEffect {
|
||||||
public ExploreSourceEffect(boolean showAbilityHint, String whosExplores) {
|
public ExploreSourceEffect(boolean showAbilityHint, String whosExplores) {
|
||||||
super(Outcome.Benefit);
|
super(Outcome.Benefit);
|
||||||
|
|
||||||
if(whosExplores != null) {
|
if (whosExplores != null) {
|
||||||
this.sourceName = whosExplores;
|
this.sourceName = whosExplores;
|
||||||
}
|
}
|
||||||
setText();
|
setText();
|
||||||
|
@ -68,7 +74,7 @@ public class ExploreSourceEffect extends OneShotEffect {
|
||||||
setText();
|
setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setText(){
|
private void setText() {
|
||||||
this.staticText = getRuleText(this.showAbilityHint, this.sourceName);
|
this.staticText = getRuleText(this.showAbilityHint, this.sourceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +89,7 @@ public class ExploreSourceEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean explorePermanent(Game game, UUID permanentId, Ability source) {
|
public static boolean explorePermanent(Game game, UUID permanentId, Ability source) {
|
||||||
|
Boolean cardWasRevealed = false;
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId);
|
Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId);
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -91,18 +98,21 @@ public class ExploreSourceEffect extends OneShotEffect {
|
||||||
if (permanentController == null) {
|
if (permanentController == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EXPLORED, permanentId, source.getSourceId(), permanent.getControllerId()));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EXPLORED, permanentId,
|
||||||
|
source.getSourceId(), permanent.getControllerId()));
|
||||||
if (permanentController.getLibrary().hasCards()) {
|
if (permanentController.getLibrary().hasCards()) {
|
||||||
Card card = permanentController.getLibrary().getFromTop(game);
|
Card card = permanentController.getLibrary().getFromTop(game);
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
permanentController.revealCards("Explored card", cards, game);
|
permanentController.revealCards("Explored card", cards, game);
|
||||||
|
cardWasRevealed = true;
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
if (card.isLand()) {
|
if (card.isLand()) {
|
||||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
||||||
} else {
|
} else {
|
||||||
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
if (game.getState().getZone(permanentId) == Zone.BATTLEFIELD) { // needed in case LKI object is used
|
||||||
|
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
||||||
|
}
|
||||||
if (permanentController.chooseUse(Outcome.Neutral, "Put " + card.getLogName() + " in your graveyard?", source, game)) {
|
if (permanentController.chooseUse(Outcome.Neutral, "Put " + card.getLogName() + " in your graveyard?", source, game)) {
|
||||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
|
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
|
||||||
game.informPlayers(permanentController.getLogName() + " puts " + card.getLogName() + " into their graveyard.");
|
game.informPlayers(permanentController.getLogName() + " puts " + card.getLogName() + " into their graveyard.");
|
||||||
|
@ -112,6 +122,12 @@ public class ExploreSourceEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!cardWasRevealed
|
||||||
|
&& game.getState().getZone(permanentId) == Zone.BATTLEFIELD) {
|
||||||
|
// If no card is revealed, most likely because that player's library is empty,
|
||||||
|
// the exploring creature receives a +1/+1 counter.
|
||||||
|
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue