Fix assignGenericAmount dialog when no targets (Lathiel)

This commit is contained in:
tool4EvEr
2021-07-08 16:13:41 +02:00
parent d7b252185a
commit a1964eb75e
12 changed files with 65 additions and 70 deletions

View File

@@ -36,8 +36,7 @@ public class ChooseNumberEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card card = sa.getHostCard(); final Card card = sa.getHostCard();
//final int min = sa.containsKey("Min") ? Integer.parseInt(sa.get("Min")) : 0;
//final int max = sa.containsKey("Max") ? Integer.parseInt(sa.get("Max")) : 99;
final boolean random = sa.hasParam("Random"); final boolean random = sa.hasParam("Random");
final boolean anyNumber = sa.hasParam("ChooseAnyNumber"); final boolean anyNumber = sa.hasParam("ChooseAnyNumber");
final boolean secretlyChoose = sa.hasParam("SecretlyChoose"); final boolean secretlyChoose = sa.hasParam("SecretlyChoose");

View File

@@ -278,7 +278,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
params.put("Target", obj); params.put("Target", obj);
params.put("CounterType", counterType); params.put("CounterType", counterType);
divrem++; divrem++;
if ((divrem == tgtObjects.size()) || (counterRemain == 1)) { counterAmount = counterRemain; } if (divrem == tgtObjects.size() || counterRemain == 1) { counterAmount = counterRemain; }
else { else {
counterAmount = pc.chooseNumber(sa, Localizer.getInstance().getMessage counterAmount = pc.chooseNumber(sa, Localizer.getInstance().getMessage
("lblHowManyCountersThis", CardTranslation.getTranslatedName(gameCard.getName())), ("lblHowManyCountersThis", CardTranslation.getTranslatedName(gameCard.getName())),

View File

@@ -92,7 +92,6 @@ public class DamageEachEffect extends DamageBaseEffect {
// TODO shouldn't that be using Num or something first? // TODO shouldn't that be using Num or something first?
final int dmg = AbilityUtils.calculateAmount(source, "X", sa); final int dmg = AbilityUtils.calculateAmount(source, "X", sa);
// System.out.println(source+" deals "+dmg+" damage to "+o.toString());
if (o instanceof Card) { if (o instanceof Card) {
final Card c = (Card) o; final Card c = (Card) o;
if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) { if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) {

View File

@@ -24,4 +24,3 @@ public class GameDrawEffect extends SpellAbilityEffect {
} }
} }

View File

@@ -33,7 +33,6 @@ public class LifeLoseEffect extends SpellAbilityEffect {
*/ */
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
int lifeLost = 0; int lifeLost = 0;
final int lifeAmount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("LifeAmount"), sa); final int lifeAmount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("LifeAmount"), sa);

View File

@@ -17,54 +17,53 @@ import forge.util.Lang;
* *
*/ */
public class PoisonEffect extends SpellAbilityEffect { public class PoisonEffect extends SpellAbilityEffect {
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.game.ability.SpellAbilityEffect#resolve(forge.game.spellability.SpellAbility) * @see forge.game.ability.SpellAbilityEffect#resolve(forge.game.spellability.SpellAbility)
*/ */
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard(); final Card host = sa.getHostCard();
final Game game = host.getGame(); final Game game = host.getGame();
final int amount = AbilityUtils.calculateAmount(host, sa.getParam("Num"), sa); final int amount = AbilityUtils.calculateAmount(host, sa.getParam("Num"), sa);
GameEntityCounterTable table = new GameEntityCounterTable(); GameEntityCounterTable table = new GameEntityCounterTable();
for (final Player p : getTargetPlayers(sa)) { for (final Player p : getTargetPlayers(sa)) {
if ((!sa.usesTargeting()) || p.canBeTargetedBy(sa)) { if ((!sa.usesTargeting()) || p.canBeTargetedBy(sa)) {
if (amount >= 0) { if (amount >= 0) {
p.addPoisonCounters(amount, host, table); p.addPoisonCounters(amount, host, table);
} else { } else {
p.removePoisonCounters(-amount, host); p.removePoisonCounters(-amount, host);
}
} }
} }
table.triggerCountersPutAll(game);
} }
table.triggerCountersPutAll(game);
/* (non-Javadoc)
* @see forge.game.ability.SpellAbilityEffect#getStackDescription(forge.game.spellability.SpellAbility)
*/
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Num"), sa);
final List<Player> tgtPlayers = getTargetPlayers(sa);
sb.append(Lang.joinHomogenous(tgtPlayers));
sb.append(" ");
sb.append("get");
if (tgtPlayers.size() < 2) {
sb.append("s");
}
String type = CounterEnumType.POISON.getName() + " counter";
sb.append(" ").append(Lang.nounWithAmount(amount, type)).append(".");
return sb.toString();
}
} }
/* (non-Javadoc)
* @see forge.game.ability.SpellAbilityEffect#getStackDescription(forge.game.spellability.SpellAbility)
*/
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Num"), sa);
final List<Player> tgtPlayers = getTargetPlayers(sa);
sb.append(Lang.joinHomogenous(tgtPlayers));
sb.append(" ");
sb.append("get");
if (tgtPlayers.size() < 2) {
sb.append("s");
}
String type = CounterEnumType.POISON.getName() + " counter";
sb.append(" ").append(Lang.nounWithAmount(amount, type)).append(".");
return sb.toString();
}
}

View File

@@ -17,10 +17,6 @@ import forge.util.Localizer;
public class TwoPilesEffect extends SpellAbilityEffect { public class TwoPilesEffect extends SpellAbilityEffect {
// *************************************************************************
// ***************************** TwoPiles **********************************
// *************************************************************************
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility) * @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
*/ */
@@ -106,10 +102,6 @@ public class TwoPilesEffect extends SpellAbilityEffect {
final CardCollection pile2 = new CardCollection(pool); final CardCollection pile2 = new CardCollection(pool);
pile2.removeAll(pile1); pile2.removeAll(pile1);
//System.out.println("Pile 1:" + pile1);
//System.out.println("Pile 2:" + pile2);
if (isLeftRightPile) { if (isLeftRightPile) {
pile1WasChosen = true; pile1WasChosen = true;
} else { } else {

View File

@@ -42,7 +42,7 @@ public class VentureEffect extends SpellAbilityEffect {
} }
} }
// Create a new dugeon card chosen by player in command zone. // Create a new dungeon card chosen by player in command zone.
List<PaperCard> dungeonCards = StaticData.instance().getVariantCards().getAllCards( List<PaperCard> dungeonCards = StaticData.instance().getVariantCards().getAllCards(
Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard.FN_GET_RULES)); Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard.FN_GET_RULES));
List<ICardFace> faces = new ArrayList<>(); List<ICardFace> faces = new ArrayList<>();

View File

@@ -175,7 +175,7 @@ public class VAssignGenericAmount {
btnReset.addActionListener(new ActionListener() { btnReset.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent arg0) { resetAssignedAmount(); initialAssignAmount(); } }); @Override public void actionPerformed(ActionEvent arg0) { resetAssignedAmount(); initialAssignAmount(); } });
// Final UI layout // Final UI layout
pnlMain.setLayout(new MigLayout("insets 0, gap 0, wrap 2, ax center")); pnlMain.setLayout(new MigLayout("insets 0, gap 0, wrap 2, ax center"));
pnlMain.add(pnlSource, "w 125px!, h 160px!, gap 50px 0 0 15px"); pnlMain.add(pnlSource, "w 125px!, h 160px!, gap 50px 0 0 15px");
pnlMain.add(pnlInfo, "gap 20px 0 0 15px"); pnlMain.add(pnlInfo, "gap 20px 0 0 15px");

View File

@@ -4,7 +4,7 @@ Types:Legendary Creature Unicorn
PT:2/2 PT:2/2
K:Lifelink K:Lifelink
T:Mode$ Phase | Phase$ End of Turn | TriggerZones$ Battlefield | CheckSVar$ X | SVarCompare$ GE1 | Execute$ TrigPutCounter | TriggerDescription$ At the beginning of each end step, if you gained life this turn, distribute up to that many +1/+1 counters among any number of other target creatures. T:Mode$ Phase | Phase$ End of Turn | TriggerZones$ Battlefield | CheckSVar$ X | SVarCompare$ GE1 | Execute$ TrigPutCounter | TriggerDescription$ At the beginning of each end step, if you gained life this turn, distribute up to that many +1/+1 counters among any number of other target creatures.
SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Creature.Other | TgtPrompt$ Select any number of other target creatures to distribute counters to | CounterType$ P1P1 | TargetMin$ 0 | TargetMax$ X | DividedAsYouChoose$ X SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Creature.Other | TgtPrompt$ Select any number of other target creatures to distribute counters to | CounterType$ P1P1 | TargetMin$ 0 | TargetMax$ X | DividedAsYouChoose$ X | DividedUpTo$ True
SVar:X:Count$LifeYouGainedThisTurn SVar:X:Count$LifeYouGainedThisTurn
DeckHints:Ability$LifeGain DeckHints:Ability$LifeGain
DeckHas:Ability$Counters & Ability$LifeGain DeckHas:Ability$Counters & Ability$LifeGain

View File

@@ -98,15 +98,15 @@ public final class InputSelectTargets extends InputSyncronizedBase {
sb.append(sa.getHostCard()).append(" - ").append(tgt.getVTSelection()); sb.append(sa.getHostCard()).append(" - ").append(tgt.getVTSelection());
} }
if (!targetDepth.entrySet().isEmpty()) { if (!targetDepth.entrySet().isEmpty()) {
sb.append("\nTargeted: "); sb.append("\nTargeted: ");
} }
for (final Entry<GameEntity, Integer> o : targetDepth.entrySet()) { for (final Entry<GameEntity, Integer> o : targetDepth.entrySet()) {
//if it's not in gdx port landscape mode, append the linebreak //if it's not in gdx port landscape mode, append the linebreak
if(!ForgeConstants.isGdxPortLandscape) if (!ForgeConstants.isGdxPortLandscape)
sb.append("\n"); sb.append("\n");
sb.append(o.getKey()); sb.append(o.getKey());
//if it's in gdx port landscape mode, instead append the comma with space... //if it's in gdx port landscape mode, instead append the comma with space...
if(ForgeConstants.isGdxPortLandscape) if (ForgeConstants.isGdxPortLandscape)
sb.append(", "); sb.append(", ");
if (o.getValue() > 1) { if (o.getValue() > 1) {
sb.append(TextUtil.concatNoSpace(" (", String.valueOf(o.getValue()), " times)")); sb.append(TextUtil.concatNoSpace(" (", String.valueOf(o.getValue()), " times)"));
@@ -128,7 +128,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
"(Targeting ERROR)", ""); "(Targeting ERROR)", "");
showMessage(message, sa.getView()); showMessage(message, sa.getView());
if ((divisionValues != null && !divisionValues.isEmpty()) && sa.getMinTargets() == 0 && sa.getTargets().size() == 0) { if (divisionValues != null && !divisionValues.isEmpty() && sa.getMinTargets() == 0 && sa.getTargets().size() == 0) {
// extra logic for Divided with min targets = 0, should only work if num targets are 0 too // extra logic for Divided with min targets = 0, should only work if num targets are 0 too
getController().getGui().updateButtons(getOwner(), true, true, false); getController().getGui().updateButtons(getOwner(), true, true, false);
} else if (!sa.isMinTargetChosen() || (divisionValues != null && !divisionValues.isEmpty())){ } else if (!sa.isMinTargetChosen() || (divisionValues != null && !divisionValues.isEmpty())){
@@ -279,7 +279,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
return false; return false;
} }
if ((divisionValues != null && !divisionValues.isEmpty())) { if (divisionValues != null && !divisionValues.isEmpty()) {
Boolean val = onDividedAsYouChoose(card); Boolean val = onDividedAsYouChoose(card);
if (val != null) { if (val != null) {
return val; return val;
@@ -321,7 +321,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
return; return;
} }
if ((divisionValues != null && !divisionValues.isEmpty())) { if (divisionValues != null && !divisionValues.isEmpty()) {
Boolean val = onDividedAsYouChoose(player); Boolean val = onDividedAsYouChoose(player);
if (val != null) { if (val != null) {
return; return;

View File

@@ -1972,16 +1972,24 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
boolean result = select.chooseTargets(null, null, null, false, canFilterMustTarget); boolean result = select.chooseTargets(null, null, null, false, canFilterMustTarget);
final List<GameEntity> targets = currentAbility.getTargets().getTargetEntities();
int amount = currentAbility.getStillToDivide();
// assign divided as you choose values // assign divided as you choose values
if (result && currentAbility.isDividedAsYouChoose() && currentAbility.getStillToDivide() > 0) { if (result && targets.size() > 0 && amount > 0) {
int amount = currentAbility.getStillToDivide(); if (currentAbility.hasParam("DividedUpTo")) {
final List<GameEntity> targets = currentAbility.getTargets().getTargetEntities(); amount = chooseNumber(currentAbility, localizer.getMessage("lblHowMany"), targets.size(), amount);
}
if (targets.size() == 1) { if (targets.size() == 1) {
currentAbility.addDividedAllocation(targets.get(0), amount); currentAbility.addDividedAllocation(targets.get(0), amount);
} else if (targets.size() == amount) { } else if (targets.size() == amount) {
for (GameEntity e : targets) { for (GameEntity e : targets) {
currentAbility.addDividedAllocation(e, 1); currentAbility.addDividedAllocation(e, 1);
} }
} else if (amount == 0) {
for (GameEntity e : targets) {
currentAbility.addDividedAllocation(e, 0);
}
} else if (targets.size() > amount) { } else if (targets.size() > amount) {
return false; return false;
} else { } else {