Merge branch 'aihints' into 'master'

DeckHints: extend Type

See merge request core-developers/forge!6263
This commit is contained in:
Michael Kamensky
2022-02-20 04:17:58 +00:00
8 changed files with 33 additions and 28 deletions

View File

@@ -275,11 +275,9 @@ public class AiBlockController {
}
if (mode == TriggerType.DamageDone) {
if ((!trigParams.containsKey("ValidSource")
|| trigger.matchesValid(attacker, trigParams.get("ValidSource").split(",")))
if (trigger.matchesValidParam("ValidSource", attacker)
&& attacker.getNetCombatDamage() > 0
&& (!trigParams.containsKey("ValidTarget")
|| trigger.matchesValid(combat.getDefenderByAttacker(attacker), trigParams.get("ValidTarget").split(",")))) {
&& trigger.matchesValidParam("ValidTarget", combat.getDefenderByAttacker(attacker))) {
value += 50;
}
} else if (mode == TriggerType.AttackerUnblocked) {

View File

@@ -2664,15 +2664,15 @@ public class ComputerUtil {
for (Trigger trigger : theTriggers) {
final Card source = trigger.getHostCard();
if (trigger.getMode() != TriggerType.SpellCast) {
continue;
}
if (!trigger.zonesCheck(game.getZoneOf(source))) {
continue;
}
if (!trigger.requirementsCheck(game)) {
continue;
}
if (trigger.getMode() != TriggerType.SpellCast) {
continue;
}
if (trigger.hasParam("ValidCard")) {
if (!card.isValid(trigger.getParam("ValidCard").split(","), source.getController(), source, sa)) {
continue;
@@ -2724,6 +2724,12 @@ public class ComputerUtil {
for (Trigger trigger : theTriggers) {
final Card source = trigger.getHostCard();
if (trigger.getMode() != TriggerType.ChangesZone) {
continue;
}
if (!"Battlefield".equals(trigger.getParam("Destination"))) {
continue;
}
if (!trigger.zonesCheck(game.getZoneOf(source))) {
continue;
}
@@ -2734,12 +2740,6 @@ public class ComputerUtil {
&& AbilityUtils.getDefinedCards(permanent, source.getSVar(trigger.getParam("CheckOnTriggeredCard").split(" ")[0]), null).isEmpty()) {
continue;
}
if (trigger.getMode() != TriggerType.ChangesZone) {
continue;
}
if (!"Battlefield".equals(trigger.getParam("Destination"))) {
continue;
}
if (trigger.hasParam("ValidCard")) {
if (!permanent.isValid(trigger.getParam("ValidCard"), source.getController(), source, null)) {
continue;

View File

@@ -176,7 +176,14 @@ public class DeckHints {
case TYPE:
String[] types = param.split("\\|");
for (String t : types) {
Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.subType(t), PaperCard.FN_GET_RULES));
Predicate<CardRules> op;
if (t.contains(".")) {
String[] typeParts = t.split("\\.");
op = Predicates.and(CardRulesPredicates.coreType(true, typeParts[0]), CardRulesPredicates.subType(typeParts[1]));
} else {
op = Predicates.or(CardRulesPredicates.coreType(true, t), CardRulesPredicates.subType(t));
}
Iterables.addAll(cards, getMatchingItems(cardList, op, PaperCard.FN_GET_RULES));
}
break;
case NONE:

View File

@@ -356,19 +356,19 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
}
CardCollection list = new CardCollection();
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
list.addAll(hostController.getCardsIn(presentZone));
}
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
for (final Player p : this.getHostCard().getController().getOpponents()) {
for (final Player p : hostController.getOpponents()) {
list.addAll(p.getCardsIn(presentZone));
}
}
if (presentPlayer.equals("Any")) {
for (final Player p : this.getHostCard().getController().getAllies()) {
for (final Player p : hostController.getAllies()) {
list.addAll(p.getCardsIn(presentZone));
}
}
list = CardLists.getValidCards(list, sIsPresent, this.getHostCard().getController(), this.getHostCard(), this);
list = CardLists.getValidCards(list, sIsPresent, hostController, this.getHostCard(), this);
final String rightString = presentCompare.substring(2);
int right = AbilityUtils.calculateAmount(getHostCard(), rightString, this);
@@ -389,15 +389,15 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
}
CardCollection list = new CardCollection();
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
list.addAll(hostController.getCardsIn(presentZone));
}
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
for (final Player p : this.getHostCard().getController().getOpponents()) {
for (final Player p : hostController.getOpponents()) {
list.addAll(p.getCardsIn(presentZone));
}
}
list = CardLists.getValidCards(list, sIsPresent, this.getHostCard().getController(), this.getHostCard(), this);
list = CardLists.getValidCards(list, sIsPresent, hostController, this.getHostCard(), this);
final String rightString = presentCompare.substring(2);
int right = AbilityUtils.calculateAmount(getHostCard(), rightString, this);

View File

@@ -130,7 +130,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
* the run params
* @return true, if successful
*/
public abstract boolean canReplace (final Map<AbilityKey, Object> runParams);
public abstract boolean canReplace(final Map<AbilityKey, Object> runParams);
/**
* <p>

View File

@@ -614,8 +614,8 @@ public class AbilityManaPart implements java.io.Serializable {
for (final Player p : g.getPlayers()) {
for (final Card crd : p.getAllCards()) {
for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
if (replacementEffect.requirementsCheck(g)
&& replacementEffect.getMode() == ReplacementType.ProduceMana
if (replacementEffect.getMode() == ReplacementType.ProduceMana
&& replacementEffect.requirementsCheck(g)
&& replacementEffect.canReplace(repParams)
&& replacementEffect.zonesCheck(g.getZoneOf(crd))) {
return true;

View File

@@ -272,7 +272,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
return true;
}
return this.subAbility != null ? this.subAbility.canProduce(s) : false;
return this.subAbility != null && this.subAbility.canProduce(s);
}
public boolean isManaAbilityFor(SpellAbility saPaidFor, byte colorNeeded) {
@@ -290,7 +290,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor) && mp.abilityProducesManaColor(this, colorNeeded)) {
return true;
}
return this.subAbility != null ? this.subAbility.isManaAbilityFor(saPaidFor, colorNeeded) : false;
return this.subAbility != null && this.subAbility.isManaAbilityFor(saPaidFor, colorNeeded);
}
public boolean isManaCannotCounter(SpellAbility saPaidFor) {
@@ -298,7 +298,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor) && mp.cannotCounterPaidWith(saPaidFor)) {
return true;
}
return this.subAbility != null ? this.subAbility.isManaCannotCounter(saPaidFor) : false;
return this.subAbility != null && this.subAbility.isManaCannotCounter(saPaidFor);
}
public int amountOfManaGenerated(boolean multiply) {

View File

@@ -369,7 +369,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
if (getPresentDefined() != null) {
list = AbilityUtils.getDefinedObjects(host, getPresentDefined(), sa);
} else {
list = new FCollection<GameObject>(game.getCardsIn(getPresentZone()));
list = new FCollection<>(game.getCardsIn(getPresentZone()));
}
final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent().split(","), sa.getActivatingPlayer(), host, sa)));