Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CantBlock Additional Text from getAbilityText to getNonAbilityText #6670

Open
Hanmac opened this issue Dec 6, 2024 · 0 comments
Open
Assignees

Comments

@Hanmac
Copy link
Contributor

Hanmac commented Dec 6, 2024

Stuff that is added to a Card Description by outside effects should not use getAbilityText, but more like getNonAbilityText or something else

currently, it is added only in getAbilityText, which because it is so complex, isn't updated often

if (game != null && isCreature() && isInPlay()) {
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
if (equals(ca)) {
continue;
}
for (final StaticAbility stAb : ca.getStaticAbilities()) {
if (!stAb.checkConditions()) {
continue;
}
boolean found = false;
if (stAb.checkMode("CantBlockBy")) {
if (!stAb.hasParam("ValidAttacker") || (stAb.hasParam("ValidBlocker") && stAb.getParam("ValidBlocker").equals("Creature.Self"))) {
continue;
}
if (stAb.matchesValidParam("ValidAttacker", this)) {
found = true;
}
} else if (stAb.checkMode(StaticAbilityCantAttackBlock.MinMaxBlockerMode)) {
if (stAb.matchesValidParam("ValidCard", this)) {
found = true;
}
}
if (found) {
final Card host = stAb.getHostCard();
String currentName = host.getName();
String desc = TextUtil.fastReplace(stAb.toString(), "CARDNAME", currentName);
desc = TextUtil.fastReplace(desc, "NICKNAME", Lang.getInstance().getNickName(currentName));
if (host.getEffectSource() != null) {
desc = TextUtil.fastReplace(desc, "EFFECTSOURCE", host.getEffectSource().getName());
}
sb.append(desc);
sb.append(linebreak);
}
}
}
}

which then causes this ugly refresh:

for (final StaticAbility stAb : c.getStaticAbilities()) {
if (!stAb.checkConditions()) {
continue;
}
if (stAb.checkMode("CantBlockBy")) {
if (!stAb.hasParam("ValidAttacker") || (stAb.hasParam("ValidBlocker") && stAb.getParam("ValidBlocker").equals("Creature.Self"))) {
continue;
}
for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)) {
if (stAb.matchesValidParam("ValidAttacker", creature)) {
creature.updateAbilityTextForView();
}
}
}
if (stAb.checkMode(StaticAbilityCantAttackBlock.MinMaxBlockerMode)) {
for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)) {
if (stAb.matchesValidParam("ValidCard", creature)) {
creature.updateAbilityTextForView();
}
}
}
}

it also would help to separate the features with "Non ability features"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants