[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

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16.1 16.1" style="enable-background:new 0 0 16.1 16.1;" xml:space="preserve">
<path d="M8.5,0.7c-0.3-0.2-0.6-0.2-0.9,0L1.9,4C1.7,4.2,1.5,4.5,1.5,4.8v6.4c0,0.3,0.2,0.6,0.5,0.8l5.6,3.4c0.3,0.2,0.6,0.2,0.9,0
l5.6-3.4c0.3-0.2,0.5-0.5,0.5-0.8V4.8c0-0.3-0.2-0.6-0.5-0.8L8.5,0.7z"/>
</svg>

After

Width:  |  Height:  |  Size: 562 B

View file

@ -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()) {

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");