mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge branch 'master' into BrawlFormat
This commit is contained in:
@@ -172,11 +172,12 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
Date today = new Date();
|
||||
|
||||
for (CardEdition e : editions.getOrderedEditions()) {
|
||||
boolean isCoreExpSet = e.getType() == CardEdition.Type.CORE || e.getType() == CardEdition.Type.EXPANSION || e.getType() == CardEdition.Type.REPRINT;
|
||||
boolean coreOrExpSet = e.getType() == CardEdition.Type.CORE || e.getType() == CardEdition.Type.EXPANSION;
|
||||
boolean isCoreExpSet = coreOrExpSet || e.getType() == CardEdition.Type.REPRINT;
|
||||
if (logMissingPerEdition && isCoreExpSet) {
|
||||
System.out.print(e.getName() + " (" + e.getCards().length + " cards)");
|
||||
}
|
||||
if (e.getDate().after(today)) {
|
||||
if (coreOrExpSet && e.getDate().after(today)) {
|
||||
upcomingSet = e;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,10 +77,14 @@ public class StaticAbilityCantTarget {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params.containsKey("SourceCanOnlyTarget")
|
||||
if (spellAbility.getParam("ValidTgts")!=null &&
|
||||
(params.containsKey("SourceCanOnlyTarget")
|
||||
&& (!spellAbility.getParam("ValidTgts").contains(params.get("SourceCanOnlyTarget"))
|
||||
|| spellAbility.getParam("ValidTgts").contains(","))
|
||||
|| spellAbility.getParam("ValidTgts").contains("non" + params.get("SourceCanOnlyTarget"))) {
|
||||
|| spellAbility.getParam("ValidTgts").contains("non" + params.get("SourceCanOnlyTarget")
|
||||
)
|
||||
)
|
||||
){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public class WrappedAbility extends Ability {
|
||||
regtrig = regtrig0;
|
||||
sa = sa0;
|
||||
decider = decider0;
|
||||
sa.setDescription(this.getStackDescription());
|
||||
}
|
||||
|
||||
public SpellAbility getWrappedAbility() {
|
||||
@@ -48,7 +49,7 @@ public class WrappedAbility extends Ability {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Trigger getTrigger(){
|
||||
public Trigger getTrigger() {
|
||||
return regtrig;
|
||||
}
|
||||
|
||||
@@ -289,8 +290,6 @@ public class WrappedAbility extends Ability {
|
||||
return sa.isXCost();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getSvarWithFallback(String name) {
|
||||
return sa.getSvarWithFallback(name);
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
@@ -21,6 +22,7 @@ import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
@@ -176,10 +178,6 @@ public class DualListBox<T> extends FDialog {
|
||||
rightPanel.add(new FScrollPane(destList, true), BorderLayout.CENTER);
|
||||
rightPanel.add(autoButton, BorderLayout.SOUTH);
|
||||
|
||||
add(leftPanel, "w 250, h 300");
|
||||
add(centerPanel, "w 100, h 300");
|
||||
add(rightPanel, "w 250, h 300");
|
||||
|
||||
_addListListeners(sourceList);
|
||||
_addListListeners(destList);
|
||||
|
||||
@@ -205,6 +203,12 @@ public class DualListBox<T> extends FDialog {
|
||||
});
|
||||
}
|
||||
|
||||
int columnWidth = getColumnWidth();
|
||||
String listConstraints = "w " + columnWidth + ", h 300";
|
||||
add(leftPanel, listConstraints);
|
||||
add(centerPanel, "w 100, h 300");
|
||||
add(rightPanel, listConstraints);
|
||||
|
||||
_setButtonState();
|
||||
|
||||
if (remainingSourcesMin <= sourceElements.size() && remainingSourcesMax >= sourceElements.size()) {
|
||||
@@ -218,6 +222,39 @@ public class DualListBox<T> extends FDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxElementWidth(UnsortedListModel<T> model) {
|
||||
final FontMetrics metrics = this.getFontMetrics(this.getFont());
|
||||
int width = 0;
|
||||
for (int i = 0; i < model.getSize(); i++) {
|
||||
final int itemWidth = metrics.stringWidth(model.getElementAt(i).toString());
|
||||
if (itemWidth > width) {
|
||||
width = itemWidth;
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
private int getColumnWidth() {
|
||||
int width = 0;
|
||||
int srcWidth = getMaxElementWidth(this.sourceListModel);
|
||||
if (srcWidth > width) {
|
||||
width = srcWidth;
|
||||
}
|
||||
int dstWidth = getMaxElementWidth(this.destListModel);
|
||||
if (dstWidth > width) {
|
||||
width = dstWidth;
|
||||
}
|
||||
final int minWidth = 250;
|
||||
if (width < minWidth) {
|
||||
width = minWidth;
|
||||
}
|
||||
final int maxWidth = (Singletons.getView().getFrame().getWidth()/2) - 100;
|
||||
if (width > maxWidth) {
|
||||
width = maxWidth;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setSecondColumnLabelText(String label) {
|
||||
orderedLabel.setText(label);
|
||||
}
|
||||
|
||||
@@ -1537,23 +1537,38 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
}
|
||||
if (needPrompt) {
|
||||
List<Integer> savedOrder = orderedSALookup.get(saLookupKey);
|
||||
List<SpellAbilityView> orderedSAVs = Lists.newArrayList();
|
||||
|
||||
// create a mapping between a spell's view and the spell itself
|
||||
HashMap<SpellAbilityView, SpellAbility> spellViewCache = new HashMap<>();
|
||||
for (SpellAbility spellAbility : orderedSAs) {
|
||||
spellViewCache.put(spellAbility.getView(), spellAbility);
|
||||
}
|
||||
|
||||
if (savedOrder != null) {
|
||||
orderedSAs = Lists.newArrayList();
|
||||
orderedSAVs = Lists.newArrayList();
|
||||
for (Integer index : savedOrder) {
|
||||
orderedSAs.add(activePlayerSAs.get(index));
|
||||
orderedSAVs.add(activePlayerSAs.get(index).getView());
|
||||
}
|
||||
} else {
|
||||
for (SpellAbility spellAbility : orderedSAs) {
|
||||
orderedSAVs.add(spellAbility.getView());
|
||||
}
|
||||
}
|
||||
if (savedOrder != null) {
|
||||
boolean preselect = FModel.getPreferences()
|
||||
.getPrefBoolean(FPref.UI_PRESELECT_PREVIOUS_ABILITY_ORDER);
|
||||
orderedSAs = getGui().order("Reorder simultaneous abilities", "Resolve first", 0, 0,
|
||||
preselect ? Lists.<SpellAbility>newArrayList() : orderedSAs,
|
||||
preselect ? orderedSAs : Lists.<SpellAbility>newArrayList(), null, false);
|
||||
orderedSAVs = getGui().order("Reorder simultaneous abilities", "Resolve first", 0, 0,
|
||||
preselect ? Lists.<SpellAbilityView>newArrayList() : orderedSAVs,
|
||||
preselect ? orderedSAVs : Lists.<SpellAbilityView>newArrayList(), null, false);
|
||||
} else {
|
||||
orderedSAs = getGui().order("Select order for simultaneous abilities", "Resolve first", orderedSAs,
|
||||
orderedSAVs = getGui().order("Select order for simultaneous abilities", "Resolve first", orderedSAVs,
|
||||
null);
|
||||
}
|
||||
orderedSAs = Lists.newArrayList();
|
||||
for (SpellAbilityView spellAbilityView : orderedSAVs) {
|
||||
orderedSAs.add(spellViewCache.get(spellAbilityView));
|
||||
}
|
||||
// save order to avoid needing to prompt a second time to order
|
||||
// the same abilities
|
||||
savedOrder = Lists.newArrayListWithCapacity(activePlayerSAs.size());
|
||||
|
||||
Reference in New Issue
Block a user