Merge remote-tracking branch 'magefree/master'

This commit is contained in:
Samuel Sandeen 2016-09-03 08:44:43 -04:00
commit 277dc19fec
149 changed files with 6582 additions and 1231 deletions

View file

@ -277,6 +277,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
try {
UIManager.put("desktop", new Color(0, 0, 0, 0));
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// stop JSplitPane from eating F6 and F8 or any other function keys
{
Object value = UIManager.get("SplitPane.ancestorInputMap");

View file

@ -92,6 +92,7 @@ import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import mage.view.StackAbilityView;
import org.apache.log4j.Logger;
/**
*
@ -191,7 +192,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.frameWidth, Config.dimensions.frameHeight), 0, 0, this);
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
gImage.drawString(card.getName(), CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
if (card.getCardTypes().contains(CardType.CREATURE)) {
gImage.drawString(card.getPower() + "/" + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
@ -205,9 +206,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.dispose();
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.nameFontSize));
gSmall.drawString(card.getName(), Config.dimensions.contentXOffset, Config.dimensions.nameYOffset);
gSmall.drawString(card.getName()+"TEST2", Config.dimensions.contentXOffset, Config.dimensions.nameYOffset);
if (card.getCardTypes().contains(CardType.CREATURE)) {
gSmall.drawString(card.getPower() + "/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
}
@ -221,7 +222,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
}
@Override
public void updateImage() {
public void updateArtImage() {
}
@ -318,6 +319,19 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
return sbType.toString();
}
protected void drawDetailed(Graphics2D g) {
// Get the size of the card
int width = getWidth();
int height = getHeight();
g.setColor(Color.black);
g.drawRoundRect(0, 0, width, height, 4, 4);
g.setColor(Color.white);
g.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
g.drawString(card.getName(), 0, 0);
Logger.getLogger(Card.class).info("Drawing");
}
/**
* This method is called from within the constructor to initialize the form.
@ -355,6 +369,8 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override
public void paintComponent(Graphics graphics) {
drawDetailed((Graphics2D)graphics);
/*
Graphics2D g2 = (Graphics2D) graphics;
g2.drawImage(small, 0, 0, this);
@ -365,6 +381,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
g2.setColor(Color.BLACK);
}
g2.drawRect(0, 0, Config.dimensions.frameWidth - 1, Config.dimensions.frameHeight - 1);
*/
}
@Override

View file

@ -114,7 +114,7 @@ public class Cards extends javax.swing.JPanel {
setGUISize();
for (MageCard mageCard : cards.values()) {
mageCard.setCardBounds(0, 0, getCardDimension().width, getCardDimension().height);
mageCard.updateImage();
mageCard.updateArtImage();
mageCard.doLayout();
}
layoutCards();

View file

@ -34,21 +34,16 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelControl" pref="703" max="32767" attributes="0"/>
<Component id="panelCardArea" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="panelControl" alignment="0" pref="467" max="32767" attributes="0"/>
<Component id="panelCardArea" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="panelControl" min="-2" pref="25" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="panelCardArea" pref="86" max="32767" attributes="0"/>
<Component id="panelControl" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="panelCardArea" pref="179" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -81,15 +76,7 @@
<Component id="lblLandCount" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblCreatureCount" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblSorceryCount" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblInstantCount" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblEnchantmentCount" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="lblArtifactCount" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="chkPiles" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="cbSortBy" min="-2" max="-2" attributes="0"/>
@ -97,7 +84,7 @@
<Component id="jToggleListView" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jToggleCardView" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="62" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -109,11 +96,7 @@
<Component id="lblCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblLandCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblCreatureCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblSorceryCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblInstantCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblEnchantmentCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkPiles" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblArtifactCount" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="cbSortBy" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jToggleListView" min="-2" max="-2" attributes="0"/>
@ -177,60 +160,6 @@
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblSorceryCount">
<Properties>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/type_sorcery.png"/>
</Property>
<Property name="text" type="java.lang.String" value="999"/>
<Property name="toolTipText" type="java.lang.String" value="Number of sorceries."/>
<Property name="verticalAlignment" type="int" value="1"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblInstantCount">
<Properties>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/type_instant.png"/>
</Property>
<Property name="text" type="java.lang.String" value="999"/>
<Property name="toolTipText" type="java.lang.String" value="Number of instants."/>
<Property name="verticalAlignment" type="int" value="1"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblEnchantmentCount">
<Properties>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/type_enchantment.png"/>
</Property>
<Property name="text" type="java.lang.String" value="999"/>
<Property name="toolTipText" type="java.lang.String" value="Number of enchantments."/>
<Property name="verticalAlignment" type="int" value="1"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="chkPiles">
<Properties>
<Property name="text" type="java.lang.String" value="Piles"/>
@ -324,24 +253,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleCardViewActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblArtifactCount">
<Properties>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/type_artifact.png"/>
</Property>
<Property name="text" type="java.lang.String" value="999"/>
<Property name="toolTipText" type="java.lang.String" value="Number of artifacts"/>
<Property name="verticalAlignment" type="int" value="1"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="panelCardArea">

View file

@ -211,7 +211,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
}
});
mainModel.setUpdateCountsCallback(new UpdateCountsCallback(lblCount, lblCreatureCount, lblLandCount, lblSorceryCount, lblInstantCount, lblEnchantmentCount, lblArtifactCount));
mainModel.setUpdateCountsCallback(new UpdateCountsCallback(lblCount, lblCreatureCount, lblLandCount, null, null, null, null));
}
// if you use the deck ediot to build a free deck, numbers can be set directly in deck and sideboard
@ -418,10 +418,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
this.lblCount.setText(Integer.toString(count));
this.lblCreatureCount.setText(Integer.toString(creatureCount));
this.lblLandCount.setText(Integer.toString(landCount));
this.lblSorceryCount.setText(Integer.toString(sorceryCount));
this.lblInstantCount.setText(Integer.toString(instantCount));
this.lblEnchantmentCount.setText(Integer.toString(enchantmentCount));
this.lblArtifactCount.setText(Integer.toString(artifactCount));
}
private MageCard addCard(CardView card, BigCard bigCard, UUID gameId) {
@ -482,14 +478,10 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
lblCount = new javax.swing.JLabel();
lblLandCount = new javax.swing.JLabel();
lblCreatureCount = new javax.swing.JLabel();
lblSorceryCount = new javax.swing.JLabel();
lblInstantCount = new javax.swing.JLabel();
lblEnchantmentCount = new javax.swing.JLabel();
chkPiles = new javax.swing.JCheckBox();
cbSortBy = new javax.swing.JComboBox();
jToggleListView = new javax.swing.JToggleButton();
jToggleCardView = new javax.swing.JToggleButton();
lblArtifactCount = new javax.swing.JLabel();
panelCardArea = new javax.swing.JScrollPane();
cardArea = new javax.swing.JLayeredPane();
@ -537,39 +529,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
lblCreatureCount.setRequestFocusEnabled(false);
lblCreatureCount.setVerifyInputWhenFocusTarget(false);
lblSorceryCount.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
lblSorceryCount.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_sorcery.png"))); // NOI18N
lblSorceryCount.setText("999");
lblSorceryCount.setToolTipText("Number of sorceries.");
lblSorceryCount.setVerticalAlignment(javax.swing.SwingConstants.TOP);
lblSorceryCount.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
lblSorceryCount.setFocusable(false);
lblSorceryCount.setInheritsPopupMenu(false);
lblSorceryCount.setRequestFocusEnabled(false);
lblSorceryCount.setVerifyInputWhenFocusTarget(false);
lblInstantCount.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
lblInstantCount.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_instant.png"))); // NOI18N
lblInstantCount.setText("999");
lblInstantCount.setToolTipText("Number of instants.");
lblInstantCount.setVerticalAlignment(javax.swing.SwingConstants.TOP);
lblInstantCount.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
lblInstantCount.setFocusable(false);
lblInstantCount.setInheritsPopupMenu(false);
lblInstantCount.setRequestFocusEnabled(false);
lblInstantCount.setVerifyInputWhenFocusTarget(false);
lblEnchantmentCount.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
lblEnchantmentCount.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_enchantment.png"))); // NOI18N
lblEnchantmentCount.setText("999");
lblEnchantmentCount.setToolTipText("Number of enchantments.");
lblEnchantmentCount.setVerticalAlignment(javax.swing.SwingConstants.TOP);
lblEnchantmentCount.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
lblEnchantmentCount.setFocusable(false);
lblEnchantmentCount.setInheritsPopupMenu(false);
lblEnchantmentCount.setRequestFocusEnabled(false);
lblEnchantmentCount.setVerifyInputWhenFocusTarget(false);
chkPiles.setText("Piles");
chkPiles.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
chkPiles.setMargin(new java.awt.Insets(3, 2, 2, 2));
@ -619,17 +578,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
}
});
lblArtifactCount.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
lblArtifactCount.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_artifact.png"))); // NOI18N
lblArtifactCount.setText("999");
lblArtifactCount.setToolTipText("Number of artifacts");
lblArtifactCount.setVerticalAlignment(javax.swing.SwingConstants.TOP);
lblArtifactCount.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
lblArtifactCount.setFocusable(false);
lblArtifactCount.setInheritsPopupMenu(false);
lblArtifactCount.setRequestFocusEnabled(false);
lblArtifactCount.setVerifyInputWhenFocusTarget(false);
javax.swing.GroupLayout panelControlLayout = new javax.swing.GroupLayout(panelControl);
panelControl.setLayout(panelControlLayout);
panelControlLayout.setHorizontalGroup(
@ -641,14 +589,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblCreatureCount)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblSorceryCount)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblInstantCount)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblEnchantmentCount)
.addGap(4, 4, 4)
.addComponent(lblArtifactCount)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkPiles)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
@ -656,7 +596,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
.addComponent(jToggleListView, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jToggleCardView, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 62, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelControlLayout.setVerticalGroup(
panelControlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -666,11 +606,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
.addComponent(lblCount)
.addComponent(lblLandCount)
.addComponent(lblCreatureCount)
.addComponent(lblSorceryCount)
.addComponent(lblInstantCount)
.addComponent(lblEnchantmentCount)
.addComponent(chkPiles)
.addComponent(lblArtifactCount))
.addComponent(chkPiles))
.addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jToggleListView, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jToggleCardView, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@ -686,21 +622,27 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelControl, javax.swing.GroupLayout.DEFAULT_SIZE, 703, Short.MAX_VALUE)
.addComponent(panelCardArea)))
.addComponent(panelControl, javax.swing.GroupLayout.PREFERRED_SIZE, 467, Short.MAX_VALUE)
.addComponent(panelCardArea)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(panelControl, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(panelCardArea, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE))
.addComponent(panelControl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addComponent(panelCardArea, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
currentView = this;
panelCardArea.setViewportView(cardArea);
cbSortBy.setEnabled(true);
chkPiles.setEnabled(true);
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_VIEW, "cardView");
redrawCards();
}//GEN-LAST:event_jToggleCardViewActionPerformed
private void jToggleListViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleListViewActionPerformed
currentView = mainModel;
panelCardArea.setViewportView(mainTable);
@ -720,15 +662,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
drawCards(sortSetting);
}//GEN-LAST:event_chkPilesActionPerformed
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
currentView = this;
panelCardArea.setViewportView(cardArea);
cbSortBy.setEnabled(true);
chkPiles.setEnabled(true);
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_VIEW, "cardView");
redrawCards();
}//GEN-LAST:event_jToggleCardViewActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup bgView;
private javax.swing.JLayeredPane cardArea;
@ -736,13 +669,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
private javax.swing.JCheckBox chkPiles;
private javax.swing.JToggleButton jToggleCardView;
private javax.swing.JToggleButton jToggleListView;
private javax.swing.JLabel lblArtifactCount;
private javax.swing.JLabel lblCount;
private javax.swing.JLabel lblCreatureCount;
private javax.swing.JLabel lblEnchantmentCount;
private javax.swing.JLabel lblInstantCount;
private javax.swing.JLabel lblLandCount;
private javax.swing.JLabel lblSorceryCount;
private javax.swing.JScrollPane panelCardArea;
private javax.swing.JPanel panelControl;
// End of variables declaration//GEN-END:variables

View file

@ -16,31 +16,26 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="deckAreaSplitPane" alignment="0" pref="740" max="32767" attributes="0"/>
<Component id="deckAreaSplitPane" alignment="0" pref="918" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="deckAreaSplitPane" alignment="0" pref="568" max="32767" attributes="0"/>
<Component id="deckAreaSplitPane" alignment="0" pref="377" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="deckAreaSplitPane">
<Properties>
<Property name="orientation" type="int" value="0"/>
<Property name="resizeWeight" type="double" value="0.8"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="resizeWeight" type="double" value="0.6"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Component class="mage.client.cards.CardsList" name="deckList">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
</Component>
<Component class="mage.client.cards.CardsList" name="sideboardList">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
@ -48,6 +43,13 @@
</Constraint>
</Constraints>
</Component>
<Component class="mage.client.cards.CardsList" name="deckList">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>

View file

@ -118,23 +118,23 @@ public class DeckArea extends javax.swing.JPanel {
private void initComponents() {
deckAreaSplitPane = new javax.swing.JSplitPane();
deckList = new mage.client.cards.CardsList();
sideboardList = new mage.client.cards.CardsList();
deckList = new mage.client.cards.CardsList();
deckAreaSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
deckAreaSplitPane.setResizeWeight(0.8);
deckAreaSplitPane.setLeftComponent(deckList);
deckAreaSplitPane.setBorder(null);
deckAreaSplitPane.setResizeWeight(0.6);
deckAreaSplitPane.setRightComponent(sideboardList);
deckAreaSplitPane.setLeftComponent(deckList);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(deckAreaSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 740, Short.MAX_VALUE)
.addComponent(deckAreaSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 918, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(deckAreaSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
.addComponent(deckAreaSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents

View file

@ -11,7 +11,7 @@ public class UpdateCountsCallback {
private final javax.swing.JLabel lblCount;
private final javax.swing.JLabel lblCreatureCount;
private final javax.swing.JLabel lblLandCount;
private final javax.swing.JLabel lblSoerceryCount;
private final javax.swing.JLabel lblSorceryCount;
private final javax.swing.JLabel lblInstantCount;
private final javax.swing.JLabel lblEnchantmentCount;
private final javax.swing.JLabel lblArtifactCount;
@ -20,19 +20,26 @@ public class UpdateCountsCallback {
this.lblCount = count;
this.lblCreatureCount = creatures;
this.lblLandCount = lands;
this.lblSoerceryCount = sorceries;
this.lblSorceryCount = sorceries;
this.lblInstantCount = instants;
this.lblEnchantmentCount = enchantments;
this.lblArtifactCount = artifacts;
}
public void update(int count, int creatures, int lands, int sorceries, int instants, int enchantments, int artifacts) {
this.lblCount.setText(Integer.toString(count));
this.lblCreatureCount.setText(Integer.toString(creatures));
this.lblLandCount.setText(Integer.toString(lands));
this.lblSoerceryCount.setText(Integer.toString(sorceries));
this.lblInstantCount.setText(Integer.toString(instants));
this.lblEnchantmentCount.setText(Integer.toString(enchantments));
this.lblArtifactCount.setText(Integer.toString(artifacts));
if (this.lblCount != null)
this.lblCount.setText(Integer.toString(count));
if (this.lblCreatureCount != null)
this.lblCreatureCount.setText(Integer.toString(creatures));
if (this.lblLandCount != null)
this.lblLandCount.setText(Integer.toString(lands));
if (this.lblSorceryCount != null)
this.lblSorceryCount.setText(Integer.toString(sorceries));
if (this.lblInstantCount != null)
this.lblInstantCount.setText(Integer.toString(instants));
if (this.lblEnchantmentCount != null)
this.lblEnchantmentCount.setText(Integer.toString(enchantments));
if (this.lblArtifactCount != null)
this.lblArtifactCount.setText(Integer.toString(artifacts));
}
}

View file

@ -31,7 +31,11 @@
<Component id="exitButton" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="tabsPanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -146,7 +150,7 @@
<Property name="toolTipText" type="java.lang.String" value="Write the card&apos;s name on the card to make the card name more recognizable."/>
<Property name="actionCommand" type="java.lang.String" value=""/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Standardcursor"/>
<Color id="Default Cursor"/>
</Property>
</Properties>
<Events>
@ -3945,7 +3949,7 @@
<Component id="checkBoxEndTurnOthers" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="phases_stopSettings" pref="260" max="32767" attributes="0"/>
<Component id="phases_stopSettings" pref="266" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -4147,11 +4151,12 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelCardImages" alignment="0" max="32767" attributes="0"/>
<Component id="panelBackgroundImages" alignment="0" max="32767" attributes="0"/>
<Component id="panelCardImages" max="32767" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="panelBackgroundImages" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -4160,11 +4165,13 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelCardImages" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelBackgroundImages" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="90" max="32767" attributes="0"/>
<EmptySpace pref="53" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -4189,36 +4196,41 @@
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtImageFolderPath" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnBrowseImageLocation" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelNumberOfDownloadThreads" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbNumberOfDownloadThreads" min="-2" pref="153" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cbUseDefaultImageFolder" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="cbCheckForNewImages" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelPreferedImageLanguage" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Group type="102" attributes="0">
<Component id="cbCheckForNewImages" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="147" max="-2" attributes="0"/>
</Group>
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelPreferedImageLanguage" max="-2" attributes="0"/>
</Group>
<Component id="cbSaveToZipFiles" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="cbSaveToZipFiles" alignment="0" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="cbPreferedImageLanguage" min="-2" pref="153" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelNumberOfDownloadThreads" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbNumberOfDownloadThreads" min="-2" pref="153" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
<Component id="cbPreferedImageLanguage" min="-2" pref="153" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="cbUseDefaultImageFolder" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="251" max="32767" attributes="0"/>
<EmptySpace min="0" pref="231" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -4228,14 +4240,13 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="cbUseDefaultImageFolder" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtImageFolderPath" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnBrowseImageLocation" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="cbCheckForNewImages" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbSaveToZipFiles" min="-2" max="-2" attributes="0"/>
@ -4249,7 +4260,6 @@
<Component id="cbPreferedImageLanguage" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelPreferedImageLanguage" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="48" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -4473,6 +4483,72 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Card rendering:">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</TitledBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cbCardRenderImageFallback" min="-2" max="-2" attributes="0"/>
<Component id="cbCardRenderShowReminderText" min="-2" max="-2" attributes="0"/>
<Component id="cbCardRenderHideSetSymbol" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="cbCardRenderImageFallback" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbCardRenderShowReminderText" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbCardRenderHideSetSymbol" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="cbCardRenderImageFallback">
<Properties>
<Property name="text" type="java.lang.String" value="Fall back to plain image based rendering"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbCardRenderImageFallbackActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbCardRenderShowReminderText">
<Properties>
<Property name="text" type="java.lang.String" value="Show reminder text in rendered card textboxes"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbCardRenderShowReminderTextActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbCardRenderHideSetSymbol">
<Properties>
<Property name="text" type="java.lang.String" value="Hide set symbols on cards (more space on the type line for card types)"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbCardRenderHideSetSymbolActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="tabSounds">
@ -5579,7 +5655,7 @@
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="111" max="32767" attributes="0"/>
<EmptySpace pref="91" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View file

@ -118,6 +118,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_CARD_IMAGES_SAVE_TO_ZIP = "cardImagesSaveToZip";
public static final String KEY_CARD_IMAGES_PREF_LANGUAGE = "cardImagesPreferedImageLaguage";
public static final String KEY_CARD_RENDERING_FALLBACK = "cardRenderingFallback";
public static final String KEY_CARD_RENDERING_REMINDER_TEXT = "cardRenderingReminderText";
public static final String KEY_CARD_RENDERING_SET_SYMBOL = "cardRenderingSetSymbol";
public static final String KEY_BACKGROUND_IMAGE = "backgroundImage";
public static final String KEY_BATTLEFIELD_IMAGE = "battlefieldImage";
public static final String KEY_BACKGROUND_IMAGE_DEFAULT = "backgroundImagedDefault";
@ -464,6 +468,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
cbUseRandomBattleImage = new javax.swing.JCheckBox();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
cbCardRenderImageFallback = new javax.swing.JCheckBox();
cbCardRenderShowReminderText = new javax.swing.JCheckBox();
cbCardRenderHideSetSymbol = new javax.swing.JCheckBox();
tabSounds = new javax.swing.JPanel();
sounds_clips = new javax.swing.JPanel();
cbEnableGameSounds = new javax.swing.JCheckBox();
@ -1385,7 +1393,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(jLabelEndOfTurn)
.add(checkBoxEndTurnOthers))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(phases_stopSettings, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
.add(phases_stopSettings, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
.addContainerGap())
);
@ -1439,41 +1447,43 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(panelCardImagesLayout.createSequentialGroup()
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(panelCardImagesLayout.createSequentialGroup()
.add(24, 24, 24)
.addContainerGap()
.add(txtImageFolderPath)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(btnBrowseImageLocation))
.add(panelCardImagesLayout.createSequentialGroup()
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, panelCardImagesLayout.createSequentialGroup()
.addContainerGap()
.add(labelNumberOfDownloadThreads)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbNumberOfDownloadThreads, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(cbUseDefaultImageFolder)
.add(cbCheckForNewImages)
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(panelCardImagesLayout.createSequentialGroup()
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, panelCardImagesLayout.createSequentialGroup()
.addContainerGap()
.add(labelPreferedImageLanguage))
.add(org.jdesktop.layout.GroupLayout.LEADING, cbSaveToZipFiles))
.add(40, 40, 40)
.add(cbPreferedImageLanguage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(0, 251, Short.MAX_VALUE)))
.add(cbCheckForNewImages)
.add(147, 147, 147))
.add(org.jdesktop.layout.GroupLayout.LEADING, panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(panelCardImagesLayout.createSequentialGroup()
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, panelCardImagesLayout.createSequentialGroup()
.addContainerGap()
.add(labelPreferedImageLanguage))
.add(org.jdesktop.layout.GroupLayout.LEADING, cbSaveToZipFiles))
.add(20, 20, 20)
.add(cbPreferedImageLanguage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(panelCardImagesLayout.createSequentialGroup()
.addContainerGap()
.add(labelNumberOfDownloadThreads)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbNumberOfDownloadThreads, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(cbUseDefaultImageFolder))
.add(0, 231, Short.MAX_VALUE)))
.addContainerGap())
);
panelCardImagesLayout.setVerticalGroup(
panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(panelCardImagesLayout.createSequentialGroup()
.addContainerGap()
.add(cbUseDefaultImageFolder)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(txtImageFolderPath, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(btnBrowseImageLocation))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(cbCheckForNewImages)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbSaveToZipFiles)
@ -1484,8 +1494,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(cbPreferedImageLanguage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(labelPreferedImageLanguage))
.addContainerGap(48, Short.MAX_VALUE))
.add(labelPreferedImageLanguage)))
);
panelBackgroundImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Background images setting:"));
@ -1592,6 +1601,51 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(jLabel15)))
);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card rendering:"));
cbCardRenderImageFallback.setText("Fall back to plain image based rendering");
cbCardRenderImageFallback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCardRenderImageFallbackActionPerformed(evt);
}
});
cbCardRenderShowReminderText.setText("Show reminder text in rendered card textboxes");
cbCardRenderShowReminderText.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCardRenderShowReminderTextActionPerformed(evt);
}
});
cbCardRenderHideSetSymbol.setText("Hide set symbols on cards (more space on the type line for card types)");
cbCardRenderHideSetSymbol.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCardRenderHideSetSymbolActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(cbCardRenderImageFallback)
.add(cbCardRenderShowReminderText)
.add(cbCardRenderHideSetSymbol))
.add(0, 0, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(cbCardRenderImageFallback)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbCardRenderShowReminderText)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbCardRenderHideSetSymbol)
.add(0, 0, Short.MAX_VALUE))
);
org.jdesktop.layout.GroupLayout tabImagesLayout = new org.jdesktop.layout.GroupLayout(tabImages);
tabImages.setLayout(tabImagesLayout);
tabImagesLayout.setHorizontalGroup(
@ -1600,6 +1654,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addContainerGap()
.add(tabImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(panelCardImages, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(panelBackgroundImages, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
@ -1607,10 +1662,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(tabImagesLayout.createSequentialGroup()
.addContainerGap()
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(panelCardImages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(panelBackgroundImages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(90, Short.MAX_VALUE))
.addContainerGap(53, Short.MAX_VALUE))
);
tabsPanel.addTab("Images", tabImages);
@ -2220,7 +2277,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(connection_serversLayout.createSequentialGroup()
.add(141, 141, 141)
.add(jLabel17)))
.addContainerGap(111, Short.MAX_VALUE))
.addContainerGap(91, Short.MAX_VALUE))
);
connection_serversLayout.setVerticalGroup(
connection_serversLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -2406,7 +2463,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(exitButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(6, 6, 6))
.add(tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.add(tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -2534,6 +2594,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.cbUseDefaultBattleImage, KEY_BATTLEFIELD_IMAGE_DEFAULT, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbUseRandomBattleImage, KEY_BATTLEFIELD_IMAGE_RANDOM, "true", "false", UPDATE_CACHE_POLICY);
// rendering
save(prefs, dialog.cbCardRenderImageFallback, KEY_CARD_RENDERING_FALLBACK, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbCardRenderHideSetSymbol, KEY_CARD_RENDERING_SET_SYMBOL, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbCardRenderShowReminderText, KEY_CARD_RENDERING_REMINDER_TEXT, "true", "false", UPDATE_CACHE_POLICY);
// sounds
save(prefs, dialog.cbEnableGameSounds, KEY_SOUNDS_GAME_ON, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbEnableDraftSounds, KEY_SOUNDS_DRAFT_ON, "true", "false", UPDATE_CACHE_POLICY);
@ -2806,6 +2871,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
// TODO add your handling code here:
}//GEN-LAST:event_cbAutoOrderTriggerActionPerformed
private void cbCardRenderImageFallbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCardRenderImageFallbackActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbCardRenderImageFallbackActionPerformed
private void cbCardRenderShowReminderTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCardRenderShowReminderTextActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbCardRenderShowReminderTextActionPerformed
private void cbSaveToZipFilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSaveToZipFilesActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbSaveToZipFilesActionPerformed
@ -2831,6 +2904,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
}//GEN-LAST:event_cbUseDefaultImageFolderActionPerformed
private void cbCardRenderHideSetSymbolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCardRenderHideSetSymbolActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbCardRenderHideSetSymbolActionPerformed
private void showProxySettings() {
Connection.ProxyType proxyType = (Connection.ProxyType) cbProxyType.getSelectedItem();
switch (proxyType) {
@ -3004,6 +3081,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
dialog.cbNumberOfDownloadThreads.setSelectedItem(MageFrame.getPreferences().get(KEY_CARD_IMAGES_THREADS, "10"));
dialog.cbPreferedImageLanguage.setSelectedItem(MageFrame.getPreferences().get(KEY_CARD_IMAGES_PREF_LANGUAGE, "en"));
// rendering settings
load(prefs, dialog.cbCardRenderImageFallback, KEY_CARD_RENDERING_FALLBACK, "true");
load(prefs, dialog.cbCardRenderHideSetSymbol, KEY_CARD_RENDERING_SET_SYMBOL, "true");
load(prefs, dialog.cbCardRenderShowReminderText, KEY_CARD_RENDERING_REMINDER_TEXT, "true");
//add background load precedure
prop = prefs.get(KEY_BACKGROUND_IMAGE_DEFAULT, "true");
if (prop.equals("true")) {
@ -3384,6 +3466,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JCheckBox cbAllowRequestToShowHandCards;
private javax.swing.JCheckBox cbAskMoveToGraveOrder;
private javax.swing.JCheckBox cbAutoOrderTrigger;
private javax.swing.JCheckBox cbCardRenderHideSetSymbol;
private javax.swing.JCheckBox cbCardRenderImageFallback;
private javax.swing.JCheckBox cbCardRenderShowReminderText;
private javax.swing.JCheckBox cbCheckForNewImages;
private javax.swing.JCheckBox cbConfirmEmptyManaPool;
private javax.swing.JCheckBox cbDraftLogAutoSave;
@ -3443,6 +3528,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JLabel jLabelOpponentsTurn;
private javax.swing.JLabel jLabelUpkeep;
private javax.swing.JLabel jLabelYourTurn;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel10;
private javax.swing.JPanel jPanel11;
private javax.swing.JPanel jPanel12;

View file

@ -159,7 +159,7 @@ public abstract class Animation {
public static void transformCard(final CardPanel panel, final MagePermanent parent, final boolean transformed) {
new Animation(1200) {
new Animation(600) {
private boolean state = false;
@Override
@ -256,7 +256,7 @@ public abstract class Animation {
public void run() {
if (placeholder != null) {
placeholder.setDisplayEnabled(true);
placeholder.setImage(animationPanel);
placeholder.transferResources(animationPanel);
}
animationPanel.setVisible(false);
animationPanel.repaint();
@ -303,7 +303,7 @@ public abstract class Animation {
public void run() {
if (placeholder != null) {
placeholder.setDisplayEnabled(true);
placeholder.setImage(animationPanel);
placeholder.transferResources(animationPanel);
}
animationPanel.setVisible(false);
animationPanel.repaint();

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
/**
* @author stravant@gmail.com
* Attributes of a card panel outside of the CardView itself that the renderer
* needs to know in order to render a card.
*/
public class CardPanelAttributes {
public final int cardWidth;
public final int cardHeight;
public final boolean isSelected;
public final boolean isChoosable;
public CardPanelAttributes(int cardWidth, int cardHeight, boolean isChoosable, boolean isSelected) {
this.cardWidth = cardWidth;
this.cardHeight = cardHeight;
this.isChoosable = isChoosable;
this.isSelected = isSelected;
}
}

View file

@ -0,0 +1,711 @@
package org.mage.card.arcane;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import mage.cards.action.ActionCallback;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.ImageCaches;
import mage.client.util.ImageHelper;
import mage.components.ImagePanel;
import mage.constants.AbilityType;
import mage.utils.CardUtil;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import mage.view.StackAbilityView;
import net.java.truevfs.access.TFile;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import static org.mage.plugins.card.constants.Constants.THUMBNAIL_SIZE_FULL;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.images.ImageCache;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
/**
* Class for drawing the mage card object by using a form based JComponent approach
*
* @author arcane, nantuko, noxx, stravant
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class CardPanelComponentImpl extends CardPanel {
private static final long serialVersionUID = -3272134219262184411L;
private static final Logger LOGGER = Logger.getLogger(CardPanelComponentImpl.class);
private static final int WIDTH_LIMIT = 90; // card width limit to create smaller counter
private static final float ROUNDED_CORNER_SIZE = 0.1f;
private static final float BLACK_BORDER_SIZE = 0.03f;
private static final int TEXT_GLOW_SIZE = 6;
private static final float TEXT_GLOW_INTENSITY = 3f;
public final ScaledImagePanel imagePanel;
public ImagePanel overlayPanel;
public JPanel iconPanel;
private JButton typeButton;
public JPanel counterPanel;
private JLabel loyaltyCounterLabel;
private JLabel plusCounterLabel;
private JLabel otherCounterLabel;
private JLabel minusCounterLabel;
private int loyaltyCounter;
private int plusCounter;
private int otherCounter;
private int minusCounter;
private int lastCardWidth;
private final GlowText titleText;
private final GlowText ptText;
private boolean hasImage = false;
private boolean displayTitleAnyway;
private final static Map<Key, BufferedImage> IMAGE_CACHE;
class Key {
final int width;
final int height;
final int cardWidth;
final int cardHeight;
final int cardXOffset;
final int cardYOffset;
final boolean hasImage;
final boolean isSelected;
final boolean isChoosable;
final boolean isPlayable;
final boolean canAttack;
public Key(int width, int height, int cardWidth, int cardHeight, int cardXOffset, int cardYOffset, boolean hasImage, boolean isSelected, boolean isChoosable, boolean isPlayable, boolean canAttack) {
this.width = width;
this.height = height;
this.cardWidth = cardWidth;
this.cardHeight = cardHeight;
this.cardXOffset = cardXOffset;
this.cardYOffset = cardYOffset;
this.hasImage = hasImage;
this.isSelected = isSelected;
this.isChoosable = isChoosable;
this.isPlayable = isPlayable;
this.canAttack = canAttack;
}
@Override
public int hashCode() {
int hash = 3;
hash = 19 * hash + this.width;
hash = 19 * hash + this.height;
hash = 19 * hash + this.cardWidth;
hash = 19 * hash + this.cardHeight;
hash = 19 * hash + this.cardXOffset;
hash = 19 * hash + this.cardYOffset;
hash = 19 * hash + (this.hasImage ? 1 : 0);
hash = 19 * hash + (this.isSelected ? 1 : 0);
hash = 19 * hash + (this.isChoosable ? 1 : 0);
hash = 19 * hash + (this.isPlayable ? 1 : 0);
hash = 19 * hash + (this.canAttack ? 1 : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Key other = (Key) obj;
if (this.width != other.width) {
return false;
}
if (this.height != other.height) {
return false;
}
if (this.cardWidth != other.cardWidth) {
return false;
}
if (this.cardHeight != other.cardHeight) {
return false;
}
if (this.cardXOffset != other.cardXOffset) {
return false;
}
if (this.cardYOffset != other.cardYOffset) {
return false;
}
if (this.hasImage != other.hasImage) {
return false;
}
if (this.isSelected != other.isSelected) {
return false;
}
if (this.isChoosable != other.isChoosable) {
return false;
}
if (this.isPlayable != other.isPlayable) {
return false;
}
if (this.canAttack != other.canAttack) {
return false;
}
return true;
}
}
static {
IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap(new Function<Key, BufferedImage>() {
@Override
public BufferedImage apply(Key key) {
return createImage(key);
}
}));
}
public CardPanelComponentImpl(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension) {
// Call to super
super(newGameCard, gameId, loadImage, callback, foil, dimension);
// Counter panel
if (!newGameCard.isAbility()) {
// panel to show counters on the card
counterPanel = new JPanel();
counterPanel.setLayout(null);
counterPanel.setOpaque(false);
add(counterPanel);
plusCounterLabel = new JLabel("");
plusCounterLabel.setToolTipText("+1/+1");
counterPanel.add(plusCounterLabel);
minusCounterLabel = new JLabel("");
minusCounterLabel.setToolTipText("-1/-1");
counterPanel.add(minusCounterLabel);
loyaltyCounterLabel = new JLabel("");
loyaltyCounterLabel.setToolTipText("loyalty");
counterPanel.add(loyaltyCounterLabel);
otherCounterLabel = new JLabel("");
counterPanel.add(otherCounterLabel);
counterPanel.setVisible(false);
}
// Ability icon
if (newGameCard.isAbility()) {
if (AbilityType.TRIGGERED.equals(newGameCard.getAbilityType())) {
setTypeIcon(ImageManagerImpl.getInstance().getTriggeredAbilityImage(), "Triggered Ability");
} else if (AbilityType.ACTIVATED.equals(newGameCard.getAbilityType())) {
setTypeIcon(ImageManagerImpl.getInstance().getActivatedAbilityImage(), "Activated Ability");
}
}
// Token icon
if (this.gameCard.isToken()) {
setTypeIcon(ImageManagerImpl.getInstance().getTokenIconImage(), "Token Permanent");
}
displayTitleAnyway = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_CARD_NAMES, "true").equals("true");
// Title Text
titleText = new GlowText();
setText(gameCard);
// int fontSize = (int) cardHeight / 11;
// titleText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
titleText.setForeground(Color.white);
titleText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY);
titleText.setWrap(true);
add(titleText);
// PT Text
ptText = new GlowText();
if (CardUtil.isCreature(gameCard)) {
ptText.setText(gameCard.getPower() + "/" + gameCard.getToughness());
} else if (CardUtil.isPlaneswalker(gameCard)) {
ptText.setText(gameCard.getLoyalty());
}
// ptText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
ptText.setForeground(Color.white);
ptText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY);
add(ptText);
// Sickness overlay
BufferedImage sickness = ImageManagerImpl.getInstance().getSicknessImage();
overlayPanel = new ImagePanel(sickness, ImagePanel.SCALED);
overlayPanel.setOpaque(false);
add(overlayPanel);
// Imagel panel
imagePanel = new ScaledImagePanel();
imagePanel.setBorder(BorderFactory.createLineBorder(Color.white));
add(imagePanel);
// Do we need to load?
if (loadImage) {
initialDraw();
} else {
// Nothing to do
}
}
private void setTypeIcon(BufferedImage bufferedImage, String toolTipText) {
iconPanel = new JPanel();
iconPanel.setLayout(null);
iconPanel.setOpaque(false);
add(iconPanel);
typeButton = new JButton("");
typeButton.setLocation(2, 2);
typeButton.setSize(25, 25);
iconPanel.setVisible(true);
typeButton.setIcon(new ImageIcon(bufferedImage));
if (toolTipText != null) {
typeButton.setToolTipText(toolTipText);
}
iconPanel.add(typeButton);
}
@Override
public void cleanUp() {
super.cleanUp();
this.counterPanel = null;
}
private void setText(CardView card) {
titleText.setText(!displayTitleAnyway && hasImage ? "" : card.getName());
}
private void setImage(BufferedImage srcImage) {
synchronized (imagePanel) {
if (srcImage != null) {
imagePanel.setImage(srcImage);
} else {
imagePanel.clearImage();
}
repaint();
}
doLayout();
}
@Override
public void transferResources(final CardPanel panelAbstract) {
if (panelAbstract instanceof CardPanelComponentImpl) {
CardPanelComponentImpl panel = (CardPanelComponentImpl)panelAbstract;
synchronized (panel.imagePanel) {
if (panel.imagePanel.hasImage()) {
setImage(panel.imagePanel.getSrcImage());
}
}
}
}
@Override
public void setSelected(boolean isSelected) {
super.setSelected(isSelected);
if (isSelected) {
this.titleText.setGlowColor(Color.green);
} else {
this.titleText.setGlowColor(Color.black);
}
}
@Override
protected void paintCard(Graphics2D g2d) {
float alpha = getAlpha();
if (alpha != 1.0f) {
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha);
g2d.setComposite(composite);
}
g2d.drawImage(
IMAGE_CACHE.get(
new Key(getWidth(), getHeight(), getCardWidth(), getCardHeight(), getCardXOffset(), getCardYOffset(),
hasImage, isSelected(), isChoosable(), gameCard.isPlayable(), gameCard.isCanAttack())),
0, 0, null);
g2d.dispose();
}
private static BufferedImage createImage(Key key) {
int cardWidth = key.cardWidth;
int cardHeight = key.cardHeight;
int cardXOffset = key.cardXOffset;
int cardYOffset = key.cardYOffset;
BufferedImage image = GraphicsUtilities.createCompatibleTranslucentImage(key.width, key.height);
Graphics2D g2d = image.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (!key.hasImage) {
g2d.setColor(new Color(30, 200, 200, 120));
} else {
g2d.setColor(new Color(0, 0, 0, 255));
}
int cornerSize = Math.max(4, Math.round(cardWidth * ROUNDED_CORNER_SIZE));
g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize);
if (key.isSelected) {
g2d.setColor(Color.green);
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
} else if (key.isChoosable) {
g2d.setColor(new Color(250, 250, 0, 230));
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
} else if (key.isPlayable) {
g2d.setColor(new Color(153, 102, 204, 200));
//g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize);
}
if (key.canAttack) {
g2d.setColor(new Color(0, 0, 255, 230));
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
}
//TODO:uncomment
/*
if (gameCard.isAttacking()) {
g2d.setColor(new Color(200,10,10,200));
g2d.fillRoundRect(cardXOffset+1, cardYOffset+1, cardWidth-2, cardHeight-2, cornerSize, cornerSize);
}*/
g2d.dispose();
return image;
}
@Override
protected void paintChildren(Graphics g) {
super.paintChildren(g);
if (getShowCastingCost() && !isAnimationPanel() && getCardWidth() < 200 && getCardWidth() > 60) {
String manaCost = ManaSymbols.getStringManaCost(gameCard.getManaCost());
int width = getWidth(manaCost);
if (hasImage) {
ManaSymbols.draw(g, manaCost, getCardXOffset() + getCardWidth() - width - 5, getCardYOffset() + 5, getSymbolWidth());
} else {
ManaSymbols.draw(g, manaCost, getCardXOffset() + 8, getCardHeight() - 9, getSymbolWidth());
}
}
}
private int getWidth(String manaCost) {
int width = 0;
manaCost = manaCost.replace("\\", "");
StringTokenizer tok = new StringTokenizer(manaCost, " ");
while (tok.hasMoreTokens()) {
tok.nextToken();
width += getSymbolWidth();
}
return width;
}
@Override
public void doLayout() {
super.doLayout();
int cardWidth = getCardWidth();
int cardHeight = getCardHeight();
int cardXOffset = getCardXOffset();
int cardYOffset = getCardYOffset();
int borderSize = Math.round(cardWidth * BLACK_BORDER_SIZE);
imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
if (hasSickness() && CardUtil.isCreature(gameCard) && isPermanent()) {
overlayPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
overlayPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
} else {
overlayPanel.setVisible(false);
}
if (iconPanel != null) {
iconPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
iconPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
}
if (counterPanel != null) {
counterPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
counterPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
int size = cardWidth > WIDTH_LIMIT ? 40 : 20;
minusCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size * 2);
minusCounterLabel.setSize(size, size);
plusCounterLabel.setLocation(5, counterPanel.getHeight() - size * 2);
plusCounterLabel.setSize(size, size);
loyaltyCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size);
loyaltyCounterLabel.setSize(size, size);
otherCounterLabel.setLocation(5, counterPanel.getHeight() - size);
otherCounterLabel.setSize(size, size);
}
int fontHeight = Math.round(cardHeight * (27f / 680));
boolean showText = (!isAnimationPanel() && fontHeight < 12);
titleText.setVisible(showText);
ptText.setVisible(showText);
if (showText) {
int fontSize = (int) cardHeight / 11;
titleText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
int titleX = Math.round(cardWidth * (20f / 480));
int titleY = Math.round(cardHeight * (9f / 680)) + getTextOffset();
titleText.setBounds(cardXOffset + titleX, cardYOffset + titleY, cardWidth - titleX, cardHeight - titleY);
ptText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
Dimension ptSize = ptText.getPreferredSize();
ptText.setSize(ptSize.width, ptSize.height);
int ptX = Math.round(cardWidth * (420f / 480)) - ptSize.width / 2;
int ptY = Math.round(cardHeight * (675f / 680)) - ptSize.height;
int offsetX = Math.round((CARD_SIZE_FULL.width - cardWidth) / 10.0f);
ptText.setLocation(cardXOffset + ptX - TEXT_GLOW_SIZE / 2 - offsetX, cardYOffset + ptY - TEXT_GLOW_SIZE / 2);
}
}
@Override
public String toString() {
return gameCard.toString();
}
@Override
public void setCardBounds(int x, int y, int cardWidth, int cardHeight) {
// Call to super
super.setCardBounds(x, y, cardWidth, cardHeight);
// Update image
if (imagePanel != null && imagePanel.getSrcImage() != null) {
updateArtImage();
}
}
@Override
public void setAlpha(float alpha) {
super.setAlpha(alpha);
// Update components
if (alpha == 0) {
this.ptText.setVisible(false);
this.titleText.setVisible(false);
} else if (alpha == 1.0f) {
this.ptText.setVisible(true);
this.titleText.setVisible(true);
}
}
///////////////////////////////////////////////////////////
// Image updating code
private int updateArtImageStamp;
@Override
public void updateArtImage() {
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
//final CardView gameCard = this.gameCard;
final int stamp = ++updateArtImageStamp;
Util.threadPool.submit(new Runnable() {
@Override
public void run() {
try {
final BufferedImage srcImage;
if (gameCard.isFaceDown()) {
srcImage = getFaceDownImage();
} else if (getCardWidth() > THUMBNAIL_SIZE_FULL.width) {
srcImage = ImageCache.getImage(gameCard, getCardWidth(), getCardHeight());
} else {
srcImage = ImageCache.getThumbnail(gameCard);
}
UI.invokeLater(new Runnable() {
@Override
public void run() {
if (stamp == updateArtImageStamp) {
hasImage = srcImage != null;
setText(gameCard);
setImage(srcImage);
}
}
});
} catch (Exception e) {
e.printStackTrace();
} catch (Error err) {
err.printStackTrace();
}
}
});
}
private BufferedImage getFaceDownImage() {
if (isPermanent()) {
if (((PermanentView) gameCard).isMorphed()) {
return ImageCache.getMorphImage();
} else {
return ImageCache.getManifestImage();
}
} else if (this.gameCard instanceof StackAbilityView) {
return ImageCache.getMorphImage();
} else {
return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
}
}
@Override
public void showCardTitle() {
displayTitleAnyway = true;
setText(gameCard);
}
@Override
public void update(CardView card) {
// Super
super.update(card);
// Update card text
if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) {
ptText.setText(card.getPower() + "/" + card.getToughness() + " (" + card.getLoyalty() + ")");
} else if (CardUtil.isCreature(card)) {
ptText.setText(card.getPower() + "/" + card.getToughness());
} else if (CardUtil.isPlaneswalker(card)) {
ptText.setText(card.getLoyalty());
} else {
ptText.setText("");
}
setText(card);
// Summoning Sickness overlay
if (hasSickness() && CardUtil.isCreature(gameCard) && isPermanent()) {
overlayPanel.setVisible(true);
} else {
overlayPanel.setVisible(false);
}
// Update counters panel
if (counterPanel != null) {
updateCounters(card);
}
// Finally, queue a repaint
repaint();
}
private void updateCounters(CardView card) {
if (card.getCounters() != null && !card.getCounters().isEmpty()) {
String name = "";
if (lastCardWidth != getCardWidth()) {
lastCardWidth = getCardWidth();
plusCounter = 0;
minusCounter = 0;
otherCounter = 0;
loyaltyCounter = 0;
}
plusCounterLabel.setVisible(false);
minusCounterLabel.setVisible(false);
loyaltyCounterLabel.setVisible(false);
otherCounterLabel.setVisible(false);
for (CounterView counterView : card.getCounters()) {
if (counterView.getCount() == 0) {
continue;
}
switch (counterView.getName()) {
case "+1/+1":
if (counterView.getCount() != plusCounter) {
plusCounter = counterView.getCount();
plusCounterLabel.setIcon(getCounterImageWithAmount(plusCounter, ImageManagerImpl.getInstance().getCounterImageGreen(), getCardWidth()));
}
plusCounterLabel.setVisible(true);
break;
case "-1/-1":
if (counterView.getCount() != minusCounter) {
minusCounter = counterView.getCount();
minusCounterLabel.setIcon(getCounterImageWithAmount(minusCounter, ImageManagerImpl.getInstance().getCounterImageRed(), getCardWidth()));
}
minusCounterLabel.setVisible(true);
break;
case "loyalty":
if (counterView.getCount() != loyaltyCounter) {
loyaltyCounter = counterView.getCount();
loyaltyCounterLabel.setIcon(getCounterImageWithAmount(loyaltyCounter, ImageManagerImpl.getInstance().getCounterImageViolet(), getCardWidth()));
}
loyaltyCounterLabel.setVisible(true);
break;
default:
if (name.isEmpty()) { // only first other counter is shown
name = counterView.getName();
otherCounter = counterView.getCount();
otherCounterLabel.setToolTipText(name);
otherCounterLabel.setIcon(getCounterImageWithAmount(otherCounter, ImageManagerImpl.getInstance().getCounterImageGrey(), getCardWidth()));
otherCounterLabel.setVisible(true);
}
}
}
counterPanel.setVisible(true);
} else {
plusCounterLabel.setVisible(false);
minusCounterLabel.setVisible(false);
loyaltyCounterLabel.setVisible(false);
otherCounterLabel.setVisible(false);
counterPanel.setVisible(false);
}
}
private static ImageIcon getCounterImageWithAmount(int amount, BufferedImage image, int cardWidth) {
int factor = cardWidth > WIDTH_LIMIT ? 2 : 1;
int xOffset = amount > 9 ? 2 : 5;
int fontSize = factor == 1 ? amount < 10 ? 12 : amount < 100 ? 10 : amount < 1000 ? 7 : 6
: amount < 10 ? 19 : amount < 100 ? 15 : amount < 1000 ? 12 : amount < 10000 ? 9 : 8;
BufferedImage newImage;
if (cardWidth > WIDTH_LIMIT) {
newImage = ImageManagerImpl.deepCopy(image);
} else {
newImage = ImageHelper.getResizedImage(image, 20, 20);
}
Graphics graphics = newImage.getGraphics();
graphics.setColor(Color.BLACK);
graphics.setFont(new Font("Arial Black", amount > 100 ? Font.PLAIN : Font.BOLD, fontSize));
graphics.drawString(Integer.toString(amount), xOffset * factor, 11 * factor);
return new ImageIcon(newImage);
}
@Override
public Image getImage() {
if (this.hasImage) {
if (gameCard.isFaceDown()) {
return getFaceDownImage();
} else {
return ImageCache.getImageOriginal(gameCard);
}
}
return null;
}
}

View file

@ -0,0 +1,397 @@
package org.mage.card.arcane;
import com.google.common.collect.MapMaker;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.UUID;
import mage.cards.action.ActionCallback;
import mage.constants.CardType;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import mage.view.StackAbilityView;
import net.java.truevfs.access.TFile;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import static org.mage.plugins.card.constants.Constants.THUMBNAIL_SIZE_FULL;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.images.ImageCache;
public class CardPanelRenderImpl extends CardPanel {
private static final Logger LOGGER = Logger.getLogger(CardPanelRenderImpl.class);
private static boolean cardViewEquals(CardView a, CardView b) {
if (a == b) {
return true;
}
if (a.getClass() != b.getClass()) {
return false;
}
if (!a.getName().equals(b.getName())) {
return false;
}
if (!a.getPower().equals(b.getPower())) {
return false;
}
if (!a.getToughness().equals(b.getToughness())) {
return false;
}
if (!a.getLoyalty().equals(b.getLoyalty())) {
return false;
}
if (0 != a.getColor().compareTo(b.getColor())) {
return false;
}
if (!a.getCardTypes().equals(b.getCardTypes())) {
return false;
}
if (!a.getSubTypes().equals(b.getSubTypes())) {
return false;
}
if (!a.getSuperTypes().equals(b.getSuperTypes())) {
return false;
}
if (!a.getManaCost().equals(b.getManaCost())) {
return false;
}
if (!a.getRules().equals(b.getRules())) {
return false;
}
if (!a.getExpansionSetCode().equals(b.getExpansionSetCode())) {
return false;
}
if (a.getCounters() == null) {
if (b.getCounters() != null) {
return false;
}
} else if (!a.getCounters().equals(b.getCounters())) {
return false;
}
if (a.isFaceDown() != b.isFaceDown()) {
return false;
}
if ((a instanceof PermanentView)) {
PermanentView aa = (PermanentView) a;
PermanentView bb = (PermanentView) b;
if (aa.hasSummoningSickness() != bb.hasSummoningSickness()) {
// Note: b must be a permanentview too as we aleady checked that classes
// are the same for a and b
return false;
}
if (aa.getDamage() != bb.getDamage()) {
return false;
}
}
return true;
}
class ImageKey {
final BufferedImage artImage;
final int width;
final int height;
final boolean isChoosable;
final boolean isSelected;
final CardView view;
final int hashCode;
public ImageKey(CardView view, BufferedImage artImage, int width, int height, boolean isChoosable, boolean isSelected) {
this.view = view;
this.artImage = artImage;
this.width = width;
this.height = height;
this.isChoosable = isChoosable;
this.isSelected = isSelected;
this.hashCode = hashCodeImpl();
}
private int hashCodeImpl() {
StringBuilder sb = new StringBuilder();
sb.append((char) (artImage != null ? 1 : 0));
sb.append((char) width);
sb.append((char) height);
sb.append((char) (isSelected ? 1 : 0));
sb.append((char) (isChoosable ? 1 : 0));
sb.append((char) (this.view.isPlayable() ? 1 : 0));
sb.append((char) (this.view.isCanAttack() ? 1 : 0));
sb.append((char) (this.view.isFaceDown() ? 1 : 0));
if (this.view instanceof PermanentView) {
sb.append((char) (((PermanentView) this.view).hasSummoningSickness() ? 1 : 0));
sb.append((char) (((PermanentView) this.view).getDamage()));
}
sb.append(this.view.getName());
sb.append(this.view.getPower());
sb.append(this.view.getToughness());
sb.append(this.view.getLoyalty());
sb.append(this.view.getColor().toString());
sb.append(this.view.getExpansionSetCode());
for (CardType type : this.view.getCardTypes()) {
sb.append((char) type.ordinal());
}
for (String s : this.view.getSuperTypes()) {
sb.append(s);
}
for (String s : this.view.getSubTypes()) {
sb.append(s);
}
for (String s : this.view.getManaCost()) {
sb.append(s);
}
for (String s : this.view.getRules()) {
sb.append(s);
}
if (this.view.getCounters() != null) {
for (CounterView v : this.view.getCounters()) {
sb.append(v.getName()).append(v.getCount());
}
}
return sb.toString().hashCode();
}
@Override
public int hashCode() {
return hashCode;
}
@Override
public boolean equals(Object object) {
// Initial checks
if (this == object) {
return true;
}
if (object == null) {
return false;
}
if (!(object instanceof ImageKey)) {
return false;
}
final ImageKey other = (ImageKey) object;
// Compare
if ((artImage != null) != (other.artImage != null)) {
return false;
}
if (width != other.width) {
return false;
}
if (height != other.height) {
return false;
}
if (isChoosable != other.isChoosable) {
return false;
}
if (isSelected != other.isSelected) {
return false;
}
return cardViewEquals(view, other.view);
}
}
// Map of generated images
private final static Map<ImageKey, BufferedImage> IMAGE_CACHE = new MapMaker().softValues().makeMap();
// The art image for the card, loaded in from the disk
private BufferedImage artImage;
// The rendered card image, with or without the art image loaded yet
// = null while invalid
private BufferedImage cardImage;
private CardRenderer cardRenderer;
public CardPanelRenderImpl(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension) {
// Call to super
super(newGameCard, gameId, loadImage, callback, foil, dimension);
// Renderer
cardRenderer = new ModernCardRenderer(gameCard, isTransformed());
// Draw the parts
initialDraw();
}
@Override
public void transferResources(CardPanel panel) {
if (panel instanceof CardPanelRenderImpl) {
CardPanelRenderImpl impl = (CardPanelRenderImpl) panel;
// Use the art image and current rendered image from the card
artImage = impl.artImage;
cardRenderer.setArtImage(artImage);
cardImage = impl.cardImage;
}
}
@Override
protected void paintCard(Graphics2D g) {
// Render the card if we don't have an image ready to use
if (cardImage == null) {
// Try to get card image from cache based on our card characteristics
ImageKey key
= new ImageKey(gameCard, artImage,
getCardWidth(), getCardHeight(),
isChoosable(), isSelected());
cardImage = IMAGE_CACHE.get(key);
// No cached copy exists? Render one and cache it
if (cardImage == null) {
cardImage = renderCard();
IMAGE_CACHE.put(key, cardImage);
}
}
// And draw the image we now have
g.drawImage(cardImage, getCardXOffset(), getCardYOffset(), null);
}
/**
* Render the card to a new BufferedImage at it's current dimensions
*
* @return
*/
private BufferedImage renderCard() {
int cardWidth = getCardWidth();
int cardHeight = getCardHeight();
// Create image to render to
BufferedImage image
= GraphicsUtilities.createCompatibleTranslucentImage(cardWidth, cardHeight);
Graphics2D g2d = image.createGraphics();
// Render with Antialialsing
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Attributes
CardPanelAttributes attribs
= new CardPanelAttributes(cardWidth, cardHeight, isChoosable(), isSelected());
// Draw card itself
cardRenderer.draw(g2d, attribs);
// Done
g2d.dispose();
return image;
}
private int updateArtImageStamp;
@Override
public void updateArtImage() {
// Invalidate
artImage = null;
cardImage = null;
cardRenderer.setArtImage(null);
// Stop animation
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
// Schedule a repaint
repaint();
// See if the image is already loaded
//artImage = ImageCache.tryGetImage(gameCard, getCardWidth(), getCardHeight());
//this.cardRenderer.setArtImage(artImage);
// Submit a task to draw with the card art when it arrives
if (artImage == null) {
final int stamp = ++updateArtImageStamp;
Util.threadPool.submit(new Runnable() {
@Override
public void run() {
try {
final BufferedImage srcImage;
if (gameCard.isFaceDown()) {
// Nothing to do
srcImage = null;
} else if (getCardWidth() > THUMBNAIL_SIZE_FULL.width) {
srcImage = ImageCache.getImage(gameCard, getCardWidth(), getCardHeight());
} else {
srcImage = ImageCache.getThumbnail(gameCard);
}
UI.invokeLater(new Runnable() {
@Override
public void run() {
if (stamp == updateArtImageStamp) {
artImage = srcImage;
cardRenderer.setArtImage(srcImage);
if (srcImage != null) {
// Invalidate and repaint
cardImage = null;
repaint();
}
}
}
});
} catch (Exception e) {
e.printStackTrace();
} catch (Error err) {
err.printStackTrace();
}
}
});
}
}
@Override
public void update(CardView card) {
// Update super
super.update(card);
// Update renderer
cardImage = null;
cardRenderer = new ModernCardRenderer(gameCard, isTransformed());
cardRenderer.setArtImage(artImage);
// Repaint
repaint();
}
@Override
public void setCardBounds(int x, int y, int cardWidth, int cardHeight) {
int oldCardWidth = getCardWidth();
int oldCardHeight = getCardHeight();
super.setCardBounds(x, y, cardWidth, cardHeight);
// Rerender if card size changed
if (getCardWidth() != oldCardWidth || getCardHeight() != oldCardHeight) {
cardImage = null;
}
}
private BufferedImage getFaceDownImage() {
if (isPermanent()) {
if (((PermanentView) gameCard).isMorphed()) {
return ImageCache.getMorphImage();
} else {
return ImageCache.getManifestImage();
}
} else if (this.gameCard instanceof StackAbilityView) {
return ImageCache.getMorphImage();
} else {
return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
}
}
@Override
public Image getImage() {
if (artImage != null) {
if (gameCard.isFaceDown()) {
return getFaceDownImage();
} else {
return ImageCache.getImageOriginal(gameCard);
}
}
return null;
}
@Override
public void showCardTitle() {
// Nothing to do, rendered cards always have a title
}
}

View file

@ -0,0 +1,374 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import mage.client.dialog.PreferencesDialog;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.utils.CardUtil;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
/**
* @author stravant@gmail.com
*
* Common base class for card renderers for each card frame / card type.
*
* Follows the template method pattern to implement a new renderer, implement
* the following methods (they are called in the following order):
*
* * drawBorder() Draws the outermost border of the card, white border or black
* border
*
* * drawBackground() Draws the background texture / color of the card
*
* * drawArt() Draws the card's art
*
* * drawFrame() Draws the card frame (over the art and background)
*
* * drawOverlays() Draws summoning sickness and possible other overlays
*
* * drawCounters() Draws counters on the card, such as +1/+1 and -1/-1
* counters
*
* Predefined methods that the implementations can use:
*
* * drawRules(font, bounding box)
*
* * drawNameLine(font, bounding box)
*
* * drawTypeLine(font, bounding box)
*
*/
public abstract class CardRenderer {
private static final Logger LOGGER = Logger.getLogger(CardPanel.class);
///////////////////////////////////////////////////////////////////////////
// Common layout metrics between all cards
// The card to be rendered
protected final CardView cardView;
// Is the card transformed?
protected final boolean isTransformed;
// The card image
protected BufferedImage artImage;
///////////////////////////////////////////////////////////////////////////
// Common layout metrics between all cards
// Polygons for counters
private static final Polygon PLUS_COUNTER_POLY = new Polygon(new int[]{
0, 5, 10, 10, 5, 0
}, new int[]{
3, 0, 3, 10, 9, 10
}, 6);
private static final Polygon MINUS_COUNTER_POLY = new Polygon(new int[]{
0, 5, 10, 10, 5, 0
}, new int[]{
0, 1, 0, 7, 10, 7
}, 6);
private static final Polygon TIME_COUNTER_POLY = new Polygon(new int[]{
0, 10, 8, 10, 0, 2
}, new int[]{
0, 0, 5, 10, 10, 5
}, 6);
private static final Polygon OTHER_COUNTER_POLY = new Polygon(new int[]{
1, 9, 9, 1
}, new int[]{
1, 1, 9, 9
}, 4);
// Paint for a card back
public static Paint BG_TEXTURE_CARDBACK = new Color(153, 102, 51);
// The size of the card
protected int cardWidth;
protected int cardHeight;
// Is it selectable / selected
protected boolean isChoosable;
protected boolean isSelected;
// Radius of the corners of the cards
protected static float CORNER_RADIUS_FRAC = 0.1f; //x cardWidth
protected static int CORNER_RADIUS_MIN = 3;
protected int cornerRadius;
// The inset of the actual card from the black / white border around it
protected static float BORDER_WIDTH_FRAC = 0.03f; //x cardWidth
protected static float BORDER_WIDTH_MIN = 2;
protected int borderWidth;
// The parsed text of the card
protected ArrayList<TextboxRule> textboxRules = new ArrayList<>();
protected ArrayList<TextboxRule> textboxKeywords = new ArrayList<>();
// The Construtor
// The constructor should prepare all of the things that it can
// without knowing the dimensions that the card will be rendered at.
// Then, the CardRenderer can be called on multiple times to render the
// card at various sizes (for instance, during animation)
public CardRenderer(CardView card, boolean isTransformed) {
// Set base parameters
this.cardView = card;
this.isTransformed = isTransformed;
// Translate the textbox text
for (String rule : card.getRules()) {
// Kill reminder text
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_REMINDER_TEXT, "false").equals("false")) {
rule = CardRendererUtils.killReminderText(rule).trim();
}
if (!rule.isEmpty()) {
TextboxRule tbRule = TextboxRuleParser.parse(card, rule);
if (tbRule.type == TextboxRuleType.SIMPLE_KEYWORD) {
textboxKeywords.add(tbRule);
} else if (tbRule.text.isEmpty()) {
// Nothing to do, rule is empty
} else {
textboxRules.add(tbRule);
}
}
}
}
// Layout operation
// Calculate common layout metrics that will be used by several
// of the operations in the template method.
protected void layout(int cardWidth, int cardHeight) {
// Store the dimensions for the template methods to use
this.cardWidth = cardWidth;
this.cardHeight = cardHeight;
// Corner radius and border width
cornerRadius = (int) Math.max(
CORNER_RADIUS_MIN,
CORNER_RADIUS_FRAC * cardWidth);
borderWidth = (int) Math.max(
BORDER_WIDTH_MIN,
BORDER_WIDTH_FRAC * cardWidth);
}
// The Draw Method
// The draw method takes the information caculated by the constructor
// and uses it to draw to a concrete size of card and graphics.
public void draw(Graphics2D g, CardPanelAttributes attribs) {
// Pre template method layout, to calculate shared layout info
layout(attribs.cardWidth, attribs.cardHeight);
isSelected = attribs.isSelected;
isChoosable = attribs.isChoosable;
// Call the template methods
drawBorder(g);
drawBackground(g);
drawArt(g);
drawFrame(g);
if (!cardView.isAbility()) {
drawOverlays(g);
drawCounters(g);
}
}
// Template methods to be implemented by sub classes
// For instance, for the Modern vs Old border card frames
protected abstract void drawBorder(Graphics2D g);
protected abstract void drawBackground(Graphics2D g);
protected abstract void drawArt(Graphics2D g);
protected abstract void drawFrame(Graphics2D g);
// Template methods that are possible to override, but unlikely to be
// overridden.
// Draw the card back
protected void drawCardBack(Graphics2D g) {
g.setPaint(BG_TEXTURE_CARDBACK);
g.fillRect(borderWidth, borderWidth,
cardWidth - 2 * borderWidth, cardHeight - 2 * borderWidth);
}
// Draw summoning sickness overlay, and possibly other overlays
protected void drawOverlays(Graphics2D g) {
if (CardUtil.isCreature(cardView) && cardView instanceof PermanentView) {
if (((PermanentView) cardView).hasSummoningSickness()) {
int x1 = (int) (0.2 * cardWidth);
int x2 = (int) (0.8 * cardWidth);
int y1 = (int) (0.2 * cardHeight);
int y2 = (int) (0.8 * cardHeight);
int xPoints[] = {
x1, x2, x1, x2
};
int yPoints[] = {
y1, y1, y2, y2
};
g.setColor(new Color(255, 255, 255, 200));
g.setStroke(new BasicStroke(7));
g.drawPolygon(xPoints, yPoints, 4);
g.setColor(new Color(0, 0, 0, 200));
g.setStroke(new BasicStroke(5));
g.drawPolygon(xPoints, yPoints, 4);
g.setStroke(new BasicStroke(1));
int[] xPoints2 = {
x1, x2, cardWidth / 2
};
int[] yPoints2 = {
y1, y1, cardHeight / 2
};
g.setColor(new Color(0, 0, 0, 100));
g.fillPolygon(xPoints2, yPoints2, 3);
}
}
}
// Draw +1/+1 and other counters
protected void drawCounters(Graphics2D g) {
int xPos = (int) (0.65 * cardWidth);
int yPos = (int) (0.15 * cardHeight);
if (cardView.getCounters() != null) {
for (CounterView v : cardView.getCounters()) {
// Don't render loyalty, we do that in the bottom corner
if (!v.getName().equals("loyalty")) {
Polygon p;
if (v.getName().equals("+1/+1")) {
p = PLUS_COUNTER_POLY;
} else if (v.getName().equals("-1/-1")) {
p = MINUS_COUNTER_POLY;
} else if (v.getName().equals("time")) {
p = TIME_COUNTER_POLY;
} else {
p = OTHER_COUNTER_POLY;
}
double scale = (0.1 * 0.25 * cardWidth);
Graphics2D g2 = (Graphics2D) g.create();
g2.translate(xPos, yPos);
g2.scale(scale, scale);
g2.setColor(Color.white);
g2.fillPolygon(p);
g2.setColor(Color.black);
g2.drawPolygon(p);
g2.setFont(new Font("Arial", Font.BOLD, 7));
String cstr = "" + v.getCount();
int strW = g2.getFontMetrics().stringWidth(cstr);
g2.drawString(cstr, 5 - strW / 2, 8);
g2.dispose();
yPos += ((int) (0.30 * cardWidth));
}
}
}
}
// Draw an expansion symbol, right justified, in a given region
// Return the width of the drawn symbol
protected int drawExpansionSymbol(Graphics2D g, int x, int y, int w, int h) {
// Draw the expansion symbol
Image setSymbol = ManaSymbols.getSetSymbolImage(cardView.getExpansionSetCode(), cardView.getRarity().getCode());
int setSymbolWidth;
if (setSymbol == null) {
// Don't draw anything when we don't have a set symbol
return 0;
/*
// Just draw the as a code
String code = cardView.getExpansionSetCode();
code = (code != null) ? code.toUpperCase() : "";
FontMetrics metrics = g.getFontMetrics();
setSymbolWidth = metrics.stringWidth(code);
if (cardView.getRarity() == Rarity.COMMON) {
g.setColor(Color.white);
} else {
g.setColor(Color.black);
}
g.fillRoundRect(
x + w - setSymbolWidth - 1, y + 2,
setSymbolWidth+2, h - 5,
5, 5);
g.setColor(getRarityColor());
g.drawString(code, x + w - setSymbolWidth, y + h - 3);
*/
} else {
// Draw the set symbol
int height = setSymbol.getHeight(null);
int scale = 1;
if (height != -1) {
while (height > h + 2) {
scale *= 2;
height /= 2;
}
}
setSymbolWidth = setSymbol.getWidth(null) / scale;
g.drawImage(setSymbol,
x + w - setSymbolWidth, y + (h - height) / 2,
setSymbolWidth, height,
null);
}
return setSymbolWidth;
}
private Color getRarityColor() {
switch (cardView.getRarity()) {
case RARE:
return new Color(255, 191, 0);
case UNCOMMON:
return new Color(192, 192, 192);
case MYTHIC:
return new Color(213, 51, 11);
case SPECIAL:
return new Color(204, 0, 255);
case BONUS:
return new Color(129, 228, 228);
case COMMON:
default:
return Color.black;
}
}
// Get a string representing the type line
protected String getCardTypeLine() {
if (cardView.isAbility()) {
if (AbilityType.TRIGGERED.equals(cardView.getAbilityType())) {
return "Triggered Ability";
} else if (AbilityType.ACTIVATED.equals(cardView.getAbilityType())) {
return "Activated Ability";
} else {
return "??? Ability";
}
} else {
StringBuilder sbType = new StringBuilder();
for (String superType : cardView.getSuperTypes()) {
sbType.append(superType).append(" ");
}
for (CardType cardType : cardView.getCardTypes()) {
sbType.append(cardType.toString()).append(" ");
}
if (cardView.getSubTypes().size() > 0) {
sbType.append("- ");
for (String subType : cardView.getSubTypes()) {
sbType.append(subType).append(" ");
}
}
return sbType.toString();
}
}
// Set the card art image (CardPanel will give it to us when it
// is loaded and ready)
public void setArtImage(Image image) {
artImage = CardRendererUtils.toBufferedImage(image);
}
}

View file

@ -0,0 +1,124 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author stravant@gmail.com
*
* Various static utilities for use in the card renderer
*/
public class CardRendererUtils {
/**
* Convert an abstract image, whose underlying implementation may or may
* not be a BufferedImage into a BufferedImage by creating one and coping
* the contents if it is not, and simply up-casting if it is.
* @param img The image to convert
* @return The converted image
*/
public static BufferedImage toBufferedImage(Image img) {
// Null? No conversion to do
if (img == null) {
return null;
}
// Already a buffered image?
if (img instanceof BufferedImage) {
return (BufferedImage) img;
}
// Create a buffered image with transparency
BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
// Draw the image on to the buffered image
Graphics2D bGr = bimage.createGraphics();
bGr.drawImage(img, 0, 0, null);
bGr.dispose();
// Return the buffered image
return bimage;
}
// Draw a rounded box with a 2-pixel border
// Used on various card parts.
public static void drawRoundedBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Color fill) {
g.setColor(new Color(0, 0, 0, 150));
g.drawOval(x-1, y-1, bevel*2, h);
g.setPaint(border);
g.drawOval(x, y, bevel*2-1, h-1);
g.drawOval(x + w - bevel*2, y, bevel*2-1, h-1);
g.drawOval(x+1, y+1, bevel*2-3, h-3);
g.drawOval(x+1 + w - bevel*2, y+1, bevel*2-3, h-3);
g.drawRect(x + bevel, y, w - 2*bevel, h-1);
g.drawRect(x+1 + bevel, y+1, w - 2*bevel-2, h-3);
g.setColor(fill);
g.fillOval(x+2, y+2, bevel*2-4, h-4);
g.fillOval(x+2 + w - bevel*2, y+2, bevel*2-4, h-4);
g.fillRect(x + bevel, y+2, w - 2*bevel, h-4);
}
// Get the width of a mana cost rendered with ManaSymbols.draw
public static int getManaCostWidth(String manaCost, int symbolSize) {
int width = 0;
manaCost = manaCost.replace("\\", "");
StringTokenizer tok = new StringTokenizer(manaCost, " ");
while (tok.hasMoreTokens()) {
tok.nextToken();
width += symbolSize;
}
return width;
}
// Abbreviate a piece of rules text, making substitutions to decrease its
// length. Also abbreviate reminder text.
private static Pattern abbreviationPattern;
private static Map<String, String> abbreviations = new HashMap<String, String>();
private static Pattern killReminderTextPattern;
static {
// Available abbreviations
abbreviations.put("enters the battlefield", "ETB");
abbreviations.put("less than", "<");
abbreviations.put("greater than", ">");
// Compile into regex
String patternString = "(";
Iterator<String> it = abbreviations.keySet().iterator();
while (it.hasNext()) {
patternString += it.next();
if (it.hasNext()) {
patternString += "|";
}
}
patternString += ")";
abbreviationPattern = Pattern.compile(patternString);
// Reminder text killing
killReminderTextPattern = Pattern.compile("\\([^\\)]*\\)");
}
public static String abbreviateRule(String rule) {
StringBuffer build = new StringBuffer();
Matcher match = abbreviationPattern.matcher(rule);
while (match.find()) {
match.appendReplacement(build, abbreviations.get(match.group(1)));
}
match.appendTail(build);
return build.toString();
}
public static String killReminderText(String rule) {
return killReminderTextPattern.matcher(rule).replaceAll("");
}
}

View file

@ -2,20 +2,12 @@ package org.mage.card.arcane;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
import javax.swing.*;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.LineBreakMeasurer;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
@ -23,10 +15,12 @@ import java.text.BreakIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import javax.swing.*;
import mage.client.util.ImageCaches;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
public class GlowText extends JLabel {
private static final long serialVersionUID = 1827677946939348001L;
private int glowSize;
@SuppressWarnings("unused")
@ -36,12 +30,12 @@ public class GlowText extends JLabel {
private int lineCount = 0;
private static Map<Key, BufferedImage> IMAGE_CACHE;
private final static class Key
{
private final static class Key {
final int width;
final int height;
final String text;
final Map<TextAttribute,?> fontAttributes;
final Map<TextAttribute, ?> fontAttributes;
final Color color;
final int glowSize;
final float glowIntensity;
@ -53,8 +47,9 @@ public class GlowText extends JLabel {
Font getFont() {
Font res = this.originalFont.get();
if(res == null)
if (res == null) {
res = Font.getFont(this.fontAttributes);
}
return res;
}
@ -138,18 +133,18 @@ public class GlowText extends JLabel {
}));
}
public void setGlow (Color glowColor, int size, float intensity) {
public void setGlow(Color glowColor, int size, float intensity) {
this.glowColor = glowColor;
this.glowSize = size;
this.glowIntensity = intensity;
}
public void setWrap (boolean wrap) {
public void setWrap(boolean wrap) {
this.wrap = wrap;
}
@Override
public Dimension getPreferredSize () {
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
size.width += glowSize;
size.height += glowSize / 2;
@ -157,7 +152,7 @@ public class GlowText extends JLabel {
}
@Override
public void paint (Graphics g) {
public void paint(Graphics g) {
if (getText().length() == 0) {
return;
}
@ -165,7 +160,7 @@ public class GlowText extends JLabel {
g.drawImage(IMAGE_CACHE.get(new Key(getWidth(), getHeight(), getText(), getFont(), getForeground(), glowSize, glowIntensity, glowColor, wrap)), 0, 0, null);
}
private static BufferedImage createImage (Key key) {
private static BufferedImage createImage(Key key) {
Dimension size = new Dimension(key.width, key.height);
BufferedImage image = GraphicsUtilities.createCompatibleTranslucentImage(size.width, size.height);
Graphics2D g2d = image.createGraphics();

View file

@ -37,7 +37,7 @@ public class ManaSymbols {
private static boolean smallSymbolsFound = false;
private static boolean mediumSymbolsFound = false;
private static final Map<String, Image> setImages = new HashMap<>();
private static final Map<String, Map<String, Image>> setImages = new HashMap<>();
private static final Map<String, Dimension> setImagesExist = new HashMap<>();
private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
private static String cachedPath;
@ -57,25 +57,32 @@ public class ManaSymbols {
return;
}
for (String set : setCodes) {
File file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET + set + "-C.jpg");
try {
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
int width = image.getWidth(null);
if (width > 21) {
int h = image.getHeight(null);
if (h > 0) {
Rectangle r = new Rectangle(21, (int) (h * 21.0f / width));
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
setImages.put(set, resized);
}
} else {
setImages.put(set, image);
}
} catch (Exception e) {
}
String[] codes = new String[]{"C", "U", "R", "M"};
Map<String, Image> rarityImages = new HashMap<>();
setImages.put(set, rarityImages);
for (String rarityCode: codes) {
File file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET + set + "-" + rarityCode + ".jpg");
try {
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
int width = image.getWidth(null);
if (width > 21) {
int h = image.getHeight(null);
if (h > 0) {
Rectangle r = new Rectangle(21, (int) (h * 21.0f / width));
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
rarityImages.put(set, resized);
}
} else {
rarityImages.put(rarityCode, image);
}
} catch (Exception e) {
}
}
try {
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET_SMALL);
File file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET_SMALL);
if (!file.exists()) {
file.mkdirs();
}
@ -298,14 +305,27 @@ public class ManaSymbols {
}
public static Image getSetSymbolImage(String set) {
return setImages.get(set);
return getSetSymbolImage(set, "C");
}
public static Image getSetSymbolImage(String set, String rarity) {
Map<String, Image> rarityImages = setImages.get(set);
if (rarityImages != null) {
return rarityImages.get(rarity);
} else {
return null;
}
}
public static BufferedImage getSizedManaSymbol(String symbol) {
if (!manaImages.containsKey(GUISizeHelper.symbolDialogSize)) {
loadSymbolsImages(GUISizeHelper.symbolDialogSize);
return getSizedManaSymbol(symbol, GUISizeHelper.symbolDialogSize);
}
public static BufferedImage getSizedManaSymbol(String symbol, int size) {
if (!manaImages.containsKey(size)) {
loadSymbolsImages(size);
}
Map<String, BufferedImage> sizedSymbols = manaImages.get(GUISizeHelper.symbolDialogSize);
Map<String, BufferedImage> sizedSymbols = manaImages.get(size);
return sizedSymbols.get(symbol);
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
import java.util.List;
/**
* @author stravant@gmail.com
*/
public class TextboxKeywordRule extends TextboxRule {
public TextboxKeywordRule(String text, List<AttributeRegion> regions) {
super(text, regions, TextboxRuleType.SIMPLE_KEYWORD);
}
}

View file

@ -0,0 +1,28 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
import java.util.List;
/**
* @author StravantUser
*
* Level rule associated with leveler cards
*/
public class TextboxLevelRule extends TextboxRule {
// The levels that this rule applies to
public int levelFrom;
public int levelTo;
public static int AND_HIGHER = 100;
public TextboxLevelRule(String text, List<AttributeRegion> regions, int levelFrom, int levelTo) {
super(text, regions, TextboxRuleType.LEVEL);
this.levelFrom = levelFrom;
this.levelTo = levelTo;
}
}

View file

@ -0,0 +1,33 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
import java.util.List;
/**
* @author StravantUser
*/
public class TextboxLoyaltyRule extends TextboxRule {
public int loyaltyChange;
public static int MINUS_X = 100;
public String getChangeString() {
if (loyaltyChange == MINUS_X) {
return "-X";
} else if (loyaltyChange > 0) {
return "+" + loyaltyChange;
} else {
return "" + loyaltyChange;
}
}
public TextboxLoyaltyRule(String text, List<AttributeRegion> regions, int loyaltyChange) {
super(text, regions, TextboxRuleType.LOYALTY);
this.loyaltyChange = loyaltyChange;
}
}

View file

@ -0,0 +1,98 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
import java.awt.Font;
import java.awt.Image;
import java.awt.font.GraphicAttribute;
import java.awt.font.ImageGraphicAttribute;
import java.awt.font.TextAttribute;
import java.text.AttributedString;
import java.util.List;
/**
* @author stravant@gmail.com
*
* Class describing parsed & translated rules in the text box of a card, ready
* to be rendered.
*/
public class TextboxRule {
// An attributed region in the text, which can be applied to an
// attributed string.
public interface AttributeRegion {
public void applyToAttributedString(AttributedString str, Font normal, Font italic);
}
// A region of italics, or bold text in a
public static class ItalicRegion implements AttributeRegion {
ItalicRegion(int start, int end) {
this.start = start;
this.end = end;
}
private final int start;
private final int end;
@Override
public void applyToAttributedString(AttributedString str, Font normal, Font italic) {
if (end > start + 1) {
str.addAttribute(TextAttribute.FONT, italic, start, end);
}
}
}
// A special symbol embedded at some point in a string
public static class EmbeddedSymbol implements AttributeRegion {
EmbeddedSymbol(String symbol, int location) {
this.symbol = symbol;
this.location = location;
}
private final String symbol;
private final int location;
@Override
public void applyToAttributedString(AttributedString str, Font normal, Font italic) {
Image symbolImage = ManaSymbols.getSizedManaSymbol(symbol.replace("/", ""), normal.getSize());
if (symbolImage != null) {
ImageGraphicAttribute imgAttr
= new ImageGraphicAttribute(symbolImage, GraphicAttribute.BOTTOM_ALIGNMENT);
str.addAttribute(TextAttribute.CHAR_REPLACEMENT, imgAttr, location, location + 1);
}
}
}
public String text;
public TextboxRuleType type;
private List<AttributeRegion> regions;
protected TextboxRule(String text, List<AttributeRegion> regions, TextboxRuleType type) {
this.text = text;
this.type = type;
this.regions = regions;
}
public TextboxRule(String text, List<AttributeRegion> regions) {
this(text, regions, TextboxRuleType.NORMAL);
}
public AttributedString generateAttributedString(Font normal, Font italic) {
// Build the final attributed text using the regions
// Do it in reverse order for proper handling of regions where
// there are multiple attributes stacked (EG: bold + italic)
AttributedString attributedRule = new AttributedString(text);
if (text.length() != 0) {
attributedRule.addAttribute(TextAttribute.FONT, normal);
for (int i = regions.size() - 1; i >= 0; --i) {
regions.get(i).applyToAttributedString(attributedRule, normal, italic);
}
}
return attributedRule;
}
}

View file

@ -0,0 +1,251 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
import java.awt.Image;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.view.CardView;
import org.apache.log4j.Logger;
/**
*
* @author StravantUser
*/
public class TextboxRuleParser {
private static final Logger LOGGER = Logger.getLogger(CardPanel.class);
private static final Pattern LevelAbilityPattern = Pattern.compile("Level (\\d+)-?(\\d*)(\\+?)");
private static final Pattern LoyaltyAbilityPattern = Pattern.compile("^(\\+|\\-)(\\d+|X): ");
private static final Pattern SimpleKeywordPattern = Pattern.compile("^(\\w+( \\w+)?)\\s*(\\([^\\)]*\\))?\\s*$");
// Parse a given rule (given as a string) into a TextboxRule, replacing
// symbol annotations, italics, etc, parsing out information such as
// if the ability is a loyalty ability, and returning an TextboxRule
// representing that information, which can be used to render the rule in
// the textbox of a card.
public static TextboxRule parse(CardView source, String rule) {
// List of regions to apply
ArrayList<TextboxRule.AttributeRegion> regions = new ArrayList<>();
// Leveler / loyalty
boolean isLeveler = false;
int levelFrom = 0;
int levelTo = 0;
boolean isLoyalty = false;
int loyaltyChange = 0;
// Parse the attributedString contents
int index = 0;
int outputIndex = 0;
// Is it a simple keyword ability?
{
Matcher simpleKeywordMatch = SimpleKeywordPattern.matcher(rule);
if (simpleKeywordMatch.find()) {
return new TextboxKeywordRule(simpleKeywordMatch.group(1), regions);
}
}
// Check if it's a loyalty ability. Must be right at the start of the rule
{
Matcher loyaltyMatch = LoyaltyAbilityPattern.matcher(rule);
if (loyaltyMatch.find()) {
// Get the loyalty change
if (loyaltyMatch.group(2).equals("X")) {
loyaltyChange = TextboxLoyaltyRule.MINUS_X;
} else {
loyaltyChange = Integer.parseInt(loyaltyMatch.group(2));
if (loyaltyMatch.group(1).equals("-")) {
loyaltyChange = -loyaltyChange;
}
}
isLoyalty = true;
// Go past the match
index = loyaltyMatch.group().length();
}
}
Deque<Integer> openingStack = new ArrayDeque<>();
StringBuilder build = new StringBuilder();
while (index < rule.length()) {
int initialIndex = index;
char ch = rule.charAt(index);
switch (ch) {
case '{': {
// Handling for `{this}`
int closeIndex = rule.indexOf('}', index);
if (closeIndex == -1) {
// Malformed input, nothing to do
++index;
++outputIndex;
build.append(ch);
} else {
String contents = rule.substring(index + 1, closeIndex);
if (contents.equals("this") || contents.equals("source")) {
// Replace {this} with the card's name
String cardName = source.getName();
build.append(cardName);
index += contents.length() + 2;
outputIndex += cardName.length();
} else {
Image symbol = ManaSymbols.getSizedManaSymbol(contents.replace("/", ""), 10);
if (symbol != null) {
// Mana or other inline symbol
build.append('#');
regions.add(new TextboxRule.EmbeddedSymbol(contents, outputIndex));
++outputIndex;
index = closeIndex + 1;
} else {
// Bad entry
build.append('{');
build.append(contents);
build.append('}');
index = closeIndex + 1;
outputIndex += (contents.length() + 2);
}
}
}
break;
}
case '&':
// Handling for `&mdash;`
if (rule.startsWith("&mdash;", index)) {
build.append('—');
index += 7;
++outputIndex;
} else if (rule.startsWith("&bull", index)) {
build.append('•');
index += 5;
++outputIndex;
} else {
LOGGER.error("Bad &...; sequence `" + rule.substring(index + 1, index + 10) + "` in rule.");
build.append('&');
++index;
++outputIndex;
}
break;
case '<': {
// Handling for `<i>` and `<br/>`
int closeIndex = rule.indexOf('>', index);
if (closeIndex != -1) {
// Is a tag
String tag = rule.substring(index + 1, closeIndex);
if (tag.charAt(tag.length() - 1) == '/') {
// Pure closing tag (like <br/>)
if (tag.equals("br/")) {
build.append('\n');
++outputIndex;
} else {
// Unknown
build.append('<').append(tag).append('>');
outputIndex += (tag.length() + 2);
}
} else if (tag.charAt(0) == '/') {
// Opening index for the tag
int openingIndex;
if (openingStack.isEmpty()) {
// Malformed input, just make an empty interval
openingIndex = outputIndex;
} else {
openingIndex = openingStack.pop();
}
// What tag is it?
switch (tag) {
case "/i":
// Italics
regions.add(new TextboxRule.ItalicRegion(openingIndex, outputIndex));
break;
case "/b":
// Bold, see if it's a level ability
String content = build.substring(openingIndex);
Matcher levelMatch = LevelAbilityPattern.matcher(content);
if (levelMatch.find()) {
try {
levelFrom = Integer.parseInt(levelMatch.group(1));
if (!levelMatch.group(2).equals("")) {
levelTo = Integer.parseInt(levelMatch.group(2));
}
if (!levelMatch.group(3).equals("")) {
levelTo = TextboxLevelRule.AND_HIGHER;
}
isLeveler = true;
} catch (Exception e) {
LOGGER.error("Bad leveler levels in rule `" + rule + "`.");
}
}
break;
default:
// Unknown
build.append('<').append(tag).append('>');
outputIndex += (tag.length() + 2);
break;
}
} else // Is it a <br> tag special case? [Why can't it have a closing `/`... =( ]
{
if (tag.equals("br")) {
build.append('\n');
++outputIndex;
} else {
// Opening tag
openingStack.push(outputIndex);
}
}
// Skip characters
index = closeIndex + 1;
} else {
// Malformed tag
build.append('<');
++outputIndex;
++index;
}
break;
}
default:
// Normal character
++index;
++outputIndex;
build.append(ch);
break;
}
if (outputIndex != build.length()) {
// Somehow our parsing code output symbols but didn't update the output index correspondingly
LOGGER.error("The human is dead; mismatch! Failed on rule: `" + rule + "` due to not updating outputIndex properly.");
// Bail out
build = new StringBuilder(rule);
regions.clear();
break;
}
if (index == initialIndex) {
// Somehow our parsing failed to consume the
LOGGER.error("Failed on rule `" + rule + "` due to not consuming a character.");
// Bail out
build = new StringBuilder(rule);
regions.clear();
break;
}
}
// Build and return the rule
rule = build.toString();
if (isLoyalty) {
return new TextboxLoyaltyRule(rule, regions, loyaltyChange);
} else if (isLeveler) {
return new TextboxLevelRule(rule, regions, levelFrom, levelTo);
} else {
return new TextboxRule(rule, regions);
}
}
}

View file

@ -0,0 +1,25 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane;
/**
* @author stravant@gmail.com
*/
public enum TextboxRuleType {
/* Normal abilities, just rendered as lines of text with embedded symbols
* replaced to the relevant images. */
NORMAL,
/* Keyword ability. To be displayed in the comma separated list at the
* very top of the rules box */
SIMPLE_KEYWORD,
/* Loyalty abilities on planeswalkers */
LOYALTY,
/* Levelup creature - static ability at a given level */
LEVEL
}

View file

@ -17,6 +17,7 @@ import javax.swing.JDialog;
import javax.swing.JLayeredPane;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.GUISizeHelper;
import mage.constants.Rarity;
import mage.interfaces.plugin.CardPlugin;
@ -31,6 +32,7 @@ import net.xeoh.plugins.base.annotations.meta.Author;
import org.apache.log4j.Logger;
import org.mage.card.arcane.Animation;
import org.mage.card.arcane.CardPanel;
import org.mage.card.arcane.CardPanelComponentImpl;
import org.mage.card.arcane.ManaSymbols;
import org.mage.plugins.card.dl.DownloadGui;
import org.mage.plugins.card.dl.DownloadJob;
@ -41,6 +43,7 @@ import org.mage.plugins.card.dl.sources.GathererSets;
import org.mage.plugins.card.dl.sources.GathererSymbols;
import org.mage.plugins.card.images.ImageCache;
import org.mage.plugins.card.info.CardInfoPaneImpl;
import org.mage.card.arcane.CardPanelRenderImpl;
/**
* {@link CardPlugin} implementation.
@ -105,10 +108,23 @@ public class CardPluginImpl implements CardPlugin {
cardWidthMin = (int) GUISizeHelper.battlefieldCardMinDimension.getWidth();
cardWidthMax = (int) GUISizeHelper.battlefieldCardMaxDimension.getWidth();
}
/**
* Temporary card rendering shim. Split card rendering isn't implemented yet, so
* use old component based rendering for the split cards.
*/
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension) {
String fallback = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false");
if (view.isSplitCard() || fallback.equals("true")) {
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
} else {
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
}
}
@Override
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
CardPanel cardPanel = new CardPanel(permanent, gameId, loadImage, callback, false, dimension);
CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension);
boolean implemented = !permanent.getRarity().equals(Rarity.NA);
cardPanel.setShowCastingCost(implemented);
return cardPanel;
@ -116,7 +132,7 @@ public class CardPluginImpl implements CardPlugin {
@Override
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
CardPanel cardPanel = new CardPanel(cardView, gameId, loadImage, callback, false, dimension);
CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension);
boolean implemented = cardView.getRarity() != null && !cardView.getRarity().equals(Rarity.NA);
cardPanel.setShowCastingCost(implemented);
return cardPanel;

View file

@ -201,6 +201,10 @@ public class ImageCache {
public static BufferedImage getThumbnail(CardView card) {
return getImage(getKey(card, card.getName(), "#thumb"));
}
public static BufferedImage tryGetThumbnail(CardView card) {
return tryGetImage(getKey(card, card.getName(), "#thumb"));
}
public static BufferedImage getImageOriginal(CardView card) {
return getImage(getKey(card, card.getName(), ""));
@ -231,6 +235,18 @@ public class ImageCache {
return null;
}
}
/**
* Returns the Image corresponding to the key only if it already exists
* in the cache.
*/
private static BufferedImage tryGetImage(String key) {
if (IMAGE_CACHE.containsKey(key)) {
return IMAGE_CACHE.get(key);
} else {
return null;
}
}
/**
* Returns the map key for a card, without any suffixes for the image size.
@ -344,6 +360,34 @@ public class ImageCache {
return TransformedImageCache.getResizedImage(original, (int) (original.getWidth() * scale), (int) (original.getHeight() * scale));
}
/**
* Returns the image appropriate to display for a card in a picture panel, but
* only it was ALREADY LOADED. That is, the call is immediate and will not block
* on file IO.
* @param card
* @param width
* @param height
* @return
*/
public static BufferedImage tryGetImage(CardView card, int width, int height) {
if (Constants.THUMBNAIL_SIZE_FULL.width + 10 > width) {
return tryGetThumbnail(card);
}
String key = getKey(card, card.getName(), Integer.toString(width));
BufferedImage original = tryGetImage(key);
if (original == null) {
LOGGER.debug(key + " not found");
return null;
}
double scale = Math.min((double) width / original.getWidth(), (double) height / original.getHeight());
if (scale >= 1) {
return original;
}
return TransformedImageCache.getResizedImage(original, (int) (original.getWidth() * scale), (int) (original.getHeight() * scale));
}
public static TFile getTFile(String path) {
try {

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

View file

@ -0,0 +1,28 @@
package mage.cards;
/**
* @author stravant@gmail.com
*
* Enum listing the possible card faces for a card
*
* Because of Time Spiral block's shifted cards it is
* not sufficient to just look at a card's edition to
* determine what the card face should be.
*/
public enum CardBorder {
/* Old border card frames. ALPHA -> 8th ED */
OLD,
/* Future Sight frames. FUT futureshifted */
FUT,
/* Planar Chaos frames. PLC planeshifted */
PLC,
/* Modern card frames. 8th ED -> M15 */
MOD,
/* New border cards, M15 -> current */
M15
}

View file

@ -32,7 +32,7 @@ public abstract class MageCard extends JPanel {
public abstract void update(CardView card);
public abstract void updateImage();
public abstract void updateArtImage();
public abstract Image getImage();

View file

@ -68,14 +68,16 @@ public class CardView extends SimpleCardView {
protected String power;
protected String toughness;
protected String loyalty;
protected String startingLoyalty;
protected List<CardType> cardTypes;
protected List<String> subTypes;
protected List<String> superTypes;
protected ObjectColor color;
protected ObjectColor frameColor;
protected List<String> manaCost;
protected int convertedManaCost;
protected Rarity rarity;
protected MageObjectType mageObjectType = MageObjectType.NULL;
protected boolean isAbility;
@ -330,6 +332,12 @@ public class CardView extends SimpleCardView {
}
}
}
// Frame color
this.frameColor = card.getFrameColor(game);
// Get starting loyalty
this.startingLoyalty = "" + card.getStartingLoyalty();
}
public CardView(MageObject object) {
@ -374,6 +382,10 @@ public class CardView extends SimpleCardView {
this.expansionSetCode = stackAbility.getExpansionSetCode();
}
}
// Frame color
this.frameColor = object.getFrameColor(null);
// Starting loyalty. Must be extracted from an ability
this.startingLoyalty = "" + object.getStartingLoyalty();
}
protected CardView() {
@ -408,10 +420,12 @@ public class CardView extends SimpleCardView {
this.power = "";
this.toughness = "";
this.loyalty = "";
this.startingLoyalty = "";
this.cardTypes = new ArrayList<>();
this.subTypes = new ArrayList<>();
this.superTypes = new ArrayList<>();
this.color = new ObjectColor();
this.frameColor = new ObjectColor();
this.manaCost = new ArrayList<>();
this.convertedManaCost = 0;
@ -452,15 +466,16 @@ public class CardView extends SimpleCardView {
this.power = token.getPower().toString();
this.toughness = token.getToughness().toString();
this.loyalty = "";
this.startingLoyalty = "";
this.cardTypes = token.getCardType();
this.subTypes = token.getSubtype(null);
this.superTypes = token.getSupertype();
this.color = token.getColor(null);
this.frameColor = token.getFrameColor(null);
this.manaCost = token.getManaCost().getSymbols();
this.rarity = Rarity.NA;
this.type = token.getTokenType();
this.tokenSetCode = token.getOriginalExpansionSetCode();
this.tokenDescriptor = token.getTokenDescriptor();
}
protected final void setTargets(Targets targets) {
@ -519,6 +534,10 @@ public class CardView extends SimpleCardView {
public String getLoyalty() {
return loyalty;
}
public String getStartingLoyalty() {
return startingLoyalty;
}
public List<CardType> getCardTypes() {
return cardTypes;
@ -535,6 +554,10 @@ public class CardView extends SimpleCardView {
public ObjectColor getColor() {
return color;
}
public ObjectColor getFrameColor() {
return frameColor;
}
public List<String> getManaCost() {
return manaCost;
@ -767,3 +790,4 @@ public class CardView extends SimpleCardView {
}
}

View file

@ -53,4 +53,21 @@ public class CounterView implements Serializable {
public int getCount() {
return count;
}
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (other == null) {
return false;
}
if (!(other instanceof CounterView)) {
return false;
}
CounterView oth = (CounterView)other;
return
(count == oth.count) &&
(name.equals(oth.name));
}
}

View file

@ -37,7 +37,7 @@ import mage.abilities.Ability;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.FearAbility;
@ -98,7 +98,7 @@ class DamageOpponentsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
DynamicValue amount = new CountersCount(CounterType.CHARGE);
DynamicValue amount = new CountersSourceCount(CounterType.CHARGE);
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {

View file

@ -34,7 +34,7 @@ import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.MultipliedValue;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -61,7 +61,7 @@ public class Tornado extends CardImpl {
this.addAbility(new CumulativeUpkeepAbility(new ManaCostsImpl("{G}")));
// {2}{G}, Pay 3 life for each velocity counter on Tornado: Destroy target permanent and put a velocity counter on Tornado. Activate this ability only once each turn.
Ability ability = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{2}{G}"));
DynamicValue lifeToPayAmount = new MultipliedValue(new CountersCount(CounterType.VELOCITY), 3);
DynamicValue lifeToPayAmount = new MultipliedValue(new CountersSourceCount(CounterType.VELOCITY), 3);
ability.addCost(new PayLifeCost(lifeToPayAmount, "3 life for each velocity counter on {source}"));
ability.addTarget(new TargetPermanent());
Effect effect = new AddCountersSourceEffect(CounterType.VELOCITY.createInstance());

View file

@ -36,7 +36,7 @@ import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -62,7 +62,7 @@ public class FalkenrathExterminator extends CardImpl {
// Whenever Falkenrath Exterminator deals combat damage to a player, put a +1/+1 counter on it.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false));
// {2}{R}: Falkenrath Exterminator deals damage to target creature equal to the number of +1/+1 counters on Falkenrath Exterminator.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new CountersCount(CounterType.P1P1)), new ManaCostsImpl("{2}{R}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new CountersSourceCount(CounterType.P1P1)), new ManaCostsImpl("{2}{R}"));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}

View file

@ -34,7 +34,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
@ -68,7 +68,7 @@ public class PetalmaneBaku extends CardImpl {
new RemovedCountersForCostValue(),
new ManaCostsImpl<>("{1}"),
"Add X mana of any one color to your mana pool",
true, new CountersCount(CounterType.KI));
true, new CountersSourceCount(CounterType.KI));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.KI.createInstance(),
"Remove X ki counters from {this}"));
this.addAbility(ability);

View file

@ -35,7 +35,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -75,7 +75,7 @@ public class BloodthirstyOgre extends CardImpl {
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.DEVOTION.createInstance()),new TapSourceCost()));
// {T}: Target creature gets -X/-X until end of turn, where X is the number of devotion counters on Bloodthirsty Ogre. Activate this ability only if you control a Demon.
DynamicValue devotionCounters = new SignInversionDynamicValue(new CountersCount(CounterType.DEVOTION));
DynamicValue devotionCounters = new SignInversionDynamicValue(new CountersSourceCount(CounterType.DEVOTION));
Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD,
new BoostTargetEffect(devotionCounters,devotionCounters, Duration.EndOfTurn, true),
new TapSourceCost(),

View file

@ -33,7 +33,7 @@ import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.cards.CardImpl;
@ -56,7 +56,7 @@ public class OrochiHatchery extends CardImpl {
this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.CHARGE.createInstance())));
// {5}, {T}: Put a 1/1 green Snake creature token onto the battlefield for each charge counter on Orochi Hatchery.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new SnakeToken(), new CountersCount(CounterType.CHARGE)), new GenericManaCost(5));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new SnakeToken(), new CountersSourceCount(CounterType.CHARGE)), new GenericManaCost(5));
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}

View file

@ -38,7 +38,7 @@ import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -71,7 +71,7 @@ public class GoblinRazerunners extends CardImpl {
this.addAbility(ability);
// At the beginning of your end step, you may have Goblin Razerunners deal damage equal to the number of +1/+1 counters on it to target player.
ability = new BeginningOfYourEndStepTriggeredAbility(new DamageTargetEffect(new CountersCount(CounterType.P1P1)), true);
ability = new BeginningOfYourEndStepTriggeredAbility(new DamageTargetEffect(new CountersSourceCount(CounterType.P1P1)), true);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}

View file

@ -32,7 +32,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.TapTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
@ -62,7 +62,7 @@ public class EvolutionVat extends CardImpl {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setText("and put a +1/+1 counter on it");
ability.addEffect(effect);
effect = new AddCountersSourceEffect(CounterType.P1P1.createInstance(), new CountersCount(CounterType.P1P1), false);
effect = new AddCountersSourceEffect(CounterType.P1P1.createInstance(), new CountersSourceCount(CounterType.P1P1), false);
effect.setText("Double the number of +1/+1 counters on this creature");
Ability gainedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{2}{G}{U}"));
ability.addEffect(new GainAbilityTargetEffect(gainedAbility, Duration.EndOfTurn,

View file

@ -36,7 +36,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.DefenderAbility;
@ -66,7 +66,7 @@ public class WalkingArchive extends CardImpl {
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), "Walking Archive enters the battlefield with a +1/+1 counter on it"));
// At the beginning of each player's upkeep, that player draws a card for each +1/+1 counter on Walking Archive.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DrawCardTargetEffect(new CountersCount(CounterType.P1P1)), TargetController.ANY, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DrawCardTargetEffect(new CountersSourceCount(CounterType.P1P1)), TargetController.ANY, false));
// {2}{W}{U}: Put a +1/+1 counter on Walking Archive.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), new ManaCostsImpl("{2}{W}{U}")));

View file

@ -37,7 +37,7 @@ import mage.abilities.condition.common.SourceTappedCondition;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -74,7 +74,7 @@ public class BottomlessVault extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {B} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -37,7 +37,7 @@ import mage.abilities.condition.common.SourceTappedCondition;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -74,7 +74,7 @@ public class HollowTrees extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {G} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -35,7 +35,7 @@ import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.SourceHasCounterCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RemoveAllCountersSourceEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
@ -108,7 +108,7 @@ class HomaridTriggeredAbility extends StateTriggeredAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return new CountersCount(CounterType.TIDE).calculate(game, this, null) == 4;
return new CountersSourceCount(CounterType.TIDE).calculate(game, this, null) == 4;
}
@Override

View file

@ -35,7 +35,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.IsStepCondition;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageControllerEffect;
import mage.abilities.effects.common.GainLifeEffect;
@ -76,7 +76,7 @@ public class IcatianMoneychanger1 extends CardImpl {
// Sacrifice Icatian Moneychanger: You gain 1 life for each credit counter on Icatian Moneychanger. Activate this ability only during your upkeep.
this.addAbility(new ConditionalActivatedAbility(Zone.BATTLEFIELD,
new GainLifeEffect(new CountersCount(CounterType.CREDIT)), new SacrificeSourceCost(), new IsStepCondition(PhaseStep.UPKEEP), null));
new GainLifeEffect(new CountersSourceCount(CounterType.CREDIT)), new SacrificeSourceCost(), new IsStepCondition(PhaseStep.UPKEEP), null));
}
public IcatianMoneychanger1(final IcatianMoneychanger1 card) {

View file

@ -37,7 +37,7 @@ import mage.abilities.condition.common.SourceTappedCondition;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -74,7 +74,7 @@ public class IcatianStore extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {W} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -38,7 +38,7 @@ import mage.abilities.condition.common.SourceHasCounterCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RemoveAllCountersSourceEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
@ -157,7 +157,7 @@ class TidalInfluenceTriggeredAbility extends StateTriggeredAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return new CountersCount(CounterType.TIDE).calculate(game, this, null) == 4;
return new CountersSourceCount(CounterType.TIDE).calculate(game, this, null) == 4;
}
@Override

View file

@ -34,7 +34,7 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -69,7 +69,7 @@ public class ScrollOfTheMasters extends CardImpl {
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.LORE.createInstance()), filterNonCreature, false));
// {3}, {T}: Target creature you control gets +1/+1 until end of turn for each lore counter on Scroll of the Masters.
DynamicValue xValue = new CountersCount(CounterType.LORE);
DynamicValue xValue = new CountersSourceCount(CounterType.LORE);
Effect effect = new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn);
effect.setText("Target creature you control gets +1/+1 until end of turn for each lore counter on {this}");
Ability ability = new SimpleActivatedAbility(

View file

@ -32,7 +32,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.SunburstAbility;
import mage.cards.CardImpl;
@ -53,7 +53,7 @@ public class ClearwaterGoblet extends CardImpl {
// Sunburst
this.addAbility(new SunburstAbility(this));
// At the beginning of your upkeep, you may gain life equal to the number of charge counters on Clearwater Goblet.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(new CountersCount(CounterType.CHARGE)), TargetController.YOU, true));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(new CountersSourceCount(CounterType.CHARGE)), TargetController.YOU, true));
}
public ClearwaterGoblet(final ClearwaterGoblet card) {

View file

@ -32,7 +32,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.SunburstAbility;
@ -56,7 +56,7 @@ public class Heliophial extends CardImpl {
// Sunburst
this.addAbility(new SunburstAbility(this));
// {2}, Sacrifice Heliophial: Heliophial deals damage equal to the number of charge counters on it to target creature or player.
Effect effect = new DamageTargetEffect(new CountersCount(CounterType.CHARGE));
Effect effect = new DamageTargetEffect(new CountersSourceCount(CounterType.CHARGE));
effect.setText("{this} deals damage equal to the number of charge counters on it to target creature or player");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{2}"));
ability.addCost(new SacrificeSourceCost());

View file

@ -30,7 +30,7 @@ package mage.sets.fifthdawn;
import java.util.UUID;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.SunburstAbility;
@ -55,7 +55,7 @@ public class OpalineBracers extends CardImpl {
// Sunburst
this.addAbility(new SunburstAbility(this));
// Equipped creature gets +X/+X, where X is the number of charge counters on Opaline Bracers.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(new CountersCount(CounterType.CHARGE), new CountersCount(CounterType.CHARGE))));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(new CountersSourceCount(CounterType.CHARGE), new CountersSourceCount(CounterType.CHARGE))));
// Equip {2}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(2)));
}

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.SunburstAbility;
@ -57,7 +57,7 @@ public class Solarion extends CardImpl {
// Sunburst
this.addAbility(new SunburstAbility(this));
// {tap}: Double the number of +1/+1 counters on Solarion.
Effect effect = new AddCountersSourceEffect(CounterType.P1P1.createInstance(1), new CountersCount(CounterType.P1P1), true);
Effect effect = new AddCountersSourceEffect(CounterType.P1P1.createInstance(1), new CountersSourceCount(CounterType.P1P1), true);
effect.setText("Double the number of +1/+1 counters on {this}");
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new TapSourceCost()));
}

View file

@ -37,7 +37,7 @@ import mage.abilities.condition.common.SourceTappedCondition;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -74,7 +74,7 @@ public class DwarvenHold extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {R} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -37,7 +37,7 @@ import mage.abilities.condition.common.SourceTappedCondition;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -74,7 +74,7 @@ public class SandSilos extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {U} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -30,7 +30,7 @@ package mage.sets.gatecrash;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -52,7 +52,7 @@ public class AssembleTheLegion extends CardImpl {
// At the beginning of your upkeep, put a muster counter on Assemble the Legion. Then put a 1/1 red and white Soldier creature token with haste onto the battlefield for each muster counter on Assemble the Legion.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.MUSTER.createInstance()), TargetController.YOU, false);
ability.addEffect(new CreateTokenEffect(new SoldierTokenWithHaste(), new CountersCount(CounterType.MUSTER)));
ability.addEffect(new CreateTokenEffect(new SoldierTokenWithHaste(), new CountersSourceCount(CounterType.MUSTER)));
this.addAbility(ability);
}

View file

@ -33,7 +33,7 @@ import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.dynamicvalue.LockedInDynamicValue;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.PermanentsTargetOpponentControlsCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PreventAllDamageToSourceEffect;
@ -72,7 +72,7 @@ public class GideonChampionOfJustice extends CardImpl {
this.addAbility(ability1);
// 0: Until end of turn, Gideon becomes an indestructible Human Soldier creature with power and toughness each equal to the number of loyalty counters on him. He's still a planeswalker. Prevent all damage that would be dealt to him this turn.
LockedInDynamicValue loyaltyCount = new LockedInDynamicValue(new CountersCount(CounterType.LOYALTY));
LockedInDynamicValue loyaltyCount = new LockedInDynamicValue(new CountersSourceCount(CounterType.LOYALTY));
LoyaltyAbility ability2 = new LoyaltyAbility(new BecomesCreatureSourceEffect(
new GideonChampionOfJusticeToken(), "planeswalker", Duration.EndOfTurn, false, false, loyaltyCount, loyaltyCount), 0);
ability2.addEffect(new PreventAllDamageToSourceEffect(Duration.EndOfTurn));

View file

@ -33,7 +33,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.Mana;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.keyword.EvolveAbility;
import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl;
@ -59,7 +59,7 @@ public class GyreSage extends CardImpl {
this.addAbility(new EvolveAbility());
//{T} : Add {G} to your mana pool for each +1/+1 counter on Gyre Sage.
this.addAbility(new DynamicManaAbility(Mana.GreenMana(1), new CountersCount(CounterType.P1P1)));
this.addAbility(new DynamicManaAbility(Mana.GreenMana(1), new CountersSourceCount(CounterType.P1P1)));
}
public GyreSage(final GyreSage card) {

View file

@ -36,7 +36,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -88,7 +88,7 @@ public class KangeeAerieKeeper extends CardImpl {
this.addAbility(new ConditionalTriggeredAbility(ability, KickedCondition.getInstance(), "When {this} enters the battlefield, if it was kicked, put X feather counters on it."));
// Other Bird creatures get +1/+1 for each feather counter on Kangee, Aerie Keeper.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(new CountersCount(CounterType.FEATHER), new CountersCount(CounterType.FEATHER), Duration.WhileOnBattlefield, filter, true, "Other Bird creatures get +1/+1 for each feather counter on {this}.")));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(new CountersSourceCount(CounterType.FEATHER), new CountersSourceCount(CounterType.FEATHER), Duration.WhileOnBattlefield, filter, true, "Other Bird creatures get +1/+1 for each feather counter on {this}.")));
}
public KangeeAerieKeeper(final KangeeAerieKeeper card) {

View file

@ -30,7 +30,7 @@ package mage.sets.judgment;
import java.util.UUID;
import mage.abilities.common.PutIntoGraveFromBattlefieldAllTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -65,8 +65,8 @@ public class SoulcatchersAerie extends CardImpl {
this.addAbility(new PutIntoGraveFromBattlefieldAllTriggeredAbility(new AddCountersSourceEffect(CounterType.FEATHER.createInstance()),
false, filter, false, true));
// Bird creatures get +1/+1 for each feather counter on Soulcatchers' Aerie.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(new CountersCount(CounterType.FEATHER),
new CountersCount(CounterType.FEATHER), Duration.WhileOnBattlefield, filter2, false,
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(new CountersSourceCount(CounterType.FEATHER),
new CountersSourceCount(CounterType.FEATHER), Duration.WhileOnBattlefield, filter2, false,
"Bird creatures get +1/+1 for each feather counter on {this}.")));
}

View file

@ -34,7 +34,7 @@ import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.AsTurnedFaceUpEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
@ -67,7 +67,7 @@ public class HoodedHydra extends CardImpl {
this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance())));
// When Hooded Hydra dies, put a 1/1 green Snake creature token onto the battlefield for each +1/+1 counter on it.
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SnakeToken("KTK"), new CountersCount(CounterType.P1P1)), false));
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SnakeToken("KTK"), new CountersSourceCount(CounterType.P1P1)), false));
// Morph {3}{G}{G}
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{3}{G}{G}")));

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.AmplifyEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.AmplifyAbility;
@ -65,7 +65,7 @@ public class KilnmouthDragon extends CardImpl {
// {tap}: Kilnmouth Dragon deals damage equal to the number of +1/+1 counters on it to target creature or player.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new DamageTargetEffect(new CountersCount(CounterType.P1P1)), new TapSourceCost());
new DamageTargetEffect(new CountersSourceCount(CounterType.P1P1)), new TapSourceCost());
ability.addTarget(new TargetCreatureOrPlayer());
this.addAbility(ability);
}

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.AmplifyEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.keyword.AmplifyAbility;
@ -60,7 +60,7 @@ public class CanopyCrawler extends CardImpl {
// Amplify 1
this.addAbility(new AmplifyAbility(AmplifyEffect.AmplifyFactor.Amplify1));
// {tap}: Target creature gets +1/+1 until end of turn for each +1/+1 counter on Canopy Crawler.
CountersCount count = new CountersCount(CounterType.P1P1);
CountersSourceCount count = new CountersSourceCount(CounterType.P1P1);
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(count, count, Duration.EndOfTurn, true), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.AmplifyEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.AmplifyAbility;
@ -59,7 +59,7 @@ public class DaruStinger extends CardImpl {
// Amplify 1
this.addAbility(new AmplifyAbility(AmplifyEffect.AmplifyFactor.Amplify1));
// {tap}: Daru Stinger deals damage equal to the number of +1/+1 counters on it to target attacking or blocking creature.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new CountersCount(CounterType.P1P1)), new TapSourceCost());
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new CountersSourceCount(CounterType.P1P1)), new TapSourceCost());
ability.addTarget(new TargetAttackingOrBlockingCreature());
this.addAbility(ability);
}

View file

@ -30,7 +30,7 @@ package mage.sets.legions;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.AmplifyEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.AmplifyAbility;
@ -55,7 +55,7 @@ public class EmbalmedBrawler extends CardImpl {
// Amplify 1
this.addAbility(new AmplifyAbility(AmplifyEffect.AmplifyFactor.Amplify1));
// Whenever Embalmed Brawler attacks or blocks, you lose 1 life for each +1/+1 counter on it.
this.addAbility(new AttacksOrBlocksTriggeredAbility(new LoseLifeSourceControllerEffect(new CountersCount(CounterType.P1P1)), false));
this.addAbility(new AttacksOrBlocksTriggeredAbility(new LoseLifeSourceControllerEffect(new CountersSourceCount(CounterType.P1P1)), false));
}
public EmbalmedBrawler(final EmbalmedBrawler card) {

View file

@ -33,7 +33,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -53,7 +53,7 @@ public class MindUnbound extends CardImpl {
// At the beginning of your upkeep, put a lore counter on Mind Unbound, then draw a card for each lore counter on Mind Unbound.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.LORE.createInstance()), TargetController.YOU, false);
ability.addEffect(new DrawCardSourceControllerEffect(new CountersCount(CounterType.LORE)));
ability.addEffect(new DrawCardSourceControllerEffect(new CountersSourceCount(CounterType.LORE)));
this.addAbility(ability);
}

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.cards.CardImpl;
@ -73,7 +73,7 @@ public class VastwoodHydra extends CardImpl {
// When Vastwood Hydra dies, you may distribute a number of +1/+1 counters equal to the number of +1/+1 counters on Vastwood Hydra among any number of creatures you control.
Ability ability = new DiesTriggeredAbility(new VastwoodHydraDistributeEffect(), true);
ability.addTarget(new TargetCreaturePermanentAmount(new CountersCount(CounterType.P1P1), filter));
ability.addTarget(new TargetCreaturePermanentAmount(new CountersSourceCount(CounterType.P1P1), filter));
this.addAbility(ability);
}

View file

@ -35,7 +35,7 @@ import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -63,7 +63,7 @@ public class HangarbackWalker extends CardImpl {
this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance())));
// When Hangarback Walker dies, put a 1/1 colorless Thopter artifact creature token with flying onto the battlefield for each +1/+1 counter on Hangarback Walker.
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new ThopterColorlessToken(), new CountersCount(CounterType.P1P1)), false));
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new ThopterColorlessToken(), new CountersSourceCount(CounterType.P1P1)), false));
// {1}, {t}: Put a +1/+1 counter on Hangarback Walker.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), new GenericManaCost(1));

View file

@ -34,7 +34,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility;
@ -69,7 +69,7 @@ public class MageRingNetwork extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {C} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove X storage counters from {this}"));
this.addAbility(ability);

View file

@ -34,7 +34,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageEverythingEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -60,7 +60,7 @@ public class TimeBomb extends CardImpl {
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.TIME.createInstance(), true), TargetController.YOU, false));
// {1}, {tap}, Sacrifice Time Bomb: Time Bomb deals damage equal to the number of time counters on it to each creature and each player.
Effect effect = new DamageEverythingEffect(new CountersCount(CounterType.TIME), new FilterCreaturePermanent());
Effect effect = new DamageEverythingEffect(new CountersSourceCount(CounterType.TIME), new FilterCreaturePermanent());
effect.setText("{this} deals damage equal to the number of time counters on it to each creature and each player");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new GenericManaCost(1));
ability.addCost(new TapSourceCost());

View file

@ -34,7 +34,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.IsStepCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.DamagePlayersEffect;
import mage.cards.CardImpl;
@ -62,7 +62,7 @@ public class ArmageddonClock extends CardImpl {
// At the beginning of your upkeep, put a doom counter on Armageddon Clock.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.DOOM.createInstance(), new StaticValue(1), true, true), TargetController.YOU, false));
// At the beginning of your draw step, Armageddon Clock deals damage equal to the number of doom counters on it to each player.
this.addAbility(new BeginningOfDrawTriggeredAbility(new DamagePlayersEffect(Outcome.Damage, new CountersCount(CounterType.DOOM)), TargetController.YOU, false));
this.addAbility(new BeginningOfDrawTriggeredAbility(new DamagePlayersEffect(Outcome.Damage, new CountersSourceCount(CounterType.DOOM)), TargetController.YOU, false));
// {4}: Remove a doom counter from Armageddon Clock. Any player may activate this ability but only during any upkeep step.
ActivatedAbilityImpl ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD,
new RemoveCounterSourceEffect(CounterType.DOOM.createInstance()), new ManaCostsImpl("{4}"), new IsStepCondition(PhaseStep.UPKEEP, false), null);

View file

@ -34,7 +34,7 @@ import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
@ -64,7 +64,7 @@ public class FountainOfCho extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {W} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -34,7 +34,7 @@ import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
@ -64,7 +64,7 @@ public class MercadianBazaar extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {R} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -34,7 +34,7 @@ import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
@ -64,7 +64,7 @@ public class RushwoodGrove extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {G} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -34,7 +34,7 @@ import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
@ -64,7 +64,7 @@ public class SaprazzanCove extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {U} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -34,7 +34,7 @@ import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
@ -64,7 +64,7 @@ public class SubterraneanHangar extends CardImpl {
new RemovedCountersForCostValue(),
new TapSourceCost(),
"Add {B} to your mana pool for each storage counter removed this way",
true, new CountersCount(CounterType.STORAGE));
true, new CountersSourceCount(CounterType.STORAGE));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance(),
"Remove any number of storage counters from {this}"));
this.addAbility(ability);

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.EquipAbility;
@ -59,7 +59,7 @@ public class BansheesBlade extends CardImpl {
this.subtype.add("Equipment");
// Equipped creature gets +1/+1 for each charge counter on Banshee's Blade.
CountersCount chargeCountersCount = new CountersCount(CounterType.CHARGE);
CountersSourceCount chargeCountersCount = new CountersSourceCount(CounterType.CHARGE);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(chargeCountersCount, chargeCountersCount)));
// Whenever equipped creature deals combat damage, put a charge counter on Banshee's Blade.
this.addAbility(new BansheesBladeAbility());

View file

@ -30,7 +30,7 @@ package mage.sets.nemesis;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.abilities.keyword.FadingAbility;
import mage.cards.CardImpl;
@ -57,7 +57,7 @@ public class RustingGolem extends CardImpl {
this.addAbility(new FadingAbility(5, this));
// Rusting Golem's power and toughness are each equal to the number of fade counters on it.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(
new CountersCount(CounterType.FADE), Duration.EndOfGame)));
new CountersSourceCount(CounterType.FADE), Duration.EndOfGame)));
}
public RustingGolem(final RustingGolem card) {

View file

@ -39,7 +39,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl;
@ -68,7 +68,7 @@ public class ShrineOfBoundlessGrowth extends CardImpl {
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false));
// {T}, Sacrifice Shrine of Boundless Growth: Add {C} to your mana pool for each charge counter on Shrine of Boundless Growth.
Ability ability = new DynamicManaAbility(Mana.ColorlessMana(1), new CountersCount(CounterType.CHARGE), new TapSourceCost());
Ability ability = new DynamicManaAbility(Mana.ColorlessMana(1), new CountersSourceCount(CounterType.CHARGE), new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
this.addAbility(ability);

View file

@ -40,7 +40,7 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -67,7 +67,7 @@ public class ShrineOfBurningRage extends CardImpl {
this.expansionSetCode = "NPH";
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, false));
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new CountersCount(CounterType.CHARGE)), new GenericManaCost(3));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new CountersSourceCount(CounterType.CHARGE)), new GenericManaCost(3));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetCreatureOrPlayer());

View file

@ -40,7 +40,7 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -68,7 +68,7 @@ public class ShrineOfLimitlessPower extends CardImpl {
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, false));
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DiscardTargetEffect(new CountersCount(CounterType.CHARGE)), new GenericManaCost(4));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DiscardTargetEffect(new CountersSourceCount(CounterType.CHARGE)), new GenericManaCost(4));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetPlayer());

View file

@ -40,7 +40,7 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -69,7 +69,7 @@ public class ShrineOfLoyalLegions extends CardImpl {
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new CreateTokenEffect(new MyrToken("NPH"), new CountersCount(CounterType.CHARGE)),
new CreateTokenEffect(new MyrToken("NPH"), new CountersSourceCount(CounterType.CHARGE)),
new GenericManaCost(3));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost());

View file

@ -28,6 +28,7 @@
package mage.sets.onslaught;
import java.util.UUID;
import mage.ObjectColor;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.FetchLandActivatedAbility;
@ -42,6 +43,7 @@ public class BloodstainedMire extends CardImpl {
public BloodstainedMire(UUID ownerId) {
super(ownerId, 313, "Bloodstained Mire", Rarity.RARE, new CardType[]{CardType.LAND}, "");
this.expansionSetCode = "ONS";
this.frameColor = new ObjectColor("RB");
// {tap}, Pay 1 life, Sacrifice Bloodstained Mire: Search your library for a Swamp or Mountain card and put it onto the battlefield. Then shuffle your library.
this.addAbility(new FetchLandActivatedAbility(new String[]{"Swamp", "Mountain"}));

View file

@ -28,6 +28,7 @@
package mage.sets.onslaught;
import java.util.UUID;
import mage.ObjectColor;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.FetchLandActivatedAbility;
@ -42,6 +43,7 @@ public class FloodedStrand extends CardImpl {
public FloodedStrand(UUID ownerId) {
super(ownerId, 316, "Flooded Strand", Rarity.RARE, new CardType[]{CardType.LAND}, "");
this.expansionSetCode = "ONS";
this.frameColor = new ObjectColor("UW");
// {tap}, Pay 1 life, Sacrifice Flooded Strand: Search your library for a Plains or Island card and put it onto the battlefield. Then shuffle your library.
this.addAbility(new FetchLandActivatedAbility(new String[]{"Plains", "Island"}));

View file

@ -28,6 +28,7 @@
package mage.sets.onslaught;
import java.util.UUID;
import mage.ObjectColor;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.FetchLandActivatedAbility;
@ -42,6 +43,7 @@ public class PollutedDelta extends CardImpl {
public PollutedDelta(UUID ownerId) {
super(ownerId, 321, "Polluted Delta", Rarity.RARE, new CardType[]{CardType.LAND}, "");
this.expansionSetCode = "ONS";
this.frameColor = new ObjectColor("UB");
// {tap}, Pay 1 life, Sacrifice Polluted Delta: Search your library for an Island or Swamp card and put it onto the battlefield. Then shuffle your library.
this.addAbility(new FetchLandActivatedAbility(new String[]{"Island", "Swamp"}));

View file

@ -28,6 +28,7 @@
package mage.sets.onslaught;
import java.util.UUID;
import mage.ObjectColor;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.FetchLandActivatedAbility;
@ -42,6 +43,7 @@ public class WindsweptHeath extends CardImpl {
public WindsweptHeath(UUID ownerId) {
super(ownerId, 328, "Windswept Heath", Rarity.RARE, new CardType[]{CardType.LAND}, "");
this.expansionSetCode = "ONS";
this.frameColor = new ObjectColor("GW");
// {tap}, Pay 1 life, Sacrifice Windswept Heath: Search your library for a Forest or Plains card and put it onto the battlefield. Then shuffle your library.
this.addAbility(new FetchLandActivatedAbility(new String[]{"Forest", "Plains"}));

View file

@ -28,6 +28,7 @@
package mage.sets.onslaught;
import java.util.UUID;
import mage.ObjectColor;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.FetchLandActivatedAbility;
@ -42,6 +43,7 @@ public class WoodedFoothills extends CardImpl {
public WoodedFoothills(UUID ownerId) {
super(ownerId, 330, "Wooded Foothills", Rarity.RARE, new CardType[]{CardType.LAND}, "");
this.expansionSetCode = "ONS";
this.frameColor = new ObjectColor("RG");
// {tap}, Pay 1 life, Sacrifice Wooded Foothills: Search your library for a Mountain or Forest card and put it onto the battlefield. Then shuffle your library.
this.addAbility(new FetchLandActivatedAbility(new String[]{"Mountain", "Forest"}));

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -71,7 +71,7 @@ public class Tidewalker extends CardImpl {
this.addAbility(new VanishingUpkeepAbility(0));
this.addAbility(new VanishingSacrificeAbility());
// Tidewalker's power and toughness are each equal to the number of time counters on it.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new CountersCount(CounterType.TIME), Duration.EndOfGame)));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new CountersSourceCount(CounterType.TIME), Duration.EndOfGame)));
}
public Tidewalker(final Tidewalker card) {

View file

@ -33,7 +33,7 @@ import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.DevourEffect.DevourFactor;
import mage.abilities.keyword.DevourAbility;
@ -63,7 +63,7 @@ public class PreyseizerDragon extends CardImpl {
this.addAbility(new DevourAbility(DevourFactor.Devour2));
// Whenever Preyseizer Dragon attacks, it deals damage to target creature or player equal to the number of +1/+1 counters on Preyseizer Dragon.
Ability ability = new AttacksTriggeredAbility(new DamageTargetEffect(new CountersCount(CounterType.P1P1)), false);
Ability ability = new AttacksTriggeredAbility(new DamageTargetEffect(new CountersSourceCount(CounterType.P1P1)), false);
ability.addTarget(new TargetCreatureOrPlayer());
this.addAbility(ability);
}

View file

@ -33,7 +33,7 @@ import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -68,7 +68,7 @@ public class SurrakarSpellblade extends CardImpl {
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, true));
// Whenever Surrakar Spellblade deals combat damage to a player, you may draw X cards, where X is the number of charge counters on it.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DrawCardSourceControllerEffect(new CountersCount(CounterType.CHARGE)), true));
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DrawCardSourceControllerEffect(new CountersSourceCount(CounterType.CHARGE)), true));
}
public SurrakarSpellblade(final SurrakarSpellblade card) {

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.cards.CardImpl;
@ -62,7 +62,7 @@ public class MagaTraitorToMortals extends CardImpl {
// When Maga enters the battlefield, target player loses life equal to the number of +1/+1 counters on it.
Ability ability = new EntersBattlefieldTriggeredAbility(
new LoseLifeTargetEffect(new CountersCount(CounterType.P1P1)), false);
new LoseLifeTargetEffect(new CountersSourceCount(CounterType.P1P1)), false);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}

View file

@ -33,7 +33,7 @@ import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
@ -81,6 +81,6 @@ class ChimericMassToken extends Token {
subtype.add("Construct");
power = new MageInt(0);
toughness = new MageInt(0);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SetPowerToughnessSourceEffect(new CountersCount(CounterType.CHARGE), Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SetPowerToughnessSourceEffect(new CountersSourceCount(CounterType.CHARGE), Duration.WhileOnBattlefield)));
}
}

Some files were not shown because too many files have changed in this diff Show more