Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -994,10 +994,10 @@ public void resetOnceResolved() {
}
}

// key for autoyield - the card description (including number) (if there is a card) plus the effect description
// key for autoyield - the card name (if there is a card) plus the effect description
public String yieldKey() {
if (getHostCard() != null) {
return getHostCard().toString() + ": " + toUnsuppressedString();
return getHostCard().getName() + ": " + toUnsuppressedString();
Comment thread
tool4ever marked this conversation as resolved.
Outdated
} else {
return toUnsuppressedString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import forge.game.card.CardView;
import forge.game.card.IHasCardView;
import forge.game.player.PlayerView;
import forge.game.trigger.Trigger;
import forge.trackable.TrackableCollection;
import forge.trackable.TrackableObject;
import forge.trackable.Tracker;
Expand Down Expand Up @@ -113,8 +114,14 @@ public boolean isTrigger() {
public int getSourceTrigger() {
return get(TrackableProperty.SourceTrigger);
}
public String getSourceTriggerYieldKey() {
String s = get(TrackableProperty.SourceTriggerYieldKey);
return s == null ? "" : s;
}
void updateSourceTrigger(SpellAbilityStackInstance si) {
set(TrackableProperty.SourceTrigger, si.getSpellAbility().getSourceTrigger());
Trigger t = si.getSpellAbility().getTrigger();
set(TrackableProperty.SourceTriggerYieldKey, t == null ? "" : t.getYieldKey());
}

public String getText() {
Expand Down
19 changes: 18 additions & 1 deletion forge-game/src/main/java/forge/game/trigger/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ public final String toString() {
}

public String toString(boolean active) {
return toString(active, true);
}

/**
* @param includeRemembered append the per-game-state "triggerRemembered" suffix.
* Pass false to obtain a stable key for persisting Always-Yes / Always-No
* decisions across game instances. Staleness across Forge versions or
* card-text edits is acceptable -- stale keys silently fail to match.
*/
public String toString(boolean active, boolean includeRemembered) {
if (hasParam("TriggerDescription") && !this.isSuppressed()) {
StringBuilder sb = new StringBuilder();
ITranslatable nameSource = getHostName(this);
Expand All @@ -140,7 +150,7 @@ public String toString(boolean active) {
desc = TextUtil.fastReplace(desc, "EFFECTSOURCE", getHostCard().getEffectSource().getDisplayName());
}
sb.append(desc);
if (!this.triggerRemembered.isEmpty()) {
if (includeRemembered && !this.triggerRemembered.isEmpty()) {
Comment thread
tool4ever marked this conversation as resolved.
Outdated
sb.append(" (").append(this.triggerRemembered).append(")");
}
return sb.toString();
Expand All @@ -149,6 +159,13 @@ public String toString(boolean active) {
}
}

/** Composed key for persisting auto-decisions, mirroring SpellAbility.yieldKey(). Empty if no stable key. */
public final String getYieldKey() {
String stable = toString(false, false);
if (stable.isEmpty()) return "";
return getHostCard() != null ? getHostCard().getName() + ": " + stable : stable;
}

public final String replaceAbilityText(final String desc, final CardState state) {
// this function is for ABILITY
if (!desc.contains("ABILITY")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public SpellAbility getSATargetingCard() {
public String yieldKey() {
if (getTrigger() != null) {
if (getHostCard() != null) {
return getHostCard().toString() + ": " + getTrigger().toString();
return getHostCard().getName() + ": " + getTrigger().toString();
} else {
return getTrigger().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public enum TrackableProperty {
//StackItem
Key(TrackableTypes.StringType),
Comment thread
tool4ever marked this conversation as resolved.
SourceTrigger(TrackableTypes.IntegerType),
SourceTriggerYieldKey(TrackableTypes.StringType),
SourceCard(TrackableTypes.CardViewType),
ActivatingPlayer(TrackableTypes.PlayerViewType),
TargetCards(TrackableTypes.CardViewCollectionType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,11 @@ public void actionPerformed(final ActionEvent e) {
if (matchUI == null) { return; }
StackItemView si = matchUI.getGameView().peekStack();
if (si != null && si.isAbility()) {
boolean abilityScope = !forge.localinstance.properties.ForgeConstants.AUTO_YIELD_PER_CARD.equals(
forge.model.FModel.getPreferences().getPref(forge.localinstance.properties.ForgePreferences.FPref.UI_AUTO_YIELD_MODE));
boolean abilityScope = matchUI.getGameController().getYieldController().isAbilityScope();
matchUI.getGameController().setShouldAutoYield(si.getKey(), true, abilityScope);
int triggerID = si.getSourceTrigger();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
matchUI.getGameController().setShouldAlwaysAcceptTrigger(triggerID);
String triggerYieldKey = si.getSourceTriggerYieldKey();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer()) && !triggerYieldKey.isEmpty()) {
matchUI.getGameController().setShouldAlwaysAcceptTrigger(triggerYieldKey, abilityScope);
}
matchUI.getGameController().passPriority();
}
Expand All @@ -179,12 +178,11 @@ public void actionPerformed(final ActionEvent e) {
if (matchUI == null) { return; }
StackItemView si = matchUI.getGameView().peekStack();
if (si != null && si.isAbility()) {
boolean abilityScope = !forge.localinstance.properties.ForgeConstants.AUTO_YIELD_PER_CARD.equals(
forge.model.FModel.getPreferences().getPref(forge.localinstance.properties.ForgePreferences.FPref.UI_AUTO_YIELD_MODE));
boolean abilityScope = matchUI.getGameController().getYieldController().isAbilityScope();
matchUI.getGameController().setShouldAutoYield(si.getKey(), true, abilityScope);
int triggerID = si.getSourceTrigger();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
matchUI.getGameController().setShouldAlwaysDeclineTrigger(triggerID);
String triggerYieldKey = si.getSourceTriggerYieldKey();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer()) && !triggerYieldKey.isEmpty()) {
matchUI.getGameController().setShouldAlwaysDeclineTrigger(triggerYieldKey, abilityScope);
}
matchUI.getGameController().passPriority();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void initialize() {
initializeLandPlayedComboBox();
initializeColorIdentityCombobox();
initializeSwitchStatesCombobox();
initializeAutoYieldModeComboBox();
initializeAutoDecisionModeComboBox();
initializeStackGroupPermanentsComboBox();
initializeMaxStackDepthComboBox();
initializeCounterDisplayTypeComboBox();
Expand Down Expand Up @@ -571,15 +571,15 @@ private void initializeSwitchStatesCombobox() {
panel.setComboBox(comboBox, selectedItem);
}

private void initializeAutoYieldModeComboBox() {
private void initializeAutoDecisionModeComboBox() {
final String[] elems = {
ForgeConstants.AUTO_YIELD_PER_CARD,
ForgeConstants.AUTO_YIELD_PER_ABILITY,
ForgeConstants.AUTO_YIELD_PER_ABILITY_SESSION,
ForgeConstants.AUTO_YIELD_PER_ABILITY_INSTALL,
ForgeConstants.AUTO_DECISION_PER_CARD,
ForgeConstants.AUTO_DECISION_PER_ABILITY,
ForgeConstants.AUTO_DECISION_PER_ABILITY_SESSION,
ForgeConstants.AUTO_DECISION_PER_ABILITY_INSTALL,
};
final FPref userSetting = FPref.UI_AUTO_YIELD_MODE;
final FComboBoxPanel<String> panel = this.view.getAutoYieldModeComboBoxPanel();
final FPref userSetting = FPref.UI_AUTO_DECISION_MODE;
final FComboBoxPanel<String> panel = this.view.getAutoDecisionModeComboBoxPanel();
final FComboBox<String> comboBox = createComboBox(elems, userSetting);
final String selectedItem = this.prefs.getPref(userSetting);
panel.setComboBox(comboBox, selectedItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final FComboBoxPanel<String> cbpStackAdditions = new FComboBoxPanel<>(localizer.getMessage("cbpStackAdditions")+":");
private final FComboBoxPanel<String> cbpLandPlayed = new FComboBoxPanel<>(localizer.getMessage("cbpLandPlayed")+":");
private final FComboBoxPanel<String> cbpDisplayCurrentCardColors = new FComboBoxPanel<>(localizer.getMessage("cbpDisplayCurrentCardColors")+":");
private final FComboBoxPanel<String> cbpAutoYieldMode = new FComboBoxPanel<>(localizer.getMessage("cbpAutoYieldMode")+":");
private final FComboBoxPanel<String> cbpAutoDecisionMode = new FComboBoxPanel<>(localizer.getMessage("cbpAutoDecisionMode")+":");
private final FComboBoxPanel<String> cbpStackGroupPermanents = new FComboBoxPanel<>(localizer.getMessage("cbpStackGroupPermanents")+":");
private final FComboBoxPanel<Integer> cbpMaxStackDepth = new FComboBoxPanel<>(localizer.getMessage("cbpMaxStackDepth")+":");
private final FComboBoxPanel<String> cbpCounterDisplayType = new FComboBoxPanel<>(localizer.getMessage("cbpCounterDisplayType")+":");
Expand Down Expand Up @@ -301,8 +301,8 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbpGraveyardOrdering, comboBoxConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlpGraveyardOrdering")), descriptionConstraints);

pnlPrefs.add(cbpAutoYieldMode, comboBoxConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlpAutoYieldMode")), descriptionConstraints);
pnlPrefs.add(cbpAutoDecisionMode, comboBoxConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlpAutoDecisionMode")), descriptionConstraints);

//Server Preferences
pnlPrefs.add(new SectionLabel(localizer.getMessage("ServerPreferences")), sectionConstraints);
Expand Down Expand Up @@ -903,8 +903,8 @@ public FComboBoxPanel<String> getCbpDefaultLanguageComboBoxPanel() {
}


public FComboBoxPanel<String> getAutoYieldModeComboBoxPanel() {
return cbpAutoYieldMode;
public FComboBoxPanel<String> getAutoDecisionModeComboBoxPanel() {
return cbpAutoDecisionMode;
}

public FComboBoxPanel<String> getCbpStackGroupPermanents() {
Expand Down
109 changes: 0 additions & 109 deletions forge-gui-desktop/src/main/java/forge/screens/match/VAutoYields.java

This file was deleted.

Loading
Loading