game: improved cost tags to support card hints on stack (example: evidence, fixes #12522);

This commit is contained in:
Oleg Agafonov 2024-06-25 18:25:08 +04:00
parent 74b3d26a41
commit 8a4a23bb8f
4 changed files with 75 additions and 5 deletions

View file

@ -1732,11 +1732,27 @@ public final class CardUtil {
*/
public static Map<String, Object> getSourceCostsTagsMap(Game game, Ability source) {
Map<String, Object> costTags;
// from spell ability - direct access
costTags = source.getCostsTagMap();
if (costTags == null && source.getSourcePermanentOrLKI(game) != null) {
costTags = game.getPermanentCostsTags().get(CardUtil.getSourceStackMomentReference(game, source));
if (costTags != null) {
return costTags;
}
return costTags;
// from any ability after resolve - access by permanent
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (permanent != null) {
costTags = game.getPermanentCostsTags().get(CardUtil.getSourceStackMomentReference(game, source));
return costTags;
}
// from any ability before resolve (on stack) - access by spell ability
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject instanceof Spell) {
return ((Spell) sourceObject).getSpellAbility().getCostsTagMap();
}
return null;
}
/**