mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
parent
04b5660d17
commit
0b6a2b2546
21 changed files with 505 additions and 407 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package mage.abilities.effects.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
|
@ -8,37 +10,45 @@ import mage.players.Player;
|
|||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, Susucr
|
||||
*/
|
||||
public class ScryEffect extends OneShotEffect {
|
||||
|
||||
protected final int scryNumber;
|
||||
protected DynamicValue amount;
|
||||
protected final boolean showEffectHint;
|
||||
|
||||
public ScryEffect(int scryNumber) {
|
||||
this(scryNumber, true);
|
||||
}
|
||||
|
||||
public ScryEffect(DynamicValue amount) {
|
||||
this(amount, false);
|
||||
}
|
||||
|
||||
public ScryEffect(int scryNumber, boolean showEffectHint) {
|
||||
this(StaticValue.get(scryNumber), showEffectHint);
|
||||
}
|
||||
|
||||
public ScryEffect(DynamicValue amount, boolean showEffectHint) {
|
||||
super(Outcome.Benefit);
|
||||
this.scryNumber = scryNumber;
|
||||
this.amount = amount.copy();
|
||||
this.showEffectHint = showEffectHint;
|
||||
this.setText();
|
||||
this.staticText = generateText();
|
||||
}
|
||||
|
||||
protected ScryEffect(final ScryEffect effect) {
|
||||
super(effect);
|
||||
this.scryNumber = effect.scryNumber;
|
||||
this.amount = effect.amount.copy();
|
||||
this.showEffectHint = effect.showEffectHint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
return player.scry(scryNumber, source, game);
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return player.scry(this.amount.calculate(game, source, this), source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -46,19 +56,24 @@ public class ScryEffect extends OneShotEffect {
|
|||
return new ScryEffect(this);
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("scry ").append(scryNumber);
|
||||
if (!showEffectHint) {
|
||||
staticText = sb.toString();
|
||||
return;
|
||||
private String generateText() {
|
||||
StringBuilder sb = new StringBuilder("scry ");
|
||||
String value = amount.toString();
|
||||
sb.append(CardUtil.numberToText(value));
|
||||
String message = amount.getMessage();
|
||||
if (!message.isEmpty()) {
|
||||
sb.append(value.equals("X") ? ", where X is " : " for each ");
|
||||
sb.append(message);
|
||||
}
|
||||
if (scryNumber == 1) {
|
||||
sb.append(". <i>(Look at the top card of your library. You may put that card on the bottom.)</i>");
|
||||
} else {
|
||||
sb.append(". <i>(Look at the top ");
|
||||
sb.append(CardUtil.numberToText(scryNumber));
|
||||
sb.append(" cards of your library, then put any number of them on the bottom and the rest on top in any order.)</i>");
|
||||
if (showEffectHint) {
|
||||
if (value == "1") {
|
||||
sb.append(". <i>(Look at the top card of your library. You may put that card on the bottom.)</i>");
|
||||
} else {
|
||||
sb.append(". <i>(Look at the top ");
|
||||
sb.append(CardUtil.numberToText(value));
|
||||
sb.append(" cards of your library, then put any number of them on the bottom and the rest on top in any order.)</i>");
|
||||
}
|
||||
}
|
||||
staticText = sb.toString();
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue