mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
Added restrict effect hints to permanents;
This commit is contained in:
parent
92ce8be91d
commit
1b32793388
7 changed files with 120 additions and 49 deletions
|
@ -775,6 +775,9 @@ public final class ManaSymbols {
|
|||
if (replaced.contains(HintUtils.HINT_ICON_BAD)) {
|
||||
replaced = replaced.replace(HintUtils.HINT_ICON_BAD, GuiDisplayUtil.getHintIconHtml("bad", symbolSize) + " ");
|
||||
}
|
||||
if (replaced.contains(HintUtils.HINT_ICON_RESTRICT)) {
|
||||
replaced = replaced.replace(HintUtils.HINT_ICON_RESTRICT, GuiDisplayUtil.getHintIconHtml("restrict", symbolSize) + " ");
|
||||
}
|
||||
|
||||
// ignored data restore
|
||||
replaced = replaced
|
||||
|
|
BIN
Mage.Client/src/main/resources/hint/restrict.png
Normal file
BIN
Mage.Client/src/main/resources/hint/restrict.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
|
@ -7,9 +7,13 @@ import java.awt.*;
|
|||
*/
|
||||
public class HintUtils {
|
||||
|
||||
public static final boolean ABILITY_HINTS_ENABLE = true;
|
||||
public static final boolean RESTRICT_HINTS_ENABLE = true;
|
||||
|
||||
// icons changes to real files on client side (see mana icons replacement)
|
||||
public static final String HINT_ICON_GOOD = "ICON_GOOD";
|
||||
public static final String HINT_ICON_BAD = "ICON_BAD";
|
||||
public static final String HINT_ICON_RESTRICT = "ICON_RESTRICT";
|
||||
|
||||
public static String prepareText(String text, Color color) {
|
||||
return prepareText(text, color, null);
|
||||
|
|
|
@ -6,6 +6,7 @@ import mage.Mana;
|
|||
import mage.ObjectColor;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.HintUtils;
|
||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.cards.repository.PluginClassloaderRegistery;
|
||||
import mage.constants.*;
|
||||
|
@ -254,16 +255,27 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
rules.add(ability.getRule());
|
||||
}
|
||||
}
|
||||
// extra hints
|
||||
|
||||
// ability hints
|
||||
List<String> abilityHints = new ArrayList<>();
|
||||
if (HintUtils.ABILITY_HINTS_ENABLE) {
|
||||
for (Ability ability : abilities) {
|
||||
for (Hint hint : ability.getHints()) {
|
||||
String s = hint.getText(game, ability);
|
||||
if (s != null && !s.isEmpty()) {
|
||||
rules.add(s);
|
||||
abilityHints.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// restrict hints only for permanents, not cards
|
||||
|
||||
// total hints
|
||||
if (!abilityHints.isEmpty()) {
|
||||
rules.addAll(abilityHints);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception in rules generation for card: " + this.getName(), e);
|
||||
|
|
|
@ -9,6 +9,7 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.HintUtils;
|
||||
import mage.abilities.keyword.*;
|
||||
import mage.abilities.text.TextPart;
|
||||
import mage.cards.Card;
|
||||
|
@ -245,15 +246,57 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
}
|
||||
|
||||
// extra hints
|
||||
// ability hints
|
||||
List<String> abilityHints = new ArrayList<>();
|
||||
if (HintUtils.ABILITY_HINTS_ENABLE) {
|
||||
for (Ability ability : abilities) {
|
||||
for (Hint hint : ability.getHints()) {
|
||||
String s = hint.getText(game, ability);
|
||||
if (s != null && !s.isEmpty()) {
|
||||
rules.add(s);
|
||||
abilityHints.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// restrict hints
|
||||
List<String> restrictHints = new ArrayList<>();
|
||||
if (HintUtils.RESTRICT_HINTS_ENABLE) {
|
||||
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
||||
for (Ability ability : entry.getValue()) {
|
||||
if (!entry.getKey().applies(this, ability, game)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entry.getKey().canAttack(game) || !entry.getKey().canAttack(this, null, ability, game)) {
|
||||
restrictHints.add(HintUtils.prepareText("Can't attack" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
||||
}
|
||||
|
||||
if (!entry.getKey().canBlock(null, this, ability, game)) {
|
||||
restrictHints.add(HintUtils.prepareText("Can't block" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
||||
}
|
||||
|
||||
if (!entry.getKey().canBeUntapped(this, ability, game)) {
|
||||
restrictHints.add(HintUtils.prepareText("Can't untapped" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
||||
}
|
||||
|
||||
if (!entry.getKey().canUseActivatedAbilities(this, ability, game)) {
|
||||
restrictHints.add(HintUtils.prepareText("Can't use activated abilities" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
||||
}
|
||||
|
||||
if (!entry.getKey().canTransform(this, ability, game)) {
|
||||
restrictHints.add(HintUtils.prepareText("Can't transform" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
||||
}
|
||||
}
|
||||
}
|
||||
restrictHints.sort(String::compareTo);
|
||||
}
|
||||
|
||||
// total hints
|
||||
if (!abilityHints.isEmpty() || !restrictHints.isEmpty()) {
|
||||
rules.addAll(abilityHints);
|
||||
rules.addAll(restrictHints);
|
||||
}
|
||||
|
||||
return rules;
|
||||
} catch (Exception e) {
|
||||
|
@ -261,6 +304,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
}
|
||||
|
||||
private String addSourceObjectName(Game game, Ability ability) {
|
||||
if (ability != null) {
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
if (object != null) {
|
||||
return " (" + object.getIdName() + ")";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Abilities<Ability> getAbilities() {
|
||||
return abilities;
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package mage.players;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import mage.ConditionalMana;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
|
@ -69,6 +65,11 @@ import mage.util.GameLog;
|
|||
import mage.util.RandomUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public abstract class PlayerImpl implements Player, Serializable {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
|
||||
|
@ -2527,7 +2528,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
for (Card card : library.getCards(game)) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability.getClass() == WhileSearchingPlayFromLibraryAbility.class) {
|
||||
libraryCastableCardTracker.put(card.getId(), card.getName() + " [" + card.getId().toString().substring(0, 3) + "]");
|
||||
libraryCastableCardTracker.put(card.getId(), card.getIdName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3707,7 +3708,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// identify cards from one owner
|
||||
Cards cards = new CardsImpl();
|
||||
UUID ownerId = null;
|
||||
for (Iterator<Card> it = allCards.iterator(); it.hasNext();) {
|
||||
for (Iterator<Card> it = allCards.iterator(); it.hasNext(); ) {
|
||||
Card card = it.next();
|
||||
if (cards.isEmpty()) {
|
||||
ownerId = card.getOwnerId();
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
package mage.util;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class GameLog {
|
||||
|
@ -40,11 +38,11 @@ public final class GameLog {
|
|||
}
|
||||
|
||||
public static String getColoredObjectIdName(MageObject mageObject) {
|
||||
return "<font color=\'" + getColorName(mageObject.getColor(null)) + "\'>" + mageObject.getName() + " [" + mageObject.getId().toString().substring(0, 3) + "]</font>";
|
||||
return "<font color=\'" + getColorName(mageObject.getColor(null)) + "\'>" + mageObject.getIdName() + "</font>";
|
||||
}
|
||||
|
||||
public static String getColoredObjectIdNameForTooltip(MageObject mageObject) {
|
||||
return "<font color=\'" + getTooltipColorName(mageObject.getColor(null)) + "\'>" + mageObject.getName() + " [" + mageObject.getId().toString().substring(0, 3) + "]</font>";
|
||||
return "<font color=\'" + getTooltipColorName(mageObject.getColor(null)) + "\'>" + mageObject.getIdName() + "</font>";
|
||||
}
|
||||
|
||||
public static String getNeutralColoredText(String text) {
|
||||
|
|
Loading…
Reference in a new issue