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,8 +1,5 @@
package mage.player.human; package mage.player.human;
import java.io.Serializable;
import java.util.*;
import mage.MageObject; import mage.MageObject;
import mage.abilities.*; import mage.abilities.*;
import mage.abilities.costs.VariableCost; import mage.abilities.costs.VariableCost;
@ -18,8 +15,6 @@ import mage.cards.decks.Deck;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.*; import mage.constants.*;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.filter.common.FilterAttackingCreature; import mage.filter.common.FilterAttackingCreature;
import mage.filter.common.FilterBlockingCreature; import mage.filter.common.FilterBlockingCreature;
@ -42,16 +37,21 @@ import mage.target.Target;
import mage.target.TargetAmount; import mage.target.TargetAmount;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetAttackingCreature;
import mage.target.common.TargetAnyTarget; import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetAttackingCreature;
import mage.target.common.TargetDefender; import mage.target.common.TargetDefender;
import mage.util.GameLog; import mage.util.GameLog;
import mage.util.ManaUtil; import mage.util.ManaUtil;
import mage.util.MessageToClient; import mage.util.MessageToClient;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class HumanPlayer extends PlayerImpl { public class HumanPlayer extends PlayerImpl {
@ -511,6 +511,7 @@ public class HumanPlayer extends PlayerImpl {
prepareForResponse(game); prepareForResponse(game);
if (!isExecutingMacro()) { if (!isExecutingMacro()) {
// hmm
game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), possibleTargets, required, getOptions(target, null)); game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), possibleTargets, required, getOptions(target, null));
} }
waitForResponse(game); waitForResponse(game);
@ -782,9 +783,9 @@ public class HumanPlayer extends PlayerImpl {
if (!skippedAtLeastOnce if (!skippedAtLeastOnce
|| (playerId.equals(game.getActivePlayerId()) || (playerId.equals(game.getActivePlayerId())
&& !controllingPlayer && !controllingPlayer
.getUserData() .getUserData()
.getUserSkipPrioritySteps() .getUserSkipPrioritySteps()
.isStopOnAllEndPhases())) { .isStopOnAllEndPhases())) {
skippedAtLeastOnce = true; skippedAtLeastOnce = true;
if (passWithManaPoolCheck(game)) { if (passWithManaPoolCheck(game)) {
return false; return false;
@ -876,9 +877,7 @@ public class HumanPlayer extends PlayerImpl {
} }
} }
return result; return result;
} else if (response.getManaType() != null) { } else return response.getManaType() == null;
return false;
}
return true; return true;
} }
return false; return false;
@ -1126,8 +1125,8 @@ public class HumanPlayer extends PlayerImpl {
if (passedAllTurns if (passedAllTurns
|| passedUntilEndStepBeforeMyTurn || passedUntilEndStepBeforeMyTurn
|| (!getControllingPlayersUserData(game) || (!getControllingPlayersUserData(game)
.getUserSkipPrioritySteps() .getUserSkipPrioritySteps()
.isStopOnDeclareAttackersDuringSkipAction() .isStopOnDeclareAttackersDuringSkipAction()
&& (passedTurn && (passedTurn
|| passedTurnSkipStack || passedTurnSkipStack
|| passedUntilEndOfTurn || passedUntilEndOfTurn
@ -1146,7 +1145,7 @@ public class HumanPlayer extends PlayerImpl {
} }
options.put(Constants.Option.POSSIBLE_ATTACKERS, (Serializable) possibleAttackers); options.put(Constants.Option.POSSIBLE_ATTACKERS, (Serializable) possibleAttackers);
if (!possibleAttackers.isEmpty()) { if (!possibleAttackers.isEmpty()) {
options.put(Constants.Option.SPECIAL_BUTTON, (Serializable) "All attack"); options.put(Constants.Option.SPECIAL_BUTTON, "All attack");
} }
prepareForResponse(game); prepareForResponse(game);
@ -1304,7 +1303,7 @@ public class HumanPlayer extends PlayerImpl {
/** /**
* Selects a defender for an attacker and adds the attacker to combat * Selects a defender for an attacker and adds the attacker to combat
* *
* @param defenders - list of possible defender * @param defenders - list of possible defender
* @param attackerId - UUID of attacker * @param attackerId - UUID of attacker
* @param game * @param game
* @return * @return
@ -1364,8 +1363,8 @@ public class HumanPlayer extends PlayerImpl {
filter.add(new ControllerIdPredicate(defendingPlayerId)); filter.add(new ControllerIdPredicate(defendingPlayerId));
if (game.getBattlefield().count(filter, null, playerId, game) == 0 if (game.getBattlefield().count(filter, null, playerId, game) == 0
&& !getControllingPlayersUserData(game) && !getControllingPlayersUserData(game)
.getUserSkipPrioritySteps() .getUserSkipPrioritySteps()
.isStopOnDeclareBlockerIfNoneAvailable()) { .isStopOnDeclareBlockerIfNoneAvailable()) {
return; return;
} }
while (!abort) { while (!abort) {

View file

@ -24,11 +24,11 @@ public final class AppliedBiomancy extends CardImpl {
// Target creature gets +1/+1 until end of turn. // Target creature gets +1/+1 until end of turn.
this.getSpellAbility().addEffect(new BoostTargetEffect(1, 1)); this.getSpellAbility().addEffect(new BoostTargetEffect(1, 1));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent().withChooseHint("gets +1/+1 until end of turn"));
// Return target creature to its owner's hand. // Return target creature to its owner's hand.
Mode mode = new Mode(new ReturnToHandTargetEffect()); Mode mode = new Mode(new ReturnToHandTargetEffect());
mode.addTarget(new TargetCreaturePermanent()); mode.addTarget(new TargetCreaturePermanent().withChooseHint("return to its owner's hand"));
this.getSpellAbility().addMode(mode); this.getSpellAbility().addMode(mode);
} }

View file

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

View file

@ -1,10 +1,5 @@
package mage.target; 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.abilities.Ability;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
@ -12,8 +7,12 @@ import mage.filter.Filter;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; 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 * @author BetaSteward_at_googlemail.com
*/ */
public interface Target extends Serializable { 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 * 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 * @param notTarget true = do not check for protection, false = check for
* protection * protection
*/ */
void setNotTarget(boolean notTarget); void setNotTarget(boolean notTarget);
@ -136,4 +135,5 @@ public interface Target extends Serializable {
// used for cards like Spellskite // used for cards like Spellskite
void setTargetAmount(UUID targetId, int amount, Game game); void setTargetAmount(UUID targetId, int amount, Game game);
Target withChooseHint(String chooseHint);
} }

View file

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