mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Fixed game errors for non started games (some cards uses dynamic hints with non-protected code)
This commit is contained in:
parent
ec7befa511
commit
35b00c3da1
2 changed files with 28 additions and 20 deletions
|
@ -275,6 +275,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
rules.addAll(info.values());
|
||||
}
|
||||
|
||||
if (game == null || game.getPhase() == null) {
|
||||
// dynamic hints for started game only
|
||||
return rules;
|
||||
}
|
||||
|
||||
// ability hints
|
||||
List<String> abilityHints = new ArrayList<>();
|
||||
if (HintUtils.ABILITY_HINTS_ENABLE) {
|
||||
|
@ -290,7 +295,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
|
||||
// restrict hints
|
||||
List<String> restrictHints = new ArrayList<>();
|
||||
if (game != null && HintUtils.RESTRICT_HINTS_ENABLE) {
|
||||
if (HintUtils.RESTRICT_HINTS_ENABLE) {
|
||||
// restrict
|
||||
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
||||
for (Ability ability : entry.getValue()) {
|
||||
|
|
|
@ -1116,31 +1116,34 @@ public final class CardUtil {
|
|||
try {
|
||||
List<String> rules = rulesSource.getRules(cardName);
|
||||
|
||||
if (game != null) {
|
||||
if (game == null || game.getPhase() == null) {
|
||||
// dynamic hints for started game only
|
||||
return rules;
|
||||
}
|
||||
|
||||
// debug state
|
||||
rules.addAll(game.getState().getCardState(cardId).getInfo().values());
|
||||
// debug state
|
||||
rules.addAll(game.getState().getCardState(cardId).getInfo().values());
|
||||
|
||||
// ability hints
|
||||
List<String> abilityHints = new ArrayList<>();
|
||||
if (HintUtils.ABILITY_HINTS_ENABLE) {
|
||||
for (Ability ability : hintsSource) {
|
||||
for (Hint hint : ability.getHints()) {
|
||||
String s = hint.getText(game, ability);
|
||||
if (s != null && !s.isEmpty()) {
|
||||
abilityHints.add(s);
|
||||
}
|
||||
// ability hints
|
||||
List<String> abilityHints = new ArrayList<>();
|
||||
if (HintUtils.ABILITY_HINTS_ENABLE) {
|
||||
for (Ability ability : hintsSource) {
|
||||
for (Hint hint : ability.getHints()) {
|
||||
String s = hint.getText(game, ability);
|
||||
if (s != null && !s.isEmpty()) {
|
||||
abilityHints.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// restrict hints only for permanents, not cards
|
||||
// total hints
|
||||
if (!abilityHints.isEmpty()) {
|
||||
rules.add(HintUtils.HINT_START_MARK);
|
||||
HintUtils.appendHints(rules, abilityHints);
|
||||
}
|
||||
}
|
||||
|
||||
// restrict hints only for permanents, not cards
|
||||
// total hints
|
||||
if (!abilityHints.isEmpty()) {
|
||||
rules.add(HintUtils.HINT_START_MARK);
|
||||
HintUtils.appendHints(rules, abilityHints);
|
||||
}
|
||||
|
||||
return rules;
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception in rules generation for card: " + cardName, e);
|
||||
|
|
Loading…
Reference in a new issue