mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
InputProxy - debug texts can be enabled with a variable
AbilityUtils - adjust order of checks removed unused imports
This commit is contained in:
@@ -4774,24 +4774,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the changed card keywords.
|
||||
*
|
||||
* @param kw
|
||||
* the new changed card keywords
|
||||
*/
|
||||
public final void setChangedCardKeywords(final ArrayList<CardKeywords> kw) {
|
||||
this.changedCardKeywords = kw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the changed card keywords.
|
||||
*
|
||||
* @return the changed card keywords
|
||||
*/
|
||||
public final ArrayList<CardKeywords> getChangedCardKeywords() {
|
||||
return this.changedCardKeywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the changed card keywords.
|
||||
|
||||
@@ -292,13 +292,12 @@ public class AbilityUtils {
|
||||
public static int calculateAmount(final Card card, String amount, final SpellAbility ability) {
|
||||
// return empty strings and constants
|
||||
if (StringUtils.isBlank(amount)) { return 0; }
|
||||
final boolean startsWithPlus = amount.charAt(0) == '+';
|
||||
if (startsWithPlus) { amount = amount.substring(1); }
|
||||
|
||||
// Strip and save sign for calculations
|
||||
boolean startsWithMinus = amount.charAt(0) == '-';
|
||||
final boolean startsWithPlus = amount.charAt(0) == '+';
|
||||
final boolean startsWithMinus = amount.charAt(0) == '-';
|
||||
if (startsWithPlus || startsWithMinus) { amount = amount.substring(1); }
|
||||
int multiplier = startsWithMinus ? -1 : 1;
|
||||
if (startsWithMinus) { amount = amount.substring(1); }
|
||||
|
||||
// return result soon for plain numbers
|
||||
if (StringUtils.isNumeric(amount)) { return Integer.parseInt(amount) * multiplier; }
|
||||
|
||||
@@ -24,12 +24,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.ColorChanger;
|
||||
import forge.GameLog;
|
||||
import forge.Singletons;
|
||||
|
||||
@@ -43,6 +43,8 @@ public class InputProxy implements Observer {
|
||||
private AtomicReference<Input> input = new AtomicReference<Input>();
|
||||
private MatchController match = null;
|
||||
|
||||
private static final boolean INPUT_DEBUG = false;
|
||||
|
||||
public void setMatch(MatchController matchController) {
|
||||
match = matchController;
|
||||
}
|
||||
@@ -51,13 +53,16 @@ public class InputProxy implements Observer {
|
||||
public final synchronized void update(final Observable observable, final Object obj) {
|
||||
final GameState game = match.getCurrentGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
//System.out.printf("%s > InputProxy.update() =>%n", FThreads.debugGetCurrThreadId());
|
||||
|
||||
if(INPUT_DEBUG)
|
||||
System.out.printf("%s > InputProxy.update() =>%n", FThreads.debugGetCurrThreadId());
|
||||
|
||||
if ( match.getInput().isEmpty() && ph.hasPhaseEffects()) {
|
||||
Runnable rPhase = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//System.out.printf("\t%s > handle begin phase during %s%n", FThreads.debugGetCurrThreadId(), ph.debugPrintState());
|
||||
if(INPUT_DEBUG)
|
||||
System.out.printf("\t%s > handle begin phase during %s%n", FThreads.debugGetCurrThreadId(), ph.debugPrintState());
|
||||
ph.handleBeginPhase();
|
||||
update(null, null);
|
||||
}
|
||||
@@ -67,12 +72,15 @@ public class InputProxy implements Observer {
|
||||
}
|
||||
|
||||
final Input nextInput = match.getInput().getActualInput(game);
|
||||
//System.out.printf("\tinput is %s during %s, \tstack = %s%n", nextInput == null ? "null" : nextInput.getClass().getSimpleName(), ph.debugPrintState(), match.getInput().printInputStack());
|
||||
|
||||
if(INPUT_DEBUG)
|
||||
System.out.printf("\tinput is %s during %s, \tstack = %s%n", nextInput == null ? "null" : nextInput.getClass().getSimpleName(), ph.debugPrintState(), match.getInput().printInputStack());
|
||||
|
||||
this.input.set(nextInput);
|
||||
Runnable showMessage = new Runnable() {
|
||||
@Override public void run() {
|
||||
//System.out.printf("%s > showMessage @ %s during %s%n", FThreads.debugGetCurrThreadId(), nextInput.getClass().getSimpleName(), ph.debugPrintState());
|
||||
if(INPUT_DEBUG)
|
||||
System.out.printf("%s > showMessage @ %s during %s%n", FThreads.debugGetCurrThreadId(), nextInput.getClass().getSimpleName(), ph.debugPrintState());
|
||||
nextInput.showMessage();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user