Improved game logs: added target hints, fixed spaces in target amount;

This commit is contained in:
Oleg Agafonov 2020-06-26 10:59:22 +04:00
parent 99167fa50e
commit 50c46e39a3
16 changed files with 76 additions and 76 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.f;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageMultiEffect;
import mage.cards.CardImpl;
@ -9,22 +7,21 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.target.common.TargetAnyTargetAmount;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class ForkedBolt extends CardImpl {
public ForkedBolt(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{R}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{R}");
// Forked Bolt deals 2 damage divided as you choose among one or two target creatures and/or players.
Effect effect = new DamageMultiEffect(2);
effect.setText("{this} deals 2 damage divided as you choose among one or two target creatures and/or players");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetAnyTargetAmount(2));
}
public ForkedBolt(final ForkedBolt card) {

View file

@ -1116,6 +1116,7 @@ public abstract class AbilityImpl implements Ability {
String usedVerb = null;
for (Target target : targets) {
if (!target.getTargets().isEmpty()) {
String targetHintInfo = target.getChooseHint() == null ? "" : " (" + target.getChooseHint() + ")";
if (!target.isNotTarget()) {
if (usedVerb == null || usedVerb.equals(" choosing ")) {
usedVerb = " targeting ";
@ -1126,6 +1127,7 @@ public abstract class AbilityImpl implements Ability {
sb.append(usedVerb);
}
sb.append(target.getTargetedName(game));
sb.append(targetHintInfo);
}
}
}

View file

@ -450,6 +450,6 @@ class TargetWithAdditionalFilter<T extends MageItem> extends TargetImpl {
}
}
}
return sb.toString();
return sb.toString().trim();
}
}

View file

@ -137,5 +137,7 @@ public interface Target extends Serializable {
Target withChooseHint(String chooseHint);
String getChooseHint();
void setEventReporting(boolean shouldReport);
}

View file

@ -112,8 +112,8 @@ public abstract class TargetImpl implements Target {
sb.append(suffix);
return sb.toString();
}
if (targetName.startsWith("another")
|| targetName.startsWith("a ")
if (targetName.startsWith("another")
|| targetName.startsWith("a ")
|| targetName.startsWith("an ")
|| targetName.startsWith("any ")) {
return "Select " + targetName + suffix;
@ -555,6 +555,11 @@ public abstract class TargetImpl implements Target {
return this;
}
@Override
public String getChooseHint() {
return chooseHint;
}
@Override
public void setEventReporting(boolean shouldReport) {
this.shouldReportEvents = shouldReport;

View file

@ -1,13 +1,13 @@
package mage.target;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.Zone;
import mage.game.Game;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public abstract class TargetObject extends TargetImpl {
@ -44,7 +44,7 @@ public abstract class TargetObject extends TargetImpl {
sb.append(object.getLogName()).append(' ');
}
}
return sb.toString();
return sb.toString().trim();
}
@Override

View file

@ -1,16 +1,16 @@
package mage.target;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.filter.FilterPlayer;
import mage.game.Game;
import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetPlayer extends TargetImpl {
@ -51,7 +51,7 @@ public class TargetPlayer extends TargetImpl {
* Checks if there are enough {@link Player} that can be chosen. Should only
* be used for Ability targets since this checks for protection, shroud etc.
*
* @param sourceId - the target event source
* @param sourceId - the target event source
* @param sourceControllerId - controller of the target event source
* @param game
* @return - true if enough valid {@link Player} exist
@ -170,7 +170,7 @@ public class TargetPlayer extends TargetImpl {
sb.append("[target missing]");
}
}
return sb.toString();
return sb.toString().trim();
}
@Override

View file

@ -1,11 +1,6 @@
package mage.target.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.constants.AbilityType;
import mage.constants.Zone;
import mage.filter.Filter;
@ -16,8 +11,11 @@ import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
import mage.target.TargetObject;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author emerald000
*/
public class TargetActivatedAbility extends TargetObject {
@ -108,7 +106,6 @@ public class TargetActivatedAbility extends TargetObject {
sb.append(object.getRule()).append(' ');
}
}
sb.append(')');
return sb.toString();
return sb.toString().trim() + ")";
}
}

View file

@ -1,9 +1,5 @@
package mage.target.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.Zone;
@ -14,6 +10,10 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetImpl;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author JRHerlehy Created on 4/8/18.
*/
@ -96,7 +96,7 @@ public class TargetAnyTarget extends TargetImpl {
* be chosen. Should only be used for Ability targets since this checks for
* protection, shroud etc.
*
* @param sourceId - the target event source
* @param sourceId - the target event source
* @param sourceControllerId - controller of the target event source
* @param game
* @return - true if enough valid {@link Permanent} or {@link Player} exist
@ -252,7 +252,7 @@ public class TargetAnyTarget extends TargetImpl {
}
}
}
return sb.toString();
return sb.toString().trim();
}
@Override

View file

@ -1,9 +1,8 @@
package mage.target.common;
import mage.constants.Zone;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterCreatureOrPlayer;
import mage.game.Game;
@ -16,7 +15,6 @@ import java.util.Set;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCreatureOrPlayer extends TargetImpl {
@ -98,7 +96,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
* be chosen. Should only be used for Ability targets since this checks for
* protection, shroud etc.
*
* @param sourceId - the target event source
* @param sourceId - the target event source
* @param sourceControllerId - controller of the target event source
* @param game
* @return - true if enough valid {@link Permanent} or {@link Player} exist
@ -211,7 +209,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
}
}
}
return sb.toString();
return sb.toString().trim();
}
@Override

View file

@ -1,9 +1,5 @@
package mage.target.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.Zone;
@ -15,8 +11,11 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetImpl;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetDefender extends TargetImpl {
@ -68,7 +67,7 @@ public class TargetDefender extends TargetImpl {
}
}
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
if ((notTarget
if ((notTarget
|| permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
&& filter.match(permanent, game)) {
count++;
@ -85,7 +84,7 @@ public class TargetDefender extends TargetImpl {
int count = 0;
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null
if (player != null
&& filter.match(player, game)) {
count++;
if (count >= this.minNumberOfTargets) {
@ -111,14 +110,14 @@ public class TargetDefender extends TargetImpl {
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null
&& (notTarget
&& (notTarget
|| player.canBeTargetedBy(targetSource, sourceControllerId, game))
&& filter.match(player, game)) {
possibleTargets.add(playerId);
}
}
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
if ((notTarget
if ((notTarget
|| permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
&& filter.match(permanent, game)) {
possibleTargets.add(permanent.getId());
@ -132,7 +131,7 @@ public class TargetDefender extends TargetImpl {
Set<UUID> possibleTargets = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null
if (player != null
&& filter.match(player, game)) {
possibleTargets.add(playerId);
}
@ -157,7 +156,7 @@ public class TargetDefender extends TargetImpl {
sb.append(player.getLogName()).append(' ');
}
}
return sb.toString();
return sb.toString().trim();
}
@Override
@ -167,7 +166,7 @@ public class TargetDefender extends TargetImpl {
return filter.match(player, game);
}
Permanent permanent = game.getPermanent(id);
return permanent != null
return permanent != null
&& filter.match(permanent, game);
}
@ -176,7 +175,7 @@ public class TargetDefender extends TargetImpl {
Player player = game.getPlayer(id);
MageObject targetSource = game.getObject(attackerId);
if (player != null) {
return (notTarget
return (notTarget
|| player.canBeTargetedBy(targetSource, (source == null ? null : source.getControllerId()), game))
&& filter.match(player, game);
}
@ -187,7 +186,7 @@ public class TargetDefender extends TargetImpl {
if (source != null) {
controllerId = source.getControllerId();
}
return (notTarget
return (notTarget
|| permanent.canBeTargetedBy(targetSource, controllerId, game))
&& filter.match(permanent, game);
}

View file

@ -78,13 +78,13 @@ public abstract class TargetPermanentAmount extends TargetAmount {
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
return game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game).size()
return game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game).size()
>= this.minNumberOfTargets;
}
@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
return game.getBattlefield().getActivePermanents(filter, sourceControllerId, game).size()
return game.getBattlefield().getActivePermanents(filter, sourceControllerId, game).size()
>= this.minNumberOfTargets;
}
@ -127,10 +127,10 @@ public abstract class TargetPermanentAmount extends TargetAmount {
getTargets().forEach((targetId) -> {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
sb.append(permanent.getLogName()).append('(').append(getTargetAmount(targetId)).append(") ");
sb.append(permanent.getLogName()).append(" (").append(getTargetAmount(targetId)).append(") ");
}
});
return sb.toString();
return sb.toString().trim();
}
@Override

View file

@ -220,7 +220,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
sb.append(player.getLogName()).append(' ');
}
}
return sb.toString();
return sb.toString().trim();
}
@Override

View file

@ -211,12 +211,12 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
for (UUID targetId : getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
sb.append(permanent.getLogName()).append('(').append(getTargetAmount(targetId)).append(") ");
sb.append(permanent.getLogName()).append(" (").append(getTargetAmount(targetId)).append(") ");
} else {
Player player = game.getPlayer(targetId);
sb.append(player.getLogName()).append('(').append(getTargetAmount(targetId)).append(") ");
sb.append(player.getLogName()).append(" (").append(getTargetAmount(targetId)).append(") ");
}
}
return sb.toString();
return sb.toString().trim();
}
}

View file

@ -29,9 +29,6 @@
*/
package mage.target.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.cards.Card;
@ -42,18 +39,21 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetImpl;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author emerald000
*/
public class TargetPermanentOrSuspendedCard extends TargetImpl {
protected final FilterPermanentOrSuspendedCard filter;
public TargetPermanentOrSuspendedCard() {
this(new FilterPermanentOrSuspendedCard(), false);
}
public TargetPermanentOrSuspendedCard(FilterPermanentOrSuspendedCard filter, boolean notTarget) {
super(notTarget);
this.filter = filter;
@ -62,17 +62,17 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
this.minNumberOfTargets = 1;
this.maxNumberOfTargets = 1;
}
public TargetPermanentOrSuspendedCard(final TargetPermanentOrSuspendedCard target) {
super(target);
this.filter = target.filter.copy();
}
@Override
public Filter<MageObject> getFilter() {
return this.filter;
}
@Override
public TargetPermanentOrSuspendedCard copy() {
return new TargetPermanentOrSuspendedCard(this);
@ -166,6 +166,6 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
}
}
}
return sb.toString();
return sb.toString().trim();
}
}

View file

@ -29,9 +29,6 @@
*/
package mage.target.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.Zone;
@ -45,8 +42,11 @@ import mage.game.stack.StackObject;
import mage.target.TargetImpl;
import mage.util.GameLog;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX
*/
public class TargetSpellOrPermanent extends TargetImpl {
@ -135,7 +135,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
* {@link mage.game.stack.Spell} that can be chosen. Should only be used for
* Ability targets since this checks for protection, shroud etc.
*
* @param sourceId - the target event source
* @param sourceId - the target event source
* @param sourceControllerId - controller of the target event source
* @param game
* @return - true if enough valid {@link mage.game.permanent.Permanent} or
@ -257,7 +257,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
}
}
}
return sb.toString();
return sb.toString().trim();
}
@Override