mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- "Upto" parameter in draw effect
- Added Temporary Truce
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -11077,6 +11077,7 @@ res/cardsfolder/t/temporal_manipulation.txt svneol=native#text/plain
|
|||||||
res/cardsfolder/t/temporal_mastery.txt -text
|
res/cardsfolder/t/temporal_mastery.txt -text
|
||||||
res/cardsfolder/t/temporal_spring.txt svneol=native#text/plain
|
res/cardsfolder/t/temporal_spring.txt svneol=native#text/plain
|
||||||
res/cardsfolder/t/temporary_insanity.txt svneol=native#text/plain
|
res/cardsfolder/t/temporary_insanity.txt svneol=native#text/plain
|
||||||
|
res/cardsfolder/t/temporary_truce.txt -text
|
||||||
res/cardsfolder/t/tempting_licid.txt -text
|
res/cardsfolder/t/tempting_licid.txt -text
|
||||||
res/cardsfolder/t/tempting_wurm.txt svneol=native#text/plain
|
res/cardsfolder/t/tempting_wurm.txt svneol=native#text/plain
|
||||||
res/cardsfolder/t/tendo_ice_bridge.txt svneol=native#text/plain
|
res/cardsfolder/t/tendo_ice_bridge.txt svneol=native#text/plain
|
||||||
|
|||||||
12
res/cardsfolder/t/temporary_truce.txt
Normal file
12
res/cardsfolder/t/temporary_truce.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Name:Temporary Truce
|
||||||
|
ManaCost:1 W
|
||||||
|
Types:Sorcery
|
||||||
|
A:SP$ RepeatEach | Cost$ 1 W | RepeatPlayers$ Player | RepeatSubAbility$ DBDraw | SpellDescription$ Each player may draw up to two cards. For each card less than two a player draws this way, that player gains 2 life.
|
||||||
|
SVar:DBDraw:DB$ Draw | Defined$ Player.IsRemembered | Upto$ True | NumCards$ 2 | RememberDrawn$ True | SubAbility$ DBGainLife | AILogic$ GainLife
|
||||||
|
SVar:DBGainLife:DB$ GainLife | LifeAmount$ X | References$ X,Y | Defined$ Player.IsRemembered | SubAbility$ DBCleanup
|
||||||
|
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||||
|
# Player is remembered here
|
||||||
|
SVar:Y:Count$RememberedSize/NMinus.3
|
||||||
|
SVar:X:SVar$Y/Twice
|
||||||
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/temporary_truce.jpg
|
||||||
|
Oracle:Each player may draw up to two cards. For each card less than two a player draws this way, that player gains 2 life.
|
||||||
@@ -216,6 +216,7 @@ public class DrawAi extends SpellAbilityAi {
|
|||||||
} else {
|
} else {
|
||||||
// Don't draw too many cards and then risk discarding cards
|
// Don't draw too many cards and then risk discarding cards
|
||||||
// at EOT
|
// at EOT
|
||||||
|
// TODO: "NextUpkeep" is deprecated
|
||||||
if (!(sa.hasParam("NextUpkeep") || (sa instanceof AbilitySub)) && !mandatory) {
|
if (!(sa.hasParam("NextUpkeep") || (sa instanceof AbilitySub)) && !mandatory) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import forge.card.cardfactory.CardFactoryUtil;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.spellability.Target;
|
import forge.card.spellability.Target;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.gui.GuiChoose;
|
|
||||||
import forge.gui.GuiDialog;
|
import forge.gui.GuiDialog;
|
||||||
|
|
||||||
public class ChooseNumberEffect extends SpellAbilityEffect {
|
public class ChooseNumberEffect extends SpellAbilityEffect {
|
||||||
@@ -43,44 +42,22 @@ public class ChooseNumberEffect extends SpellAbilityEffect {
|
|||||||
final String sMax = sa.getParamOrDefault("Max", "99");
|
final String sMax = sa.getParamOrDefault("Max", "99");
|
||||||
final int max = StringUtils.isNumeric(sMax) ? Integer.parseInt(sMax) : CardFactoryUtil.xCount(card, card.getSVar(sMax));
|
final int max = StringUtils.isNumeric(sMax) ? Integer.parseInt(sMax) : CardFactoryUtil.xCount(card, card.getSVar(sMax));
|
||||||
|
|
||||||
final String[] choices = new String[max + 1];
|
|
||||||
if (!random) {
|
|
||||||
// initialize the array
|
|
||||||
for (int i = min; i <= max; i++) {
|
|
||||||
choices[i] = Integer.toString(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||||
final Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
|
|
||||||
for (final Player p : tgtPlayers) {
|
for (final Player p : tgtPlayers) {
|
||||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||||
if (p.isHuman()) {
|
int chosen;
|
||||||
int chosen;
|
if (random) {
|
||||||
if (random) {
|
final Random randomGen = new Random();
|
||||||
final Random randomGen = new Random();
|
chosen = randomGen.nextInt(max - min) + min;
|
||||||
chosen = randomGen.nextInt(max - min) + min;
|
final String message = "Randomly chosen number: " + chosen;
|
||||||
final String message = "Randomly chosen number: " + chosen;
|
GuiDialog.message(message, card.toString());
|
||||||
GuiDialog.message(message, card.toString());
|
|
||||||
} else if (sa.hasParam("ListTitle")) {
|
|
||||||
final Object o = GuiChoose.one(sa.getParam("ListTitle"), choices);
|
|
||||||
if (null == o) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chosen = Integer.parseInt((String) o);
|
|
||||||
} else {
|
|
||||||
final Object o = GuiChoose.one("Choose a number", choices);
|
|
||||||
if (null == o) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chosen = Integer.parseInt((String) o);
|
|
||||||
}
|
|
||||||
card.setChosenNumber(chosen);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO - not implemented
|
String title = sa.hasParam("ListTitle") ? sa.getParam("ListTitle") : "Choose a number";
|
||||||
|
chosen = p.getController().chooseNumber(sa, title, min, max);
|
||||||
}
|
}
|
||||||
|
card.setChosenNumber(chosen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,12 +37,13 @@ public class DrawEffect extends SpellAbilityEffect {
|
|||||||
@Override
|
@Override
|
||||||
public void resolve(SpellAbility sa) {
|
public void resolve(SpellAbility sa) {
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa) : 1;
|
final int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa) : 1;
|
||||||
|
|
||||||
|
|
||||||
final Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
|
|
||||||
final boolean optional = sa.hasParam("OptionalDecider");
|
final boolean optional = sa.hasParam("OptionalDecider");
|
||||||
|
final boolean upto = sa.hasParam("Upto");
|
||||||
|
|
||||||
|
|
||||||
for (final Player p : getDefinedPlayersBeforeTargetOnes(sa)) {
|
for (final Player p : getDefinedPlayersBeforeTargetOnes(sa)) {
|
||||||
@@ -50,8 +51,12 @@ public class DrawEffect extends SpellAbilityEffect {
|
|||||||
if (optional && !p.getController().confirmAction(sa, null, "Do you want to draw " + Lang.nounWithAmount(numCards, " card") + "?"))
|
if (optional && !p.getController().confirmAction(sa, null, "Do you want to draw " + Lang.nounWithAmount(numCards, " card") + "?"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//TODO: remove this deprecation exception
|
int actualNum = numCards;
|
||||||
final List<Card> drawn = p.drawCards(numCards);
|
if (upto) {
|
||||||
|
actualNum = p.getController().chooseNumber(sa, "Choose a number", 0, numCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Card> drawn = p.drawCards(actualNum);
|
||||||
if (sa.hasParam("Reveal")) {
|
if (sa.hasParam("Reveal")) {
|
||||||
p.getGame().getAction().reveal(drawn, p);
|
p.getGame().getAction().reveal(drawn, p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -855,5 +855,15 @@ public class AiController {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int chooseNumber(SpellAbility sa, String title, int min, int max) {
|
||||||
|
//TODO: AILogic
|
||||||
|
if ("GainLife".equals(sa.getParam("AILogic"))) {
|
||||||
|
if (player.getLife() < 5 || player.getCardsIn(ZoneType.Hand).size() >= player.getMaxHandSize()) {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,4 +142,6 @@ public abstract class PlayerController {
|
|||||||
public abstract List<Card> chooseCardsToDiscardToMaximumHandSize(int numDiscard);
|
public abstract List<Card> chooseCardsToDiscardToMaximumHandSize(int numDiscard);
|
||||||
public abstract boolean payManaOptional(Card card, Cost cost, String prompt, ManaPaymentPurpose purpose);
|
public abstract boolean payManaOptional(Card card, Cost cost, String prompt, ManaPaymentPurpose purpose);
|
||||||
|
|
||||||
|
public abstract int chooseNumber(SpellAbility sa, String title, int min, int max);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -350,4 +350,9 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
// AI would play everything. But limits to one copy of (Leyline of Singularity) and (Gemstone Caverns)
|
// AI would play everything. But limits to one copy of (Leyline of Singularity) and (Gemstone Caverns)
|
||||||
return brains.chooseSaToActivateFromOpeningHand(usableFromOpeningHand);
|
return brains.chooseSaToActivateFromOpeningHand(usableFromOpeningHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int chooseNumber(SpellAbility sa, String title, int min, int max) {
|
||||||
|
return brains.chooseNumber(sa, title, min, max);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,6 +269,15 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
return options.get(0);
|
return options.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int chooseNumber(SpellAbility sa, String title, int min, int max) {
|
||||||
|
final String[] choices = new String[max + 1];
|
||||||
|
for (int i = min; i <= max; i++) {
|
||||||
|
choices[i] = Integer.toString(i);
|
||||||
|
}
|
||||||
|
return Integer.parseInt(GuiChoose.one(title, choices));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Player chooseSinglePlayerForEffect(List<Player> options, SpellAbility sa, String title) {
|
public Player chooseSinglePlayerForEffect(List<Player> options, SpellAbility sa, String title) {
|
||||||
// Human is supposed to read the message and understand from it what to choose
|
// Human is supposed to read the message and understand from it what to choose
|
||||||
|
|||||||
Reference in New Issue
Block a user