Improved target messages for users: added extra hints;

Applied Biomancy - added target's choose hints;
This commit is contained in:
Oleg Agafonov 2019-01-21 12:53:02 +04:00
parent 91a3328907
commit ff5839860e
5 changed files with 52 additions and 49 deletions

View file

@ -1,14 +1,14 @@
package mage.abilities;
import java.io.Serializable;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.target.Target;
import mage.target.Targets;
import java.io.Serializable;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class Mode implements Serializable {
@ -53,7 +53,14 @@ public class Mode implements Serializable {
}
public void addTarget(Target target) {
this.addTarget(target, false);
}
public void addTarget(Target target, Boolean addChooseHintFromEffect) {
targets.add(target);
if (addChooseHintFromEffect) {
target.withChooseHint(this.getEffects().getText(this));
}
}
public Effects getEffects() {

View file

@ -1,10 +1,5 @@
package mage.target;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -12,8 +7,12 @@ import mage.filter.Filter;
import mage.game.Game;
import mage.players.Player;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public interface Target extends Serializable {
@ -30,7 +29,7 @@ public interface Target extends Serializable {
* controls if it will be checked, if the target can be targeted from source
*
* @param notTarget true = do not check for protection, false = check for
* protection
* protection
*/
void setNotTarget(boolean notTarget);
@ -136,4 +135,5 @@ public interface Target extends Serializable {
// used for cards like Spellskite
void setTargetAmount(UUID targetId, int amount, Game game);
Target withChooseHint(String chooseHint);
}

View file

@ -1,16 +1,5 @@
package mage.target;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.cards.Card;
@ -23,6 +12,8 @@ import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import mage.util.RandomUtil;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -45,6 +36,7 @@ public abstract class TargetImpl implements Target {
protected UUID abilityController = null; // only used if target controller != ability controller
protected int targetTag; // can be set if other target check is needed (AnotherTargetPredicate)
protected String chooseHint = null; // UI choose hints after target name
@Override
public abstract TargetImpl copy();
@ -72,6 +64,7 @@ public abstract class TargetImpl implements Target {
this.targetController = target.targetController;
this.abilityController = target.abilityController;
this.targetTag = target.targetTag;
this.chooseHint = target.chooseHint;
}
@Override
@ -101,12 +94,11 @@ public abstract class TargetImpl implements Target {
@Override
public String getMessage() {
// UI choose message
String suffix = "";
// if (targetController != null) {
// // Hint for the selecting player that the targets must be valid from the point of the ability controller
// // e.g. select opponent text may be misleading otherwise
// suffix = " (target controlling!)";
// }
if (this.chooseHint != null) {
suffix = " (" + this.chooseHint + ")";
}
if (getMaxNumberOfTargets() != 1) {
StringBuilder sb = new StringBuilder();
sb.append("Select ").append(targetName);
@ -401,7 +393,7 @@ public abstract class TargetImpl implements Target {
for (int K = minK; K <= maxK; K++) {
// get the combination by index
// e.g. 01 --> AB , 23 --> CD
int combination[] = new int[K];
int[] combination = new int[K];
// position of current index
// if (r = 1) r*
@ -544,4 +536,9 @@ public abstract class TargetImpl implements Target {
rememberZoneChangeCounter(targetId, game);
}
@Override
public Target withChooseHint(String chooseHint) {
this.chooseHint = chooseHint;
return this;
}
}