mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Doomsday Confluence and support (#4012)
* Doomsday Confluence and support * Clean up * Fix NPE * +AIhint --------- Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.60>
This commit is contained in:
@@ -59,19 +59,21 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
Card source = sa.getHostCard();
|
||||
|
||||
List<AbilitySub> list = CharmEffect.makePossibleOptions(sa);
|
||||
final int num;
|
||||
String numParam = sa.getParamOrDefault("CharmNum", "1");
|
||||
boolean isX = numParam.equals("X");
|
||||
int num = 0;
|
||||
boolean additionalDesc = sa.hasParam("AdditionalDescription");
|
||||
boolean optional = sa.hasParam("Optional");
|
||||
// hotfix for complex cards when using getCardForUi
|
||||
if (source.getController() == null && additionalDesc && !optional) {
|
||||
// using getCardForUi game is not set, so can't guess max charm
|
||||
num = Integer.MAX_VALUE;
|
||||
} else {
|
||||
} else if (!isX) {
|
||||
// fallback needed while ability building
|
||||
if (sa.getActivatingPlayer() == null) {
|
||||
sa.setActivatingPlayer(source.getController(), true);
|
||||
}
|
||||
num = Math.min(AbilityUtils.calculateAmount(source, sa.getParamOrDefault("CharmNum", "1"), sa), list.size());
|
||||
num = Math.min(AbilityUtils.calculateAmount(source, numParam, sa), list.size());
|
||||
}
|
||||
final int min = sa.hasParam("MinCharmNum") ? AbilityUtils.calculateAmount(source, sa.getParam("MinCharmNum"), sa) : num;
|
||||
|
||||
@@ -85,7 +87,9 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
sb.append(sa.getCostDescription());
|
||||
sb.append(oppChooses ? "An opponent chooses " : "Choose ");
|
||||
|
||||
if (num == min || num == Integer.MAX_VALUE) {
|
||||
if (isX) {
|
||||
sb.append("X");
|
||||
} else if (num == min || num == Integer.MAX_VALUE) {
|
||||
sb.append(num == 0 ? "up to that many" : Lang.getNumeral(min));
|
||||
} else if (min == 0 && num == sa.getParam("Choices").split(",").length) {
|
||||
sb.append("any number ");
|
||||
@@ -188,14 +192,17 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
final Card source = sa.getHostCard();
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
|
||||
boolean canRepeat = sa.hasParam("CanRepeatModes");
|
||||
int num = AbilityUtils.calculateAmount(source, sa.getParamOrDefault("CharmNum", "1"), sa);
|
||||
final int min = sa.hasParam("MinCharmNum") ? AbilityUtils.calculateAmount(source, sa.getParam("MinCharmNum"), sa) : num;
|
||||
|
||||
// if the amount of choices is smaller than min then they can't be chosen
|
||||
if (min > choices.size()) {
|
||||
return false;
|
||||
if (!canRepeat) {
|
||||
if (min > choices.size()) {
|
||||
return false;
|
||||
}
|
||||
num = Math.min(num, choices.size());
|
||||
}
|
||||
num = Math.min(num, choices.size());
|
||||
|
||||
boolean isOptional = sa.hasParam("Optional");
|
||||
if (isOptional && !activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblWouldYouLikeCharm", CardTranslation.getTranslatedName(source.getName())), null)) {
|
||||
@@ -219,7 +226,7 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
source.setChosenPlayer(chooser);
|
||||
}
|
||||
|
||||
List<AbilitySub> chosen = chooser.getController().chooseModeForAbility(sa, choices, min, num, sa.hasParam("CanRepeatModes"));
|
||||
List<AbilitySub> chosen = chooser.getController().chooseModeForAbility(sa, choices, min, num, canRepeat);
|
||||
chainAbilities(sa, chosen);
|
||||
|
||||
// trigger without chosen modes are removed from stack
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -65,7 +67,7 @@ public class CleanUpEffect extends SpellAbilityEffect {
|
||||
source.setChosenColors(null);
|
||||
}
|
||||
if (sa.hasParam("ClearNamedCard")) {
|
||||
source.setNamedCards(null);
|
||||
source.setNamedCards(Lists.newArrayList());
|
||||
}
|
||||
if (sa.hasParam("Log")) {
|
||||
source.getController().getGame().fireEvent(new GameEventRandomLog(logMessage));
|
||||
|
||||
@@ -293,7 +293,7 @@ public class EffectEffect extends SpellAbilityEffect {
|
||||
|
||||
// Set Chosen name
|
||||
if (!hostCard.getNamedCard().isEmpty()) {
|
||||
eff.setNamedCards(hostCard.getNamedCards());
|
||||
eff.setNamedCards(Lists.newArrayList(hostCard.getNamedCards()));
|
||||
}
|
||||
|
||||
// chosen number
|
||||
|
||||
@@ -1987,7 +1987,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
return hasNamedCard() ? Iterables.getLast(chosenName) : "";
|
||||
}
|
||||
public final List<String> getNamedCards() {
|
||||
return chosenName == null ? Lists.newArrayList() : chosenName;
|
||||
return chosenName;
|
||||
}
|
||||
public final void setNamedCards(final List<String> s) {
|
||||
chosenName = s;
|
||||
@@ -2000,7 +2000,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
|
||||
public boolean hasNamedCard() {
|
||||
return chosenName != null && !chosenName.isEmpty();
|
||||
return !chosenName.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasChosenEvenOdd() {
|
||||
|
||||
@@ -296,7 +296,7 @@ public final class CardUtil {
|
||||
|
||||
newCopy.setChosenType(in.getChosenType());
|
||||
newCopy.setChosenType2(in.getChosenType2());
|
||||
newCopy.setNamedCards(in.getNamedCards());
|
||||
newCopy.setNamedCards(Lists.newArrayList(in.getNamedCards()));
|
||||
newCopy.setChosenColors(Lists.newArrayList(in.getChosenColors()));
|
||||
if (in.hasChosenNumber()) {
|
||||
newCopy.setChosenNumber(in.getChosenNumber());
|
||||
|
||||
Reference in New Issue
Block a user