mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Merge branch 'sd' into 'master'
more Effect getStackDescription improvements See merge request core-developers/forge!6275
This commit is contained in:
@@ -25,6 +25,7 @@ import forge.game.spellability.SpellAbility;
|
|||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
import forge.util.CardTranslation;
|
import forge.util.CardTranslation;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
import forge.util.Lang;
|
||||||
|
|
||||||
|
|
||||||
public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||||
@@ -48,7 +49,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
|||||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
|
amount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
|
||||||
}
|
}
|
||||||
if (amount > 1) {
|
if (amount > 1) {
|
||||||
sb.append(amount).append(" times");
|
sb.append(" ").append(Lang.getNumeral(amount)).append(" times");
|
||||||
}
|
}
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
// TODO probably add an optional "You may choose new targets..."
|
// TODO probably add an optional "You may choose new targets..."
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import forge.util.Lang;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@@ -217,20 +218,19 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
|||||||
sb.append("Sacrifices ").append(sa.getHostCard().toString());
|
sb.append("Sacrifices ").append(sa.getHostCard().toString());
|
||||||
} else if (valid.equals("Card.AttachedBy")) {
|
} else if (valid.equals("Card.AttachedBy")) {
|
||||||
final Card toSac = sa.getHostCard().getEnchantingCard();
|
final Card toSac = sa.getHostCard().getEnchantingCard();
|
||||||
sb.append(toSac.getController()).append(" Sacrifices ").append(toSac).append(".");
|
sb.append(toSac.getController()).append(" sacrifices ").append(toSac).append(".");
|
||||||
} else {
|
} else {
|
||||||
for (final Player p : tgts) {
|
sb.append(Lang.joinHomogenous(tgts)).append(" ");
|
||||||
sb.append(p.getName()).append(" ");
|
boolean oneTgtP = tgts.size() == 1;
|
||||||
}
|
|
||||||
|
|
||||||
String msg = sa.getParamOrDefault("SacMessage", valid);
|
String msg = sa.getParamOrDefault("SacMessage", valid);
|
||||||
|
|
||||||
if (sa.hasParam("Destroy")) {
|
if (sa.hasParam("Destroy")) {
|
||||||
sb.append("Destroys ");
|
sb.append(oneTgtP ? "destroys " : " destroys ");
|
||||||
} else {
|
} else {
|
||||||
sb.append("Sacrifices ");
|
sb.append(oneTgtP ? "sacrifices " : "sacrifices ");
|
||||||
}
|
}
|
||||||
sb.append(amount).append(" ").append(msg).append(".");
|
sb.append(Lang.nounWithNumeralExceptOne(amount, msg)).append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.ability.effects;
|
package forge.game.ability.effects;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
@@ -42,9 +43,40 @@ public class TokenEffect extends TokenEffectBase {
|
|||||||
final Card host = sa.getHostCard();
|
final Card host = sa.getHostCard();
|
||||||
final List<Player> creators = AbilityUtils.getDefinedPlayers(host, sa.getParamOrDefault("TokenOwner",
|
final List<Player> creators = AbilityUtils.getDefinedPlayers(host, sa.getParamOrDefault("TokenOwner",
|
||||||
"You"), sa);
|
"You"), sa);
|
||||||
String start = Lang.joinHomogenous(creators) + (creators.size() == 1 ? " creates" : " create");
|
String verb = creators.size() == 1 ? "creates" : "create";
|
||||||
|
String start = Lang.joinHomogenous(creators) + " " + verb;
|
||||||
String create = desc.contains("Create") ? "Create" : "create";
|
String create = desc.contains("Create") ? "Create" : "create";
|
||||||
desc = desc.replace(create, start);
|
desc = desc.replaceFirst(".*" + create, "");
|
||||||
|
desc = start + desc;
|
||||||
|
//try to put the right amount of tokens for X calculations and the like
|
||||||
|
if (sa.hasParam("TokenAmount") && !StringUtils.isNumeric(sa.getParam("TokenAmount"))) {
|
||||||
|
final int numTokens = AbilityUtils.calculateAmount(host, sa.getParam("TokenAmount"), sa);
|
||||||
|
if (numTokens != 0) { //0 probably means calculation isn't ready in time for stack
|
||||||
|
if (numTokens != 1) { //if we are making more than one, substitute the numeral for a/an
|
||||||
|
String numeral = " " + Lang.getNumeral(numTokens) + " ";
|
||||||
|
List<String> words = Arrays.asList(desc.split(" "));
|
||||||
|
String target = " " + words.get(words.indexOf(verb) + 1) + " ";
|
||||||
|
desc = desc.replaceFirst(target, numeral);
|
||||||
|
}
|
||||||
|
//try to cut out unneeded description, which would now be confusing
|
||||||
|
String truncate = null;
|
||||||
|
if (desc.contains(", where")) {
|
||||||
|
truncate = ", where";
|
||||||
|
} else if (desc.contains(" for each")) {
|
||||||
|
truncate = " for each";
|
||||||
|
}
|
||||||
|
if (truncate != null) { //if we do truncate, make sure the string ends properly
|
||||||
|
desc = desc.split(truncate)[0];
|
||||||
|
if (desc.endsWith("token") && numTokens > 1) {
|
||||||
|
desc = desc + "s.";
|
||||||
|
} else {
|
||||||
|
desc = desc + ".";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//pronoun replacement for things that create an amount based on what you control
|
||||||
|
desc = desc.replace("you control","they control");
|
||||||
}
|
}
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user