From 2d8be6663b10f08aca8cf79396cd84a449d61a24 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Thu, 15 Jul 2021 23:46:19 +0400 Subject: [PATCH] [AFR] added card icons with class level info (#7808) --- .../card/icons/prepared/hexagon-fill.svg | 7 +++++ .../src/main/java/mage/view/CardView.java | 2 +- .../src/main/java/mage/abilities/Ability.java | 13 ++++++++ .../main/java/mage/abilities/AbilityImpl.java | 7 ++++- .../mage/abilities/icon/CardIconImpl.java | 4 ++- .../mage/abilities/icon/CardIconType.java | 1 + .../keyword/ClassReminderAbility.java | 31 +++++++++++++++++++ .../java/mage/game/stack/StackAbility.java | 5 +++ 8 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 Mage.Client/src/main/resources/card/icons/prepared/hexagon-fill.svg diff --git a/Mage.Client/src/main/resources/card/icons/prepared/hexagon-fill.svg b/Mage.Client/src/main/resources/card/icons/prepared/hexagon-fill.svg new file mode 100644 index 0000000000..2f310a22d6 --- /dev/null +++ b/Mage.Client/src/main/resources/card/icons/prepared/hexagon-fill.svg @@ -0,0 +1,7 @@ + + + + + diff --git a/Mage.Common/src/main/java/mage/view/CardView.java b/Mage.Common/src/main/java/mage/view/CardView.java index 79afbb0a8a..c76b68a24d 100644 --- a/Mage.Common/src/main/java/mage/view/CardView.java +++ b/Mage.Common/src/main/java/mage/view/CardView.java @@ -416,7 +416,7 @@ public class CardView extends SimpleCardView { // card icons for permanents on battlefield permanent.getAbilities(game).forEach(ability -> { - this.cardIcons.addAll(ability.getIcons()); + this.cardIcons.addAll(ability.getIcons(game)); }); } else { if (card.isCopy()) { diff --git a/Mage/src/main/java/mage/abilities/Ability.java b/Mage/src/main/java/mage/abilities/Ability.java index 610d878513..c4f6cda350 100644 --- a/Mage/src/main/java/mage/abilities/Ability.java +++ b/Mage/src/main/java/mage/abilities/Ability.java @@ -552,8 +552,21 @@ public interface Ability extends Controllable, Serializable { Ability addHint(Hint hint); + /** + * For abilities with static icons + * + * @return + */ List getIcons(); + /** + * For abilities with dynamic icons + * + * @param game can be null for static calls like copies + * @return + */ + List getIcons(Game game); + Ability addIcon(CardIcon cardIcon); Ability addCustomOutcome(Outcome customOutcome); diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index 1fc78638a4..a354670438 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -1342,7 +1342,12 @@ public abstract class AbilityImpl implements Ability { } @Override - public List getIcons() { + final public List getIcons() { + return getIcons(null); + } + + @Override + public List getIcons(Game game) { return this.icons; } diff --git a/Mage/src/main/java/mage/abilities/icon/CardIconImpl.java b/Mage/src/main/java/mage/abilities/icon/CardIconImpl.java index 89318cb15a..4ea64fc84a 100644 --- a/Mage/src/main/java/mage/abilities/icon/CardIconImpl.java +++ b/Mage/src/main/java/mage/abilities/icon/CardIconImpl.java @@ -1,9 +1,11 @@ package mage.abilities.icon; +import java.io.Serializable; + /** * @author JayDi85 */ -public class CardIconImpl implements CardIcon { +public class CardIconImpl implements CardIcon, Serializable { private final CardIconType cardIconType; private final String text; diff --git a/Mage/src/main/java/mage/abilities/icon/CardIconType.java b/Mage/src/main/java/mage/abilities/icon/CardIconType.java index c4e8c1111a..42e3b0160e 100644 --- a/Mage/src/main/java/mage/abilities/icon/CardIconType.java +++ b/Mage/src/main/java/mage/abilities/icon/CardIconType.java @@ -29,6 +29,7 @@ public enum CardIconType { ABILITY_INFECT("prepared/flask.svg", CardIconCategory.ABILITY, 100), ABILITY_INDESTRUCTIBLE("prepared/ankh.svg", CardIconCategory.ABILITY, 100), ABILITY_VIGILANCE("prepared/eye.svg", CardIconCategory.ABILITY, 100), + ABILITY_CLASS_LEVEL("prepared/hexagon-fill.svg", CardIconCategory.ABILITY, 100), // SYSTEM_COMBINED("prepared/square-fill.svg", CardIconCategory.SYSTEM, 1000), // inner usage, must use last order SYSTEM_DEBUG("prepared/link.svg", CardIconCategory.SYSTEM, 1000); // used for test render dialog diff --git a/Mage/src/main/java/mage/abilities/keyword/ClassReminderAbility.java b/Mage/src/main/java/mage/abilities/keyword/ClassReminderAbility.java index b9964bf564..b5fd4b85b9 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ClassReminderAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ClassReminderAbility.java @@ -2,7 +2,15 @@ package mage.abilities.keyword; import mage.abilities.StaticAbility; import mage.abilities.hint.common.ClassLevelHint; +import mage.abilities.icon.CardIcon; +import mage.abilities.icon.CardIconImpl; +import mage.abilities.icon.CardIconType; import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.ArrayList; +import java.util.List; /** * @author TheElk801 @@ -27,4 +35,27 @@ public class ClassReminderAbility extends StaticAbility { public String getRule() { return "(Gain the next level as a sorcery to add its ability.)"; } + + @Override + public List getIcons(Game game) { + if (game == null) { + return this.icons; + } + + // dynamic GUI icon with current level + List res = new ArrayList<>(); + Permanent permanent = this.getSourcePermanentOrLKI(game); + if (permanent == null) { + return res; + } + + CardIcon levelIcon = new CardIconImpl( + CardIconType.ABILITY_CLASS_LEVEL, + "Current class level: " + permanent.getClassLevel(), + String.valueOf(permanent.getClassLevel()) + ); + res.add(levelIcon); + + return res; + } } diff --git a/Mage/src/main/java/mage/game/stack/StackAbility.java b/Mage/src/main/java/mage/game/stack/StackAbility.java index 61a3969b13..3a6585c0bd 100644 --- a/Mage/src/main/java/mage/game/stack/StackAbility.java +++ b/Mage/src/main/java/mage/game/stack/StackAbility.java @@ -692,6 +692,11 @@ public class StackAbility extends StackObjectImpl implements Ability { return this.ability.getIcons(); } + @Override + public List getIcons(Game game) { + return this.ability.getIcons(game); + } + @Override public Ability addIcon(CardIcon cardIcon) { throw new IllegalArgumentException("Stack ability is not supports icon adding");