mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Refactor: fixed getRules usage, clean SplitCard code
This commit is contained in:
parent
8f748b0f2c
commit
914cfc1d3a
9 changed files with 70 additions and 51 deletions
|
|
@ -118,13 +118,7 @@ public abstract class CardRenderer {
|
|||
public CardRenderer(CardView card) {
|
||||
// Set base parameters
|
||||
this.cardView = card;
|
||||
|
||||
if (card.getArtRect() == ArtRect.SPLIT_FUSED) {
|
||||
parseRules(card.getLeftSplitRules(), textboxKeywords, textboxRules);
|
||||
parseRules(card.getRightSplitRules(), textboxKeywords, textboxRules);
|
||||
} else {
|
||||
parseRules(card.getRules(), textboxKeywords, textboxRules);
|
||||
}
|
||||
parseRules(card.getRules(), textboxKeywords, textboxRules);
|
||||
}
|
||||
|
||||
protected void parseRules(List<String> stringRules, List<TextboxRule> keywords, List<TextboxRule> rules) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.mage.card.arcane;
|
|||
|
||||
import mage.ObjectColor;
|
||||
import mage.cards.ArtRect;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.CardType;
|
||||
import mage.view.CardView;
|
||||
|
||||
|
|
@ -17,6 +18,9 @@ import java.util.List;
|
|||
*/
|
||||
public class ModernSplitCardRenderer extends ModernCardRenderer {
|
||||
|
||||
static String RULES_MARK_FUSE = "Fuse";
|
||||
static String RULES_MARK_AFTERMATH = "Aftermath";
|
||||
|
||||
private static class HalfCardProps {
|
||||
|
||||
int x, y, w, h, cw, ch;
|
||||
|
|
@ -61,8 +65,8 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
rightHalf.name = cardView.getRightSplitName();
|
||||
leftHalf.name = cardView.getLeftSplitName();
|
||||
|
||||
isFuse = view.getRules().stream().anyMatch(rule -> rule.contains("Fuse"));
|
||||
isAftermath = view.getRightSplitRules().stream().anyMatch(rule -> rule.contains("Aftermath"));
|
||||
isFuse = view.getRules().stream().anyMatch(rule -> rule.contains(RULES_MARK_FUSE));
|
||||
isAftermath = view.getRightSplitRules().stream().anyMatch(rule -> rule.contains(RULES_MARK_AFTERMATH));
|
||||
|
||||
// It's easier for rendering to swap the card halves here because for aftermath cards
|
||||
// they "rotate" in opposite directions making consquence and normal split cards
|
||||
|
|
@ -298,7 +302,7 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
totalFuseBoxWidth, boxHeight,
|
||||
contentInset,
|
||||
borderPaint, boxColor);
|
||||
drawNameLine(g2, attribs, "Fuse (You may cast both halves from your hand)", "",
|
||||
drawNameLine(g2, attribs, SplitCard.FUSE_RULE, "",
|
||||
0, rightHalf.ch,
|
||||
totalFuseBoxWidth - 2 * borderWidth, boxHeight);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue