This commit is contained in:
magenoxx 2011-02-23 10:59:30 +03:00
commit f1472d1fa4
32 changed files with 727 additions and 80 deletions

View file

@ -75,7 +75,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
setOpaque(false); setOpaque(false);
} }
public void loadCards(CardsView showCards, SortBy sortBy, BigCard bigCard, UUID gameId) { public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
this.bigCard = bigCard; this.bigCard = bigCard;
this.gameId = gameId; this.gameId = gameId;
for (CardView card: showCards.values()) { for (CardView card: showCards.values()) {
@ -90,7 +90,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
i.remove(); i.remove();
} }
} }
drawCards(sortBy); drawCards(sortBy, piles);
this.setVisible(true); this.setVisible(true);
} }
@ -106,7 +106,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
cards.put(card.getId(), cardImg); cards.put(card.getId(), cardImg);
} }
public void drawCards(SortBy sortBy) { public void drawCards(SortBy sortBy, boolean piles) {
int maxWidth = this.getParent().getWidth(); int maxWidth = this.getParent().getWidth();
int numColumns = maxWidth / Config.dimensions.frameWidth; int numColumns = maxWidth / Config.dimensions.frameWidth;
int curColumn = 0; int curColumn = 0;
@ -128,15 +128,54 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
Collections.sort(sortedCards, new CardCostComparator()); Collections.sort(sortedCards, new CardCostComparator());
break; break;
} }
MageCard lastCard = null;
for (MageCard cardImg: sortedCards) { for (MageCard cardImg: sortedCards) {
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20); if (piles) {
cardImg.setBounds(rectangle); if (lastCard == null)
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight); lastCard = cardImg;
moveToFront(cardImg); switch (sortBy) {
curColumn++; case NAME:
if (curColumn == numColumns) { if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
curColumn = 0; curColumn++;
curRow = 0;
}
break;
case RARITY:
if (!cardImg.getOriginal().getRarity().equals(lastCard.getOriginal().getRarity())) {
curColumn++;
curRow = 0;
}
break;
case COLOR:
if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor()) != 0) {
curColumn++;
curRow = 0;
}
break;
case CASTING_COST:
if (cardImg.getOriginal().getConvertedManaCost() != lastCard.getOriginal().getConvertedManaCost()) {
curColumn++;
curRow = 0;
}
break;
}
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
cardImg.setBounds(rectangle);
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
moveToFront(cardImg);
curRow++; curRow++;
lastCard = cardImg;
}
else {
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
cardImg.setBounds(rectangle);
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
moveToFront(cardImg);
curColumn++;
if (curColumn == numColumns) {
curColumn = 0;
curRow++;
}
} }
} }
} }

View file

@ -27,7 +27,7 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> <Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="639" max="32767" attributes="0"/> <Component id="jScrollPane1" alignment="0" pref="625" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
@ -35,7 +35,7 @@
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/> <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="397" max="32767" attributes="0"/> <Component id="jScrollPane1" pref="258" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -58,12 +58,14 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Component id="lblCount" min="-2" pref="81" max="-2" attributes="0"/> <Component id="lblCount" min="-2" pref="81" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="1"/>
<Component id="lblCreatureCount" min="-2" pref="100" max="-2" attributes="0"/> <Component id="lblCreatureCount" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="lblLandCount" min="-2" pref="75" max="-2" attributes="0"/> <Component id="lblLandCount" min="-2" pref="75" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="cbSortBy" pref="353" max="32767" attributes="0"/> <Component id="chkPiles" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="cbSortBy" pref="300" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -74,6 +76,7 @@
<Component id="lblCount" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblCreatureCount" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblCreatureCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblLandCount" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblLandCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkPiles" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -109,6 +112,14 @@
<Property name="text" type="java.lang.String" value="Land Count"/> <Property name="text" type="java.lang.String" value="Land Count"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chkPiles">
<Properties>
<Property name="text" type="java.lang.String" value="Piles"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkPilesActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
</SubComponents> </SubComponents>

View file

@ -46,6 +46,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.ObjectColor;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.client.constants.Constants.SortBy; import mage.client.constants.Constants.SortBy;
@ -115,17 +116,58 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
Collections.sort(sortedCards, new CardViewCostComparator()); Collections.sort(sortedCards, new CardViewCostComparator());
break; break;
} }
CardView lastCard = null;
for (CardView card: sortedCards) { for (CardView card: sortedCards) {
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20); if (chkPiles.isSelected()) {
addCard(card, bigCard, gameId, rectangle); if (lastCard == null)
if (card.getCardTypes().contains(CardType.LAND)) lastCard = card;
landCount++; switch (sortBy) {
if (card.getCardTypes().contains(CardType.CREATURE)) case NAME:
creatureCount++; if (!card.getName().equals(lastCard.getName())) {
curColumn++; curColumn++;
if (curColumn == numColumns) { curRow = 0;
curColumn = 0; }
break;
case RARITY:
if (!card.getRarity().equals(lastCard.getRarity())) {
curColumn++;
curRow = 0;
}
break;
case COLOR:
if (card.getColor().compareTo(lastCard.getColor()) != 0) {
curColumn++;
curRow = 0;
}
break;
case CASTING_COST:
if (card.getConvertedManaCost() != lastCard.getConvertedManaCost()) {
curColumn++;
curRow = 0;
}
break;
}
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
addCard(card, bigCard, gameId, rectangle);
if (card.getCardTypes().contains(CardType.LAND))
landCount++;
if (card.getCardTypes().contains(CardType.CREATURE))
creatureCount++;
curRow++; curRow++;
lastCard = card;
}
else {
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
addCard(card, bigCard, gameId, rectangle);
if (card.getCardTypes().contains(CardType.LAND))
landCount++;
if (card.getCardTypes().contains(CardType.CREATURE))
creatureCount++;
curColumn++;
if (curColumn == numColumns) {
curColumn = 0;
curRow++;
}
} }
} }
} }
@ -176,6 +218,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
lblCount = new javax.swing.JLabel(); lblCount = new javax.swing.JLabel();
lblCreatureCount = new javax.swing.JLabel(); lblCreatureCount = new javax.swing.JLabel();
lblLandCount = new javax.swing.JLabel(); lblLandCount = new javax.swing.JLabel();
chkPiles = new javax.swing.JCheckBox();
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
setPreferredSize((!Beans.isDesignTime())?(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)):(new Dimension(100, 100))); setPreferredSize((!Beans.isDesignTime())?(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)):(new Dimension(100, 100)));
@ -195,6 +238,13 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
lblLandCount.setText("Land Count"); lblLandCount.setText("Land Count");
chkPiles.setText("Piles");
chkPiles.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkPilesActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.setHorizontalGroup(
@ -205,8 +255,10 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
.addComponent(lblCreatureCount, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblCreatureCount, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblLandCount, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblLandCount, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSortBy, 0, 353, Short.MAX_VALUE)) .addComponent(chkPiles)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSortBy, 0, 300, Short.MAX_VALUE))
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -214,7 +266,8 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
.addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblCount) .addComponent(lblCount)
.addComponent(lblCreatureCount) .addComponent(lblCreatureCount)
.addComponent(lblLandCount)) .addComponent(lblLandCount)
.addComponent(chkPiles))
); );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@ -222,14 +275,14 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 625, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@ -237,10 +290,15 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
drawCards((SortBy) cbSortBy.getSelectedItem()); drawCards((SortBy) cbSortBy.getSelectedItem());
}//GEN-LAST:event_cbSortByActionPerformed }//GEN-LAST:event_cbSortByActionPerformed
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
drawCards((SortBy) cbSortBy.getSelectedItem());
}//GEN-LAST:event_chkPilesActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLayeredPane cardArea; private javax.swing.JLayeredPane cardArea;
private javax.swing.JComboBox cbSortBy; private javax.swing.JComboBox cbSortBy;
private javax.swing.JCheckBox chkPiles;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblCount; private javax.swing.JLabel lblCount;

View file

@ -255,6 +255,17 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rdoPlaneswalkersActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rdoPlaneswalkersActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chkPiles">
<Properties>
<Property name="text" type="java.lang.String" value="Piles"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkPilesActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="cbSortBy"> <Component class="javax.swing.JComboBox" name="cbSortBy">
<Properties> <Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">

View file

@ -142,7 +142,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
filteredCards.add(card); filteredCards.add(card);
} }
} }
this.cardGrid.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), bigCard, null); this.cardGrid.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null);
} }
finally { finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
@ -198,6 +198,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
rdoInstants = new javax.swing.JRadioButton(); rdoInstants = new javax.swing.JRadioButton();
rdoSorceries = new javax.swing.JRadioButton(); rdoSorceries = new javax.swing.JRadioButton();
rdoPlaneswalkers = new javax.swing.JRadioButton(); rdoPlaneswalkers = new javax.swing.JRadioButton();
chkPiles = new javax.swing.JCheckBox();
cbSortBy = new javax.swing.JComboBox(); cbSortBy = new javax.swing.JComboBox();
tbColor.setFloatable(false); tbColor.setFloatable(false);
@ -394,6 +395,17 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}); });
tbTypes.add(rdoPlaneswalkers); tbTypes.add(rdoPlaneswalkers);
chkPiles.setText("Piles");
chkPiles.setFocusable(false);
chkPiles.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
chkPiles.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
chkPiles.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkPilesActionPerformed(evt);
}
});
tbTypes.add(chkPiles);
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbSortBy.addActionListener(new java.awt.event.ActionListener() { cbSortBy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -530,9 +542,14 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
if (cbSortBy.getSelectedItem() instanceof SortBy) if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}//GEN-LAST:event_cbSortByActionPerformed }//GEN-LAST:event_cbSortByActionPerformed
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}//GEN-LAST:event_chkPilesActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnBooster; private javax.swing.JButton btnBooster;
@ -540,6 +557,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private mage.client.cards.CardGrid cardGrid; private mage.client.cards.CardGrid cardGrid;
private javax.swing.JComboBox cbExpansionSet; private javax.swing.JComboBox cbExpansionSet;
private javax.swing.JComboBox cbSortBy; private javax.swing.JComboBox cbSortBy;
private javax.swing.JCheckBox chkPiles;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JRadioButton rdoArtifacts; private javax.swing.JRadioButton rdoArtifacts;
private javax.swing.JRadioButton rdoBlack; private javax.swing.JRadioButton rdoBlack;
@ -561,25 +579,25 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
@Override @Override
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy) if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
} }
@Override @Override
public void componentMoved(ComponentEvent e) { public void componentMoved(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy) if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
} }
@Override @Override
public void componentShown(ComponentEvent e) { public void componentShown(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy) if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
} }
@Override @Override
public void componentHidden(ComponentEvent e) { public void componentHidden(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy) if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
} }
} }

View file

@ -98,7 +98,7 @@ public class DraftPanel extends javax.swing.JPanel {
public void loadBooster(DraftPickView draftPickView) { public void loadBooster(DraftPickView draftPickView) {
draftBooster.loadBooster(draftPickView.getBooster(), bigCard); draftBooster.loadBooster(draftPickView.getBooster(), bigCard);
draftPicks.loadCards(draftPickView.getPicks(), SortBy.NAME, bigCard, null); draftPicks.loadCards(draftPickView.getPicks(), SortBy.NAME, false, bigCard, null);
this.draftBooster.clearCardEventListeners(); this.draftBooster.clearCardEventListeners();
this.draftBooster.addCardEventListener( this.draftBooster.addCardEventListener(
new Listener<Event> () { new Listener<Event> () {
@ -108,7 +108,7 @@ public class DraftPanel extends javax.swing.JPanel {
DraftPickView view = session.sendCardPick(draftId, (UUID)event.getSource()); DraftPickView view = session.sendCardPick(draftId, (UUID)event.getSource());
if (view != null) { if (view != null) {
draftBooster.loadBooster(view.getBooster(), bigCard); draftBooster.loadBooster(view.getBooster(), bigCard);
draftPicks.loadCards(view.getPicks(), SortBy.NAME, bigCard, null); draftPicks.loadCards(view.getPicks(), SortBy.NAME, false, bigCard, null);
setMessage("Waiting for other players"); setMessage("Waiting for other players");
} }
} }

View file

@ -44,6 +44,7 @@ import mage.MageObject;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility; import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbilities; import mage.abilities.TriggeredAbilities;
import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbility;
import mage.abilities.costs.mana.ColoredManaCost; import mage.abilities.costs.mana.ColoredManaCost;
@ -225,7 +226,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
if (target instanceof TargetDiscard) { if (target instanceof TargetDiscard) {
findPlayables(game); findPlayables(game);
@ -243,7 +245,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
if (target instanceof TargetControlledPermanent) { if (target instanceof TargetControlledPermanent) {
List<Permanent> targets; List<Permanent> targets;
@ -271,7 +274,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
if (target instanceof TargetCreatureOrPlayer) { if (target instanceof TargetCreatureOrPlayer) {
List<Permanent> targets; List<Permanent> targets;
@ -300,7 +304,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString()); throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString());
} }
@ -484,10 +489,13 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
for (Mana mana: options) { for (Mana mana: options) {
for (Mana avail: available) { for (Mana avail: available) {
if (mana.enough(avail)) { if (mana.enough(avail)) {
if (card.getCardType().contains(CardType.INSTANT)) SpellAbility ability = card.getSpellAbility();
playableInstant.add(card); if (ability != null && ability.canActivate(playerId, game)) {
else if (card.getCardType().contains(CardType.INSTANT))
playableNonInstant.add(card); playableInstant.add(card);
else
playableNonInstant.add(card);
}
} }
else { else {
if (!playableInstant.contains(card) && !playableNonInstant.contains(card)) if (!playableInstant.contains(card) && !playableNonInstant.contains(card))

View file

@ -160,6 +160,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
logger.debug("simulating pre combat actions -----------------------------------------------------------------------------------------"); logger.debug("simulating pre combat actions -----------------------------------------------------------------------------------------");
addActionsTimed(new FilterAbility()); addActionsTimed(new FilterAbility());
// addActions(root, new FilterAbility(), maxDepth, Integer.MIN_VALUE, Integer.MAX_VALUE);
if (root.children.size() > 0) { if (root.children.size() > 0) {
root = root.children.get(0); root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities); actions = new LinkedList<Ability>(root.abilities);
@ -176,6 +177,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
root = new SimulationNode(null, sim, maxDepth, playerId); root = new SimulationNode(null, sim, maxDepth, playerId);
logger.debug("simulating post combat actions ----------------------------------------------------------------------------------------"); logger.debug("simulating post combat actions ----------------------------------------------------------------------------------------");
addActionsTimed(new FilterAbility()); addActionsTimed(new FilterAbility());
// addActions(root, new FilterAbility(), maxDepth, Integer.MIN_VALUE, Integer.MAX_VALUE);
if (root.children.size() > 0) { if (root.children.size() > 0) {
root = root.children.get(0); root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities); actions = new LinkedList<Ability>(root.abilities);
@ -296,8 +298,8 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
} }
else if (!counter) { else if (!counter) {
finishCombat(game); finishCombat(game);
val = GameStateEvaluator.evaluate(playerId, game); // val = GameStateEvaluator.evaluate(playerId, game);
// val = simulateCounterAttack(game, node, depth, alpha, beta); val = simulateCounterAttack(game, node, depth, alpha, beta);
} }
} }
if (val == null) if (val == null)
@ -326,16 +328,16 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
break; break;
} }
Game sim = game.copy(); Game sim = game.copy();
UUID defenderId = game.getOpponents(playerId).iterator().next(); UUID defenderId = game.getOpponents(attackerId).iterator().next();
for (CombatGroup group: engagement.getGroups()) { for (CombatGroup group: engagement.getGroups()) {
for (UUID attackId: group.getAttackers()) { for (UUID attackId: group.getAttackers()) {
sim.getPlayer(attackerId).declareAttacker(attackId, defenderId, sim); sim.getPlayer(attackerId).declareAttacker(attackId, defenderId, sim);
} }
} }
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, playerId, playerId)); sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, attackerId, attackerId));
SimulationNode newNode = new SimulationNode(node, sim, depth, attackerId); SimulationNode newNode = new SimulationNode(node, sim, depth, attackerId);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("simulating attack for player:" + game.getPlayer(newNode.getPlayerId()).getName()); logger.debug("simulating attack for player:" + game.getPlayer(attackerId).getName());
sim.checkStateAndTriggered(); sim.checkStateAndTriggered();
while (!sim.getStack().isEmpty()) { while (!sim.getStack().isEmpty()) {
sim.getStack().resolve(sim); sim.getStack().resolve(sim);
@ -399,10 +401,10 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
} }
} }
} }
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, playerId, playerId)); sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defenderId, defenderId));
SimulationNode newNode = new SimulationNode(node, sim, depth, defenderId); SimulationNode newNode = new SimulationNode(node, sim, depth, defenderId);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("simulating block for player:" + game.getPlayer(newNode.getPlayerId()).getName()); logger.debug("simulating block for player:" + game.getPlayer(defenderId).getName());
sim.checkStateAndTriggered(); sim.checkStateAndTriggered();
while (!sim.getStack().isEmpty()) { while (!sim.getStack().isEmpty()) {
sim.getStack().resolve(sim); sim.getStack().resolve(sim);
@ -455,9 +457,9 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
} }
Integer val = null; Integer val = null;
if (!game.isGameOver()) { if (!game.isGameOver()) {
logger.debug("simulating -- counter attack");
simulateToEnd(game); simulateToEnd(game);
game.getState().setActivePlayerId(game.getState().getPlayerList(game.getActivePlayerId()).getNext()); game.getState().setActivePlayerId(game.getState().getPlayerList(game.getActivePlayerId()).getNext());
logger.debug("simulating -- counter attack for player " + game.getPlayer(game.getActivePlayerId()).getName());
game.getTurn().setPhase(new BeginningPhase()); game.getTurn().setPhase(new BeginningPhase());
if (game.getPhase().beginPhase(game, game.getActivePlayerId())) { if (game.getPhase().beginPhase(game, game.getActivePlayerId())) {
simulateStep(game, new UntapStep()); simulateStep(game, new UntapStep());

View file

@ -59,7 +59,7 @@ public class GameStateEvaluator {
int score = lifeScore + permanentScore + handScore; int score = lifeScore + permanentScore + handScore;
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("game state evaluated to- lifeScore:" + lifeScore + " permanentScore:" + permanentScore + " handScore:" + handScore + " total:" + score); logger.debug("game state for player " + player.getName() + " evaluated to- lifeScore:" + lifeScore + " permanentScore:" + permanentScore + " handScore:" + handScore + " total:" + score);
return score; return score;
} }

View file

@ -36,8 +36,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -56,11 +54,11 @@ import mage.players.Player;
import mage.server.ChatManager; import mage.server.ChatManager;
import mage.server.util.ThreadExecutor; import mage.server.util.ThreadExecutor;
import mage.sets.Sets; import mage.sets.Sets;
import mage.util.Logging;
import mage.view.AbilityPickerView; import mage.view.AbilityPickerView;
import mage.view.CardsView; import mage.view.CardsView;
import mage.view.GameView; import mage.view.GameView;
import mage.view.ChatMessage.MessageColor; import mage.view.ChatMessage.MessageColor;
import org.apache.log4j.Logger;
/** /**
* *
@ -69,7 +67,7 @@ import mage.view.ChatMessage.MessageColor;
public class GameController implements GameCallback { public class GameController implements GameCallback {
private static ExecutorService gameExecutor = ThreadExecutor.getInstance().getGameExecutor(); private static ExecutorService gameExecutor = ThreadExecutor.getInstance().getGameExecutor();
private final static Logger logger = Logging.getLogger(GameController.class.getName()); private final static Logger logger = Logger.getLogger(GameController.class);
public static final String INIT_FILE_PATH = "config" + File.separator + "init.txt"; public static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>(); private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>();
@ -104,7 +102,7 @@ public class GameController implements GameCallback {
break; break;
case INFO: case INFO:
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK); ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK);
logger.finest(game.getId() + " " + event.getMessage()); logger.debug(game.getId() + " " + event.getMessage());
break; break;
case REVEAL: case REVEAL:
revealCards(event.getMessage(), event.getCards()); revealCards(event.getMessage(), event.getCards());
@ -178,7 +176,7 @@ public class GameController implements GameCallback {
if (gameFuture == null) { if (gameFuture == null) {
for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) { for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) {
if (!entry.getValue().init(getGameView(entry.getKey()))) { if (!entry.getValue().init(getGameView(entry.getKey()))) {
logger.severe("Unable to initialize client"); logger.fatal("Unable to initialize client");
//TODO: generate client error message //TODO: generate client error message
return; return;
} }
@ -238,7 +236,7 @@ public class GameController implements GameCallback {
card.putOntoBattlefield(game, Zone.OUTSIDE, null, playerId); card.putOntoBattlefield(game, Zone.OUTSIDE, null, playerId);
} }
} catch (GameException ex) { } catch (GameException ex) {
logger.warning(ex.getMessage()); logger.warn(ex.getMessage());
} }
addCardsForTesting(game); addCardsForTesting(game);
updateGame(); updateGame();
@ -434,7 +432,7 @@ public class GameController implements GameCallback {
File f = new File(INIT_FILE_PATH); File f = new File(INIT_FILE_PATH);
Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)"); Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)");
if (!f.exists()) { if (!f.exists()) {
logger.warning("Couldn't find init file: " + INIT_FILE_PATH); logger.warn("Couldn't find init file: " + INIT_FILE_PATH);
return; return;
} }
@ -444,7 +442,7 @@ public class GameController implements GameCallback {
try { try {
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim(); String line = scanner.nextLine().trim();
if (line.startsWith("#")) continue; if (line.trim().length() == 0 || line.startsWith("#")) continue;
Matcher m = pattern.matcher(line); Matcher m = pattern.matcher(line);
if (m.matches()) { if (m.matches()) {
@ -476,14 +474,14 @@ public class GameController implements GameCallback {
game.loadCards(cards, player.getId()); game.loadCards(cards, player.getId());
swapWithAnyCard(game, player, card, gameZone); swapWithAnyCard(game, player, card, gameZone);
} else { } else {
logger.severe("Couldn't find a card: " + cardName); logger.fatal("Couldn't find a card: " + cardName);
} }
} }
} else { } else {
logger.warning("Was skipped: " + line); logger.warn("Was skipped: " + line);
} }
} else { } else {
logger.warning("Init string wasn't parsed: " + line); logger.warn("Init string wasn't parsed: " + line);
} }
} }
} }
@ -491,7 +489,7 @@ public class GameController implements GameCallback {
scanner.close(); scanner.close();
} }
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.SEVERE, "", e); logger.fatal("", e);
} }
} }

View file

@ -90,8 +90,8 @@ class MartialCoupEffect extends OneShotEffect<MartialCoupEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int amount = 0; int amount = 0;
if (source.getManaCosts().getVariableCosts().size() > 0) { if (source.getManaCostsToPay().getVariableCosts().size() > 0) {
amount = source.getManaCosts().getVariableCosts().get(0).getAmount(); amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
} }
if (amount > 4) { if (amount > 4) {

View file

@ -93,7 +93,7 @@ class EarthquakeEffect extends OneShotEffect<EarthquakeEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount(); int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
permanent.damage(amount, source.getId(), game, true, false); permanent.damage(amount, source.getId(), game, true, false);

View file

@ -91,7 +91,7 @@ class FireballEffect extends OneShotEffect<FireballEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int numTargets = source.getTargets().get(0).getTargets().size(); int numTargets = source.getTargets().get(0).getTargets().size();
int damage = source.getManaCosts().getVariableCosts().get(0).getAmount(); int damage = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
if (numTargets > 0) { if (numTargets > 0) {
int damagePer = damage/numTargets; int damagePer = damage/numTargets;
if (damagePer > 0) { if (damagePer > 0) {

View file

@ -84,7 +84,7 @@ class MindSpringEffect extends OneShotEffect<MindSpringEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount(); int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
player.drawCards(amount, game); player.drawCards(amount, game);

View file

@ -99,7 +99,7 @@ public class ProteanHydra extends CardImpl<ProteanHydra> {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount(); int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
permanent.addCounters(new PlusOneCounter(amount)); permanent.addCounters(new PlusOneCounter(amount));
} }
return true; return true;

View file

@ -102,8 +102,8 @@ class VengefulArchonEffect extends PreventionEffectImpl<VengefulArchonEffect> {
@Override @Override
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
if (source.getManaCosts().getVariableCosts().size() > 0) if (source.getManaCostsToPay().getVariableCosts().size() > 0)
amount = source.getManaCosts().getVariableCosts().get(0).getAmount(); amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
} }
@Override @Override

View file

@ -0,0 +1,66 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.keyword.BattleCryAbility;
import mage.cards.CardImpl;
/**
*
* @author Loki
*/
public class AccorderPaladin extends CardImpl<AccorderPaladin> {
public AccorderPaladin (UUID ownerId) {
super(ownerId, 1, "Accorder Paladin", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{W}");
this.expansionSetCode = "MBS";
this.subtype.add("Human");
this.subtype.add("Knight");
this.color.setWhite(true);
this.power = new MageInt(3);
this.toughness = new MageInt(1);
this.addAbility(new BattleCryAbility());
}
public AccorderPaladin (final AccorderPaladin card) {
super(card);
}
@Override
public AccorderPaladin copy() {
return new AccorderPaladin(this);
}
}

View file

@ -0,0 +1,74 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.Metalcraft;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.cards.CardImpl;
/**
* @author Loki
*/
public class ArdentRecruit extends CardImpl<ArdentRecruit> {
private final String myText = "Metalcraft - Ardent Recruit gets +2/+2 as long as you control three or more artifacts";
public ArdentRecruit(UUID ownerId) {
super(ownerId, 2, "Ardent Recruit", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{W}");
this.expansionSetCode = "MBS";
this.subtype.add("Human");
this.subtype.add("Soldier");
this.color.setWhite(true);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
ContinuousEffect boostSource = new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield);
ConditionalContinousEffect effect = new ConditionalContinousEffect(boostSource, Metalcraft.getInstance(), myText);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
public ArdentRecruit(final ArdentRecruit card) {
super(card);
}
@Override
public ArdentRecruit copy() {
return new ArdentRecruit(this);
}
}

View file

@ -0,0 +1,67 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.keyword.InfectAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
/**
*
* @author Loki
*/
public class Flensermite extends CardImpl<Flensermite> {
public Flensermite (UUID ownerId) {
super(ownerId, 41, "Flensermite", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B}");
this.expansionSetCode = "MBS";
this.subtype.add("Gremlin");
this.color.setBlack(true);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
this.addAbility(InfectAbility.getInstance());
this.addAbility(LifelinkAbility.getInstance());
}
public Flensermite (final Flensermite card) {
super(card);
}
@Override
public Flensermite copy() {
return new Flensermite(this);
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.keyword.BattleCryAbility;
import mage.cards.CardImpl;
/**
*
* @author Loki
*/
public class GoblinWardriver extends CardImpl<GoblinWardriver> {
public GoblinWardriver (UUID ownerId) {
super(ownerId, 64, "Goblin Wardriver", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{R}{R}");
this.expansionSetCode = "MBS";
this.subtype.add("Goblin");
this.subtype.add("Warrior");
this.color.setRed(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(new BattleCryAbility());
}
public GoblinWardriver (final GoblinWardriver card) {
super(card);
}
@Override
public GoblinWardriver copy() {
return new GoblinWardriver(this);
}
}

View file

@ -0,0 +1,67 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
/**
*
* @author Loki
*/
public class GustSkimmer extends CardImpl<GustSkimmer> {
public GustSkimmer (UUID ownerId) {
super(ownerId, 108, "Gust-Skimmer", Rarity.COMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}");
this.expansionSetCode = "MBS";
this.subtype.add("Insect");
this.power = new MageInt(2);
this.toughness = new MageInt(1);
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{U}")));
}
public GustSkimmer (final GustSkimmer card) {
super(card);
}
@Override
public GustSkimmer copy() {
return new GustSkimmer(this);
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.keyword.BattleCryAbility;
import mage.cards.CardImpl;
/**
*
* @author Loki
*/
public class LoxodonPartisan extends CardImpl<LoxodonPartisan> {
public LoxodonPartisan (UUID ownerId) {
super(ownerId, 12, "Loxodon Partisan", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{W}");
this.expansionSetCode = "MBS";
this.subtype.add("Elephant");
this.subtype.add("Soldier");
this.color.setWhite(true);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
this.addAbility(new BattleCryAbility());
}
public LoxodonPartisan (final LoxodonPartisan card) {
super(card);
}
@Override
public LoxodonPartisan copy() {
return new LoxodonPartisan(this);
}
}

View file

@ -0,0 +1,68 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR P N CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.continious.BoostEquippedEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.cards.CardImpl;
/**
*
* @author Loki
*/
public class ViridianClaw extends CardImpl<ViridianClaw> {
public ViridianClaw (UUID ownerId) {
super(ownerId, 143, "Viridian Claw", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "MBS";
this.subtype.add("Equipment");
this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(3)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 0)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), Constants.AttachmentType.EQUIPMENT)));
}
public ViridianClaw (final ViridianClaw card) {
super(card);
}
@Override
public ViridianClaw copy() {
return new ViridianClaw(this);
}
}

View file

@ -76,7 +76,7 @@ class ExsanguinateEffect extends OneShotEffect<ExsanguinateEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int loseLife = 0; int loseLife = 0;
int damage = source.getManaCosts().getVariableCosts().get(0).getAmount(); int damage = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
for (UUID opponentId : game.getOpponents(source.getControllerId())) { for (UUID opponentId : game.getOpponents(source.getControllerId())) {
loseLife += game.getPlayer(opponentId).loseLife(damage, game); loseLife += game.getPlayer(opponentId).loseLife(damage, game);
} }

View file

@ -85,7 +85,7 @@ class SigilofDistinctionEffect extends OneShotEffect<SigilofDistinctionEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount(); int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
Permanent p = game.getPermanent(source.getSourceId()); Permanent p = game.getPermanent(source.getSourceId());
if (p != null) { if (p != null) {
p.addCounters(CounterType.CHARGE.createInstance(amount)); p.addCounters(CounterType.CHARGE.createInstance(amount));

View file

@ -0,0 +1,26 @@
package mage.abilities.keyword;
import mage.Constants;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.filter.common.FilterAttackingCreature;
public class BattleCryAbility extends AttacksTriggeredAbility {
public BattleCryAbility() {
super(new BoostControlledEffect(1, 0, Constants.Duration.EndOfTurn, new FilterAttackingCreature(), true), false);
}
public BattleCryAbility(final BattleCryAbility ability) {
super(ability);
}
@Override
public String getRule() {
return "Battle cry (Whenever this creature attacks, each other attacking creature gets +1/+0 until end of turn.)";
}
@Override
public BattleCryAbility copy() {
return new BattleCryAbility(this);
}
}

View file

@ -325,6 +325,9 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
for (Player player: state.getPlayers().values()) { for (Player player: state.getPlayers().values()) {
player.init(this, testMode); player.init(this, testMode);
} }
for (Player player: state.getPlayers().values()) {
player.beginTurn(this);
}
fireInformEvent("game has started"); fireInformEvent("game has started");
saveState(); saveState();
@ -344,7 +347,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
else { else {
choosingPlayer = this.getPlayer(choosingPlayerId); choosingPlayer = this.getPlayer(choosingPlayerId);
} }
if (choosingPlayer.chooseTarget(Outcome.Benefit, targetPlayer, null, this)) { if (choosingPlayer.choose(Outcome.Benefit, targetPlayer, this)) {
startingPlayerId = ((List<UUID>)targetPlayer.getTargets()).get(0); startingPlayerId = ((List<UUID>)targetPlayer.getTargets()).get(0);
fireInformEvent(state.getPlayer(startingPlayerId).getName() + " will start"); fireInformEvent(state.getPlayer(startingPlayerId).getName() + " will start");
} }

View file

@ -168,7 +168,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
this.left = false; this.left = false;
this.passed = false; this.passed = false;
this.passedTurn = false; this.passedTurn = false;
findRange(game);
} }
@Override @Override

View file

@ -25,7 +25,7 @@
<repositories> <repositories>
<repository> <repository>
<id>mage.googlecode.com</id> <id>mage.googlecode.com</id>
<url>http://mage.googlecode.com/svn/trunk/repository</url> <url>https://mage.googlecode.com/hg/repository/</url>
</repository> </repository>
<repository> <repository>
<id>jetlang.googlecode.com</id> <id>jetlang.googlecode.com</id>