mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
CardDetailPanel - text composition moved to a separate method
a method to determine if a player may see cards cntrolld by other player
This commit is contained in:
@@ -173,20 +173,17 @@ public class CardDetailPanel extends FPanel implements CardContainer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean faceDown = card.isFaceDown() && (card.getController() != Singletons.getControl().getPlayer());
|
final boolean canShowThis = canShowCard(card);
|
||||||
if (!faceDown) {
|
if (canShowThis) {
|
||||||
if (card.getManaCost().toString().equals("") || card.isLand()) {
|
if (card.getManaCost().toString().equals("") || card.isLand()) {
|
||||||
this.nameCostLabel.setText(card.getName());
|
this.nameCostLabel.setText(card.getName());
|
||||||
} else {
|
} else {
|
||||||
this.nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
this.nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
||||||
}
|
}
|
||||||
|
this.typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
||||||
|
this.setInfoLabel.setText(card.getCurSetCode());
|
||||||
} else {
|
} else {
|
||||||
this.nameCostLabel.setText("Morph");
|
this.nameCostLabel.setText("Morph");
|
||||||
}
|
|
||||||
|
|
||||||
if (!faceDown) {
|
|
||||||
this.typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
|
||||||
} else {
|
|
||||||
this.typeLabel.setText("Creature");
|
this.typeLabel.setText("Creature");
|
||||||
}
|
}
|
||||||
if (card.isCreature()) {
|
if (card.isCreature()) {
|
||||||
@@ -195,12 +192,6 @@ public class CardDetailPanel extends FPanel implements CardContainer {
|
|||||||
|
|
||||||
this.idLabel.setText("Card ID " + card.getUniqueNumber());
|
this.idLabel.setText("Card ID " + card.getUniqueNumber());
|
||||||
|
|
||||||
// rarity and set of a face down card should not be visible to the
|
|
||||||
// opponent
|
|
||||||
if (!card.isFaceDown() || card.getController().isHuman()) {
|
|
||||||
this.setInfoLabel.setText(card.getCurSetCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.setInfoLabel.getText().equals("")) {
|
if (!this.setInfoLabel.getText().equals("")) {
|
||||||
this.setInfoLabel.setOpaque(true);
|
this.setInfoLabel.setOpaque(true);
|
||||||
final String csr = card.getCurSetRarity();
|
final String csr = card.getCurSetRarity();
|
||||||
@@ -231,6 +222,22 @@ public class CardDetailPanel extends FPanel implements CardContainer {
|
|||||||
|
|
||||||
// fill the card text
|
// fill the card text
|
||||||
|
|
||||||
|
this.cdArea.setText(composeCardText(card, canShowThis));
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
scrArea.getVerticalScrollBar().setValue(scrArea.getVerticalScrollBar().getMinimum());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// here be checks for card owner and possibility to show to human Player watching this panel
|
||||||
|
private boolean canShowCard(final Card card) {
|
||||||
|
return !card.isFaceDown() && card.getController() == Singletons.getControl().getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String composeCardText(final Card card, final boolean canShow) {
|
||||||
final StringBuilder area = new StringBuilder();
|
final StringBuilder area = new StringBuilder();
|
||||||
|
|
||||||
// Token
|
// Token
|
||||||
@@ -238,7 +245,7 @@ public class CardDetailPanel extends FPanel implements CardContainer {
|
|||||||
area.append("Token");
|
area.append("Token");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!faceDown) {
|
if (canShow) {
|
||||||
// card text
|
// card text
|
||||||
if (area.length() != 0) {
|
if (area.length() != 0) {
|
||||||
area.append("\n");
|
area.append("\n");
|
||||||
@@ -410,7 +417,7 @@ public class CardDetailPanel extends FPanel implements CardContainer {
|
|||||||
|
|
||||||
if (entity instanceof Card) {
|
if (entity instanceof Card) {
|
||||||
final Card c = (Card) entity;
|
final Card c = (Card) entity;
|
||||||
if (c.isFaceDown() && c.getController().isComputer()) {
|
if (!canShowCard(c)) {
|
||||||
area.append("Morph (");
|
area.append("Morph (");
|
||||||
area.append(card.getUniqueNumber());
|
area.append(card.getUniqueNumber());
|
||||||
area.append(")");
|
area.append(")");
|
||||||
@@ -485,15 +492,7 @@ public class CardDetailPanel extends FPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
area.append("Must block an attacker");
|
area.append("Must block an attacker");
|
||||||
}
|
}
|
||||||
|
return area.toString();
|
||||||
this.cdArea.setText(area.toString());
|
|
||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
scrArea.getVerticalScrollBar().setValue(scrArea.getVerticalScrollBar().getMinimum());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user