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
public void resolve(SpellAbility sa) {
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 anyNumber = sa.hasParam("ChooseAnyNumber");
final boolean secretlyChoose = sa.hasParam("SecretlyChoose");

View File

@@ -278,7 +278,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
params.put("Target", obj);
params.put("CounterType", counterType);
divrem++;
if ((divrem == tgtObjects.size()) || (counterRemain == 1)) { counterAmount = counterRemain; }
if (divrem == tgtObjects.size() || counterRemain == 1) { counterAmount = counterRemain; }
else {
counterAmount = pc.chooseNumber(sa, Localizer.getInstance().getMessage
("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?
final int dmg = AbilityUtils.calculateAmount(source, "X", sa);
// System.out.println(source+" deals "+dmg+" damage to "+o.toString());
if (o instanceof Card) {
final Card c = (Card) o;
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
public void resolve(SpellAbility sa) {
int lifeLost = 0;
final int lifeAmount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("LifeAmount"), sa);

View File

@@ -17,7 +17,7 @@ import forge.util.Lang;
*
*/
public class PoisonEffect extends SpellAbilityEffect {
public class PoisonEffect extends SpellAbilityEffect {
/* (non-Javadoc)
* @see forge.game.ability.SpellAbilityEffect#resolve(forge.game.spellability.SpellAbility)
@@ -66,5 +66,4 @@ import forge.util.Lang;
return sb.toString();
}
}
}

View File

@@ -17,10 +17,6 @@ import forge.util.Localizer;
public class TwoPilesEffect extends SpellAbilityEffect {
// *************************************************************************
// ***************************** TwoPiles **********************************
// *************************************************************************
/* (non-Javadoc)
* @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);
pile2.removeAll(pile1);
//System.out.println("Pile 1:" + pile1);
//System.out.println("Pile 2:" + pile2);
if (isLeftRightPile) {
pile1WasChosen = true;
} 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(
Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard.FN_GET_RULES));
List<ICardFace> faces = new ArrayList<>();

View File

@@ -4,7 +4,7 @@ Types:Legendary Creature Unicorn
PT:2/2
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.
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
DeckHints:Ability$LifeGain
DeckHas:Ability$Counters & Ability$LifeGain

View File

@@ -102,11 +102,11 @@ public final class InputSelectTargets extends InputSyncronizedBase {
}
for (final Entry<GameEntity, Integer> o : targetDepth.entrySet()) {
//if it's not in gdx port landscape mode, append the linebreak
if(!ForgeConstants.isGdxPortLandscape)
if (!ForgeConstants.isGdxPortLandscape)
sb.append("\n");
sb.append(o.getKey());
//if it's in gdx port landscape mode, instead append the comma with space...
if(ForgeConstants.isGdxPortLandscape)
if (ForgeConstants.isGdxPortLandscape)
sb.append(", ");
if (o.getValue() > 1) {
sb.append(TextUtil.concatNoSpace(" (", String.valueOf(o.getValue()), " times)"));
@@ -128,7 +128,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
"(Targeting ERROR)", "");
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
getController().getGui().updateButtons(getOwner(), true, true, false);
} else if (!sa.isMinTargetChosen() || (divisionValues != null && !divisionValues.isEmpty())){
@@ -279,7 +279,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
return false;
}
if ((divisionValues != null && !divisionValues.isEmpty())) {
if (divisionValues != null && !divisionValues.isEmpty()) {
Boolean val = onDividedAsYouChoose(card);
if (val != null) {
return val;
@@ -321,7 +321,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
return;
}
if ((divisionValues != null && !divisionValues.isEmpty())) {
if (divisionValues != null && !divisionValues.isEmpty()) {
Boolean val = onDividedAsYouChoose(player);
if (val != null) {
return;

View File

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