Commit 773f2b28 authored by Hans Mackowiak's avatar Hans Mackowiak

Loyalty: use String Property for X

parent e509931f
......@@ -1339,7 +1339,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
});
for (Card pw : aiPlaneswalkers) {
int curLoyalty = pw.getCounters(CounterType.LOYALTY);
int freshLoyalty = pw.getCurrentState().getBaseLoyalty();
int freshLoyalty = Integer.valueOf(pw.getCurrentState().getBaseLoyalty());
if (freshLoyalty - curLoyalty >= loyaltyDiff && curLoyalty <= maxLoyaltyToConsider) {
return pw;
}
......
......@@ -38,7 +38,7 @@ final class CardFace implements ICardFace {
private int iToughness = Integer.MAX_VALUE;
private String power = null;
private String toughness = null;
private int initialLoyalty = -1;
private String initialLoyalty = "";
private String nonAbilityText = null;
private List<String> keywords = null;
......@@ -56,7 +56,7 @@ final class CardFace implements ICardFace {
@Override public int getIntToughness() { return iToughness; }
@Override public String getPower() { return power; }
@Override public String getToughness() { return toughness; }
@Override public int getInitialLoyalty() { return initialLoyalty; }
@Override public String getInitialLoyalty() { return initialLoyalty; }
@Override public String getName() { return this.name; }
@Override public CardType getType() { return this.type; }
@Override public ManaCost getManaCost() { return this.manaCost; }
......@@ -84,7 +84,7 @@ final class CardFace implements ICardFace {
void setManaCost(ManaCost manaCost0) { this.manaCost = manaCost0; }
void setColor(ColorSet color0) { this.color = color0; }
void setOracleText(String text) { this.oracleText = text; }
void setInitialLoyalty(int value) { this.initialLoyalty = value; }
void setInitialLoyalty(String value) { this.initialLoyalty = value; }
void setPtText(String value) {
final String k[] = value.split("/");
......
......@@ -186,7 +186,7 @@ public final class CardRules implements ICardCharacteristics {
@Override public int getIntToughness() { return mainPart.getIntToughness(); }
@Override public String getPower() { return mainPart.getPower(); }
@Override public String getToughness() { return mainPart.getToughness(); }
@Override public int getInitialLoyalty() { return mainPart.getInitialLoyalty(); }
@Override public String getInitialLoyalty() { return mainPart.getInitialLoyalty(); }
@Override
public String getOracleText() {
......@@ -409,7 +409,7 @@ public final class CardRules implements ICardCharacteristics {
case 'L':
if ("Loyalty".equals(key)) {
this.faces[this.curFace].setInitialLoyalty(Integer.valueOf(value));
this.faces[this.curFace].setInitialLoyalty(value);
}
break;
......
......@@ -12,7 +12,7 @@ public interface ICardCharacteristics {
int getIntToughness();
String getPower();
String getToughness();
int getInitialLoyalty();
String getInitialLoyalty();
String getOracleText();
}
......@@ -325,9 +325,6 @@ public class CardFactory {
// ******************************************************************
// ************** Link to different CardFactories *******************
if (card.isPlaneswalker()) {
buildPlaneswalkerAbilities(card);
}
if (state == CardStateName.LeftSplit || state == CardStateName.RightSplit) {
for (final SpellAbility sa : card.getSpellAbilities()) {
......@@ -383,18 +380,6 @@ public class CardFactory {
card.addSpellAbility(planarRoll);
}
private static void buildPlaneswalkerAbilities(Card card) {
CardState state = card.getCurrentState();
// etbCounter only for Original Card
if (state.getBaseLoyalty() > 0) {
final String loyalty = Integer.toString(state.getBaseLoyalty());
// keyword need to be added to state directly, so init can be disabled
if (state.addIntrinsicKeyword("etbCounter:LOYALTY:" + loyalty + ":no Condition:no desc", false) != null) {
card.updateKeywords();
}
}
}
private static Card readCard(final CardRules rules, final IPaperCard paperCard, int cardId, Game game) {
final Card card = new Card(cardId, paperCard, game);
......
......@@ -53,7 +53,7 @@ public class CardState extends GameObject {
private byte color = MagicColor.COLORLESS;
private int basePower = 0;
private int baseToughness = 0;
private int baseLoyalty = 0;
private String baseLoyalty = "";
private KeywordCollection intrinsicKeywords = new KeywordCollection();
private final FCollection<SpellAbility> nonManaAbilities = new FCollection<SpellAbility>();
......@@ -72,6 +72,8 @@ public class CardState extends GameObject {
private final CardStateView view;
private final Card card;
private ReplacementEffect loyaltyRep = null;
public CardState(Card card, CardStateName name) {
this(card.getView().createAlternateState(name), card);
}
......@@ -174,11 +176,11 @@ public class CardState extends GameObject {
view.updateToughness(this);
}
public int getBaseLoyalty() {
public String getBaseLoyalty() {
return baseLoyalty;
}
public final void setBaseLoyalty(final int loyalty) {
baseLoyalty = loyalty;
public final void setBaseLoyalty(final String string) {
baseLoyalty = string;
view.updateLoyalty(this);
}
......@@ -400,6 +402,14 @@ public class CardState extends GameObject {
public FCollectionView<ReplacementEffect> getReplacementEffects() {
FCollection<ReplacementEffect> result = new FCollection<>(replacementEffects);
if (getTypeWithChanges().isPlaneswalker()) {
if (loyaltyRep == null) {
loyaltyRep = CardFactoryUtil.makeEtbCounter("etbCounter:LOYALTY:" + this.baseLoyalty, card, true);
}
result.add(loyaltyRep);
}
card.updateReplacementEffects(result, this);
return result;
}
......
......@@ -889,13 +889,17 @@ public class CardView extends GameEntityView {
set(TrackableProperty.Toughness, c.getBaseToughness());
}
public int getLoyalty() {
public String getLoyalty() {
return get(TrackableProperty.Loyalty);
}
void updateLoyalty(Card c) {
updateLoyalty(c.getCurrentLoyalty());
if (c.isInZone(ZoneType.Battlefield)) {
updateLoyalty(String.valueOf(c.getCurrentLoyalty()));
} else {
updateLoyalty(c.getCurrentState().getBaseLoyalty());
}
}
void updateLoyalty(int loyalty) {
void updateLoyalty(String loyalty) {
set(TrackableProperty.Loyalty, loyalty);
}
void updateLoyalty(CardState c) {
......@@ -911,7 +915,7 @@ public class CardView extends GameEntityView {
return;
}
}
set(TrackableProperty.Loyalty, 0); //alternates don't need loyalty
set(TrackableProperty.Loyalty, "0"); //alternates don't need loyalty
}
public String getSetCode() {
......
......@@ -77,7 +77,7 @@ public enum TrackableProperty {
RulesText(TrackableTypes.StringType),
Power(TrackableTypes.IntegerType),
Toughness(TrackableTypes.IntegerType),
Loyalty(TrackableTypes.IntegerType),
Loyalty(TrackableTypes.StringType),
ChangedColorWords(TrackableTypes.StringMapType),
ChangedTypes(TrackableTypes.StringMapType),
HasDeathtouch(TrackableTypes.BooleanType),
......
......@@ -437,7 +437,7 @@ public class VAssignDamage {
}
else if (defender instanceof CardView) { // planeswalker
final CardView pw = (CardView)defender;
lethalDamage = pw.getCurrentState().getLoyalty();
lethalDamage = Integer.valueOf(pw.getCurrentState().getLoyalty());
}
}
else {
......
......@@ -705,7 +705,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
String sPt = "";
if (state.isCreature() && state.isPlaneswalker()) {
sPt = state.getPower() + "/" + state.getToughness() +
" (" + String.valueOf(state.getLoyalty()) + ")";
" (" + state.getLoyalty() + ")";
}
else if (state.isCreature()) {
sPt = state.getPower() + "/" + state.getToughness();
......@@ -714,7 +714,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
sPt = "[" + state.getPower() + "/" + state.getToughness() + "]";
}
else if (state.isPlaneswalker()) {
sPt = String.valueOf(state.getLoyalty());
sPt = state.getLoyalty();
}
ptText.setText(sPt);
}
......
Name:Nissa, Steward of Elements
ManaCost:X G U
Types:Legendary Planeswalker Nissa
Loyalty:0
K:etbCounter:LOYALTY:X
Loyalty:X
SVar:X:Count$xPaid
A:AB$ Scry | Cost$ AddCounter<2/LOYALTY> | Planeswalker$ True | ScryNum$ 2 | SpellDescription$ Scry 2.
A:AB$ Dig | Cost$ AddCounter<0/LOYALTY> | Planeswalker$ True | DigNum$ 1 | ChangeNum$ 1 | Optional$ True | ChangeValid$ Land,Creature.cmcLEY | ForceRevealToController$ True | PromptToSkipOptionalAbility$ True | References$ Y | AILogic$ AlwaysConfirm | OptionalAbilityPrompt$ Would you like to put the permanent onto the battlefield? | DestinationZone$ Battlefield | LibraryPosition2$ 0 | SpellDescription$ Look at the top card of your library. If it's a land card or a creature card with converted mana cost less than or equal to the number of loyalty counters on Nissa, Steward of Elements, you may put that card onto the battlefield.
......
......@@ -35,6 +35,8 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
public enum ColumnDef {
/**The column containing the inventory item name.*/
STRING("", "", 0, false, SortState.ASC,
......@@ -512,7 +514,8 @@ public enum ColumnDef {
result = ((IPaperCard) i).getRules().getIntPower();
if (result == Integer.MAX_VALUE) {
if (((IPaperCard)i).getRules().getType().isPlaneswalker()) {
result = ((IPaperCard) i).getRules().getInitialLoyalty();
String loy = ((IPaperCard) i).getRules().getInitialLoyalty();
result = StringUtils.isNumeric(loy) ? Integer.valueOf(loy) : 0;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment