Minor clean up

This commit is contained in:
tool4EvEr
2021-07-19 23:20:10 +02:00
parent bc854a0572
commit a1a326adc6
33 changed files with 198 additions and 253 deletions

View File

@@ -879,7 +879,7 @@ public class AiController {
public boolean isNonDisabledCardInPlay(final String cardName) { public boolean isNonDisabledCardInPlay(final String cardName) {
for (Card card : player.getCardsIn(ZoneType.Battlefield)) { for (Card card : player.getCardsIn(ZoneType.Battlefield)) {
if (card.getName().equals(cardName)) { if (card.getName().equals(cardName)) {
// TODO - Better logic to detemine if a permanent is disabled by local effects // TODO - Better logic to determine if a permanent is disabled by local effects
// currently assuming any permanent enchanted by another player // currently assuming any permanent enchanted by another player
// is disabled and a second copy is necessary // is disabled and a second copy is necessary
// will need actual logic that determines if the enchantment is able // will need actual logic that determines if the enchantment is able

View File

@@ -78,15 +78,13 @@ public class AiCostDecision extends CostDecisionMakerBase {
return null; return null;
} }
return PaymentDecision.card(player.getLastDrawnCard()); return PaymentDecision.card(player.getLastDrawnCard());
} } else if (cost.payCostFromSource()) {
else if (cost.payCostFromSource()) {
if (!hand.contains(source)) { if (!hand.contains(source)) {
return null; return null;
} }
return PaymentDecision.card(source); return PaymentDecision.card(source);
} } else if (type.equals("Hand")) {
else if (type.equals("Hand")) {
if (hand.size() > 1 && ability.getActivatingPlayer() != null) { if (hand.size() > 1 && ability.getActivatingPlayer() != null) {
hand = ability.getActivatingPlayer().getController().orderMoveToZoneList(hand, ZoneType.Graveyard, ability); hand = ability.getActivatingPlayer().getController().orderMoveToZoneList(hand, ZoneType.Graveyard, ability);
} }
@@ -107,8 +105,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
randomSubset = ability.getActivatingPlayer().getController().orderMoveToZoneList(randomSubset, ZoneType.Graveyard, ability); randomSubset = ability.getActivatingPlayer().getController().orderMoveToZoneList(randomSubset, ZoneType.Graveyard, ability);
} }
return PaymentDecision.card(randomSubset); return PaymentDecision.card(randomSubset);
} } else if (type.equals("DifferentNames")) {
else if (type.equals("DifferentNames")) {
CardCollection differentNames = new CardCollection(); CardCollection differentNames = new CardCollection();
CardCollection discardMe = CardLists.filter(hand, CardPredicates.hasSVar("DiscardMe")); CardCollection discardMe = CardLists.filter(hand, CardPredicates.hasSVar("DiscardMe"));
while (c > 0) { while (c > 0) {
@@ -125,8 +122,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
c--; c--;
} }
return PaymentDecision.card(differentNames); return PaymentDecision.card(differentNames);
} } else {
else {
final AiController aic = ((PlayerControllerAi)player.getController()).getAi(); final AiController aic = ((PlayerControllerAi)player.getController()).getAi();
CardCollection result = aic.getCardsToDiscard(c, type.split(";"), ability, discarded); CardCollection result = aic.getCardsToDiscard(c, type.split(";"), ability, discarded);
@@ -183,8 +179,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
else if (cost.sameZone) { else if (cost.sameZone) {
// TODO Determine exile from same zone for AI // TODO Determine exile from same zone for AI
return null; return null;
} } else {
else {
CardCollectionView chosen = ComputerUtil.chooseExileFrom(player, cost.getFrom(), cost.getType(), source, ability.getTargetCard(), c, ability); CardCollectionView chosen = ComputerUtil.chooseExileFrom(player, cost.getFrom(), cost.getType(), source, ability.getTargetCard(), c, ability);
return null == chosen ? null : PaymentDecision.card(chosen); return null == chosen ? null : PaymentDecision.card(chosen);
} }
@@ -375,8 +370,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
if (cost.isSameZone()) { if (cost.isSameZone()) {
list = new CardCollection(game.getCardsIn(cost.getFrom())); list = new CardCollection(game.getCardsIn(cost.getFrom()));
} } else {
else {
list = new CardCollection(player.getCardsIn(cost.getFrom())); list = new CardCollection(player.getCardsIn(cost.getFrom()));
} }
@@ -871,4 +865,3 @@ public class AiCostDecision extends CostDecisionMakerBase {
return false; return false;
} }
} }

View File

@@ -947,7 +947,7 @@ public class ComputerUtil {
canRegen = true; canRegen = true;
} }
} catch (final Exception ex) { } catch (final Exception ex) {
throw new RuntimeException(TextUtil.concatNoSpace("There is an error in the card code for ", c.getName(), ":", ex.getMessage()), ex); throw new RuntimeException(TextUtil.concatNoSpace("There is an error in the card code for ", c.getName(), ":", ex.getMessage()), ex);
} }
} }
@@ -2832,7 +2832,6 @@ public class ComputerUtil {
} }
public static boolean lifegainPositive(final Player player, final Card source) { public static boolean lifegainPositive(final Player player, final Card source) {
if (!player.canGainLife()) { if (!player.canGainLife()) {
return false; return false;
} }

View File

@@ -716,6 +716,7 @@ public class ComputerUtilCard {
int bigCMC = -1; int bigCMC = -1;
for (final Card card : all) { for (final Card card : all) {
// TODO when PlayAi can consider MDFC this should also look at the back face (if not on stack or battlefield)
int curCMC = card.getCMC(); int curCMC = card.getCMC();
// Add all cost of all auras with the same controller // Add all cost of all auras with the same controller

View File

@@ -70,13 +70,12 @@ public class PlayAi extends SpellAbilityAi {
} }
} }
if (sa.hasParam("ValidSA")) { if (cards != null & sa.hasParam("ValidSA")) {
final String valid[] = {sa.getParam("ValidSA")}; final String valid[] = {sa.getParam("ValidSA")};
final Iterator<Card> itr = cards.iterator(); final Iterator<Card> itr = cards.iterator();
while (itr.hasNext()) { while (itr.hasNext()) {
final Card c = itr.next(); final Card c = itr.next();
final List<SpellAbility> validSA = Lists.newArrayList(Iterables.filter(AbilityUtils.getBasicSpellsFromPlayEffect(c, ai), SpellAbilityPredicates.isValid(valid, ai , c, sa))); if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, ai), SpellAbilityPredicates.isValid(valid, ai , c, sa))) {
if (validSA.size() == 0) {
itr.remove(); itr.remove();
} }
} }
@@ -173,6 +172,8 @@ public class PlayAi extends SpellAbilityAi {
List<Card> tgtCards = CardLists.filter(options, new Predicate<Card>() { List<Card> tgtCards = CardLists.filter(options, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
// TODO needs to be aligned for MDFC along with getAbilityToPlay so the knowledge
// of which spell was the reason for the choice can be used there
for (SpellAbility s : c.getBasicSpells(c.getState(CardStateName.Original))) { for (SpellAbility s : c.getBasicSpells(c.getState(CardStateName.Original))) {
Spell spell = (Spell) s; Spell spell = (Spell) s;
s.setActivatingPlayer(ai); s.setActivatingPlayer(ai);

View File

@@ -87,7 +87,6 @@ public class DeckGeneratorMonoColor extends DeckGeneratorBase {
} }
} }
@Override @Override
public final CardPool getDeck(final int size, final boolean forAi) { public final CardPool getDeck(final int size, final boolean forAi) {
addCreaturesAndSpells(size, cmcLevels, forAi); addCreaturesAndSpells(size, cmcLevels, forAi);

View File

@@ -61,7 +61,6 @@ import forge.util.TextUtil;
*/ */
public class BoosterGenerator { public class BoosterGenerator {
private final static Map<String, PrintSheet> cachedSheets = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); private final static Map<String, PrintSheet> cachedSheets = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private static synchronized PrintSheet getPrintSheet(String key) { private static synchronized PrintSheet getPrintSheet(String key) {
if( !cachedSheets.containsKey(key) ) if( !cachedSheets.containsKey(key) )

View File

@@ -31,7 +31,6 @@ public class UnOpenedProduct implements IUnOpenedProduct {
this.poolLimited = considerNumbersInPool; // TODO: Add 0 to parameter's name. this.poolLimited = considerNumbersInPool; // TODO: Add 0 to parameter's name.
} }
// Means to select from all unique cards (from base game, ie. no schemes or avatars) // Means to select from all unique cards (from base game, ie. no schemes or avatars)
public UnOpenedProduct(SealedProduct.Template template) { public UnOpenedProduct(SealedProduct.Template template) {
tpl = template; tpl = template;

View File

@@ -1080,7 +1080,7 @@ public class CombatUtil {
return canAttackerBeBlockedWithAmount(attacker, amount, combat != null ? combat.getDefenderPlayerByAttacker(attacker) : null); return canAttackerBeBlockedWithAmount(attacker, amount, combat != null ? combat.getDefenderPlayerByAttacker(attacker) : null);
} }
public static boolean canAttackerBeBlockedWithAmount(Card attacker, int amount, Player defender) { public static boolean canAttackerBeBlockedWithAmount(Card attacker, int amount, Player defender) {
if(amount == 0 ) if (amount == 0)
return false; // no block return false; // no block
List<String> restrictions = Lists.newArrayList(); List<String> restrictions = Lists.newArrayList();
@@ -1093,7 +1093,7 @@ public class CombatUtil {
restrictions.add("LT2"); restrictions.add("LT2");
} }
} }
for ( String res : restrictions ) { for (String res : restrictions) {
int operand = Integer.parseInt(res.substring(2)); int operand = Integer.parseInt(res.substring(2));
String operator = res.substring(0,2); String operator = res.substring(0,2);
if (Expressions.compare(amount, operator, operand) ) if (Expressions.compare(amount, operator, operand) )
@@ -1118,7 +1118,7 @@ public class CombatUtil {
} }
} }
int minBlockers = 1; int minBlockers = 1;
for ( String res : restrictions ) { for (String res : restrictions) {
int operand = Integer.parseInt(res.substring(2)); int operand = Integer.parseInt(res.substring(2));
String operator = res.substring(0, 2); String operator = res.substring(0, 2);
if (operator.equals("LT") || operator.equals("GE")) { if (operator.equals("LT") || operator.equals("GE")) {

View File

@@ -211,7 +211,7 @@ public class CostPayment extends ManaConversionMatrix {
return false; return false;
} }
// abilities care what was used to pay for them // abilities care what was used to pay for them
if( part instanceof CostPartWithList ) { if (part instanceof CostPartWithList) {
((CostPartWithList) part).resetLists(); ((CostPartWithList) part).resetLists();
} }

View File

@@ -414,4 +414,3 @@ public enum FControl implements KeyEventDispatcher {
return GamePlayerUtil.getGuiPlayer(); return GamePlayerUtil.getGuiPlayer();
} }
} }

View File

@@ -194,7 +194,6 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
} }
@Override @Override
protected void buildAddFilterMenu(final JMenu menu) { protected void buildAddFilterMenu(final JMenu menu) {
GuiUtils.addSeparator(menu); //separate from current search item GuiUtils.addSeparator(menu); //separate from current search item
@@ -228,7 +227,6 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
} }
menu.add(fmt); menu.add(fmt);
GuiUtils.addMenuItem(menu, localizer.getMessage("lblFormats") + "...", null, new Runnable() { GuiUtils.addMenuItem(menu, localizer.getMessage("lblFormats") + "...", null, new Runnable() {
@Override public void run() { @Override public void run() {
final DeckFormatFilter existingFilter = getFilter(DeckFormatFilter.class); final DeckFormatFilter existingFilter = getFilter(DeckFormatFilter.class);

View File

@@ -340,4 +340,3 @@ public enum CDeckEditorUI implements ICDoc {
@Override @Override
public void update() { } public void update() { }
} }

View File

@@ -294,8 +294,7 @@ public class DeckController<T extends DeckBase> {
final String name = getModelName(); final String name = getModelName();
if (name.isEmpty()) { if (name.isEmpty()) {
newModel(); newModel();
} } else {
else {
load(name); load(name);
} }
} }
@@ -303,8 +302,7 @@ public class DeckController<T extends DeckBase> {
public void load(final String path, final String name) { public void load(final String path, final String name) {
if (StringUtils.isBlank(path)) { if (StringUtils.isBlank(path)) {
currentFolder = rootFolder; currentFolder = rootFolder;
} } else {
else {
currentFolder = rootFolder.tryGetFolder(path); currentFolder = rootFolder.tryGetFolder(path);
} }
modelPath = path; modelPath = path;
@@ -386,8 +384,7 @@ public class DeckController<T extends DeckBase> {
public void refreshModel() { public void refreshModel() {
if (model == null) { if (model == null) {
newModel(); newModel();
} } else {
else {
setModel(model, modelInStorage); setModel(model, modelInStorage);
} }
} }

View File

@@ -501,7 +501,7 @@ public final class CMatchUI
@Override @Override
public void hideZones(final PlayerView controller, final Iterable<PlayerZoneUpdate> zonesToUpdate) { public void hideZones(final PlayerView controller, final Iterable<PlayerZoneUpdate> zonesToUpdate) {
if ( zonesToUpdate != null ) { if (zonesToUpdate != null) {
for (final PlayerZoneUpdate update : zonesToUpdate) { for (final PlayerZoneUpdate update : zonesToUpdate) {
final PlayerView player = update.getPlayer(); final PlayerView player = update.getPlayer();
for (final ZoneType zone : update.getZones()) { for (final ZoneType zone : update.getZones()) {
@@ -532,7 +532,6 @@ public final class CMatchUI
for (final PlayerView p : manaPoolUpdate) { for (final PlayerView p : manaPoolUpdate) {
getFieldViewFor(p).updateManaPool(); getFieldViewFor(p).updateManaPool();
} }
} }
// Player's lives and poison counters // Player's lives and poison counters
@@ -575,15 +574,15 @@ public final class CMatchUI
@Override @Override
public void setSelectables(final Iterable<CardView> cards) { public void setSelectables(final Iterable<CardView> cards) {
super.setSelectables(cards); super.setSelectables(cards);
// update zones on tabletop and floating zones - non-selectable cards may be rendered differently // update zones on tabletop and floating zones - non-selectable cards may be rendered differently
FThreads.invokeInEdtNowOrLater(new Runnable() { FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override public final void run() { @Override public final void run() {
for (final PlayerView p : getGameView().getPlayers()) { for (final PlayerView p : getGameView().getPlayers()) {
if ( p.getCards(ZoneType.Battlefield) != null ) { if (p.getCards(ZoneType.Battlefield) != null) {
updateCards(p.getCards(ZoneType.Battlefield)); updateCards(p.getCards(ZoneType.Battlefield));
} }
if ( p.getCards(ZoneType.Hand) != null ) { if (p.getCards(ZoneType.Hand) != null) {
updateCards(p.getCards(ZoneType.Hand)); updateCards(p.getCards(ZoneType.Hand));
} }
} }
@@ -594,15 +593,15 @@ public final class CMatchUI
@Override @Override
public void clearSelectables() { public void clearSelectables() {
super.clearSelectables(); super.clearSelectables();
// update zones on tabletop and floating zones - non-selectable cards may be rendered differently // update zones on tabletop and floating zones - non-selectable cards may be rendered differently
FThreads.invokeInEdtNowOrLater(new Runnable() { FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override public final void run() { @Override public final void run() {
for (final PlayerView p : getGameView().getPlayers()) { for (final PlayerView p : getGameView().getPlayers()) {
if ( p.getCards(ZoneType.Battlefield) != null ) { if (p.getCards(ZoneType.Battlefield) != null) {
updateCards(p.getCards(ZoneType.Battlefield)); updateCards(p.getCards(ZoneType.Battlefield));
} }
if ( p.getCards(ZoneType.Hand) != null ) { if (p.getCards(ZoneType.Hand) != null) {
updateCards(p.getCards(ZoneType.Hand)); updateCards(p.getCards(ZoneType.Hand));
} }
} }
@@ -617,7 +616,7 @@ public final class CMatchUI
FThreads.invokeInEdtNowOrLater(new Runnable() { FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override public final void run() { @Override public final void run() {
for (final PlayerView p : getGameView().getPlayers()) { for (final PlayerView p : getGameView().getPlayers()) {
if ( p.getCards(ZoneType.Battlefield) != null ) { if (p.getCards(ZoneType.Battlefield) != null) {
updateCards(p.getCards(ZoneType.Battlefield)); updateCards(p.getCards(ZoneType.Battlefield));
} }
} }
@@ -787,7 +786,7 @@ public final class CMatchUI
final PhaseType ph = getGameView().getPhase(); final PhaseType ph = getGameView().getPhase();
// this should never happen, but I've seen it periodically... so, need to get to the bottom of it // this should never happen, but I've seen it periodically... so, need to get to the bottom of it
PhaseLabel lbl = null; PhaseLabel lbl = null;
if (ph != null ) { if (ph != null) {
lbl = p == null ? null : getFieldViewFor(p).getPhaseIndicator().getLabelFor(ph); lbl = p == null ? null : getFieldViewFor(p).getPhaseIndicator().getLabelFor(ph);
} else { } else {
// not sure what debugging information would help here, log for now // not sure what debugging information would help here, log for now
@@ -1295,79 +1294,78 @@ public final class CMatchUI
boolean isAi = sa.getActivatingPlayer().isAI(); boolean isAi = sa.getActivatingPlayer().isAI();
boolean isTrigger = sa.isTrigger(); boolean isTrigger = sa.isTrigger();
int stackIndex = event.stackIndex; int stackIndex = event.stackIndex;
if(stackIndex == nextNotifiableStackIndex) { if (stackIndex == nextNotifiableStackIndex) {
if(ForgeConstants.STACK_EFFECT_NOTIFICATION_ALWAYS.equals(stackNotificationPolicy) || (ForgeConstants.STACK_EFFECT_NOTIFICATION_AI_AND_TRIGGERED.equals(stackNotificationPolicy) && (isAi || isTrigger))) { if (ForgeConstants.STACK_EFFECT_NOTIFICATION_ALWAYS.equals(stackNotificationPolicy) || (ForgeConstants.STACK_EFFECT_NOTIFICATION_AI_AND_TRIGGERED.equals(stackNotificationPolicy) && (isAi || isTrigger))) {
// We can go and show the modal // We can go and show the modal
SpellAbilityStackInstance si = event.si; SpellAbilityStackInstance si = event.si;
MigLayout migLayout = new MigLayout("insets 15, left, gap 30, fill"); MigLayout migLayout = new MigLayout("insets 15, left, gap 30, fill");
JPanel mainPanel = new JPanel(migLayout); JPanel mainPanel = new JPanel(migLayout);
final Dimension parentSize = JOptionPane.getRootFrame().getSize(); final Dimension parentSize = JOptionPane.getRootFrame().getSize();
Dimension maxSize = new Dimension(1400, parentSize.height - 100); Dimension maxSize = new Dimension(1400, parentSize.height - 100);
mainPanel.setMaximumSize(maxSize); mainPanel.setMaximumSize(maxSize);
mainPanel.setOpaque(false); mainPanel.setOpaque(false);
// Big Image // Big Image
addBigImageToStackModalPanel(mainPanel, si); addBigImageToStackModalPanel(mainPanel, si);
// Text // Text
addTextToStackModalPanel(mainPanel,sa,si); addTextToStackModalPanel(mainPanel,sa,si);
// Small images // Small images
int numSmallImages = 0; int numSmallImages = 0;
// If current effect is a triggered/activated ability of an enchantment card, I want to show the enchanted card // If current effect is a triggered/activated ability of an enchantment card, I want to show the enchanted card
GameEntityView enchantedEntityView = null; GameEntityView enchantedEntityView = null;
Card hostCard = sa.getHostCard(); Card hostCard = sa.getHostCard();
if(hostCard.isEnchantment()) { if (hostCard.isEnchantment()) {
GameEntity enchantedEntity = hostCard.getEntityAttachedTo(); GameEntity enchantedEntity = hostCard.getEntityAttachedTo();
if(enchantedEntity != null) { if (enchantedEntity != null) {
enchantedEntityView = enchantedEntity.getView();
numSmallImages++;
} else if ((sa.getRootAbility() != null)
&& (sa.getRootAbility().getPaidList("Sacrificed") != null)
&& !sa.getRootAbility().getPaidList("Sacrificed").isEmpty()) {
// If the player activated its ability by sacrificing the enchantment, the enchantment has not anything attached anymore and the ex-enchanted card has to be searched in other ways.. for example, the green enchantment "Carapace"
enchantedEntity = sa.getRootAbility().getPaidList("Sacrificed").get(0).getEnchantingCard();
if(enchantedEntity != null) {
enchantedEntityView = enchantedEntity.getView(); enchantedEntityView = enchantedEntity.getView();
numSmallImages++; numSmallImages++;
} else if ((sa.getRootAbility() != null)
&& (sa.getRootAbility().getPaidList("Sacrificed") != null)
&& !sa.getRootAbility().getPaidList("Sacrificed").isEmpty()) {
// If the player activated its ability by sacrificing the enchantment, the enchantment has not anything attached anymore and the ex-enchanted card has to be searched in other ways.. for example, the green enchantment "Carapace"
enchantedEntity = sa.getRootAbility().getPaidList("Sacrificed").get(0).getEnchantingCard();
if (enchantedEntity != null) {
enchantedEntityView = enchantedEntity.getView();
numSmallImages++;
}
} }
} }
}
// If current effect is a triggered ability, I want to show the triggering card if present // If current effect is a triggered ability, I want to show the triggering card if present
SpellAbility sourceSA = (SpellAbility) si.getTriggeringObject(AbilityKey.SourceSA); SpellAbility sourceSA = (SpellAbility) si.getTriggeringObject(AbilityKey.SourceSA);
CardView sourceCardView = null; CardView sourceCardView = null;
if(sourceSA != null) { if (sourceSA != null) {
sourceCardView = sourceSA.getHostCard().getView(); sourceCardView = sourceSA.getHostCard().getView();
numSmallImages++; numSmallImages++;
} }
// I also want to show each type of targets (both cards and players) // I also want to show each type of targets (both cards and players)
List<GameEntityView> targets = getTargets(si,new ArrayList<GameEntityView>()); List<GameEntityView> targets = getTargets(si,new ArrayList<GameEntityView>());
numSmallImages = numSmallImages + targets.size(); numSmallImages = numSmallImages + targets.size();
// Now I know how many small images - on to render them // Now I know how many small images - on to render them
if(enchantedEntityView != null) { if (enchantedEntityView != null) {
addSmallImageToStackModalPanel(enchantedEntityView,mainPanel,numSmallImages); addSmallImageToStackModalPanel(enchantedEntityView,mainPanel,numSmallImages);
} }
if(sourceCardView != null) { if (sourceCardView != null) {
addSmallImageToStackModalPanel(sourceCardView,mainPanel,numSmallImages); addSmallImageToStackModalPanel(sourceCardView,mainPanel,numSmallImages);
} }
for(GameEntityView gev : targets) { for (GameEntityView gev : targets) {
addSmallImageToStackModalPanel(gev, mainPanel, numSmallImages); addSmallImageToStackModalPanel(gev, mainPanel, numSmallImages);
} }
FOptionPane.showOptionDialog(null, "Forge", null, mainPanel, ImmutableList.of(Localizer.getInstance().getMessage("lblOK"))); FOptionPane.showOptionDialog(null, "Forge", null, mainPanel, ImmutableList.of(Localizer.getInstance().getMessage("lblOK")));
// here the user closed the modal - time to update the next notifiable stack index // here the user closed the modal - time to update the next notifiable stack index
} }
// In any case, I have to increase the counter // In any case, I have to increase the counter
nextNotifiableStackIndex++; nextNotifiableStackIndex++;
} else { } else {
// Not yet time to show the modal - schedule the method again, and try again later // Not yet time to show the modal - schedule the method again, and try again later
Runnable tryAgainThread = new Runnable() { Runnable tryAgainThread = new Runnable() {
@Override @Override
@@ -1381,21 +1379,21 @@ public final class CMatchUI
} }
private List<GameEntityView> getTargets(SpellAbilityStackInstance si, List<GameEntityView> result){ private List<GameEntityView> getTargets(SpellAbilityStackInstance si, List<GameEntityView> result){
if(si == null) { if (si == null) {
return result; return result;
} }
FCollectionView<CardView> targetCards = CardView.getCollection(si.getTargetChoices().getTargetCards()); FCollectionView<CardView> targetCards = CardView.getCollection(si.getTargetChoices().getTargetCards());
for(CardView currCardView: targetCards) { for (CardView currCardView: targetCards) {
result.add(currCardView); result.add(currCardView);
} }
for(SpellAbility currSA : si.getTargetChoices().getTargetSpells()) { for (SpellAbility currSA : si.getTargetChoices().getTargetSpells()) {
CardView currCardView = currSA.getCardView(); CardView currCardView = currSA.getCardView();
result.add(currCardView); result.add(currCardView);
} }
FCollectionView<PlayerView> targetPlayers = PlayerView.getCollection(si.getTargetChoices().getTargetPlayers()); FCollectionView<PlayerView> targetPlayers = PlayerView.getCollection(si.getTargetChoices().getTargetPlayers());
for(PlayerView currPlayerView : targetPlayers) { for (PlayerView currPlayerView : targetPlayers) {
result.add(currPlayerView); result.add(currPlayerView);
} }
@@ -1443,7 +1441,7 @@ public final class CMatchUI
} }
private void addSmallImageToStackModalPanel(GameEntityView gameEntityView, JPanel mainPanel, int numTarget) { private void addSmallImageToStackModalPanel(GameEntityView gameEntityView, JPanel mainPanel, int numTarget) {
if(gameEntityView instanceof CardView) { if (gameEntityView instanceof CardView) {
CardView cardView = (CardView) gameEntityView; CardView cardView = (CardView) gameEntityView;
int currRotation = getRotation(cardView); int currRotation = getRotation(cardView);
FImagePanel targetPanel = new FImagePanel(); FImagePanel targetPanel = new FImagePanel();
@@ -1454,7 +1452,7 @@ public final class CMatchUI
Dimension targetPanelDimension = new Dimension(imageWidth,imageHeight); Dimension targetPanelDimension = new Dimension(imageWidth,imageHeight);
targetPanel.setMinimumSize(targetPanelDimension); targetPanel.setMinimumSize(targetPanelDimension);
mainPanel.add(targetPanel, "cell 1 1, split " + numTarget+ ", aligny bottom"); mainPanel.add(targetPanel, "cell 1 1, split " + numTarget+ ", aligny bottom");
} else if(gameEntityView instanceof PlayerView) { } else if (gameEntityView instanceof PlayerView) {
PlayerView playerView = (PlayerView) gameEntityView; PlayerView playerView = (PlayerView) gameEntityView;
SkinImage playerAvatar = getPlayerAvatar(playerView, 0); SkinImage playerAvatar = getPlayerAvatar(playerView, 0);
final FLabel lblIcon = new FLabel.Builder().icon(playerAvatar).build(); final FLabel lblIcon = new FLabel.Builder().icon(playerAvatar).build();
@@ -1499,11 +1497,10 @@ public final class CMatchUI
} }
private void createLandPopupPanel(Card land) { private void createLandPopupPanel(Card land) {
String landPlayedNotificationPolicy = FModel.getPreferences().getPref(FPref.UI_LAND_PLAYED_NOTIFICATION_POLICY); String landPlayedNotificationPolicy = FModel.getPreferences().getPref(FPref.UI_LAND_PLAYED_NOTIFICATION_POLICY);
Player cardController = land.getController(); Player cardController = land.getController();
boolean isAi = cardController.isAI(); boolean isAi = cardController.isAI();
if(ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS.equals(landPlayedNotificationPolicy) if (ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS.equals(landPlayedNotificationPolicy)
|| (ForgeConstants.LAND_PLAYED_NOTIFICATION_AI.equals(landPlayedNotificationPolicy) && (isAi)) || (ForgeConstants.LAND_PLAYED_NOTIFICATION_AI.equals(landPlayedNotificationPolicy) && (isAi))
|| (ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS_FOR_NONBASIC_LANDS.equals(landPlayedNotificationPolicy) && !land.isBasicLand()) || (ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS_FOR_NONBASIC_LANDS.equals(landPlayedNotificationPolicy) && !land.isBasicLand())
|| (ForgeConstants.LAND_PLAYED_NOTIFICATION_AI_FOR_NONBASIC_LANDS.equals(landPlayedNotificationPolicy) && !land.isBasicLand()) && (isAi)) { || (ForgeConstants.LAND_PLAYED_NOTIFICATION_AI_FOR_NONBASIC_LANDS.equals(landPlayedNotificationPolicy) && !land.isBasicLand()) && (isAi)) {

View File

@@ -121,7 +121,6 @@ public class GameLogPanel extends JPanel {
} }
public void addLogEntry(final String text) { public void addLogEntry(final String text) {
final boolean useAlternateBackColor = (scrollablePanel.getComponents().length % 2 == 0); final boolean useAlternateBackColor = (scrollablePanel.getComponents().length % 2 == 0);
final JTextArea tar = createNewLogEntryJTextArea(text, useAlternateBackColor); final JTextArea tar = createNewLogEntryJTextArea(text, useAlternateBackColor);
@@ -138,7 +137,6 @@ public class GameLogPanel extends JPanel {
} }
forceVerticalScrollbarToMax(); forceVerticalScrollbarToMax();
} }
public void setTextFont(final SkinFont newFont) { public void setTextFont(final SkinFont newFont) {

View File

@@ -107,8 +107,8 @@ public class VAssignCombatDamage {
private boolean canAssignTo(final CardView card) { private boolean canAssignTo(final CardView card) {
for (DamageTarget dt : defenders) { for (DamageTarget dt : defenders) {
if (dt.card == card ) return true; if (dt.card == card) return true;
if (getDamageToKill(dt.card) > dt.damage ) if (getDamageToKill(dt.card) > dt.damage)
return false; return false;
} }
throw new RuntimeException("Asking to assign damage to object which is not present in defenders list"); throw new RuntimeException("Asking to assign damage to object which is not present in defenders list");
@@ -145,7 +145,7 @@ public class VAssignCombatDamage {
boolean isLMB = SwingUtilities.isLeftMouseButton(evt); boolean isLMB = SwingUtilities.isLeftMouseButton(evt);
boolean isRMB = SwingUtilities.isRightMouseButton(evt); boolean isRMB = SwingUtilities.isRightMouseButton(evt);
if ( isLMB || isRMB) if (isLMB || isRMB)
assignDamageTo(source, meta, isLMB); assignDamageTo(source, meta, isLMB);
} }
}; };
@@ -305,7 +305,7 @@ public class VAssignCombatDamage {
int leftToAssign = getRemainingDamage(); int leftToAssign = getRemainingDamage();
// Left click adds damage, right click substracts damage. // Left click adds damage, right click substracts damage.
// Hold Ctrl to assign lethal damage, Ctrl-click again on a creature with lethal damage to assign all available damage to it // Hold Ctrl to assign lethal damage, Ctrl-click again on a creature with lethal damage to assign all available damage to it
if ( meta ) { if (meta) {
if (isAdding) { if (isAdding) {
damageToAdd = leftToKill > 0 ? leftToKill : leftToAssign; damageToAdd = leftToKill > 0 ? leftToKill : leftToAssign;
} else { } else {
@@ -313,7 +313,7 @@ public class VAssignCombatDamage {
} }
} }
if ( damageToAdd > leftToAssign ) if (damageToAdd > leftToAssign)
damageToAdd = leftToAssign; damageToAdd = leftToAssign;
// cannot assign first blocker less than lethal damage except when overriding order // cannot assign first blocker less than lethal damage except when overriding order
@@ -321,7 +321,7 @@ public class VAssignCombatDamage {
if (!overrideCombatantOrder && isFirstBlocker && damageToAdd + damageItHad < lethalDamage ) if (!overrideCombatantOrder && isFirstBlocker && damageToAdd + damageItHad < lethalDamage )
return; return;
if ( 0 == damageToAdd || damageToAdd + damageItHad < 0) if (0 == damageToAdd || damageToAdd + damageItHad < 0)
return; return;
addDamage(source, damageToAdd); addDamage(source, damageToAdd);
@@ -335,12 +335,12 @@ public class VAssignCombatDamage {
} }
// Clear out any Damage that shouldn't be assigned to other combatants // Clear out any Damage that shouldn't be assigned to other combatants
boolean hasAliveEnemy = false; boolean hasAliveEnemy = false;
for(DamageTarget dt : defenders) { for (DamageTarget dt : defenders) {
int lethal = getDamageToKill(dt.card); int lethal = getDamageToKill(dt.card);
int damage = dt.damage; int damage = dt.damage;
// If overriding combatant order, make sure everything has lethal if defender has damage assigned to it // If overriding combatant order, make sure everything has lethal if defender has damage assigned to it
// Otherwise, follow normal combatant order // Otherwise, follow normal combatant order
if ( hasAliveEnemy && (!overrideCombatantOrder || dt.card == null || dt.card == defender)) if (hasAliveEnemy && (!overrideCombatantOrder || dt.card == null || dt.card == defender))
dt.damage = 0; dt.damage = 0;
else else
hasAliveEnemy |= damage < lethal; hasAliveEnemy |= damage < lethal;
@@ -357,15 +357,15 @@ public class VAssignCombatDamage {
int dmgLeft = totalDamageToAssign; int dmgLeft = totalDamageToAssign;
DamageTarget dtLast = null; DamageTarget dtLast = null;
for(DamageTarget dt : defenders) { // MUST NOT RUN WITH EMPTY collection for (DamageTarget dt : defenders) { // MUST NOT RUN WITH EMPTY collection
int lethal = getDamageToKill(dt.card); int lethal = getDamageToKill(dt.card);
int damage = Math.min(lethal, dmgLeft); int damage = Math.min(lethal, dmgLeft);
addDamage(dt.card, damage); addDamage(dt.card, damage);
dmgLeft -= damage; dmgLeft -= damage;
dtLast = dt; dtLast = dt;
if ( dmgLeft <= 0 || !toAllBlockers ) break; if (dmgLeft <= 0 || !toAllBlockers) break;
} }
if ( dmgLeft < 0 ) if (dmgLeft < 0)
throw new RuntimeException("initialAssignDamage managed to assign more damage than it could"); throw new RuntimeException("initialAssignDamage managed to assign more damage than it could");
if (toAllBlockers && dmgLeft > 0) { if (toAllBlockers && dmgLeft > 0) {
// flush the remaining damage into last defender if assigning all damage // flush the remaining damage into last defender if assigning all damage
@@ -376,7 +376,7 @@ public class VAssignCombatDamage {
/** Reset Assign Damage back to how it was at the beginning. */ /** Reset Assign Damage back to how it was at the beginning. */
private void resetAssignedDamage() { private void resetAssignedDamage() {
for(DamageTarget dt : defenders) for (DamageTarget dt : defenders)
dt.damage = 0; dt.damage = 0;
} }
@@ -398,7 +398,7 @@ public class VAssignCombatDamage {
*/ */
private int getRemainingDamage() { private int getRemainingDamage() {
int spent = 0; int spent = 0;
for(DamageTarget dt : defenders) { for (DamageTarget dt : defenders) {
spent += dt.damage; spent += dt.damage;
} }
return totalDamageToAssign - spent; return totalDamageToAssign - spent;
@@ -407,11 +407,10 @@ public class VAssignCombatDamage {
/** Updates labels and other UI elements. /** Updates labels and other UI elements.
* @param index index of the last assigned damage*/ * @param index index of the last assigned damage*/
private void updateLabels() { private void updateLabels() {
int damageLeft = totalDamageToAssign; int damageLeft = totalDamageToAssign;
boolean allHaveLethal = true; boolean allHaveLethal = true;
for ( DamageTarget dt : defenders ) for (DamageTarget dt : defenders)
{ {
int dmg = dt.damage; int dmg = dt.damage;
damageLeft -= dmg; damageLeft -= dmg;
@@ -438,7 +437,7 @@ public class VAssignCombatDamage {
// assigned dynamically, the cards die off and further damage to them can't // assigned dynamically, the cards die off and further damage to them can't
// be modified. // be modified.
private void finish() { private void finish() {
if ( getRemainingDamage() > 0 ) if (getRemainingDamage() > 0)
return; return;
dlg.dispose(); dlg.dispose();
@@ -456,8 +455,7 @@ public class VAssignCombatDamage {
final CardView pw = (CardView)defender; final CardView pw = (CardView)defender;
lethalDamage = Integer.valueOf(pw.getCurrentState().getLoyalty()); lethalDamage = Integer.valueOf(pw.getCurrentState().getLoyalty());
} }
} } else {
else {
lethalDamage = Math.max(0, card.getLethalDamage()); lethalDamage = Math.max(0, card.getLethalDamage());
if (card.getCurrentState().getType().isPlaneswalker()) { if (card.getCurrentState().getType().isPlaneswalker()) {
lethalDamage = Integer.valueOf(card.getCurrentState().getLoyalty()); lethalDamage = Integer.valueOf(card.getCurrentState().getLoyalty());

View File

@@ -156,7 +156,7 @@ public class CCombat implements ICDoc {
sb.append("( ").append(state.getPower()).append(" / ").append(state.getToughness()).append(" ) ... "); sb.append("( ").append(state.getPower()).append(" / ").append(state.getToughness()).append(" ) ... ");
if (c.isFaceDown()) { if (c.isFaceDown()) {
sb.append("Morph"); sb.append("Morph");
} else { } else {
sb.append(name); sb.append(name);
} }
sb.append(" [").append(state.getDisplayId()).append("] "); sb.append(" [").append(state.getDisplayId()).append("] ");

View File

@@ -78,7 +78,6 @@ public class CDetail implements ICDoc {
@Override @Override
public void initialize() { public void initialize() {
} }
@Override @Override

View File

@@ -269,7 +269,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
g2d.rotate(getTappedAngle(), cardXOffset + edgeOffset, (cardYOffset + cardHeight) g2d.rotate(getTappedAngle(), cardXOffset + edgeOffset, (cardYOffset + cardHeight)
- edgeOffset); - edgeOffset);
} }
super.paint(g2d); super.paint(g2d);
} }
@Override @Override
@@ -284,12 +284,12 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE)); final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0; final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0;
// Magenta outline for when card is chosen // Magenta outline for when card is chosen
if (matchUI.isUsedToPay(getCard())) { if (matchUI.isUsedToPay(getCard())) {
g2d.setColor(Color.magenta); g2d.setColor(Color.magenta);
final int n2 = Math.max(1, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE)); final int n2 = Math.max(1, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE));
g2d.fillRoundRect(cardXOffset - n2, (cardYOffset - n2) + offset, cardWidth + (n2 * 2), cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2); g2d.fillRoundRect(cardXOffset - n2, (cardYOffset - n2) + offset, cardWidth + (n2 * 2), cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2);
} }
// Green outline for hover // Green outline for hover
if (isSelected) { if (isSelected) {
@@ -318,17 +318,17 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} else if (ed != null && state.getFoilIndex() == 0) { } else if (ed != null && state.getFoilIndex() == 0) {
// Non-foil cards from white-bordered sets are drawn with white border // Non-foil cards from white-bordered sets are drawn with white border
switch (ed.getBorderColor()) { switch (ed.getBorderColor()) {
case WHITE: case WHITE:
g2d.setColor(Color.WHITE); g2d.setColor(Color.WHITE);
colorIsSet = true; colorIsSet = true;
break; break;
case GOLD: case GOLD:
g2d.setColor(Color.ORANGE); g2d.setColor(Color.ORANGE);
colorIsSet = true; colorIsSet = true;
break; break;
case SILVER: case SILVER:
g2d.setColor(Color.GRAY); g2d.setColor(Color.GRAY);
colorIsSet = true; colorIsSet = true;
} }
} }
if (colorIsSet) { if (colorIsSet) {
@@ -337,11 +337,11 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
} }
if (matchUI.isSelectable(getCard())) { // White border for selectable cards to further highlight them if (matchUI.isSelectable(getCard())) { // White border for selectable cards to further highlight them
g2d.setColor(Color.WHITE); g2d.setColor(Color.WHITE);
final int ins = 1; final int ins = 1;
g2d.fillRoundRect(cardXOffset+ins, cardYOffset+ins, cardWidth-ins*2, cardHeight-ins*2, cornerSize-ins, cornerSize-ins); g2d.fillRoundRect(cardXOffset+ins, cardYOffset+ins, cardWidth-ins*2, cardHeight-ins*2, cornerSize-ins, cornerSize-ins);
} }
} }
private void drawManaCost(final Graphics g, final ManaCost cost, final int deltaY) { private void drawManaCost(final Graphics g, final ManaCost cost, final int deltaY) {
@@ -366,16 +366,16 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE)); cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE));
} }
boolean nonselectable = matchUI.isSelecting() && !matchUI.isSelectable(getCard()); boolean nonselectable = matchUI.isSelecting() && !matchUI.isSelectable(getCard());
// if selecting, darken non-selectable cards // if selecting, darken non-selectable cards
if ( nonselectable ) { if (nonselectable) {
boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS); boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS);
boolean cardImgHasAlpha = imagePanel != null && imagePanel.getSrcImage() != null && imagePanel.getSrcImage().getColorModel().hasAlpha(); boolean cardImgHasAlpha = imagePanel != null && imagePanel.getSrcImage() != null && imagePanel.getSrcImage().getColorModel().hasAlpha();
final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE)); final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0; final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0;
g.setColor(new Color(0.0f,0.0f,0.0f,0.6f)); g.setColor(new Color(0.0f,0.0f,0.0f,0.6f));
g.fillRoundRect(cardXOffset, cardYOffset + offset, cardWidth, cardHeight, cornerSize, cornerSize); g.fillRoundRect(cardXOffset, cardYOffset + offset, cardWidth, cardHeight, cornerSize, cornerSize);
} }
} }
public static void drawFoilEffect(final Graphics g, final CardView card2, final int x, final int y, final int width, final int height, final int borderSize) { public static void drawFoilEffect(final Graphics g, final CardView card2, final int x, final int y, final int width, final int height, final int borderSize) {
@@ -390,7 +390,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
@Override @Override
public final void doLayout() { public final void doLayout() {
int borderSize = calculateBorderSize(); int borderSize = calculateBorderSize();
final Point imgPos = new Point(cardXOffset + borderSize, cardYOffset + borderSize); final Point imgPos = new Point(cardXOffset + borderSize, cardYOffset + borderSize);
@@ -408,7 +407,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
private int calculateBorderSize() { private int calculateBorderSize() {
// Determine whether to render border from properties // Determine whether to render border from properties
boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS); boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS);
@@ -426,7 +424,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
return 0; return 0;
} }
private Dimension calculateImageSize() { private Dimension calculateImageSize() {
@@ -491,7 +488,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
} }
if (card.getCounters() != null && !card.getCounters().isEmpty()) { if (card.getCounters() != null && !card.getCounters().isEmpty()) {
switch (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE))) { switch (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE))) {
@@ -734,8 +730,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
abiY += abiSpace; abiY += abiSpace;
} }
} }
} } else {
else {
String keywordKey = card.getCurrentState().getKeywordKey(); String keywordKey = card.getCurrentState().getKeywordKey();
String abilityText = card.getCurrentState().getAbilityText(); String abilityText = card.getCurrentState().getAbilityText();
if (((keywordKey.indexOf("Flashback") == -1) if (((keywordKey.indexOf("Flashback") == -1)
@@ -752,7 +747,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
private void drawCounterTabs(final Graphics g) { private void drawCounterTabs(final Graphics g) {
final Dimension imgSize = calculateImageSize(); final Dimension imgSize = calculateImageSize();
final int titleY = Math.round(imgSize.height * (54f / 640)) - 15; final int titleY = Math.round(imgSize.height * (54f / 640)) - 15;
@@ -767,7 +761,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
FontMetrics largeFontMetrics = g.getFontMetrics(largeCounterFont); FontMetrics largeFontMetrics = g.getFontMetrics(largeCounterFont);
if (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE)) == CounterDisplayType.OLD_WHEN_SMALL) { if (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE)) == CounterDisplayType.OLD_WHEN_SMALL) {
int maxCounters = 0; int maxCounters = 0;
for (Integer numberOfCounters : card.getCounters().values()) { for (Integer numberOfCounters : card.getCounters().values()) {
maxCounters = Math.max(maxCounters, numberOfCounters); maxCounters = Math.max(maxCounters, numberOfCounters);
@@ -780,9 +773,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
for (Map.Entry<CounterType, Integer> counterEntry : card.getCounters().entrySet()) { for (Map.Entry<CounterType, Integer> counterEntry : card.getCounters().entrySet()) {
final CounterType counter = counterEntry.getKey(); final CounterType counter = counterEntry.getKey();
final int numberOfCounters = counterEntry.getValue(); final int numberOfCounters = counterEntry.getValue();
final int counterBoxRealWidth = counterBoxBaseWidth + largeFontMetrics.stringWidth(String.valueOf(numberOfCounters)); final int counterBoxRealWidth = counterBoxBaseWidth + largeFontMetrics.stringWidth(String.valueOf(numberOfCounters));
@@ -827,7 +818,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
private void drawCounterImage(final Graphics g) { private void drawCounterImage(final Graphics g) {
int counters = 0; int counters = 0;
for (final Integer i : card.getCounters().values()) { for (final Integer i : card.getCounters().values()) {
counters += i; counters += i;
@@ -848,7 +838,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
private void drawMarkersTabs(final Graphics g, List<String> markers) { private void drawMarkersTabs(final Graphics g, List<String> markers) {
final Dimension imgSize = calculateImageSize(); final Dimension imgSize = calculateImageSize();
final int titleY = Math.round(imgSize.height * (54f / 640)) - 15; final int titleY = Math.round(imgSize.height * (54f / 640)) - 15;
@@ -862,7 +851,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
FontMetrics smallFontMetrics = g.getFontMetrics(smallCounterFont); FontMetrics smallFontMetrics = g.getFontMetrics(smallCounterFont);
for (String marker : markers) { for (String marker : markers) {
final int markerBoxRealWidth = markerBoxBaseWidth + smallFontMetrics.stringWidth(marker); final int markerBoxRealWidth = markerBoxBaseWidth + smallFontMetrics.stringWidth(marker);
final int markerYOffset; final int markerYOffset;
@@ -907,7 +895,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
* @param font The font to use to draw the text. * @param font The font to use to draw the text.
*/ */
private void drawVerticallyCenteredString(Graphics g, String text, Rectangle area, Font font, final FontMetrics fontMetrics) { private void drawVerticallyCenteredString(Graphics g, String text, Rectangle area, Font font, final FontMetrics fontMetrics) {
Font oldFont = g.getFont(); Font oldFont = g.getFont();
int x = area.x; int x = area.x;
@@ -1114,8 +1101,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
} }
private boolean showCardManaCostOverlay() { private boolean showCardManaCostOverlay() {
return isShowingOverlays() && return isShowingOverlays() && isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST);
isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST);
} }
private boolean showCardIdOverlay() { private boolean showCardIdOverlay() {

View File

@@ -183,7 +183,7 @@ public abstract class CardPanelContainer extends SkinnedPanel {
} }
protected boolean cardPanelDraggable(final CardPanel panel) { protected boolean cardPanelDraggable(final CardPanel panel) {
return true; return true;
} }
private MouseMotionListener setupMotionMouseListener() { private MouseMotionListener setupMotionMouseListener() {
@@ -212,22 +212,22 @@ public abstract class CardPanelContainer extends SkinnedPanel {
return; return;
} }
if (cardPanelDraggable(panel)) { // allow for non-draggable cards if (cardPanelDraggable(panel)) { // allow for non-draggable cards
if (intialMouseDragX == -1) { if (intialMouseDragX == -1) {
intialMouseDragX = x; intialMouseDragX = x;
intialMouseDragY = y; intialMouseDragY = y;
return; return;
} }
if ((Math.abs(x - intialMouseDragX) < CardPanelContainer.DRAG_SMUDGE) if ((Math.abs(x - intialMouseDragX) < CardPanelContainer.DRAG_SMUDGE)
&& (Math.abs(y - intialMouseDragY) < CardPanelContainer.DRAG_SMUDGE)) { && (Math.abs(y - intialMouseDragY) < CardPanelContainer.DRAG_SMUDGE)) {
return; return;
} }
mouseDownPanel = null; mouseDownPanel = null;
setMouseDragPanel(panel); setMouseDragPanel(panel);
mouseDragOffsetX = panel.getX() - intialMouseDragX; mouseDragOffsetX = panel.getX() - intialMouseDragX;
mouseDragOffsetY = panel.getY() - intialMouseDragY; mouseDragOffsetY = panel.getY() - intialMouseDragY;
mouseDragStart(getMouseDragPanel(), evt); mouseDragStart(getMouseDragPanel(), evt);
} }
} }
@Override @Override
@@ -291,7 +291,7 @@ public abstract class CardPanelContainer extends SkinnedPanel {
} }
public final void removeCardPanel(final CardPanel fromPanel) { public final void removeCardPanel(final CardPanel fromPanel) {
removeCardPanel(fromPanel,true); removeCardPanel(fromPanel,true);
} }
public final void removeCardPanel(final CardPanel fromPanel, final boolean repaint) { public final void removeCardPanel(final CardPanel fromPanel, final boolean repaint) {
@@ -307,11 +307,11 @@ public abstract class CardPanelContainer extends SkinnedPanel {
fromPanel.dispose(); fromPanel.dispose();
getCardPanels().remove(fromPanel); getCardPanels().remove(fromPanel);
remove(fromPanel); remove(fromPanel);
if ( repaint ) { if (repaint) {
invalidate(); invalidate();
repaint(); repaint();
doingLayout(); doingLayout();
} }
} }
public final void setCardPanels(final List<CardPanel> cardPanels) { public final void setCardPanels(final List<CardPanel> cardPanels) {
@@ -331,14 +331,14 @@ public abstract class CardPanelContainer extends SkinnedPanel {
for (final CardPanel cardPanel : cardPanels) { for (final CardPanel cardPanel : cardPanels) {
this.add(cardPanel); this.add(cardPanel);
} }
//pfps the validate just below will do the layout, so don't do it here this.doLayout(); //pfps the validate just below will do the layout, so don't do it here this.doLayout();
this.invalidate(); this.invalidate();
this.getParent().validate(); this.getParent().validate();
this.repaint(); this.repaint();
} }
public final void clear() { public final void clear() {
clear(true); clear(true);
} }
public final void clear(final boolean repaint) { public final void clear(final boolean repaint) {
FThreads.assertExecutedByEdt(true); FThreads.assertExecutedByEdt(true);
@@ -347,12 +347,12 @@ public abstract class CardPanelContainer extends SkinnedPanel {
} }
getCardPanels().clear(); getCardPanels().clear();
removeAll(); removeAll();
if ( repaint ) { if (repaint) {
setPreferredSize(new Dimension(0, 0)); setPreferredSize(new Dimension(0, 0));
invalidate(); invalidate();
getParent().validate(); getParent().validate();
repaint(); repaint();
} }
} }
public final FScrollPane getScrollPane() { public final FScrollPane getScrollPane() {

View File

@@ -57,10 +57,10 @@ public abstract class FloatingCardArea extends CardArea {
protected abstract Iterable<CardView> getCards(); protected abstract Iterable<CardView> getCards();
protected FloatingCardArea(final CMatchUI matchUI) { protected FloatingCardArea(final CMatchUI matchUI) {
this(matchUI, new FScrollPane(false, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); this(matchUI, new FScrollPane(false, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
} }
protected FloatingCardArea(final CMatchUI matchUI, final FScrollPane scrollPane) { protected FloatingCardArea(final CMatchUI matchUI, final FScrollPane scrollPane) {
super(matchUI, scrollPane); super(matchUI, scrollPane);
} }
protected void showWindow() { protected void showWindow() {
@@ -127,7 +127,7 @@ public abstract class FloatingCardArea extends CardArea {
} }
protected FDialog getWindow() { protected FDialog getWindow() {
return window; return window;
} }
protected void loadLocation() { protected void loadLocation() {

View File

@@ -624,8 +624,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
if (toDelete.size() == getCardPanels().size()) { if (toDelete.size() == getCardPanels().size()) {
clear(false); clear(false);
} } else {
else {
for (final CardView card : toDelete) { for (final CardView card : toDelete) {
removeCardPanel(getCardPanel(card.getId()),false); removeCardPanel(getCardPanel(card.getId()),false);
} }
@@ -649,9 +648,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
needLayoutRefresh = true; needLayoutRefresh = true;
} }
} }
if (needLayoutRefresh) { if (needLayoutRefresh) {
doLayout(); doLayout();
} }
invalidate(); //pfps do the extra invalidate before any scrolling invalidate(); //pfps do the extra invalidate before any scrolling
if (!newPanels.isEmpty()) { if (!newPanels.isEmpty()) {
@@ -681,8 +680,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
if (card.isTapped()) { if (card.isTapped()) {
toPanel.setTapped(true); toPanel.setTapped(true);
toPanel.setTappedAngle(forge.view.arcane.CardPanel.TAPPED_ANGLE); toPanel.setTappedAngle(forge.view.arcane.CardPanel.TAPPED_ANGLE);
} } else {
else {
toPanel.setTapped(false); toPanel.setTapped(false);
toPanel.setTappedAngle(0); toPanel.setTappedAngle(0);
} }
@@ -705,8 +703,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
CardPanel attachedToPanel; CardPanel attachedToPanel;
if (card.getAttachedTo() != null) { if (card.getAttachedTo() != null) {
attachedToPanel = getCardPanel(card.getAttachedTo().getId()); attachedToPanel = getCardPanel(card.getAttachedTo().getId());
} } else {
else {
attachedToPanel = null; attachedToPanel = null;
} }
if (toPanel.getAttachedToPanel() != attachedToPanel) { if (toPanel.getAttachedToPanel() != attachedToPanel) {

View File

@@ -103,8 +103,6 @@ public class ScaledImagePanel extends JPanel {
if (src == null) { if (src == null) {
return; return;
} }
//System.out.println(sz + " -- " + src);
//ResampleOp resizer = new ResampleOp(DimensionConstrain.createMaxDimension(this.getWidth(), this.getHeight(), !scaleLarger)); //ResampleOp resizer = new ResampleOp(DimensionConstrain.createMaxDimension(this.getWidth(), this.getHeight(), !scaleLarger));
//resizer.setUnsharpenMask(UnsharpenMask.Soft); //resizer.setUnsharpenMask(UnsharpenMask.Soft);
@@ -112,10 +110,7 @@ public class ScaledImagePanel extends JPanel {
boolean needsScale = img.getWidth() < sz.width; boolean needsScale = img.getWidth() < sz.width;
float scaleFactor = ((float)img.getWidth()) / sz.width; float scaleFactor = ((float)img.getWidth()) / sz.width;
if ( needsScale && ( scaleFactor < 0.95 || scaleFactor > 1.05 ) ) { // This should very low-quality scaling to draw during animation if (needsScale && ( scaleFactor < 0.95 || scaleFactor > 1.05 )) { // This should very low-quality scaling to draw during animation
//System.out.println("Painting: " + img.getWidth() + " -> " + sz.width );
float maxZoomX = ((float)sz.width) / img.getWidth(); float maxZoomX = ((float)sz.width) / img.getWidth();
float maxZoomY = ((float)sz.height) / img.getHeight(); float maxZoomY = ((float)sz.height) / img.getHeight();
float zoom = Math.min(maxZoomX, maxZoomY); float zoom = Math.min(maxZoomX, maxZoomY);

View File

@@ -4,6 +4,6 @@ Types:Artifact Creature Construct
PT:5/6 PT:5/6
K:Flash K:Flash
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPlay | TriggerDescription$ When CARDNAME enters the battlefield, you may cast target instant card from your graveyard without paying its mana cost. If that spell would be put into your graveyard this turn, exile it instead. T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPlay | TriggerDescription$ When CARDNAME enters the battlefield, you may cast target instant card from your graveyard without paying its mana cost. If that spell would be put into your graveyard this turn, exile it instead.
SVar:TrigPlay:DB$ Play | TgtZone$ Graveyard | ValidTgts$ Instant.YouCtrl | TgtPrompt$ Choose target instant or sorcery card from your graveyard | WithoutManaCost$ True | Optional$ True | ReplaceGraveyard$ Exile | AILogic$ ReplaySpell SVar:TrigPlay:DB$ Play | TgtZone$ Graveyard | ValidTgts$ Instant.YouCtrl | TgtPrompt$ Choose target instant card from your graveyard | WithoutManaCost$ True | Optional$ True | ReplaceGraveyard$ Exile | AILogic$ ReplaySpell
SVar:Picture:http://www.wizards.com/global/images/magic/general/torrential_gearhulk.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/torrential_gearhulk.jpg
Oracle:Flash\nWhen Torrential Gearhulk enters the battlefield, you may cast target instant card from your graveyard without paying its mana cost. If that spell would be put into your graveyard this turn, exile it instead. Oracle:Flash\nWhen Torrential Gearhulk enters the battlefield, you may cast target instant card from your graveyard without paying its mana cost. If that spell would be put into your graveyard this turn, exile it instead.

View File

@@ -14,9 +14,9 @@ import forge.model.FModel;
public class CardThemedDeckGenerator extends DeckProxy implements Comparable<CardThemedDeckGenerator> { public class CardThemedDeckGenerator extends DeckProxy implements Comparable<CardThemedDeckGenerator> {
public static List<DeckProxy> getMatrixDecks(GameFormat format, boolean isForAi){ public static List<DeckProxy> getMatrixDecks(GameFormat format, boolean isForAi){
final List<DeckProxy> decks = new ArrayList<>(); final List<DeckProxy> decks = new ArrayList<>();
for(String card: CardArchetypeLDAGenerator.ldaPools.get(format.getName()).keySet()) { for (String card: CardArchetypeLDAGenerator.ldaPools.get(format.getName()).keySet()) {
//exclude non AI playables as keycards for AI decks //exclude non AI playables as keycards for AI decks
if(isForAi&&FModel.getMagicDb().getCommonCards().getUniqueByName(card).getRules().getAiHints().getRemAIDecks()){ if (isForAi&&FModel.getMagicDb().getCommonCards().getUniqueByName(card).getRules().getAiHints().getRemAIDecks()) {
continue; continue;
} }
decks.add(new CardThemedDeckGenerator(card, format, isForAi)); decks.add(new CardThemedDeckGenerator(card, format, isForAi));
@@ -42,7 +42,6 @@ public class CardThemedDeckGenerator extends DeckProxy implements Comparable<Car
return CardEdition.UNKNOWN; return CardEdition.UNKNOWN;
} }
@Override @Override
public String getName() { public String getName() {
return name; return name;

View File

@@ -153,8 +153,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
setCurrentPlayer(Iterables.getFirst(gameControllers.keySet(), null)); setCurrentPlayer(Iterables.getFirst(gameControllers.keySet(), null));
} }
} }
} } else {
else {
gameControllers.put(player, gameController); gameControllers.put(player, gameController);
} }
} }
@@ -270,7 +269,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
private final Set<CardView> selectableCards = Sets.newHashSet(); private final Set<CardView> selectableCards = Sets.newHashSet();
public void setSelectables(final Iterable<CardView> cards) { public void setSelectables(final Iterable<CardView> cards) {
for ( CardView cv : cards ) { selectableCards.add(cv); } for (CardView cv : cards) { selectableCards.add(cv); }
} }
public void clearSelectables() { public void clearSelectables() {
selectableCards.clear(); selectableCards.clear();
@@ -285,12 +284,12 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
public void setgamePause(boolean pause) { gamePause = pause; } public void setgamePause(boolean pause) { gamePause = pause; }
public void pauseMatch() { public void pauseMatch() {
IGameController controller = spectator; IGameController controller = spectator;
if(controller != null && !isGamePaused()) if (controller != null && !isGamePaused())
controller.selectButtonOk(); controller.selectButtonOk();
} }
public void resumeMatch() { public void resumeMatch() {
IGameController controller = spectator; IGameController controller = spectator;
if(controller != null && isGamePaused()) if (controller != null && isGamePaused())
controller.selectButtonOk(); controller.selectButtonOk();
} }
@@ -315,12 +314,10 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
// Concede each player on this Gui (except mind-controlled players) // Concede each player on this Gui (except mind-controlled players)
c.concede(); c.concede();
} }
} } else {
else {
return false; return false;
} }
} } else {
else {
return !ignoreConcedeChain; return !ignoreConcedeChain;
} }
if (gameView.isGameOver()) { if (gameView.isGameOver()) {

View File

@@ -392,8 +392,8 @@ public final class InputSelectTargets extends InputSyncronizedBase {
@Override @Override
protected void onStop() { protected void onStop() {
getController().getGui().clearSelectables(); getController().getGui().clearSelectables();
super.onStop(); super.onStop();
} }
} }

View File

@@ -200,8 +200,7 @@ public class CardDetailUtil {
if (ptText.length() > 0) { if (ptText.length() > 0) {
ptText.insert(0, "P/T: "); ptText.insert(0, "P/T: ");
ptText.append(" - ").append("Loy: "); ptText.append(" - ").append("Loy: ");
} } else {
else {
ptText.append("Loyalty: "); ptText.append("Loyalty: ");
} }
@@ -278,9 +277,9 @@ public class CardDetailUtil {
area.append("Token"); area.append("Token");
} else if (card.isTokenCard()) { } else if (card.isTokenCard()) {
area.append("Token card"); area.append("Token card");
} else if(card.isEmblem()) { } else if (card.isEmblem()) {
area.append("Emblem"); area.append("Emblem");
} else if(card.isImmutable()) { } else if (card.isImmutable()) {
area.append("Effect"); area.append("Effect");
} }
// card text // card text
@@ -297,7 +296,6 @@ public class CardDetailUtil {
card.getText(state, needTranslation ? CardTranslation.getTranslationTexts(state.getName(), "") : null) : card.getText(state, needTranslation ? CardTranslation.getTranslationTexts(state.getName(), "") : null) :
card.getText(state, needTranslation ? CardTranslation.getTranslationTexts(card.getLeftSplitState().getName(), card.getRightSplitState().getName()) : null ); card.getText(state, needTranslation ? CardTranslation.getTranslationTexts(card.getLeftSplitState().getName(), card.getRightSplitState().getName()) : null );
// LEVEL [0-9]+-[0-9]+ // LEVEL [0-9]+-[0-9]+
// LEVEL [0-9]+\+ // LEVEL [0-9]+\+

View File

@@ -72,7 +72,7 @@ public final class CardScriptInfo {
final String filename = name.toLowerCase().replaceAll("[^-a-z0-9\\s]","").replaceAll("[-\\s]","_").replaceAll("__","_") + ".txt"; final String filename = name.toLowerCase().replaceAll("[^-a-z0-9\\s]","").replaceAll("[-\\s]","_").replaceAll("__","_") + ".txt";
String[] folders = { String.valueOf(filename.charAt(0)), "upcoming"}; String[] folders = { String.valueOf(filename.charAt(0)), "upcoming"};
for(String folder : folders){ for (String folder : folders) {
final File file = new File(ForgeConstants.CARD_DATA_DIR + folder + File.separator + filename); final File file = new File(ForgeConstants.CARD_DATA_DIR + folder + File.separator + filename);
if (file.exists()) { if (file.exists()) {
script = new CardScriptInfo(FileUtil.readFileToString(file), file); script = new CardScriptInfo(FileUtil.readFileToString(file), file);

View File

@@ -104,7 +104,7 @@ public final class GamePlayerUtil {
final String oldPlayerName = FModel.getPreferences().getPref(FPref.PLAYER_NAME); final String oldPlayerName = FModel.getPreferences().getPref(FPref.PLAYER_NAME);
String newPlayerName; String newPlayerName;
try{ try {
if (StringUtils.isBlank(oldPlayerName)) { if (StringUtils.isBlank(oldPlayerName)) {
newPlayerName = getVerifiedPlayerName(getPlayerNameUsingFirstTimePrompt(), oldPlayerName); newPlayerName = getVerifiedPlayerName(getPlayerNameUsingFirstTimePrompt(), oldPlayerName);
} else { } else {

View File

@@ -277,8 +277,6 @@ public class HumanCostDecision extends CostDecisionMakerBase {
return exileFromSame(cost, list, c, payableZone); return exileFromSame(cost, list, c, payableZone);
} }
// Inputs // Inputs
// Exile<Num/Type{/TypeDescription}> // Exile<Num/Type{/TypeDescription}>

View File

@@ -334,7 +334,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
String errMsg; String errMsg;
if (newMain.size() < deckMinSize) { if (newMain.size() < deckMinSize) {
errMsg = TextUtil.concatNoSpace(localizer.getMessage("lblTooFewCardsMainDeck", String.valueOf(deckMinSize))); errMsg = TextUtil.concatNoSpace(localizer.getMessage("lblTooFewCardsMainDeck", String.valueOf(deckMinSize)));
} else { } else {
errMsg = TextUtil.concatNoSpace(localizer.getMessage("lblTooManyCardsSideboard", String.valueOf(sbMax))); errMsg = TextUtil.concatNoSpace(localizer.getMessage("lblTooManyCardsSideboard", String.valueOf(sbMax)));
} }