Basic groundwork for extra decks (contraptions, attractions) (#10378)

* extra deck cards not counted in deck size

* extra deck handling in deckbuilder

* move responsibility for extraDeckCard boolean to CardImpl

* remove redundant field copy
This commit is contained in:
Artemis Kearney 2023-08-06 20:06:32 -05:00 committed by GitHub
parent 978ebfc873
commit 9ba0da00ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 97 additions and 47 deletions

View file

@ -80,6 +80,13 @@ public interface Card extends MageObject {
return null;
}
/**
* Is this an extra deck card? (such as contraptions and attractions)
* @return true if this is an extra deck card, false otherwise
*/
default boolean isExtraDeckCard() {
return false;
}
void assignNewId();
void addInfo(String key, String value, Game game);

View file

@ -53,6 +53,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
protected boolean usesVariousArt = false;
protected boolean morphCard;
protected List<UUID> attachments = new ArrayList<>();
protected boolean extraDeckCard = false;
protected CardImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs) {
this(ownerId, setInfo, cardTypes, costs, SpellAbilityType.BASE);
@ -130,6 +131,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
flipCardName = card.flipCardName;
usesVariousArt = card.usesVariousArt;
morphCard = card.morphCard;
extraDeckCard = card.extraDeckCard;
this.attachments.addAll(card.attachments);
}
@ -952,4 +954,9 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
// Only way to get here is if none of the effects on the card care about mana color.
return false;
}
@Override
public boolean isExtraDeckCard() {
return extraDeckCard;
}
}

View file

@ -214,8 +214,8 @@ public class Constructed extends DeckValidator {
boolean valid = true;
errorsList.clear();
//20091005 - 100.2a
if (deck.getCards().size() < getDeckMinSize()) {
addError(DeckValidatorErrorType.DECK_SIZE, "Deck", "Must contain at least " + getDeckMinSize() + " cards: has only " + deck.getCards().size() + " cards");
if (deck.getMaindeckCards().size() < getDeckMinSize()) {
addError(DeckValidatorErrorType.DECK_SIZE, "Deck", "Must contain at least " + getDeckMinSize() + " cards: has only " + deck.getMaindeckCards().size() + " cards");
valid = false;
}
//20130713 - 100.4a

View file

@ -227,6 +227,13 @@ public class Deck implements Serializable, Copyable<Deck> {
return cards;
}
public Set<Card> getMaindeckCards() {
return cards
.stream()
.filter(card -> !card.isExtraDeckCard())
.collect(Collectors.toSet());
}
public Card findCard(UUID cardId) {
return cards
.stream()

View file

@ -88,6 +88,8 @@ public class MockCard extends CardImpl {
for (String ruleText : card.getRules()) {
this.addAbility(textAbilityFromString(ruleText));
}
this.extraDeckCard = card.isExtraDeckCard();
}
protected MockCard(final MockCard card) {

View file

@ -19,7 +19,6 @@ import java.util.List;
* @author North
*/
public class MockSplitCard extends SplitCard {
public MockSplitCard(CardInfo card) {
super(null, new CardSetInfo(card.getName(), card.getSetCode(), card.getCardNumber(), card.getRarity()),
card.getTypes().toArray(new CardType[0]),
@ -62,6 +61,8 @@ public class MockSplitCard extends SplitCard {
this.rightHalfCard = new MockSplitCardHalf(rightHalf);
((SplitCardHalf) this.rightHalfCard).setParentCard(this);
}
this.extraDeckCard = card.isExtraDeckCard();
}
protected MockSplitCard(final MockSplitCard card) {

View file

@ -113,6 +113,8 @@ public class CardInfo {
protected String modalDoubleFacedSecondSideName;
@DatabaseField
protected String meldsToCardName;
@DatabaseField
protected boolean isExtraDeckCard;
// if you add new field with card side name then update CardRepository.addNewNames too
@ -232,6 +234,8 @@ public class CardInfo {
// Starting loyalty
this.startingLoyalty = CardUtil.convertLoyaltyOrDefense(card.getStartingLoyalty());
this.startingDefense = CardUtil.convertLoyaltyOrDefense(card.getStartingDefense());
this.isExtraDeckCard = card.isExtraDeckCard();
}
public Card getCard() {
@ -482,4 +486,8 @@ public class CardInfo {
public String toString() {
return String.format("%s (%s, %s)", getName(), getSetCode(), getCardNumber());
}
public boolean isExtraDeckCard() {
return isExtraDeckCard;
}
}