mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Merge branch 'Shorikai' into 'master'
Fix for Shorikai See merge request core-developers/forge!6375
This commit is contained in:
@@ -540,11 +540,8 @@ public class PumpAi extends PumpAiBase {
|
|||||||
// Filter AI-specific targets if provided
|
// Filter AI-specific targets if provided
|
||||||
list = ComputerUtil.filterAITgts(sa, ai, list, true);
|
list = ComputerUtil.filterAITgts(sa, ai, list, true);
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty() || ComputerUtil.activateForCost(sa, ai)) {
|
||||||
if (ComputerUtil.activateForCost(sa, ai)) {
|
return pumpMandatoryTarget(ai, sa);
|
||||||
return pumpMandatoryTarget(ai, sa);
|
|
||||||
}
|
|
||||||
return mandatory && pumpMandatoryTarget(ai, sa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sa.isCurse()) {
|
if (!sa.isCurse()) {
|
||||||
@@ -623,9 +620,9 @@ public class PumpAi extends PumpAiBase {
|
|||||||
|
|
||||||
if (sa.isCurse()) {
|
if (sa.isCurse()) {
|
||||||
pref = CardLists.filterControlledBy(list, ai.getOpponents());
|
pref = CardLists.filterControlledBy(list, ai.getOpponents());
|
||||||
forced = CardLists.filterControlledBy(list, ai);
|
forced = CardLists.filterControlledBy(list, ai.getYourTeam());
|
||||||
} else {
|
} else {
|
||||||
pref = CardLists.filterControlledBy(list, ai);
|
pref = CardLists.filterControlledBy(list, ai.getYourTeam());
|
||||||
forced = CardLists.filterControlledBy(list, ai.getOpponents());
|
forced = CardLists.filterControlledBy(list, ai.getOpponents());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +631,7 @@ public class PumpAi extends PumpAiBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Card c = ComputerUtilCard.getBestAI(list);
|
Card c = ComputerUtilCard.getBestAI(pref);
|
||||||
pref.remove(c);
|
pref.remove(c);
|
||||||
sa.getTargets().add(c);
|
sa.getTargets().add(c);
|
||||||
}
|
}
|
||||||
@@ -652,7 +649,6 @@ public class PumpAi extends PumpAiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
forced.remove(c);
|
forced.remove(c);
|
||||||
|
|
||||||
sa.getTargets().add(c);
|
sa.getTargets().add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -448,14 +448,11 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
|||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
protected CardCollection getCurseCreatures(final Player ai, final SpellAbility sa, final int defense, final int attack, final List<String> keywords) {
|
protected CardCollection getCurseCreatures(final Player ai, final SpellAbility sa, final int defense, final int attack, final List<String> keywords) {
|
||||||
CardCollection list = new CardCollection();
|
CardCollection list = ai.getOpponents().getCardsIn(ZoneType.Battlefield);
|
||||||
for (final Player opp : ai.getOpponents()) {
|
|
||||||
list.addAll(opp.getCardsIn(ZoneType.Battlefield));
|
|
||||||
}
|
|
||||||
final Game game = ai.getGame();
|
final Game game = ai.getGame();
|
||||||
final Combat combat = game.getCombat();
|
final Combat combat = game.getCombat();
|
||||||
list = CardLists.getTargetableCards(list, sa);
|
list = CardLists.getTargetableCards(list, sa);
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ public enum DeckSection {
|
|||||||
// NOTE: Same rules applies to both Deck and Side, despite "Conspiracy cards" are allowed
|
// NOTE: Same rules applies to both Deck and Side, despite "Conspiracy cards" are allowed
|
||||||
// in the SideBoard (see Rule 313.2)
|
// in the SideBoard (see Rule 313.2)
|
||||||
// Those will be matched later, in case (see `Deck::validateDeferredSections`)
|
// Those will be matched later, in case (see `Deck::validateDeferredSections`)
|
||||||
return (!t.isConspiracy() && !t.isDungeon() && !t.isPhenomenon() && !t.isPlane() && !t.isScheme() &&
|
return !t.isConspiracy() && !t.isDungeon() && !t.isPhenomenon() && !t.isPlane() && !t.isScheme() && !t.isVanguard();
|
||||||
!t.isVanguard());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ public enum DeckSection {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean apply(PaperCard card) {
|
public Boolean apply(PaperCard card) {
|
||||||
CardType t = card.getRules().getType();
|
CardType t = card.getRules().getType();
|
||||||
return (t.isPlaneswalker() || (t.isCreature() && t.isLegendary()));
|
return card.getRules().canBeCommander() || t.isPlaneswalker();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,7 +83,7 @@ public enum DeckSection {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean apply(PaperCard card) {
|
public Boolean apply(PaperCard card) {
|
||||||
CardType t = card.getRules().getType();
|
CardType t = card.getRules().getType();
|
||||||
return (t.isPlane() || t.isPhenomenon());
|
return t.isPlane() || t.isPhenomenon();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -100,7 +99,7 @@ public enum DeckSection {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean apply(PaperCard card) {
|
public Boolean apply(PaperCard card) {
|
||||||
CardType t = card.getRules().getType();
|
CardType t = card.getRules().getType();
|
||||||
return (t.isScheme());
|
return t.isScheme();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,7 +107,7 @@ public enum DeckSection {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean apply(PaperCard card) {
|
public Boolean apply(PaperCard card) {
|
||||||
CardType t = card.getRules().getType();
|
CardType t = card.getRules().getType();
|
||||||
return (t.isConspiracy());
|
return t.isConspiracy();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -116,7 +115,7 @@ public enum DeckSection {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean apply(PaperCard card) {
|
public Boolean apply(PaperCard card) {
|
||||||
CardType t = card.getRules().getType();
|
CardType t = card.getRules().getType();
|
||||||
return ((t.isCreature() && t.hasSubtype("Avatar")) || t.isVanguard());
|
return (t.isCreature() && t.hasSubtype("Avatar")) || t.isVanguard();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import com.google.common.base.Predicates;
|
|||||||
*/
|
*/
|
||||||
public abstract class ItemPredicate {
|
public abstract class ItemPredicate {
|
||||||
|
|
||||||
// Static builder methods - they choose concrete implementation by
|
// Static builder methods - they choose concrete implementation by themselves
|
||||||
// themselves
|
|
||||||
|
|
||||||
public static final Predicate<Object> IsBoosterPack = Predicates.instanceOf(BoosterPack.class);
|
public static final Predicate<Object> IsBoosterPack = Predicates.instanceOf(BoosterPack.class);
|
||||||
public static final Predicate<Object> IsPrebuiltDeck = Predicates.instanceOf(PreconDeck.class);
|
public static final Predicate<Object> IsPrebuiltDeck = Predicates.instanceOf(PreconDeck.class);
|
||||||
|
|||||||
@@ -12,12 +12,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.card.CardRules;
|
|
||||||
import forge.card.CardRulesPredicates;
|
import forge.card.CardRulesPredicates;
|
||||||
import forge.deck.io.CardThemedMatrixIO;
|
import forge.deck.io.CardThemedMatrixIO;
|
||||||
import forge.deck.io.DeckStorage;
|
import forge.deck.io.DeckStorage;
|
||||||
@@ -159,13 +157,7 @@ public final class CardRelationMatrixGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//filter to just legal commanders
|
//filter to just legal commanders
|
||||||
List<PaperCard> legends = Lists.newArrayList(Iterables.filter(cardList,Predicates.compose(
|
List<PaperCard> legends = Lists.newArrayList(Iterables.filter(cardList, format.isLegalCommanderPredicate()));
|
||||||
new Predicate<CardRules>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(CardRules rules) {
|
|
||||||
return format.isLegalCommander(rules);
|
|
||||||
}
|
|
||||||
}, PaperCard.FN_GET_RULES)));
|
|
||||||
|
|
||||||
//generate lookups for legends to link commander names to matrix rows
|
//generate lookups for legends to link commander names to matrix rows
|
||||||
for (int i=0; i<legends.size(); ++i){
|
for (int i=0; i<legends.size(); ++i){
|
||||||
|
|||||||
@@ -37,14 +37,8 @@ public class CommanderDeckGenerator extends DeckProxy implements Comparable<Comm
|
|||||||
}
|
}
|
||||||
Predicate<CardRules> canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : DeckGeneratorBase.HUMAN_CAN_PLAY;
|
Predicate<CardRules> canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : DeckGeneratorBase.HUMAN_CAN_PLAY;
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Iterable<PaperCard> legends = Iterables.filter(uniqueCards.toFlatList(), Predicates.compose(Predicates.and(
|
Iterable<PaperCard> legends = Iterables.filter(uniqueCards.toFlatList(), Predicates.and(format.isLegalCommanderPredicate(), Predicates.compose(
|
||||||
new Predicate<CardRules>() {
|
canPlay, PaperCard.FN_GET_RULES)));
|
||||||
@Override
|
|
||||||
public boolean apply(CardRules rules) {
|
|
||||||
return format.isLegalCommander(rules);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
canPlay), PaperCard.FN_GET_RULES));
|
|
||||||
final List<DeckProxy> decks = new ArrayList<>();
|
final List<DeckProxy> decks = new ArrayList<>();
|
||||||
for (PaperCard legend: legends) {
|
for (PaperCard legend: legends) {
|
||||||
decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen));
|
decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen));
|
||||||
|
|||||||
@@ -601,15 +601,8 @@ public class DeckgenUtil {
|
|||||||
final DeckFormat format = gameType.getDeckFormat();
|
final DeckFormat format = gameType.getDeckFormat();
|
||||||
Predicate<CardRules> canPlay = forAi ? DeckGeneratorBase.AI_CAN_PLAY : DeckGeneratorBase.HUMAN_CAN_PLAY;
|
Predicate<CardRules> canPlay = forAi ? DeckGeneratorBase.AI_CAN_PLAY : DeckGeneratorBase.HUMAN_CAN_PLAY;
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Iterable<PaperCard> legends = cardDb.getAllCards(Predicates.and(format.isLegalCardPredicate(),
|
Iterable<PaperCard> legends = cardDb.getAllCards(Predicates.and(format.isLegalCardPredicate(), format.isLegalCommanderPredicate(),
|
||||||
Predicates.compose(Predicates.and(
|
Predicates.compose(canPlay, PaperCard.FN_GET_RULES)));
|
||||||
new Predicate<CardRules>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(CardRules rules) {
|
|
||||||
return format.isLegalCommander(rules);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
canPlay), PaperCard.FN_GET_RULES)));
|
|
||||||
|
|
||||||
commander = Aggregates.random(legends);
|
commander = Aggregates.random(legends);
|
||||||
return generateRandomCommanderDeck(commander, format, forAi, false);
|
return generateRandomCommanderDeck(commander, format, forAi, false);
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(CardRules subject) {
|
public boolean apply(CardRules subject) {
|
||||||
return ((allowedColor.containsAllColorsFrom(subject.getColorIdentity().getColor())));
|
return allowedColor.containsAllColorsFrom(subject.getColorIdentity().getColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user