Skip to content

Commit

Permalink
GUI: fixed broken add lands and random deck dialogs in deck editor (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JayDi85 committed Feb 13, 2021
1 parent e94fd1b commit eb64a7b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private static void generateSpells(CardCriteria criteria, int spellCount) {
while (count < spellCount) {
Card card = cardPool.get(RandomUtil.nextInt(retrievedCount)).getMockCard();
if (genPool.isValidSpellCard(card)) {
int cardCMC = card.getManaCost().convertedManaCost();
int cardCMC = card.getConvertedManaCost();
for (DeckGeneratorCMC.CMC deckCMC : deckCMCs) {
if (cardCMC >= deckCMC.min && cardCMC <= deckCMC.max) {
int currentAmount = deckCMC.getAmount();
Expand Down
13 changes: 7 additions & 6 deletions Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,13 @@ private void autoAddLands() {
land_number = 0;
}
for (Card cd : cards) {
Mana m = cd.getManaCost().getMana();
red += m.getRed();
green += m.getGreen();
black += m.getBlack();
blue += m.getBlue();
white += m.getWhite();
for (String s : cd.getManaCostSymbols()) {
if (s.contains("W")) white++;
if (s.contains("U")) blue++;
if (s.contains("B")) black++;
if (s.contains("R")) red++;
if (s.contains("G")) green++;
}
}
int total = red + green + black + blue + white;

Expand Down
4 changes: 2 additions & 2 deletions Mage.Common/src/main/java/mage/utils/DeckBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public MageScoredCard(Card card, List<ColoredManaSymbol> allowedColors, RateCall
}

private int getManaCostScore(Card card, List<ColoredManaSymbol> allowedColors) {
int converted = card.getManaCost().convertedManaCost();
int converted = card.getConvertedManaCost();
final Map<String, Integer> singleCount = new HashMap<>();
int maxSingleCount = 0;
int multicolor = 0;
Expand Down Expand Up @@ -276,7 +276,7 @@ public int getScore() {
}

public int getConvertedCost() {
return this.card.getManaCost().convertedManaCost();
return this.card.getConvertedManaCost();
}

public Card getCard() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@ public int getEdhPowerLevel(Deck deck) {
whenYouCast |= s.contains("when you cast") || s.contains("whenever you cast");
}

for (ManaCost cost : card.getManaCost()) {
if (cost.getText().contains("X")) {
for (String s : card.getManaCostSymbols()) {
if (s.contains("X")) {
xCost = true;
}
}
for (Ability a : card.getAbilities()) {
for (ManaCost cost : a.getManaCosts()) {
if (cost.getText().contains("X")) {
for (String s : a.getManaCostSymbols()) {
if (s.contains("X")) {
xCost = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public boolean validate(Deck deck) {
* would be legal independently.
*/

if (commander == null || commander.getManaCost().convertedManaCost() > 3) {
if (commander == null || commander.getConvertedManaCost() > 3) {
if (commander == null) {
if (deck.getName() == null) {
addError(DeckValidatorErrorType.PRIMARY, "Leader", "You have to save your deck with the leader card name entered to the DECK NAME field of the DECK EDITOR (top left) so that XMage knows your leader."
Expand All @@ -141,7 +141,7 @@ public boolean validate(Deck deck) {

}
}
if (commander != null && commander.getManaCost().convertedManaCost() > 3) {
if (commander != null && commander.getConvertedManaCost() > 3) {
addError(DeckValidatorErrorType.PRIMARY, "Leader", "Commanders converted mana cost is greater than 3");
}
return false;
Expand Down Expand Up @@ -201,13 +201,13 @@ private boolean isCardFormatValid(Card card, Card commander, FilterMana color) {
// as zero for this purpose. Split cards are legal only if both of their halves would be legal independently.
List<Integer> costs = new ArrayList<>();
if (card instanceof SplitCard) {
costs.add(((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost());
costs.add(((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost());
costs.add(((SplitCard) card).getLeftHalfCard().getConvertedManaCost());
costs.add(((SplitCard) card).getRightHalfCard().getConvertedManaCost());
} else if (card instanceof ModalDoubleFacesCard) {
costs.add(((ModalDoubleFacesCard) card).getLeftHalfCard().getManaCost().convertedManaCost());
costs.add(((ModalDoubleFacesCard) card).getRightHalfCard().getManaCost().convertedManaCost());
costs.add(((ModalDoubleFacesCard) card).getLeftHalfCard().getConvertedManaCost());
costs.add(((ModalDoubleFacesCard) card).getRightHalfCard().getConvertedManaCost());
} else {
costs.add(card.getManaCost().convertedManaCost());
costs.add(card.getConvertedManaCost());
}

return costs.stream().allMatch(cost -> {
Expand Down
9 changes: 9 additions & 0 deletions Mage/src/main/java/mage/cards/mock/MockCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import mage.cards.repository.CardRepository;
import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -99,6 +100,14 @@ public MockCard(CardInfo card) {

public MockCard(final MockCard card) {
super(card);

this.startingLoyalty = card.startingLoyalty;
this.manaCostLeftStr = new ArrayList<>(card.manaCostLeftStr);
this.manaCostRightStr = new ArrayList<>(card.manaCostRightStr);
this.manaCostStr = new ArrayList<>(card.manaCostStr);
this.adventureSpellName = card.adventureSpellName;
this.isModalDoubleFacesCard = card.isModalDoubleFacesCard;
this.convertedManaCost = card.convertedManaCost;
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions Mage/src/main/java/mage/cards/mock/MockSplitCardHalf.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mage.cards.SplitCardHalf;
import mage.cards.repository.CardInfo;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -29,6 +30,9 @@ public MockSplitCardHalf(CardInfo card) {

public MockSplitCardHalf(final MockSplitCardHalf card) {
super(card);
this.splitCardParent = card.splitCardParent;
this.manaCosts = card.manaCosts.copy();
this.manaCostsSymbols = new ArrayList<>(card.manaCostsSymbols);
}

@Override
Expand Down

0 comments on commit eb64a7b

Please sign in to comment.