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.permanent.token.Token;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.game.stack.StackAbility;
|
import mage.game.stack.StackAbility;
|
||||||
|
import mage.game.stack.StackObject;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.Targets;
|
import mage.target.Targets;
|
||||||
|
@ -40,7 +41,6 @@ import mage.util.SubTypes;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import mage.game.stack.StackObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -589,7 +589,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.frameStyle = card.getFrameStyle();
|
this.frameStyle = card.getFrameStyle();
|
||||||
|
|
||||||
// Get starting loyalty
|
// Get starting loyalty
|
||||||
this.startingLoyalty = "" + card.getStartingLoyalty();
|
this.startingLoyalty = CardUtil.convertStartingLoyalty(card.getStartingLoyalty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(MageObject object, Game game) {
|
public CardView(MageObject object, Game game) {
|
||||||
|
@ -663,7 +663,7 @@ public class CardView extends SimpleCardView {
|
||||||
// Frame style
|
// Frame style
|
||||||
this.frameStyle = object.getFrameStyle();
|
this.frameStyle = object.getFrameStyle();
|
||||||
// Starting loyalty. Must be extracted from an ability
|
// Starting loyalty. Must be extracted from an ability
|
||||||
this.startingLoyalty = "" + object.getStartingLoyalty();
|
this.startingLoyalty = CardUtil.convertStartingLoyalty(object.getStartingLoyalty());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CardView() {
|
protected CardView() {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.ModalDoubleFacesCard;
|
import mage.cards.ModalDoubleFacesCard;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -26,7 +25,7 @@ public class MockCard extends CardImpl {
|
||||||
// Needs to be here, as it is normally calculated from the
|
// Needs to be here, as it is normally calculated from the
|
||||||
// PlaneswalkerEntersWithLoyaltyAbility of the card... but the MockCard
|
// PlaneswalkerEntersWithLoyaltyAbility of the card... but the MockCard
|
||||||
// only has MockAbilities.
|
// only has MockAbilities.
|
||||||
private int startingLoyalty;
|
private final int startingLoyalty;
|
||||||
|
|
||||||
// mana cost extra info for multiple mana drawing
|
// mana cost extra info for multiple mana drawing
|
||||||
// warning, don't use ManaCost objects here due too much memory consumptions
|
// warning, don't use ManaCost objects here due too much memory consumptions
|
||||||
|
@ -79,18 +78,16 @@ public class MockCard extends CardImpl {
|
||||||
this.isModalDoubleFacesCard = true;
|
this.isModalDoubleFacesCard = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isPlaneswalker()) {
|
switch (card.getStartingLoyalty()) {
|
||||||
String startingLoyaltyString = card.getStartingLoyalty();
|
case "X":
|
||||||
if (startingLoyaltyString.isEmpty()) {
|
this.startingLoyalty = -2;
|
||||||
} else {
|
break;
|
||||||
try {
|
case "":
|
||||||
this.startingLoyalty = Integer.parseInt(startingLoyaltyString);
|
this.startingLoyalty = -1;
|
||||||
} catch (NumberFormatException e) {
|
break;
|
||||||
Logger.getLogger(MockCard.class).warn("Planeswalker `" + this.name + "` starting loyalty in bad format: `" + startingLoyaltyString + "`.");
|
default:
|
||||||
|
this.startingLoyalty = Integer.parseInt(card.getStartingLoyalty());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.flipCardName = card.getFlipCardName();
|
this.flipCardName = card.getFlipCardName();
|
||||||
for (String ruleText : card.getRules()) {
|
for (String ruleText : card.getRules()) {
|
||||||
this.addAbility(textAbilityFromString(ruleText));
|
this.addAbility(textAbilityFromString(ruleText));
|
||||||
|
|
|
@ -243,20 +243,7 @@ public class CardInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starting loyalty
|
// Starting loyalty
|
||||||
if (card.isPlaneswalker()) {
|
this.startingLoyalty = CardUtil.convertStartingLoyalty(card.getStartingLoyalty());
|
||||||
switch (card.getStartingLoyalty()) {
|
|
||||||
case -2:
|
|
||||||
this.startingLoyalty = "X";
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
this.startingLoyalty = "";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.startingLoyalty = "" + card.getStartingLoyalty();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.startingLoyalty = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Card getCard() {
|
public Card getCard() {
|
||||||
|
|
|
@ -1587,4 +1587,15 @@ public final class CardUtil {
|
||||||
public static <T> int setOrIncrementValue(T u, Integer i) {
|
public static <T> int setOrIncrementValue(T u, Integer i) {
|
||||||
return i == null ? 1 : Integer.sum(i, 1);
|
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