forked from External/mage
Merge
This commit is contained in:
commit
f0c8bf2034
44 changed files with 326 additions and 123 deletions
|
|
@ -41,7 +41,6 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
|
|
@ -50,9 +49,11 @@ import mage.view.CardsView;
|
|||
import mage.view.PermanentView;
|
||||
import mage.view.StackAbilityView;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.sets.Sets;
|
||||
import mage.view.SimpleCardView;
|
||||
import mage.view.SimpleCardsView;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -113,6 +114,10 @@ public class Cards extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId);
|
||||
}
|
||||
|
||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||
boolean changed = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ import java.awt.*;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.UUID;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.view.SimpleCardsView;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -67,7 +69,11 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
this.setModal(false);
|
||||
}
|
||||
|
||||
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||
public void loadCards(String name, SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||
loadCards(name, CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId, modal);
|
||||
}
|
||||
|
||||
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||
this.reloaded = true;
|
||||
this.title = name;
|
||||
cardArea.removeAll();
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import javax.swing.Timer;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.remote.Session;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
|
|
@ -101,8 +102,8 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void loadBooster(DraftPickView draftPickView) {
|
||||
draftBooster.loadBooster(draftPickView.getBooster(), bigCard);
|
||||
draftPicks.loadCards(draftPickView.getPicks(), bigCard, null);
|
||||
draftBooster.loadBooster(CardsViewUtil.convertSimple(draftPickView.getBooster()), bigCard);
|
||||
draftPicks.loadCards(CardsViewUtil.convertSimple(draftPickView.getPicks()), bigCard, null);
|
||||
this.draftBooster.clearCardEventListeners();
|
||||
this.draftBooster.addCardEventListener(
|
||||
new Listener<Event> () {
|
||||
|
|
@ -113,7 +114,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
if (view != null) {
|
||||
//draftBooster.loadBooster(view.getBooster(), bigCard);
|
||||
draftBooster.loadBooster(emptyView, bigCard);
|
||||
draftPicks.loadCards(view.getPicks(), bigCard, null);
|
||||
draftPicks.loadCards(CardsViewUtil.convertSimple(view.getPicks()), bigCard, null);
|
||||
Plugins.getInstance().getActionCallback().hidePopup();
|
||||
setMessage("Waiting for other players");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
// Get opponents hand cards if available
|
||||
if (game.getOpponentHands() != null) {
|
||||
for (Map.Entry<String, CardsView> hand: game.getOpponentHands().entrySet()) {
|
||||
for (Map.Entry<String, SimpleCardsView> hand: game.getOpponentHands().entrySet()) {
|
||||
handCards.put(hand.getKey(), hand.getValue());
|
||||
}
|
||||
}
|
||||
|
|
@ -577,7 +577,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
jTabbedPane1 = new JTabbedPane();
|
||||
|
||||
hand.setCardDimension(getHandCardDimension());
|
||||
handCards = new HashMap<String, CardsView>();
|
||||
handCards = new HashMap<String, SimpleCardsView>();
|
||||
|
||||
jSplitPane1.setBorder(null);
|
||||
jSplitPane1.setDividerSize(7);
|
||||
|
|
@ -882,7 +882,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
if (chosenHandKey != null && chosenHandKey.length() > 0) {
|
||||
this.chosenHandKey = chosenHandKey;
|
||||
CardsView cards = handCards.get(chosenHandKey);
|
||||
SimpleCardsView cards = handCards.get(chosenHandKey);
|
||||
this.hand.loadCards(cards, bigCard, gameId);
|
||||
hand.setPreferredSize(new java.awt.Dimension((getHandCardDimension().width + 5) * cards.size() + 5, getHandCardDimension().height + 20)); // for scroll
|
||||
}
|
||||
|
|
@ -983,8 +983,6 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
private mage.client.chat.ChatPanel gameChatPanel;
|
||||
private mage.client.game.FeedbackPanel feedbackPanel;
|
||||
private mage.client.chat.ChatPanel userChatPanel;
|
||||
private mage.client.cards.Cards hand;
|
||||
private Map<String, CardsView> handCards;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JLabel lblActivePlayer;
|
||||
|
|
@ -995,7 +993,6 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
private javax.swing.JPanel pnlBattlefield;
|
||||
private javax.swing.JPanel pnlGameInfo;
|
||||
private javax.swing.JPanel pnlReplay;
|
||||
private mage.client.cards.Cards stack;
|
||||
private javax.swing.JLabel txtActivePlayer;
|
||||
private javax.swing.JLabel txtPhase;
|
||||
private javax.swing.JLabel txtPriority;
|
||||
|
|
@ -1003,6 +1000,10 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
private javax.swing.JLabel txtTurn;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private mage.client.cards.Cards hand;
|
||||
private Map<String, SimpleCardsView> handCards;
|
||||
private mage.client.cards.Cards stack;
|
||||
|
||||
private JTabbedPane jTabbedPane1;
|
||||
private Border emptyBorder = new EmptyBorder(0,0,0,0);
|
||||
private Color prevBGColor;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright 2011 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.client.util;
|
||||
|
||||
import mage.sets.Sets;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.SimpleCardView;
|
||||
import mage.view.SimpleCardsView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardsViewUtil {
|
||||
|
||||
public static CardsView convertSimple(SimpleCardsView view) {
|
||||
CardsView cards = new CardsView();
|
||||
|
||||
for (SimpleCardView simple: view.values()) {
|
||||
mage.cards.Card card = Sets.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
||||
if (card != null) {
|
||||
|
||||
cards.put(simple.getId(), new CardView(card, simple.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
return cards;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ import mage.cards.decks.Deck;
|
|||
import mage.sets.Sets;
|
||||
import mage.view.CardView;
|
||||
import mage.view.DeckView;
|
||||
import mage.view.SimpleCardView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -50,25 +51,25 @@ public class DeckUtil {
|
|||
|
||||
public static Deck construct(DeckView view) {
|
||||
Deck deck = new Deck();
|
||||
for (CardView cardView : view.getCards().values()) {
|
||||
for (SimpleCardView cardView : view.getCards().values()) {
|
||||
ExpansionSet set = Sets.findSet(cardView.getExpansionSetCode());
|
||||
if (set != null) {
|
||||
Card card = set.findCard(cardView.getName(), cardView.getCardNumber());
|
||||
Card card = set.findCard(cardView.getCardNumber());
|
||||
if (card != null) {
|
||||
deck.getCards().add(card);
|
||||
} else {
|
||||
log.fatal("(Deck constructing) Couldn't find card: " + cardView.getName() + ", set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
|
||||
log.fatal("(Deck constructing) Couldn't find card: set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CardView cardView : view.getSideboard().values()) {
|
||||
for (SimpleCardView cardView : view.getSideboard().values()) {
|
||||
ExpansionSet set = Sets.findSet(cardView.getExpansionSetCode());
|
||||
if (set != null) {
|
||||
Card card = set.findCard(cardView.getName(), cardView.getCardNumber());
|
||||
Card card = set.findCard(cardView.getCardNumber());
|
||||
if (card != null) {
|
||||
deck.getSideboard().add(card);
|
||||
} else {
|
||||
log.fatal("(Deck constructing) Couldn't find card: " + cardView.getName() + ", set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
|
||||
log.fatal("(Deck constructing) Couldn't find card: set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,10 +49,9 @@ import mage.target.Targets;
|
|||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardView implements Serializable {
|
||||
public class CardView extends SimpleCardView {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected UUID id;
|
||||
protected UUID parentId;
|
||||
protected String name;
|
||||
protected List<String> rules;
|
||||
|
|
@ -66,17 +65,18 @@ public class CardView implements Serializable {
|
|||
protected List<String> manaCost;
|
||||
protected int convertedManaCost;
|
||||
protected Rarity rarity;
|
||||
protected String expansionSetCode;
|
||||
protected int cardNumber;
|
||||
protected boolean isAbility;
|
||||
protected CardView ability;
|
||||
protected boolean faceDown;
|
||||
|
||||
public List<UUID> targets;
|
||||
|
||||
public CardView(Card card, UUID cardId) {
|
||||
this(card);
|
||||
this.id = cardId;
|
||||
}
|
||||
|
||||
public CardView(Card card) {
|
||||
this.id = card.getId();
|
||||
this.faceDown = card.isFaceDown();
|
||||
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown());
|
||||
|
||||
// no information available for face down cards
|
||||
if (this.faceDown) {
|
||||
|
|
@ -106,8 +106,6 @@ public class CardView implements Serializable {
|
|||
} else {
|
||||
this.rarity = card.getRarity();
|
||||
}
|
||||
this.expansionSetCode = card.getExpansionSetCode();
|
||||
this.cardNumber = card.getCardNumber();
|
||||
|
||||
if (card instanceof Spell) {
|
||||
Spell<?> spell = (Spell<?>) card;
|
||||
|
|
@ -118,7 +116,7 @@ public class CardView implements Serializable {
|
|||
}
|
||||
|
||||
public CardView(MageObject card) {
|
||||
this.id = card.getId();
|
||||
super(card.getId(), "", 0, false);
|
||||
|
||||
this.name = card.getName();
|
||||
if (card instanceof Permanent) {
|
||||
|
|
@ -144,9 +142,10 @@ public class CardView implements Serializable {
|
|||
}
|
||||
|
||||
protected CardView() {
|
||||
super(null, "", 0, false);
|
||||
}
|
||||
|
||||
private void fillEmpty() {
|
||||
private void fillEmpty() {
|
||||
this.name = "Face Down";
|
||||
this.rules = new ArrayList<String>();
|
||||
this.power = "";
|
||||
|
|
@ -164,6 +163,7 @@ public class CardView implements Serializable {
|
|||
}
|
||||
|
||||
CardView(Token token) {
|
||||
super(token.getId(), "", 0, false);
|
||||
this.id = token.getId();
|
||||
this.name = token.getName();
|
||||
this.rules = token.getAbilities().getRules(this.name);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import mage.abilities.Ability;
|
|||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameState;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,13 +27,9 @@
|
|||
*/
|
||||
package mage.view;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.decks.Deck;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
|
@ -41,24 +37,24 @@ import java.util.Set;
|
|||
public class DeckView implements Serializable {
|
||||
|
||||
private String name;
|
||||
private CardsView cards;
|
||||
private CardsView sideboard;
|
||||
private SimpleCardsView cards;
|
||||
private SimpleCardsView sideboard;
|
||||
|
||||
public DeckView(Deck deck) {
|
||||
name = deck.getName();
|
||||
cards = new CardsView(deck.getCards());
|
||||
sideboard = new CardsView(deck.getSideboard());
|
||||
cards = new SimpleCardsView(deck.getCards());
|
||||
sideboard = new SimpleCardsView(deck.getSideboard());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CardsView getCards() {
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
|
||||
public CardsView getSideboard() {
|
||||
public SimpleCardsView getSideboard() {
|
||||
return sideboard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,23 +38,23 @@ import mage.game.draft.DraftPlayer;
|
|||
public class DraftPickView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected CardsView booster;
|
||||
protected CardsView picks;
|
||||
protected SimpleCardsView booster;
|
||||
protected SimpleCardsView picks;
|
||||
protected boolean picking;
|
||||
protected int timeout;
|
||||
|
||||
public DraftPickView(DraftPlayer player, int timeout) {
|
||||
this.booster = new CardsView(player.getBooster());
|
||||
this.picks = new CardsView(player.getDeck().getSideboard());
|
||||
this.booster = new SimpleCardsView(player.getBooster());
|
||||
this.picks = new SimpleCardsView(player.getDeck().getSideboard());
|
||||
this.picking = player.isPicking();
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public CardsView getBooster() {
|
||||
public SimpleCardsView getBooster() {
|
||||
return booster;
|
||||
}
|
||||
|
||||
public CardsView getPicks() {
|
||||
public SimpleCardsView getPicks() {
|
||||
return picks;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import mage.game.Game;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ExileView extends CardsView {
|
||||
public class ExileView extends SimpleCardsView {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
|
|
@ -47,7 +47,7 @@ public class ExileView extends CardsView {
|
|||
this.name = exileZone.getName();
|
||||
this.id = exileZone.getId();
|
||||
for (Card card: exileZone.getCards(game)) {
|
||||
this.put(card.getId(), new CardView(card));
|
||||
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,11 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.Constants.PhaseStep;
|
||||
import mage.Constants.TurnPhase;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameState;
|
||||
|
|
@ -56,8 +54,8 @@ public class GameView implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<PlayerView> players = new ArrayList<PlayerView>();
|
||||
private CardsView hand;
|
||||
private Map<String, CardsView> opponentHands;
|
||||
private SimpleCardsView hand;
|
||||
private Map<String, SimpleCardsView> opponentHands;
|
||||
private CardsView stack = new CardsView();
|
||||
private List<ExileView> exiles = new ArrayList<ExileView>();
|
||||
private List<RevealedView> revealed = new ArrayList<RevealedView>();
|
||||
|
|
@ -118,19 +116,19 @@ public class GameView implements Serializable {
|
|||
return players;
|
||||
}
|
||||
|
||||
public CardsView getHand() {
|
||||
public SimpleCardsView getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(CardsView hand) {
|
||||
public void setHand(SimpleCardsView hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public Map<String, CardsView> getOpponentHands() {
|
||||
public Map<String, SimpleCardsView> getOpponentHands() {
|
||||
return opponentHands;
|
||||
}
|
||||
|
||||
public void setOpponentHands(Map<String, CardsView> opponentHands) {
|
||||
public void setOpponentHands(Map<String, SimpleCardsView> opponentHands) {
|
||||
this.opponentHands = opponentHands;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ import java.io.Serializable;
|
|||
public class LookedAtView implements Serializable {
|
||||
|
||||
private String name;
|
||||
private CardsView cards = new CardsView();
|
||||
private SimpleCardsView cards = new SimpleCardsView();
|
||||
|
||||
public LookedAtView(String name, Cards cards, Game game) {
|
||||
this.name = name;
|
||||
for (Card card: cards.getCards(game)) {
|
||||
this.cards.put(card.getId(), new CardView(card));
|
||||
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ public class LookedAtView implements Serializable {
|
|||
return name;
|
||||
}
|
||||
|
||||
public CardsView getCards() {
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class PlayerView implements Serializable {
|
|||
private boolean isActive;
|
||||
private boolean hasLeft;
|
||||
private ManaPoolView manaPool;
|
||||
private CardsView graveyard = new CardsView();
|
||||
private SimpleCardsView graveyard = new SimpleCardsView();
|
||||
private Map<UUID, PermanentView> battlefield = new HashMap<UUID, PermanentView>();
|
||||
|
||||
public PlayerView(Player player, GameState state, Game game) {
|
||||
|
|
@ -69,7 +69,7 @@ public class PlayerView implements Serializable {
|
|||
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
||||
this.hasLeft = player.hasLeft();
|
||||
for (Card card: player.getGraveyard().getCards(game)) {
|
||||
graveyard.put(card.getId(), new CardView(card));
|
||||
graveyard.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
for (Permanent permanent: state.getBattlefield().getAllPermanents()) {
|
||||
if (showInBattlefield(permanent, state)) {
|
||||
|
|
@ -113,7 +113,7 @@ public class PlayerView implements Serializable {
|
|||
return this.manaPool;
|
||||
}
|
||||
|
||||
public CardsView getGraveyard() {
|
||||
public SimpleCardsView getGraveyard() {
|
||||
return this.graveyard;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ import mage.game.Game;
|
|||
public class RevealedView implements Serializable {
|
||||
|
||||
private String name;
|
||||
private CardsView cards = new CardsView();
|
||||
private SimpleCardsView cards = new SimpleCardsView();
|
||||
|
||||
public RevealedView(String name, Cards cards, Game game) {
|
||||
this.name = name;
|
||||
for (Card card: cards.getCards(game)) {
|
||||
this.cards.put(card.getId(), new CardView(card));
|
||||
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public class RevealedView implements Serializable {
|
|||
return name;
|
||||
}
|
||||
|
||||
public CardsView getCards() {
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
66
Mage.Common/src/mage/view/SimpleCardView.java
Normal file
66
Mage.Common/src/mage/view/SimpleCardView.java
Normal 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.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SimpleCardView implements Serializable {
|
||||
protected UUID id;
|
||||
protected String expansionSetCode;
|
||||
protected int cardNumber;
|
||||
protected boolean faceDown;
|
||||
|
||||
public SimpleCardView(UUID id, String expansionSetCode, int cardNumber, boolean faceDown) {
|
||||
this.id = id;
|
||||
this.expansionSetCode = expansionSetCode;
|
||||
this.cardNumber = cardNumber;
|
||||
this.faceDown = faceDown;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getExpansionSetCode() {
|
||||
return expansionSetCode;
|
||||
}
|
||||
|
||||
public int getCardNumber() {
|
||||
return cardNumber;
|
||||
}
|
||||
|
||||
public boolean isFaceDown() {
|
||||
return faceDown;
|
||||
}
|
||||
}
|
||||
50
Mage.Common/src/mage/view/SimpleCardsView.java
Normal file
50
Mage.Common/src/mage/view/SimpleCardsView.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.view;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import mage.cards.Card;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SimpleCardsView extends HashMap<UUID, SimpleCardView> {
|
||||
|
||||
public SimpleCardsView() {}
|
||||
|
||||
public SimpleCardsView(Collection<Card> cards) {
|
||||
for (Card card: cards) {
|
||||
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ import mage.view.CardsView;
|
|||
import mage.view.GameClientMessage;
|
||||
import mage.view.GameView;
|
||||
import mage.view.LookedAtView;
|
||||
import mage.view.SimpleCardsView;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -196,13 +197,13 @@ public class GameSession extends GameWatcher {
|
|||
public GameView getGameView() {
|
||||
Player player = game.getPlayer(playerId);
|
||||
GameView gameView = new GameView(game.getState(), game);
|
||||
gameView.setHand(new CardsView(player.getHand().getCards(game)));
|
||||
gameView.setHand(new SimpleCardsView(player.getHand().getCards(game)));
|
||||
|
||||
if (player.getPlayersUnderYourControl().size() > 0) {
|
||||
Map<String, CardsView> handCards = new HashMap<String, CardsView>();
|
||||
Map<String, SimpleCardsView> handCards = new HashMap<String, SimpleCardsView>();
|
||||
for (UUID playerId : player.getPlayersUnderYourControl()) {
|
||||
Player opponent = game.getPlayer(playerId);
|
||||
handCards.put(opponent.getName(), new CardsView(opponent.getHand().getCards(game)));
|
||||
handCards.put(opponent.getName(), new SimpleCardsView(opponent.getHand().getCards(game)));
|
||||
}
|
||||
gameView.setOpponentHands(handCards);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
private static Set<String> nonLandNames;
|
||||
private static Set<String> creatureTypes;
|
||||
private static List<Card> cards;
|
||||
private static Map<String, Card> cardMap;
|
||||
protected static Random rnd = new Random();
|
||||
|
||||
public static Sets getInstance() {
|
||||
|
|
@ -67,6 +68,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
names = new TreeSet<String>();
|
||||
nonLandNames = new TreeSet<String>();
|
||||
cards = new ArrayList<Card>();
|
||||
cardMap = new HashMap<String, Card>();
|
||||
creatureTypes = new TreeSet<String>();
|
||||
this.addSet(AlaraReborn.getInstance());
|
||||
this.addSet(Apocalypse.getInstance());
|
||||
|
|
@ -243,6 +245,23 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Card findCard(String expansionsetCode, int cardNum) {
|
||||
if (cardMap.containsKey(expansionsetCode + Integer.toString(cardNum))) {
|
||||
return cardMap.get(expansionsetCode + Integer.toString(cardNum));
|
||||
}
|
||||
if (fINSTANCE.containsKey(expansionsetCode)) {
|
||||
ExpansionSet set = fINSTANCE.get(expansionsetCode);
|
||||
Card card = set.findCard(cardNum);
|
||||
if (card != null) {
|
||||
cardMap.put(expansionsetCode + Integer.toString(cardNum), card);
|
||||
return card;
|
||||
}
|
||||
}
|
||||
logger.warn("Could not find card: set=" + expansionsetCode + "cardNum=" + Integer.toString(cardNum));
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static Card createCard(Class clazz) {
|
||||
try {
|
||||
|
|
@ -280,7 +299,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
String setCode = m.group(3);
|
||||
int cardNum = Integer.parseInt(m.group(4));
|
||||
ExpansionSet set = Sets.findSet(setCode);
|
||||
String card = set.findCard(cardNum);
|
||||
String card = set.findCardName(cardNum);
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (!sideboard) {
|
||||
deckList.getCards().add(card);
|
||||
|
|
|
|||
|
|
@ -84,11 +84,7 @@ class MartialCoupEffect extends OneShotEffect<MartialCoupEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = 0;
|
||||
if (source.getManaCostsToPay().getVariableCosts().size() > 0) {
|
||||
amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
}
|
||||
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
if (amount > 4) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), source.getControllerId(), game)) {
|
||||
permanent.destroy(source.getSourceId(), game, false);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class ConsumeSpiritEffect extends OneShotEffect<ConsumeSpiritEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int damage = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int damage = source.getManaCostsToPay().getX();
|
||||
if (damage > 0) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(source));
|
||||
if (permanent != null) {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,7 @@ class EarthquakeEffect extends OneShotEffect<EarthquakeEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||
permanent.damage(amount, source.getId(), game, true, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class FireballEffect extends OneShotEffect<FireballEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int numTargets = source.getTargets().get(0).getTargets().size();
|
||||
int damage = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int damage = source.getManaCostsToPay().getX();
|
||||
if (numTargets > 0) {
|
||||
int damagePer = damage/numTargets;
|
||||
if (damagePer > 0) {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class MindSpringEffect extends OneShotEffect<MindSpringEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
player.drawCards(amount, game);
|
||||
|
|
|
|||
|
|
@ -93,8 +93,8 @@ public class ProteanHydra extends CardImpl<ProteanHydra> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && source.getManaCostsToPay().getVariableCosts().size() > 0) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
if (permanent != null && amount > 0) {
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -98,8 +98,7 @@ class VengefulArchonEffect extends PreventionEffectImpl<VengefulArchonEffect> {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (source.getManaCostsToPay().getVariableCosts().size() > 0)
|
||||
amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
amount = source.getManaCostsToPay().getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -38,11 +38,8 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.HasCounterCondition;
|
||||
import mage.abilities.decorator.ConditionalContinousEffect;
|
||||
import mage.abilities.decorator.ConditionalStaticAbility;
|
||||
import mage.abilities.dynamicvalue.common.CountersCount;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
|
|
@ -96,7 +93,7 @@ class PrimordialHydraEntersEffect extends OneShotEffect<PrimordialHydraEntersEff
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
p.addCounters(CounterType.P1P1.createInstance(amount), game);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class BlackSunsZenithEffect extends OneShotEffect<BlackSunsZenithEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
permanent.addCounters(CounterType.M1M1.createInstance(amount), game);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class GreenSunsZenithSearchEffect extends OneShotEffect<GreenSunsZenithSearchEff
|
|||
filter.setUseColor(true);
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
//Set the mana cost one higher to 'emulate' a less than or equal to comparison.
|
||||
filter.setConvertedManaCost(source.getManaCostsToPay().getVariableCosts().get(0).getAmount() + 1);
|
||||
filter.setConvertedManaCost(source.getManaCostsToPay().getX() + 1);
|
||||
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
if (player.searchLibrary(target, game)) {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class ChimericMassEffect extends OneShotEffect<ChimericMassEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
p.addCounters(CounterType.CHARGE.createInstance(amount), game);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class ExsanguinateEffect extends OneShotEffect<ExsanguinateEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int loseLife = 0;
|
||||
int damage = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int damage = source.getManaCostsToPay().getX();
|
||||
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
|
||||
loseLife += game.getPlayer(opponentId).loseLife(damage, game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class GenesisWaveEffect extends OneShotEffect<GenesisWaveEffect> {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
int count = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int count = source.getManaCostsToPay().getX();
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
cards.add(card);
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class MyrBattlesphereEffect extends OneShotEffect<MyrBattlesphereEffect> {
|
|||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
||||
Player defender = game.getPlayer(defenderId);
|
||||
if (defender != null) {
|
||||
defender.damage(source.getManaCostsToPay().getVariableCosts().get(0).getAmount(), source.getSourceId(), game, false, false);
|
||||
defender.damage(source.getManaCostsToPay().getX(), source.getSourceId(), game, false, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class SteelHellkiteDestroyEffect extends OneShotEffect {
|
|||
SteelHellkiteWatcher watcher = (SteelHellkiteWatcher) game.getState().getWatchers().get(source.getControllerId(), "SteelHellkiteWatcher");
|
||||
if (watcher != null && watcher.damagedPlayers.containsKey(source.getSourceId())) {
|
||||
Set<UUID> players = watcher.damagedPlayers.get(source.getSourceId());
|
||||
int xValue = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int xValue = source.getManaCostsToPay().getX();
|
||||
for (UUID uuid : players) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getControllerId().equals(uuid) && permanent.getManaCost().convertedManaCost() == xValue) {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class VigilForTheLostEffect extends OneShotEffect<VigilForTheLostEffect> {
|
|||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.gainLife(((VariableCost)cost.getVariableCosts().get(0)).getAmount(), game);
|
||||
player.gainLife(cost.getX(), game);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class FlameblastDragonEffect extends OneShotEffect<FlameblastDragonEffect> {
|
|||
if (player.chooseUse(Constants.Outcome.Damage, "Pay " + cost.getText() + "? If you do, Flameblast Dragon deals X damage to target creature or player", game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) {
|
||||
int costX = ((VariableCost) cost.getVariableCosts().get(0)).getAmount();
|
||||
int costX = cost.getX();
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
permanent.damage(costX, source.getId(), game, true, false);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class SigilOfDistinctionEffect extends OneShotEffect<SigilOfDistinctionEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
p.addCounters(CounterType.CHARGE.createInstance(amount), game);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,12 @@ public interface ManaCosts<T extends ManaCost> extends List<T>, ManaCost {
|
|||
|
||||
public ManaCosts<T> getUnpaidVariableCosts();
|
||||
public List<VariableCost> getVariableCosts();
|
||||
public int getX();
|
||||
public void load(String mana);
|
||||
public List<String> getSymbols();
|
||||
|
||||
|
||||
@Override
|
||||
public Mana getMana();
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -146,6 +146,8 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
return unpaid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<VariableCost> getVariableCosts() {
|
||||
List<VariableCost> variableCosts = new ArrayList<VariableCost>();
|
||||
|
|
@ -153,13 +155,22 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
if (cost instanceof VariableCost)
|
||||
variableCosts.add((VariableCost) cost);
|
||||
}
|
||||
if (variableCosts.size() == 0) {
|
||||
// add empty cost (#Issue 210)
|
||||
variableCosts.add(new VariableManaCost());
|
||||
}
|
||||
// if (variableCosts.size() == 0) {
|
||||
// // add empty cost (#Issue 210)
|
||||
// variableCosts.add(new VariableManaCost());
|
||||
// }
|
||||
return variableCosts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
int amount = 0;
|
||||
List<VariableCost> variableCosts = getVariableCosts();
|
||||
if (!variableCosts.isEmpty())
|
||||
amount = variableCosts.get(0).getAmount();
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPayment(Mana mana) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import mage.game.Game;
|
|||
public class ManacostVariableValue implements DynamicValue {
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility) {
|
||||
return sourceAbility.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
return sourceAbility.getManaCostsToPay().getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class DamageXTargetEffect extends OneShotEffect<DamageXTargetEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
permanent.damage(amount, source.getId(), game, true, false);
|
||||
|
|
|
|||
|
|
@ -61,14 +61,14 @@ public class BoostPowerToughnessXTargetEffect extends ContinuousEffectImpl<Boost
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
if (amount == 0) {
|
||||
int amountX = source.getManaCostsToPay().getX();
|
||||
if (amountX == 0) {
|
||||
return false;
|
||||
}
|
||||
Permanent target = game.getPermanent(source.getFirstTarget());
|
||||
if (target != null) {
|
||||
target.addPower(amount);
|
||||
target.addToughness(amount);
|
||||
target.addPower(amountX);
|
||||
target.addToughness(amountX);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -64,17 +64,15 @@ public class BoostPowerXSourceEffect extends ContinuousEffectImpl<BoostPowerXSou
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (source.getManaCostsToPay().getVariableCosts().size() > 0) {
|
||||
int amountX = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
if (amountX == 0) {
|
||||
return false;
|
||||
}
|
||||
Permanent target = (Permanent) game.getPermanent(source.getSourceId());
|
||||
if (target != null) {
|
||||
target.addPower(amountX);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int amountX = source.getManaCostsToPay().getX();
|
||||
if (amountX == 0) {
|
||||
return false;
|
||||
}
|
||||
Permanent target = (Permanent) game.getPermanent(source.getSourceId());
|
||||
if (target != null) {
|
||||
target.addPower(amountX);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import java.net.URL;
|
|||
import java.net.URLClassLoader;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -132,9 +131,9 @@ public abstract class ExpansionSet implements Serializable {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Card findCard(String name, int cardNum) {
|
||||
public Card findCard(int cardNum) {
|
||||
for (Card card : cards) {
|
||||
if (cardNum == card.getCardNumber() && name.equalsIgnoreCase(card.getName())) {
|
||||
if (cardNum == card.getCardNumber()) {
|
||||
Card newCard = card.copy();
|
||||
newCard.assignNewId();
|
||||
return newCard;
|
||||
|
|
@ -158,7 +157,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
return null;
|
||||
}
|
||||
|
||||
public String findCard(int cardNum) {
|
||||
public String findCardName(int cardNum) {
|
||||
for (Card card : cards) {
|
||||
if (card.getCardNumber() == cardNum)
|
||||
return card.getClass().getCanonicalName();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue