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

View File

@@ -2832,7 +2832,6 @@ public class ComputerUtil {
}
public static boolean lifegainPositive(final Player player, final Card source) {
if (!player.canGainLife()) {
return false;
}

View File

@@ -716,6 +716,7 @@ public class ComputerUtilCard {
int bigCMC = -1;
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();
// 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 Iterator<Card> itr = cards.iterator();
while (itr.hasNext()) {
final Card c = itr.next();
final List<SpellAbility> validSA = Lists.newArrayList(Iterables.filter(AbilityUtils.getBasicSpellsFromPlayEffect(c, ai), SpellAbilityPredicates.isValid(valid, ai , c, sa)));
if (validSA.size() == 0) {
if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, ai), SpellAbilityPredicates.isValid(valid, ai , c, sa))) {
itr.remove();
}
}
@@ -173,6 +172,8 @@ public class PlayAi extends SpellAbilityAi {
List<Card> tgtCards = CardLists.filter(options, new Predicate<Card>() {
@Override
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))) {
Spell spell = (Spell) s;
s.setActivatingPlayer(ai);

View File

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

View File

@@ -61,7 +61,6 @@ import forge.util.TextUtil;
*/
public class BoosterGenerator {
private final static Map<String, PrintSheet> cachedSheets = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private static synchronized PrintSheet getPrintSheet(String 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.
}
// Means to select from all unique cards (from base game, ie. no schemes or avatars)
public UnOpenedProduct(SealedProduct.Template template) {
tpl = template;

View File

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

View File

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

View File

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

View File

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

View File

@@ -532,7 +532,6 @@ public final class CMatchUI
for (final PlayerView p : manaPoolUpdate) {
getFieldViewFor(p).updateManaPool();
}
}
// Player's lives and poison counters
@@ -1367,7 +1366,6 @@ public final class CMatchUI
nextNotifiableStackIndex++;
} else {
// Not yet time to show the modal - schedule the method again, and try again later
Runnable tryAgainThread = new Runnable() {
@Override
@@ -1499,7 +1497,6 @@ public final class CMatchUI
}
private void createLandPopupPanel(Card land) {
String landPlayedNotificationPolicy = FModel.getPreferences().getPref(FPref.UI_LAND_PLAYED_NOTIFICATION_POLICY);
Player cardController = land.getController();
boolean isAi = cardController.isAI();

View File

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

View File

@@ -407,7 +407,6 @@ public class VAssignCombatDamage {
/** Updates labels and other UI elements.
* @param index index of the last assigned damage*/
private void updateLabels() {
int damageLeft = totalDamageToAssign;
boolean allHaveLethal = true;
@@ -456,8 +455,7 @@ public class VAssignCombatDamage {
final CardView pw = (CardView)defender;
lethalDamage = Integer.valueOf(pw.getCurrentState().getLoyalty());
}
}
else {
} else {
lethalDamage = Math.max(0, card.getLethalDamage());
if (card.getCurrentState().getType().isPlaneswalker()) {
lethalDamage = Integer.valueOf(card.getCurrentState().getLoyalty());

View File

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

View File

@@ -390,7 +390,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
@Override
public final void doLayout() {
int borderSize = calculateBorderSize();
final Point imgPos = new Point(cardXOffset + borderSize, cardYOffset + borderSize);
@@ -408,7 +407,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
}
private int calculateBorderSize() {
// Determine whether to render border from properties
boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS);
@@ -426,7 +424,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
}
return 0;
}
private Dimension calculateImageSize() {
@@ -491,7 +488,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
}
}
if (card.getCounters() != null && !card.getCounters().isEmpty()) {
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;
}
}
}
else {
} else {
String keywordKey = card.getCurrentState().getKeywordKey();
String abilityText = card.getCurrentState().getAbilityText();
if (((keywordKey.indexOf("Flashback") == -1)
@@ -752,7 +747,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
}
private void drawCounterTabs(final Graphics g) {
final Dimension imgSize = calculateImageSize();
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);
if (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE)) == CounterDisplayType.OLD_WHEN_SMALL) {
int maxCounters = 0;
for (Integer numberOfCounters : card.getCounters().values()) {
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()) {
final CounterType counter = counterEntry.getKey();
final int numberOfCounters = counterEntry.getValue();
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) {
int counters = 0;
for (final Integer i : card.getCounters().values()) {
counters += i;
@@ -848,7 +838,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
}
private void drawMarkersTabs(final Graphics g, List<String> markers) {
final Dimension imgSize = calculateImageSize();
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);
for (String marker : markers) {
final int markerBoxRealWidth = markerBoxBaseWidth + smallFontMetrics.stringWidth(marker);
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.
*/
private void drawVerticallyCenteredString(Graphics g, String text, Rectangle area, Font font, final FontMetrics fontMetrics) {
Font oldFont = g.getFont();
int x = area.x;
@@ -1114,8 +1101,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
}
private boolean showCardManaCostOverlay() {
return isShowingOverlays() &&
isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST);
return isShowingOverlays() && isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST);
}
private boolean showCardIdOverlay() {

View File

@@ -624,8 +624,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
if (toDelete.size() == getCardPanels().size()) {
clear(false);
}
else {
} else {
for (final CardView card : toDelete) {
removeCardPanel(getCardPanel(card.getId()),false);
}
@@ -681,8 +680,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
if (card.isTapped()) {
toPanel.setTapped(true);
toPanel.setTappedAngle(forge.view.arcane.CardPanel.TAPPED_ANGLE);
}
else {
} else {
toPanel.setTapped(false);
toPanel.setTappedAngle(0);
}
@@ -705,8 +703,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
CardPanel attachedToPanel;
if (card.getAttachedTo() != null) {
attachedToPanel = getCardPanel(card.getAttachedTo().getId());
}
else {
} else {
attachedToPanel = null;
}
if (toPanel.getAttachedToPanel() != attachedToPanel) {

View File

@@ -104,8 +104,6 @@ public class ScaledImagePanel extends JPanel {
return;
}
//System.out.println(sz + " -- " + src);
//ResampleOp resizer = new ResampleOp(DimensionConstrain.createMaxDimension(this.getWidth(), this.getHeight(), !scaleLarger));
//resizer.setUnsharpenMask(UnsharpenMask.Soft);
BufferedImage img = getSrcImage(); //resizer.filter(getSrcImage(), null);
@@ -113,9 +111,6 @@ public class ScaledImagePanel extends JPanel {
boolean needsScale = 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
//System.out.println("Painting: " + img.getWidth() + " -> " + sz.width );
float maxZoomX = ((float)sz.width) / img.getWidth();
float maxZoomY = ((float)sz.height) / img.getHeight();
float zoom = Math.min(maxZoomX, maxZoomY);

View File

@@ -4,6 +4,6 @@ Types:Artifact Creature Construct
PT:5/6
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.
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
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

@@ -42,7 +42,6 @@ public class CardThemedDeckGenerator extends DeckProxy implements Comparable<Car
return CardEdition.UNKNOWN;
}
@Override
public String getName() {
return name;

View File

@@ -153,8 +153,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
setCurrentPlayer(Iterables.getFirst(gameControllers.keySet(), null));
}
}
}
else {
} else {
gameControllers.put(player, gameController);
}
}
@@ -315,12 +314,10 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
// Concede each player on this Gui (except mind-controlled players)
c.concede();
}
}
else {
} else {
return false;
}
}
else {
} else {
return !ignoreConcedeChain;
}
if (gameView.isGameOver()) {

View File

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

View File

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

View File

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