mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
fixed starting loyalty display in mock card
This commit is contained in:
parent
f94c79f6b4
commit
09636d7332
4 changed files with 32 additions and 37 deletions
|
|
@ -8,7 +8,6 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.ModalDoubleFacesCard;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -26,7 +25,7 @@ public class MockCard extends CardImpl {
|
|||
// Needs to be here, as it is normally calculated from the
|
||||
// PlaneswalkerEntersWithLoyaltyAbility of the card... but the MockCard
|
||||
// only has MockAbilities.
|
||||
private int startingLoyalty;
|
||||
private final int startingLoyalty;
|
||||
|
||||
// mana cost extra info for multiple mana drawing
|
||||
// warning, don't use ManaCost objects here due too much memory consumptions
|
||||
|
|
@ -79,18 +78,16 @@ public class MockCard extends CardImpl {
|
|||
this.isModalDoubleFacesCard = true;
|
||||
}
|
||||
|
||||
if (this.isPlaneswalker()) {
|
||||
String startingLoyaltyString = card.getStartingLoyalty();
|
||||
if (startingLoyaltyString.isEmpty()) {
|
||||
} else {
|
||||
try {
|
||||
this.startingLoyalty = Integer.parseInt(startingLoyaltyString);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.getLogger(MockCard.class).warn("Planeswalker `" + this.name + "` starting loyalty in bad format: `" + startingLoyaltyString + "`.");
|
||||
}
|
||||
}
|
||||
switch (card.getStartingLoyalty()) {
|
||||
case "X":
|
||||
this.startingLoyalty = -2;
|
||||
break;
|
||||
case "":
|
||||
this.startingLoyalty = -1;
|
||||
break;
|
||||
default:
|
||||
this.startingLoyalty = Integer.parseInt(card.getStartingLoyalty());
|
||||
}
|
||||
|
||||
this.flipCardName = card.getFlipCardName();
|
||||
for (String ruleText : card.getRules()) {
|
||||
this.addAbility(textAbilityFromString(ruleText));
|
||||
|
|
|
|||
|
|
@ -243,20 +243,7 @@ public class CardInfo {
|
|||
}
|
||||
|
||||
// Starting loyalty
|
||||
if (card.isPlaneswalker()) {
|
||||
switch (card.getStartingLoyalty()) {
|
||||
case -2:
|
||||
this.startingLoyalty = "X";
|
||||
break;
|
||||
case -1:
|
||||
this.startingLoyalty = "";
|
||||
break;
|
||||
default:
|
||||
this.startingLoyalty = "" + card.getStartingLoyalty();
|
||||
}
|
||||
} else {
|
||||
this.startingLoyalty = "";
|
||||
}
|
||||
this.startingLoyalty = CardUtil.convertStartingLoyalty(card.getStartingLoyalty());
|
||||
}
|
||||
|
||||
public Card getCard() {
|
||||
|
|
|
|||
|
|
@ -1587,4 +1587,15 @@ public final class CardUtil {
|
|||
public static <T> int setOrIncrementValue(T u, Integer i) {
|
||||
return i == null ? 1 : Integer.sum(i, 1);
|
||||
}
|
||||
|
||||
public static String convertStartingLoyalty(int startingLoyalty) {
|
||||
switch (startingLoyalty) {
|
||||
case -2:
|
||||
return "X";
|
||||
case -1:
|
||||
return "";
|
||||
default:
|
||||
return "" + startingLoyalty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue