mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
[AFC] Implemented Diviner's Portent
This commit is contained in:
parent
f991e0e89a
commit
aa06893f4d
3 changed files with 96 additions and 4 deletions
77
Mage.Sets/src/mage/cards/d/DivinersPortent.java
Normal file
77
Mage.Sets/src/mage/cards/d/DivinersPortent.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.CardsInControllerHandCount;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.RollDieWithResultTableEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class DivinersPortent extends CardImpl {
|
||||
|
||||
public DivinersPortent(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}{U}{U}");
|
||||
|
||||
// Roll a d20 and add the number of cards in your hand.
|
||||
RollDieWithResultTableEffect effect = new RollDieWithResultTableEffect(
|
||||
20, "roll a d20 and add the number " +
|
||||
"of cards in your hand", CardsInControllerHandCount.instance
|
||||
);
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
|
||||
// 1-14 | Draw X cards.
|
||||
effect.addTableEntry(1, 14, new DrawCardSourceControllerEffect(ManacostVariableValue.REGULAR));
|
||||
|
||||
// 15+ | Scry X, then draw X cards.
|
||||
effect.addTableEntry(15, Integer.MAX_VALUE, new DivinersPortentEffect());
|
||||
}
|
||||
|
||||
private DivinersPortent(final DivinersPortent card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DivinersPortent copy() {
|
||||
return new DivinersPortent(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DivinersPortentEffect extends OneShotEffect {
|
||||
|
||||
DivinersPortentEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "scry X, then draw X cards";
|
||||
}
|
||||
|
||||
private DivinersPortentEffect(final DivinersPortentEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DivinersPortentEffect copy() {
|
||||
return new DivinersPortentEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
int xValue = source.getManaCostsToPay().getX();
|
||||
if (player == null || xValue < 1) {
|
||||
return false;
|
||||
}
|
||||
player.scry(xValue, source, game);
|
||||
player.drawCards(xValue, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -76,6 +76,7 @@ public final class ForgottenRealmsCommander extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Dimir Aqueduct", 234, Rarity.UNCOMMON, mage.cards.d.DimirAqueduct.class));
|
||||
cards.add(new SetCardInfo("Dire Fleet Daredevil", 121, Rarity.RARE, mage.cards.d.DireFleetDaredevil.class));
|
||||
cards.add(new SetCardInfo("Disrupt Decorum", 122, Rarity.RARE, mage.cards.d.DisruptDecorum.class));
|
||||
cards.add(new SetCardInfo("Diviner's Portent", 15, Rarity.RARE, mage.cards.d.DivinersPortent.class));
|
||||
cards.add(new SetCardInfo("Doomed Necromancer", 98, Rarity.RARE, mage.cards.d.DoomedNecromancer.class));
|
||||
cards.add(new SetCardInfo("Dragon's Hoard", 204, Rarity.RARE, mage.cards.d.DragonsHoard.class));
|
||||
cards.add(new SetCardInfo("Dragonlord's Servant", 123, Rarity.UNCOMMON, mage.cards.d.DragonlordsServant.class));
|
||||
|
|
|
@ -2,6 +2,8 @@ package mage.abilities.effects.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
|
@ -24,6 +26,7 @@ public class RollDieWithResultTableEffect extends OneShotEffect {
|
|||
protected final int sides;
|
||||
private final String prefixText;
|
||||
private final List<TableEntry> resultsTable = new ArrayList<>();
|
||||
private final DynamicValue modifier;
|
||||
|
||||
public RollDieWithResultTableEffect() {
|
||||
this(20);
|
||||
|
@ -34,9 +37,14 @@ public class RollDieWithResultTableEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
public RollDieWithResultTableEffect(int sides, String prefixText) {
|
||||
this(sides, prefixText, StaticValue.get(0));
|
||||
}
|
||||
|
||||
public RollDieWithResultTableEffect(int sides, String prefixText, DynamicValue modifier) {
|
||||
super(Outcome.Benefit);
|
||||
this.sides = sides;
|
||||
this.prefixText = prefixText;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
protected RollDieWithResultTableEffect(final RollDieWithResultTableEffect effect) {
|
||||
|
@ -46,6 +54,7 @@ public class RollDieWithResultTableEffect extends OneShotEffect {
|
|||
for (TableEntry tableEntry : effect.resultsTable) {
|
||||
this.resultsTable.add(tableEntry.copy());
|
||||
}
|
||||
this.modifier = effect.modifier.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +68,7 @@ public class RollDieWithResultTableEffect extends OneShotEffect {
|
|||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
int result = player.rollDice(source, game, sides);
|
||||
int result = player.rollDice(source, game, sides) + modifier.calculate(game, source, this);
|
||||
this.applyResult(result, game, source);
|
||||
return true;
|
||||
}
|
||||
|
@ -79,11 +88,16 @@ public class RollDieWithResultTableEffect extends OneShotEffect {
|
|||
sb.append(prefixText).append('.');
|
||||
for (TableEntry tableEntry : this.resultsTable) {
|
||||
sb.append("<br>");
|
||||
if (tableEntry.min != tableEntry.max) {
|
||||
if (tableEntry.max == Integer.MAX_VALUE) {
|
||||
sb.append(tableEntry.min);
|
||||
sb.append('-');
|
||||
sb.append('+');
|
||||
} else {
|
||||
if (tableEntry.min != tableEntry.max) {
|
||||
sb.append(tableEntry.min);
|
||||
sb.append('-');
|
||||
}
|
||||
sb.append(tableEntry.max);
|
||||
}
|
||||
sb.append(tableEntry.max);
|
||||
sb.append(" | ");
|
||||
sb.append(CardUtil.getTextWithFirstCharUpperCase(tableEntry.effects.getText(mode)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue