mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
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:
parent
978ebfc873
commit
9ba0da00ff
29 changed files with 97 additions and 47 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class MatchPlayer implements Serializable {
|
|||
|
||||
public Deck generateDeck(DeckValidator deckValidator) {
|
||||
// auto complete deck
|
||||
while (deck.getCards().size() < deckValidator.getDeckMinSize() && !deck.getSideboard().isEmpty()) {
|
||||
while (deck.getMaindeckCards().size() < deckValidator.getDeckMinSize() && !deck.getSideboard().isEmpty()) {
|
||||
Card card = deck.getSideboard().iterator().next();
|
||||
deck.getCards().add(card);
|
||||
deck.getSideboard().remove(card);
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ public class TournamentPlayer {
|
|||
If user fails to submit deck on time, submit deck as is if meets minimum size,
|
||||
else add basic lands per suggested land counts
|
||||
*/
|
||||
if (deck.getCards().size() < minDeckSize) {
|
||||
int[] lands = DeckBuildUtils.landCountSuggestion(minDeckSize, deck.getCards());
|
||||
if (deck.getMaindeckCards().size() < minDeckSize) {
|
||||
int[] lands = DeckBuildUtils.landCountSuggestion(minDeckSize, deck.getMaindeckCards());
|
||||
Set<String> landSets = TournamentUtil.getLandSetCodeForDeckSets(deck.getExpansionSetCodes());
|
||||
deck.getCards().addAll(TournamentUtil.getLands("Plains", lands[0], landSets));
|
||||
deck.getCards().addAll(TournamentUtil.getLands("Island", lands[1], landSets));
|
||||
|
|
|
|||
|
|
@ -388,11 +388,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
@Override
|
||||
public void useDeck(Deck deck, Game game) {
|
||||
library.clear();
|
||||
library.addAll(deck.getCards(), game);
|
||||
library.addAll(deck.getMaindeckCards(), game);
|
||||
sideboard.clear();
|
||||
for (Card card : deck.getSideboard()) {
|
||||
sideboard.add(card);
|
||||
}
|
||||
//TODO ARTI initialize extra decks here!
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue