refactor: removed unused data from special action, improved code (related to #11137)

This commit is contained in:
Oleg Agafonov 2023-09-17 14:37:49 +04:00
parent a4daad1f92
commit 4e77ccb381
7 changed files with 31 additions and 38 deletions

View file

@ -17,7 +17,6 @@ import java.util.UUID;
public abstract class SpecialAction extends ActivatedAbilityImpl {
private final AlternateManaPaymentAbility manaAbility; // mana actions generates on every pay cycle, no need to copy it
protected ManaCost unpaidMana;
public SpecialAction() {
this(Zone.ALL);
@ -35,7 +34,6 @@ public abstract class SpecialAction extends ActivatedAbilityImpl {
protected SpecialAction(final SpecialAction action) {
super(action);
this.unpaidMana = action.unpaidMana;
this.manaAbility = action.manaAbility;
}
@ -43,14 +41,6 @@ public abstract class SpecialAction extends ActivatedAbilityImpl {
return manaAbility != null;
}
public void setUnpaidMana(ManaCost manaCost) {
this.unpaidMana = manaCost;
}
public ManaCost getUnpaidMana() {
return unpaidMana;
}
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
if (manaAbility != null) {
return manaAbility.getManaOptions(source, game, unpaid);

View file

@ -1,5 +1,3 @@
package mage.abilities;
import java.util.LinkedHashMap;
@ -7,6 +5,12 @@ import java.util.Map;
import java.util.UUID;
/**
* Special actions to activate at any priority time (GUI has special button to show a special commands list)
* <p>
* Two types of action:
* - mana actions (auto-generated on each mana pay cycle, auto-clean)
* - another actions (manual added, manual removed - like one short effects)
*
* @author BetaSteward_at_googlemail.com
*/
public class SpecialActions extends AbilitiesImpl<SpecialAction> {

View file

@ -14,22 +14,22 @@ import java.util.UUID;
public class CreateSpecialActionEffect extends OneShotEffect {
private final SpecialAction action;
private final UUID playerId; // If set, that player can activate the special action. If null, use the source controller instead.
private final UUID newActionControllerId; // another player can activate the special action
public CreateSpecialActionEffect(SpecialAction action) {
this(action, null);
}
public CreateSpecialActionEffect(SpecialAction action, UUID playerId) {
public CreateSpecialActionEffect(SpecialAction action, UUID newActionControllerId) {
super(action.getEffects().getOutcome(action));
this.action = action;
this.playerId = playerId;
this.newActionControllerId = newActionControllerId;
}
protected CreateSpecialActionEffect(final CreateSpecialActionEffect effect) {
super(effect);
this.action = (SpecialAction) effect.action.copy();
this.playerId = effect.playerId;
this.newActionControllerId = effect.newActionControllerId;
}
@Override
@ -41,7 +41,7 @@ public class CreateSpecialActionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
SpecialAction newAction = (SpecialAction) action.copy();
newAction.setSourceId(source.getSourceId());
newAction.setControllerId(playerId == null ? source.getControllerId() : playerId);
newAction.setControllerId(newActionControllerId != null ? newActionControllerId : source.getControllerId());
newAction.getTargets().addAll(source.getTargets());
game.getState().getSpecialActions().add(newAction);
return true;

View file

@ -228,6 +228,7 @@ class ConvokeEffect extends OneShotEffect {
if (chooseManaType.getChoices().size() > 1) {
chooseManaType.getChoices().add("Colorless");
chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName());
// TODO: must be AI optimization to pay most rare mana color first
if (!controller.choose(Outcome.Benefit, chooseManaType, game)) {
return false;
}