Ready for Review: Implementing Battles (#10156)

* add types and subtypes

* add startingDefense attribute

* [MOM] Implement Invasion of Ravnica / Guildpact Paragon

* fix two small errors

* refactor various instances of "any target"

* fully implement defense counters

* battles can now be attacked

* [MOM] Implement Invasion of Dominaria / Serra Faithkeeper

* [MOM] Implement Invasion of Innistrad / Deluge of the Dead

* [MOM] Implement Invasion of Kaladesh / Aetherwing, Golden-Scale Flagship

* [MOM] Implement Invasion of Kamigawa / Rooftop Saboteurs

* [MOM] Implement Invasion of Karsus / Refraction Elemental

* [MOM] Implement Invasion of Tolvada / The Broken Sky

* simplify battle info ability

* fix verify failure

* some more fixes for attacking battles

* [MOM] Implement Invasion of Kaldheim / Pyre of the World Tree

* [MOM] Implement Invasion of Lorwyn / Winnowing Forces

* [MOM] Implement Invasion of Moag / Bloomwielder Dryads

* [MOM] Implement Invasion of Shandalar / Leyline Surge

* [MOM] Implement Invasion of Belenon / Belenon War Anthem

* [MOM] Implement Invasion of Pyrulea / Gargantuan Slabhorn

* [MOM] Implement Invasion of Vryn / Overloaded Mage-Ring

* [MOM] Implement Marshal of Zhalfir

* [MOM] Implement Sunfall

* implement protectors for sieges

* partially implement siege defeated trigger

* fix verify failure

* some updates to blocking

* [MOM] Implement Invasion of Mercadia / Kyren Flamewright

* [MOM] Implement Invasion of Theros / Ephara, Ever-Sheltering

* [MOM] Implement Invasion of Ulgrotha / Grandmother Ravi Sengir

* [MOM] Implement Invasion of Xerex / Vertex Paladin

* add initial battle test

* fix verify failure

* [MOM] Implement Invasion of Amonkhet / Lazotep Convert

* [MOM] update spoiler

* update how protectors are chosen

* update text

* battles can't block

* add control change test

* rename battle test for duel

* add multiplayer test

* [MOM] Implement Invasion of Alara / Awaken the Maelstrom

* [MOM] Implement Invasion of Eldraine

* [MOM] Implement Invasion of Ergamon / Truga Cliffhanger

* [MOM] Implement Invasion of Ixalan / Belligerent Regisaur

* battles now cast transformed (this is super hacky but we need to refactor TDFCs anyway)

* add TODO

* add ignore for randomly failing test

* a few small fixes

* add defense to MtgJsonCard (unused like loyalty)

* implement ProtectorIdPredicate

* small fixes
This commit is contained in:
Evan Kranzler 2023-04-13 20:03:16 -04:00 committed by GitHub
parent edf1cff8a8
commit 947351932b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
129 changed files with 4057 additions and 1087 deletions

View file

@ -64,7 +64,10 @@ public class CardView extends SimpleCardView {
protected String toughness;
@Expose
protected String loyalty = "";
@Expose
protected String defense = "";
protected String startingLoyalty;
protected String startingDefense;
protected List<CardType> cardTypes;
protected SubTypes subTypes;
protected Set<SuperType> superTypes;
@ -172,6 +175,8 @@ public class CardView extends SimpleCardView {
this.toughness = cardView.toughness;
this.loyalty = cardView.loyalty;
this.startingLoyalty = cardView.startingLoyalty;
this.defense = cardView.defense;
this.startingDefense = cardView.startingDefense;
this.cardTypes = new ArrayList<>(cardView.cardTypes);
this.subTypes = new SubTypes(cardView.subTypes);
this.superTypes = cardView.superTypes;
@ -397,6 +402,7 @@ public class CardView extends SimpleCardView {
if (game != null) {
if (permanent.getCounters(game) != null && !permanent.getCounters(game).isEmpty()) {
this.loyalty = Integer.toString(permanent.getCounters(game).getCount(CounterType.LOYALTY));
this.defense = Integer.toString(permanent.getCounters(game).getCount(CounterType.DEFENSE));
counters = new ArrayList<>();
for (Counter counter : permanent.getCounters(game).values()) {
counters.add(new CounterView(counter));
@ -435,6 +441,7 @@ public class CardView extends SimpleCardView {
this.mageObjectType = MageObjectType.CARD;
}
this.loyalty = "";
this.defense = "";
if (game != null && card.getCounters(game) != null && !card.getCounters(game).isEmpty()) {
counters = new ArrayList<>();
for (Counter counter : card.getCounters(game).values()) {
@ -591,7 +598,10 @@ public class CardView extends SimpleCardView {
this.frameStyle = card.getFrameStyle();
// Get starting loyalty
this.startingLoyalty = CardUtil.convertStartingLoyalty(card.getStartingLoyalty());
this.startingLoyalty = CardUtil.convertLoyaltyOrDefense(card.getStartingLoyalty());
// Get starting defense
this.startingDefense = CardUtil.convertLoyaltyOrDefense(card.getStartingDefense());
}
public CardView(MageObject object, Game game) {
@ -606,10 +616,12 @@ public class CardView extends SimpleCardView {
this.power = Integer.toString(object.getPower().getValue());
this.toughness = Integer.toString(object.getToughness().getValue());
this.loyalty = Integer.toString(((Permanent) object).getCounters((Game) null).getCount(CounterType.LOYALTY));
this.defense = Integer.toString(((Permanent) object).getCounters((Game) null).getCount(CounterType.DEFENSE));
} else {
this.power = object.getPower().toString();
this.toughness = object.getToughness().toString();
this.loyalty = "";
this.defense = "";
}
this.cardTypes = new ArrayList<>(object.getCardType(game));
this.subTypes = new SubTypes(object.getSubtype(game));
@ -664,8 +676,10 @@ public class CardView extends SimpleCardView {
this.frameColor = object.getFrameColor(game).copy();
// Frame style
this.frameStyle = object.getFrameStyle();
// Starting loyalty. Must be extracted from an ability
this.startingLoyalty = CardUtil.convertStartingLoyalty(object.getStartingLoyalty());
// Starting loyalty
this.startingLoyalty = CardUtil.convertLoyaltyOrDefense(object.getStartingLoyalty());
// Starting defense
this.startingDefense = CardUtil.convertLoyaltyOrDefense(object.getStartingDefense());
}
protected CardView() {
@ -750,6 +764,8 @@ public class CardView extends SimpleCardView {
this.toughness = "";
this.loyalty = "";
this.startingLoyalty = "";
this.defense = "";
this.startingDefense = "";
this.cardTypes = new ArrayList<>();
this.subTypes = new SubTypes();
this.superTypes = EnumSet.noneOf(SuperType.class);
@ -800,6 +816,8 @@ public class CardView extends SimpleCardView {
this.toughness = token.getToughness().toString();
this.loyalty = "";
this.startingLoyalty = "";
this.defense = "";
this.startingDefense = "";
this.cardTypes = new ArrayList<>(token.getCardType(game));
this.subTypes = new SubTypes(token.getSubtype(game));
this.superTypes = token.getSuperType();
@ -891,6 +909,14 @@ public class CardView extends SimpleCardView {
return startingLoyalty;
}
public String getDefense() {
return defense;
}
public String getStartingDefense() {
return startingDefense;
}
public List<CardType> getCardTypes() {
return cardTypes;
}
@ -1147,10 +1173,14 @@ public class CardView extends SimpleCardView {
return cardTypes.contains(CardType.CREATURE);
}
public boolean isPlanesWalker() {
public boolean isPlaneswalker() {
return cardTypes.contains(CardType.PLANESWALKER);
}
public boolean isBattle() {
return cardTypes.contains(CardType.BATTLE);
}
public String getColorText() {
String colorText = getColor().getDescription();
return colorText.substring(0, 1).toUpperCase(Locale.ENGLISH) + colorText.substring(1);