mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge remote-tracking branch 'upstream/master' into collector-number-in-card-list-and-card-db-refactoring
This commit is contained in:
@@ -59,7 +59,7 @@ public class InputConfirm extends InputSyncronizedBase {
|
||||
return controller.getGui().confirm(card, message, defaultIsYes, options);
|
||||
} else {
|
||||
InputConfirm inp;
|
||||
if ( options.size() == 2 ) {
|
||||
if (options.size() == 2) {
|
||||
inp = new InputConfirm(controller, message, options.get(0), options.get(1), defaultIsYes, card);
|
||||
} else {
|
||||
inp = new InputConfirm(controller, message, defaultOptions.get(0), defaultOptions.get(1), defaultIsYes, card);
|
||||
@@ -76,7 +76,7 @@ public class InputConfirm extends InputSyncronizedBase {
|
||||
return controller.getGui().confirm((sa==null)?null:CardView.get(sa.getHostCard()), message, defaultIsYes, options);
|
||||
} else {
|
||||
InputConfirm inp;
|
||||
if ( options.size() == 2 ) {
|
||||
if (options.size() == 2) {
|
||||
inp = new InputConfirm(controller, message, options.get(0), options.get(1), defaultIsYes, sa);
|
||||
} else {
|
||||
inp = new InputConfirm(controller, message, defaultOptions.get(0), defaultOptions.get(1), defaultIsYes, sa);
|
||||
@@ -147,17 +147,16 @@ public class InputConfirm extends InputSyncronizedBase {
|
||||
@Override
|
||||
protected final void showMessage() {
|
||||
getController().getGui().updateButtons(getOwner(), yesButtonText, noButtonText, true, true, defaultYes);
|
||||
if ( FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DETAILED_SPELLDESC_IN_PROMPT) &&
|
||||
(card!=null) ) {
|
||||
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DETAILED_SPELLDESC_IN_PROMPT) && card != null) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(card.toString());
|
||||
if ( (sa != null) && (sa.toString().length()>1) ) { // some spell abilities have no useful string value
|
||||
if (sa != null && sa.toString().length() > 1) { // some spell abilities have no useful string value
|
||||
sb.append(" - ").append(sa.toString());
|
||||
}
|
||||
sb.append("\n\n").append(message);
|
||||
showMessage(sb.toString(), card);
|
||||
} else {
|
||||
if ( card!=null ) {
|
||||
if (card != null) {
|
||||
showMessage(message, card);
|
||||
} else {
|
||||
showMessage(message);
|
||||
|
||||
@@ -356,11 +356,9 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
player.getManaPool().payManaFromAbility(saPaidFor, InputPayMana.this.manaCost, chosen);
|
||||
}
|
||||
onManaAbilityPaid();
|
||||
onStateChanged();
|
||||
} else {
|
||||
// Need to call this to unlock
|
||||
onStateChanged();
|
||||
}
|
||||
// Need to call this to unlock
|
||||
onStateChanged();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
||||
}
|
||||
|
||||
protected final void stop() {
|
||||
onStop();
|
||||
|
||||
// ensure input won't accept any user actions.
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
@@ -44,8 +46,6 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
||||
}
|
||||
});
|
||||
|
||||
onStop();
|
||||
|
||||
// thread irrelevant
|
||||
if (getController().getInputQueue().getInput() != null) {
|
||||
getController().getInputQueue().removeInput(InputSyncronizedBase.this);
|
||||
|
||||
@@ -93,6 +93,7 @@ public enum FSkinProp {
|
||||
IMG_MANA_HYBRID_UR (new int[] {412, 330, 80, 80}, PropType.MANAICONS),
|
||||
IMG_MANA_HYBRID_WB (new int[] {330, 412, 80, 80}, PropType.MANAICONS),
|
||||
IMG_MANA_HYBRID_WU (new int[] {412, 412, 80, 80}, PropType.MANAICONS),
|
||||
IMG_MANA_PHRYX (new int[] {166, 822, 80, 80}, PropType.MANAICONS),
|
||||
IMG_MANA_PHRYX_U (new int[] {330, 248, 80, 80}, PropType.MANAICONS),
|
||||
IMG_MANA_PHRYX_W (new int[] {412, 248, 80, 80}, PropType.MANAICONS),
|
||||
IMG_MANA_PHRYX_R (new int[] {412, 166, 80, 80}, PropType.MANAICONS),
|
||||
|
||||
@@ -149,7 +149,6 @@ public class HumanPlay {
|
||||
}
|
||||
|
||||
return GameActionUtil.addOptionalCosts(choosen, list);
|
||||
//final List<SpellAbility> abilities = GameActionUtil.getOptionalCosts(original);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +189,6 @@ public class HumanPlay {
|
||||
public final static void playSpellAbilityNoStack(final PlayerControllerHuman controller, final Player player, final SpellAbility sa) {
|
||||
playSpellAbilityNoStack(controller, player, sa, false);
|
||||
}
|
||||
|
||||
public final static void playSpellAbilityNoStack(final PlayerControllerHuman controller, final Player player, final SpellAbility sa, boolean useOldTargets) {
|
||||
sa.setActivatingPlayer(player);
|
||||
|
||||
@@ -293,8 +291,7 @@ public class HumanPlay {
|
||||
String message = null;
|
||||
if (res.contains(p)) {
|
||||
message = Localizer.getInstance().getMessage("lblDoYouWantLetThatPlayerDrawNCardOrDoAction", String.valueOf(amount), orString);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
message = Localizer.getInstance().getMessage("lblDoYouWantDrawNCardOrDoAction", String.valueOf(amount), orString);
|
||||
}
|
||||
|
||||
@@ -309,10 +306,10 @@ public class HumanPlay {
|
||||
else if (part instanceof CostGainLife) {
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostAddMana) {
|
||||
String desc = part.toString();
|
||||
@@ -323,10 +320,10 @@ public class HumanPlay {
|
||||
}
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostMill) {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
@@ -345,10 +342,10 @@ public class HumanPlay {
|
||||
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostRollDice) {
|
||||
if (!part.canPay(sourceAbility, p)) {
|
||||
@@ -357,10 +354,10 @@ public class HumanPlay {
|
||||
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostDamage) {
|
||||
if (!part.canPay(sourceAbility, p)) {
|
||||
@@ -370,10 +367,10 @@ public class HumanPlay {
|
||||
// not a pay life but damage!
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostPutCounter) {
|
||||
if (!part.canPay(sourceAbility, p)) {
|
||||
@@ -382,26 +379,26 @@ public class HumanPlay {
|
||||
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostRemoveCounter) {
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostRemoveAnyCounter) {
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostExile) {
|
||||
CostExile costExile = (CostExile) part;
|
||||
@@ -413,8 +410,7 @@ public class HumanPlay {
|
||||
}
|
||||
|
||||
costExile.payAsDecided(p, PaymentDecision.card(p.getCardsIn(ZoneType.Graveyard)), sourceAbility);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
from = costExile.getFrom();
|
||||
CardCollection list = CardLists.getValidCards(p.getCardsIn(from), part.getType().split(";"), p, source, sourceAbility);
|
||||
final int nNeeded = getAmountFromPart(costPart, source, sourceAbility);
|
||||
@@ -432,7 +428,12 @@ public class HumanPlay {
|
||||
CardCollection newList = new CardCollection();
|
||||
GameEntityViewMap<Card, CardView> gameCacheList = GameEntityView.getMap(list);
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final CardView cv = SGuiChoose.oneOrNone(Localizer.getInstance().getMessage("lblExileFromZone", from.getTranslatedName()), gameCacheList.getTrackableKeys());
|
||||
final CardView cv;
|
||||
if (mandatory) {
|
||||
cv = SGuiChoose.one(Localizer.getInstance().getMessage("lblExileFromZone", from.getTranslatedName()), gameCacheList.getTrackableKeys());
|
||||
} else {
|
||||
cv = SGuiChoose.oneOrNone(Localizer.getInstance().getMessage("lblExileFromZone", from.getTranslatedName()), gameCacheList.getTrackableKeys());
|
||||
}
|
||||
if (cv == null || !gameCacheList.containsKey(cv)) {
|
||||
return false;
|
||||
}
|
||||
@@ -497,8 +498,7 @@ public class HumanPlay {
|
||||
CardCollectionView listView;
|
||||
if (sameZone) {
|
||||
listView = p.getGame().getCardsIn(from);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
listView = p.getCardsIn(from);
|
||||
}
|
||||
CardCollection list = CardLists.getValidCards(listView, part.getType().split(";"), p, source, sourceAbility);
|
||||
@@ -548,10 +548,10 @@ public class HumanPlay {
|
||||
}
|
||||
else if (part instanceof CostSacrifice) {
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
if (pd == null)
|
||||
if (pd == null) {
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostGainControl) {
|
||||
int amount = Integer.parseInt(part.getAmount());
|
||||
|
||||
@@ -63,6 +63,9 @@ public class HumanPlaySpellAbility {
|
||||
final Player human = ability.getActivatingPlayer();
|
||||
final Game game = ability.getActivatingPlayer().getGame();
|
||||
|
||||
// CR 401.5: freeze top library cards until cast so player can't cheat and see the next
|
||||
game.setTopLibsCast();
|
||||
|
||||
// used to rollback
|
||||
Zone fromZone = null;
|
||||
int zonePosition = 0;
|
||||
@@ -141,6 +144,9 @@ public class HumanPlaySpellAbility {
|
||||
}
|
||||
}
|
||||
|
||||
// reset is also done early here, because if an ability is canceled from targeting it might otherwise lead to refunding mana from earlier cast
|
||||
ability.clearManaPaid();
|
||||
|
||||
// This line makes use of short-circuit evaluation of boolean values, that is each subsequent argument
|
||||
// is only executed or evaluated if the first argument does not suffice to determine the value of the expression
|
||||
// because of Selective Snare do announceType first
|
||||
@@ -168,6 +174,7 @@ public class HumanPlaySpellAbility {
|
||||
manapool.restoreColorReplacements();
|
||||
human.decNumManaConversion();
|
||||
}
|
||||
game.clearTopLibsCast(ability);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -180,7 +187,7 @@ public class HumanPlaySpellAbility {
|
||||
// Should unfreeze stack
|
||||
game.getStack().unfreezeStack();
|
||||
} else {
|
||||
enusureAbilityHasDescription(ability);
|
||||
ensureAbilityHasDescription(ability);
|
||||
game.getStack().addAndUnfreeze(ability);
|
||||
}
|
||||
|
||||
@@ -193,6 +200,7 @@ public class HumanPlaySpellAbility {
|
||||
manapool.restoreColorReplacements();
|
||||
}
|
||||
}
|
||||
game.clearTopLibsCast(ability);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -256,8 +264,7 @@ public class HumanPlaySpellAbility {
|
||||
card.setKickerMagnitude(value);
|
||||
} else if ("Pseudo-multikicker".equals(varName)) {
|
||||
card.setPseudoMultiKickerMagnitude(value);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
card.setSVar(varName, value.toString());
|
||||
}
|
||||
}
|
||||
@@ -305,7 +312,7 @@ public class HumanPlaySpellAbility {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void enusureAbilityHasDescription(final SpellAbility ability) {
|
||||
private static void ensureAbilityHasDescription(final SpellAbility ability) {
|
||||
if (!StringUtils.isBlank(ability.getStackDescription())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -785,8 +785,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
buildQuestion.append(regtrig.getHostCard().toString()).append("?");
|
||||
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_COMPACT_PROMPT)
|
||||
&& !FModel.getPreferences().getPrefBoolean(FPref.UI_DETAILED_SPELLDESC_IN_PROMPT)) {
|
||||
// append trigger description unless prompt is compact or detailed
|
||||
// descriptions are on
|
||||
// append trigger description unless prompt is compact or detailed descriptions are on
|
||||
buildQuestion.append("\n(");
|
||||
buildQuestion.append(regtrig.toString());
|
||||
buildQuestion.append(")");
|
||||
@@ -1405,22 +1404,19 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
if (CombatUtil.validateAttackers(combat)) {
|
||||
return; // don't prompt to declare attackers if user chose to
|
||||
// end the turn and not attacking is legal
|
||||
} else {
|
||||
autoPassCancel(); // otherwise: cancel auto pass because of this
|
||||
// unexpected attack
|
||||
}
|
||||
// otherwise: cancel auto pass because of this unexpected attack
|
||||
autoPassCancel();
|
||||
}
|
||||
|
||||
// This input should not modify combat object itself, but should return
|
||||
// user choice
|
||||
// This input should not modify combat object itself, but should return user choice
|
||||
final InputAttack inpAttack = new InputAttack(this, attackingPlayer, combat);
|
||||
inpAttack.showAndWait();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareBlockers(final Player defender, final Combat combat) {
|
||||
// This input should not modify combat object itself, but should return
|
||||
// user choice
|
||||
// This input should not modify combat object itself, but should return user choice
|
||||
final InputBlock inpBlock = new InputBlock(this, defender, combat);
|
||||
inpBlock.showAndWait();
|
||||
getGui().updateAutoPassPrompt();
|
||||
@@ -1796,8 +1792,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
return getGui().one(prompt, possibleReplacers);
|
||||
}
|
||||
}
|
||||
return first; // return first option without prompting if all options
|
||||
// are the same
|
||||
// return first option without prompting if all options are the same
|
||||
return first;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1808,8 +1804,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
@Override
|
||||
public boolean payCostToPreventEffect(final Cost cost, final SpellAbility sa, final boolean alreadyPaid,
|
||||
final FCollectionView<Player> allPayers) {
|
||||
// if it's paid by the AI already the human can pay, but it won't change
|
||||
// anything
|
||||
// if it's paid by the AI already the human can pay, but it won't change anything
|
||||
return HumanPlay.payCostDuringAbilityResolve(this, player, sa.getHostCard(), cost, sa, null);
|
||||
}
|
||||
|
||||
@@ -2075,8 +2070,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
|
||||
@Override
|
||||
public List<PaperCard> chooseCardsYouWonToAddToDeck(final List<PaperCard> losses) {
|
||||
return getGui().many(localizer.getMessage("lblSelectCardstoAddtoYourDeck"), localizer.getMessage("lblAddTheseToMyDeck"), 0, losses.size(), losses,
|
||||
null);
|
||||
return getGui().many(localizer.getMessage("lblSelectCardstoAddtoYourDeck"), localizer.getMessage("lblAddTheseToMyDeck"), 0, losses.size(), losses, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3278,8 +3272,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chooseNumberForKeywordCost(SpellAbility sa, Cost cost, KeywordInterface keyword, String prompt,
|
||||
int max) {
|
||||
public int chooseNumberForKeywordCost(SpellAbility sa, Cost cost, KeywordInterface keyword, String prompt, int max) {
|
||||
if (max <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user