mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Modify implementation of Target's required status
This commit is contained in:
parent
6c8b818d89
commit
9629c3f0f5
3 changed files with 13 additions and 4 deletions
|
@ -330,7 +330,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
|
||||
updateGameStatePriority("choose(4)", game);
|
||||
while (!abort) {
|
||||
boolean required = true;
|
||||
boolean required = target.isRequired();
|
||||
// if there is no cards to select from, then add possibility to cancel choosing action
|
||||
if (cards == null) {
|
||||
required = false;
|
||||
|
|
|
@ -93,6 +93,7 @@ public interface Target extends Serializable {
|
|||
List<UUID> getTargets();
|
||||
Filter getFilter();
|
||||
|
||||
boolean isRequired();
|
||||
boolean isRequired(UUID sourceId, Game game);
|
||||
boolean isRequired(Ability ability);
|
||||
void setRequired(boolean required);
|
||||
|
|
|
@ -54,7 +54,8 @@ public abstract class TargetImpl implements Target {
|
|||
protected Zone zone;
|
||||
protected int maxNumberOfTargets;
|
||||
protected int minNumberOfTargets;
|
||||
protected boolean required = false;
|
||||
protected boolean required = true;
|
||||
protected boolean requiredExplicitlySet = false;
|
||||
protected boolean chosen = false;
|
||||
// is the target handled as targeted spell/ability (notTarget = true is used for not targeted effects like e.g. sacrifice)
|
||||
protected boolean notTarget = false;
|
||||
|
@ -77,6 +78,7 @@ public abstract class TargetImpl implements Target {
|
|||
this.maxNumberOfTargets = target.maxNumberOfTargets;
|
||||
this.minNumberOfTargets = target.minNumberOfTargets;
|
||||
this.required = target.required;
|
||||
this.requiredExplicitlySet = target.requiredExplicitlySet;
|
||||
this.chosen = target.chosen;
|
||||
this.targets.putAll(target.targets);
|
||||
this.zoneChangeCounters.putAll(target.zoneChangeCounters);
|
||||
|
@ -148,13 +150,18 @@ public abstract class TargetImpl implements Target {
|
|||
@Override
|
||||
public boolean isRequired(UUID sourceId, Game game) {
|
||||
MageObject object = game.getObject(sourceId);
|
||||
if (object != null && object instanceof Ability) {
|
||||
if (!requiredExplicitlySet && object != null && object instanceof Ability) {
|
||||
return isRequired((Ability) object);
|
||||
} else {
|
||||
return required;
|
||||
return isRequired();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequired(Ability ability) {
|
||||
return ability.isActivated() || !(ability.getAbilityType().equals(AbilityType.SPELL) || ability.getAbilityType().equals(AbilityType.ACTIVATED));
|
||||
|
@ -163,6 +170,7 @@ public abstract class TargetImpl implements Target {
|
|||
@Override
|
||||
public void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
this.requiredExplicitlySet = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue