mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Card & CardState: add has functions to check for SpellAbility, Trigger and ReplacementEffects
This commit is contained in:
@@ -847,6 +847,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
currentState.clearTriggers();
|
||||
}
|
||||
|
||||
public final boolean hasTrigger(final Trigger t) {
|
||||
return currentState.hasTrigger(t);
|
||||
}
|
||||
|
||||
public final boolean hasTrigger(final int id) {
|
||||
return currentState.hasTrigger(id);
|
||||
}
|
||||
|
||||
public void updateTriggers(List<Trigger> list, CardState state) {
|
||||
for (KeywordInterface kw : getUnhiddenKeywords(state)) {
|
||||
list.addAll(kw.getTriggers());
|
||||
@@ -2193,13 +2201,15 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
public final void addSpellAbility(final SpellAbility a) {
|
||||
a.setHostCard(this);
|
||||
currentState.addSpellAbility(a);
|
||||
currentState.getView().updateAbilityText(this, currentState);
|
||||
if (currentState.addSpellAbility(a)) {
|
||||
currentState.getView().updateAbilityText(this, currentState);
|
||||
}
|
||||
}
|
||||
|
||||
public final void removeSpellAbility(final SpellAbility a) {
|
||||
currentState.removeSpellAbility(a);
|
||||
currentState.getView().updateAbilityText(this, currentState);
|
||||
if (currentState.removeSpellAbility(a)) {
|
||||
currentState.getView().updateAbilityText(this, currentState);
|
||||
}
|
||||
}
|
||||
|
||||
public final FCollectionView<SpellAbility> getSpellAbilities() {
|
||||
@@ -2212,6 +2222,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return currentState.getNonManaAbilities();
|
||||
}
|
||||
|
||||
public final boolean hasSpellAbility(final SpellAbility sa) {
|
||||
return currentState.hasSpellAbility(sa);
|
||||
}
|
||||
|
||||
public final boolean hasSpellAbility(final int id) {
|
||||
return currentState.hasSpellAbility(id);
|
||||
}
|
||||
|
||||
public void updateSpellAbilities(List<SpellAbility> list, CardState state, Boolean mana) {
|
||||
for (KeywordInterface kw : getUnhiddenKeywords(state)) {
|
||||
for (SpellAbility sa : kw.getAbilities()) {
|
||||
|
||||
@@ -222,6 +222,19 @@ public class CardState extends GameObject {
|
||||
return new FCollection<SpellAbility>(Iterables.filter(getSpellAbilities(), SpellAbilityPredicates.isIntrinsic()));
|
||||
}
|
||||
|
||||
public final boolean hasSpellAbility(final SpellAbility sa) {
|
||||
return getSpellAbilities().contains(sa);
|
||||
}
|
||||
|
||||
public final boolean hasSpellAbility(final int id) {
|
||||
for (SpellAbility sa : getSpellAbilities()) {
|
||||
if (id == sa.getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void setNonManaAbilities(SpellAbility sa) {
|
||||
nonManaAbilities.clear();
|
||||
if (sa != null) {
|
||||
@@ -279,6 +292,20 @@ public class CardState extends GameObject {
|
||||
card.updateTriggers(result, this);
|
||||
return result;
|
||||
}
|
||||
|
||||
public final boolean hasTrigger(final Trigger t) {
|
||||
return getTriggers().contains(t);
|
||||
}
|
||||
|
||||
public final boolean hasTrigger(final int id) {
|
||||
for (final Trigger t : getTriggers()) {
|
||||
if (id == t.getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void setTriggers(final FCollection<Trigger> triggers0) {
|
||||
triggers = triggers0;
|
||||
}
|
||||
@@ -333,6 +360,10 @@ public class CardState extends GameObject {
|
||||
replacementEffects.clear();
|
||||
}
|
||||
|
||||
public final boolean hasReplacementEffect(final ReplacementEffect re) {
|
||||
return getReplacementEffects().contains(re);
|
||||
}
|
||||
|
||||
public final Map<String, String> getSVars() {
|
||||
return sVars;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user