[AFR] added card icons with class level info (#7808)

This commit is contained in:
Oleg Agafonov 2021-07-15 23:46:19 +04:00
parent 20245f32f6
commit 2d8be6663b
8 changed files with 67 additions and 3 deletions

View file

@ -552,8 +552,21 @@ public interface Ability extends Controllable, Serializable {
Ability addHint(Hint hint);
/**
* For abilities with static icons
*
* @return
*/
List<CardIcon> getIcons();
/**
* For abilities with dynamic icons
*
* @param game can be null for static calls like copies
* @return
*/
List<CardIcon> getIcons(Game game);
Ability addIcon(CardIcon cardIcon);
Ability addCustomOutcome(Outcome customOutcome);

View file

@ -1342,7 +1342,12 @@ public abstract class AbilityImpl implements Ability {
}
@Override
public List<CardIcon> getIcons() {
final public List<CardIcon> getIcons() {
return getIcons(null);
}
@Override
public List<CardIcon> getIcons(Game game) {
return this.icons;
}

View file

@ -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;

View file

@ -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

View file

@ -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 "<i>(Gain the next level as a sorcery to add its ability.)</i>";
}
@Override
public List<CardIcon> getIcons(Game game) {
if (game == null) {
return this.icons;
}
// dynamic GUI icon with current level
List<CardIcon> 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;
}
}

View file

@ -692,6 +692,11 @@ public class StackAbility extends StackObjectImpl implements Ability {
return this.ability.getIcons();
}
@Override
public List<CardIcon> getIcons(Game game) {
return this.ability.getIcons(game);
}
@Override
public Ability addIcon(CardIcon cardIcon) {
throw new IllegalArgumentException("Stack ability is not supports icon adding");