mirror of
https://github.com/correl/mage.git
synced 2025-04-12 09:11:05 -09:00
Fixed random stack abilities display order in client
This commit is contained in:
parent
d07236352b
commit
2c175dadf4
6 changed files with 53 additions and 34 deletions
Mage.Client/src/main/java/mage/client
Mage.Common/src/mage/view
Mage.Sets/src/mage/sets
|
@ -34,22 +34,19 @@
|
|||
|
||||
package mage.client.cards;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
import mage.view.*;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import javax.swing.border.Border;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.PermanentView;
|
||||
import mage.view.SimpleCardsView;
|
||||
import mage.view.StackAbilityView;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -111,10 +108,10 @@ public class Cards extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId);
|
||||
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, null);
|
||||
}
|
||||
|
||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, java.util.List<UUID> order) {
|
||||
boolean changed = false;
|
||||
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
|
@ -148,7 +145,7 @@ public class Cards extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
if (changed) {
|
||||
layoutCards(getCardDimension());
|
||||
layoutCards(getCardDimension(), cards, order);
|
||||
}
|
||||
|
||||
if (!isVisibleIfEmpty) {
|
||||
|
@ -195,14 +192,27 @@ public class Cards extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
private void layoutCards(Dimension dimension) {
|
||||
private void layoutCards(Dimension dimension, Map<UUID, MageCard> cards, java.util.List<UUID> order) {
|
||||
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||
int dx = GAP_X;
|
||||
for (MageCard card: cards.values()) {
|
||||
card.setLocation(dx, 0);
|
||||
card.setCardBounds(dx, 0, dimension.width, dimension.height);
|
||||
dx += dimension.width + GAP_X;
|
||||
}
|
||||
if (order != null) {
|
||||
for (UUID cardId : order) {
|
||||
MageCard card = cards.get(cardId);
|
||||
if (card != null) {
|
||||
card.setLocation(dx, 0);
|
||||
card.setCardBounds(dx, 0, dimension.width, dimension.height);
|
||||
dx += dimension.width + GAP_X;
|
||||
} else {
|
||||
System.err.println("[ERROR] Cards.java: couldn't find a card from ordered list!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (MageCard card: cards.values()) {
|
||||
card.setLocation(dx, 0);
|
||||
card.setCardBounds(dx, 0, dimension.width, dimension.height);
|
||||
dx += dimension.width + GAP_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +264,7 @@ public class Cards extends javax.swing.JPanel {
|
|||
|
||||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
layoutCards(cardDimension);
|
||||
layoutCards(cardDimension, cards, null);
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
|
|
|
@ -34,12 +34,12 @@
|
|||
|
||||
package mage.client.game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.util.Config;
|
||||
import mage.view.CombatGroupView;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -62,9 +62,9 @@ public class CombatGroup extends javax.swing.JPanel {
|
|||
|
||||
public void update(CombatGroupView combatGroup) {
|
||||
this.lblDefender.setText(combatGroup.getDefenderName());
|
||||
this.attackers.loadCards(combatGroup.getAttackers(), bigCard, gameId);
|
||||
this.attackers.loadCards(combatGroup.getAttackers(), bigCard, gameId, null);
|
||||
// attackers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
|
||||
this.blockers.loadCards(combatGroup.getBlockers(), bigCard, gameId);
|
||||
this.blockers.loadCards(combatGroup.getBlockers(), bigCard, gameId, null);
|
||||
// blockers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
|
||||
this.attackers.setVisible(true);
|
||||
this.blockers.setVisible(true);
|
||||
|
|
|
@ -397,7 +397,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
this.stack.loadCards(game.getStack(), bigCard, gameId);
|
||||
this.stack.loadCards(game.getStack(), bigCard, gameId, game.getStackOrder());
|
||||
GameManager.getInstance().setStackSize(game.getStack().size());
|
||||
|
||||
for (ExileView exile: game.getExile()) {
|
||||
|
|
|
@ -28,12 +28,6 @@
|
|||
|
||||
package mage.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.PhaseStep;
|
||||
import mage.Constants.TurnPhase;
|
||||
|
@ -49,6 +43,9 @@ import mage.game.stack.StackAbility;
|
|||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -60,6 +57,7 @@ public class GameView implements Serializable {
|
|||
private SimpleCardsView hand;
|
||||
private Map<String, SimpleCardsView> opponentHands;
|
||||
private CardsView stack = new CardsView();
|
||||
private List<UUID> stackOrder = new ArrayList<UUID>();
|
||||
private List<ExileView> exiles = new ArrayList<ExileView>();
|
||||
private List<RevealedView> revealed = new ArrayList<RevealedView>();
|
||||
private List<LookedAtView> lookedAt = new ArrayList<LookedAtView>();
|
||||
|
@ -95,7 +93,9 @@ public class GameView implements Serializable {
|
|||
else {
|
||||
stack.put(stackObject.getId(), new CardView((Spell)stackObject));
|
||||
}
|
||||
stackOrder.add(stackObject.getId());
|
||||
}
|
||||
Collections.reverse(stackOrder);
|
||||
for (ExileZone exileZone: state.getExile().getExileZones()) {
|
||||
exiles.add(new ExileView(exileZone, game));
|
||||
}
|
||||
|
@ -202,4 +202,8 @@ public class GameView implements Serializable {
|
|||
public boolean getSpecial() {
|
||||
return special;
|
||||
}
|
||||
|
||||
public List<UUID> getStackOrder() {
|
||||
return stackOrder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.sets.riseoftheeldrazi;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
|
@ -35,6 +34,8 @@ import mage.abilities.common.AnotherCreatureEntersBattlefieldTriggeredAbility;
|
|||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
|
@ -51,6 +52,7 @@ public class SoulsAttendant extends CardImpl<SoulsAttendant> {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Whenever another creature enters the battlefield, you may gain 1 life.
|
||||
this.addAbility(new AnotherCreatureEntersBattlefieldTriggeredAbility(new GainLifeEffect(1), true));
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.sets.worldwake;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
|
@ -44,6 +43,8 @@ import mage.filter.FilterCard;
|
|||
import mage.target.common.TargetCardInHand;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -66,9 +67,11 @@ public class StoneforgeMystic extends CardImpl<StoneforgeMystic> {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(1, 1, filter);
|
||||
// When Stoneforge Mystic enters the battlefield, you may search your library for an Equipment card, reveal it, put it into your hand, then shuffle your library.
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(1, 1, filter);
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryRevealPutInHandEffect(target), true));
|
||||
|
||||
// {1}{W}, {T}: You may put an Equipment card from your hand onto the battlefield.
|
||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PlayTargetWithoutPayingManaEffect(), new ManaCostsImpl("{1}{W}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addTarget(new TargetCardInHand(0, 1, filter));
|
||||
|
|
Loading…
Add table
Reference in a new issue