mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00: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
|
@ -32,6 +32,7 @@ import mage.game.permanent.PermanentToken;
|
|||
import mage.game.permanent.token.Token;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
|
@ -40,7 +41,6 @@ import mage.util.SubTypes;
|
|||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -589,7 +589,7 @@ public class CardView extends SimpleCardView {
|
|||
this.frameStyle = card.getFrameStyle();
|
||||
|
||||
// Get starting loyalty
|
||||
this.startingLoyalty = "" + card.getStartingLoyalty();
|
||||
this.startingLoyalty = CardUtil.convertStartingLoyalty(card.getStartingLoyalty());
|
||||
}
|
||||
|
||||
public CardView(MageObject object, Game game) {
|
||||
|
@ -663,7 +663,7 @@ public class CardView extends SimpleCardView {
|
|||
// Frame style
|
||||
this.frameStyle = object.getFrameStyle();
|
||||
// Starting loyalty. Must be extracted from an ability
|
||||
this.startingLoyalty = "" + object.getStartingLoyalty();
|
||||
this.startingLoyalty = CardUtil.convertStartingLoyalty(object.getStartingLoyalty());
|
||||
}
|
||||
|
||||
protected CardView() {
|
||||
|
|
|
@ -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…
Reference in a new issue