Merge branch 'practical' into 'master'

Practical Research and support

See merge request core-developers/forge!4323
This commit is contained in:
Michael Kamensky
2021-04-01 08:02:02 +00:00
3 changed files with 32 additions and 4 deletions

View File

@@ -530,7 +530,14 @@ public class PlayerControllerAi extends PlayerController {
@Override
public CardCollectionView chooseCardsToDiscardUnlessType(int num, CardCollectionView hand, String uType, SpellAbility sa) {
final CardCollectionView cardsOfType = CardLists.getType(hand, uType);
String [] splitUTypes = uType.split(",");
CardCollection cardsOfType = new CardCollection();
for (String part : splitUTypes) {
CardCollection partCards = CardLists.getType(hand, part);
if (!partCards.isEmpty()) {
cardsOfType.addAll(partCards);
}
}
if (!cardsOfType.isEmpty()) {
Card toDiscard = Aggregates.itemWithMin(cardsOfType, CardPredicates.Accessors.fnGetCmc);
return new CardCollection(toDiscard);

View File

@@ -0,0 +1,8 @@
Name:Practical Research
ManaCost:3 U R
Types:Instant
A:SP$ Draw | NumCards$ 4 | SubAbility$ DBDiscard | StackDescription$ SpellDescription | SpellDescription$ Draw four cards.
SVar:DBDiscard:DB$ Discard | Defined$ You | NumCards$ 2 | Mode$ TgtChoose | UnlessType$ Instant,Sorcery | StackDescription$ SpellDescription | SpellDescription$ Then discard two cards unless you discard an instant or sorcery card.
DeckHas:Ability$Discard
DeckHints:Type$Instant|Sorcery
Oracle:Draw four cards. Then discard two cards unless you discard an instant or sorcery card.

View File

@@ -1149,6 +1149,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public CardCollectionView chooseCardsToDiscardUnlessType(final int num, final CardCollectionView hand,
final String uType, final SpellAbility sa) {
String [] splitUTypes = uType.split(",");
final InputSelectEntitiesFromList<Card> target = new InputSelectEntitiesFromList<Card>(this, num, num, hand,
sa) {
private static final long serialVersionUID = -5774108410928795591L;
@@ -1156,14 +1157,26 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
protected boolean hasAllTargets() {
for (final Card c : selected) {
if (c.getType().hasStringType(uType)) {
return true;
for (String part : splitUTypes) {
if (c.getType().hasStringType(part)) {
return true;
}
}
}
return super.hasAllTargets();
}
};
target.setMessage(localizer.getMessage("lblSelectNCardsToDiscardUnlessDiscarduType", uType));
int n=1;
StringBuilder promptType = new StringBuilder();
for (String part : splitUTypes) {
if (n==1) {
promptType.append(part);
} else {
promptType.append(" or ").append(part);
}
n++;
}
target.setMessage(localizer.getMessage("lblSelectNCardsToDiscardUnlessDiscarduType", promptType));
target.showAndWait();
return new CardCollection(target.getSelected());
}