mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
More code cleanup
This commit is contained in:
@@ -131,8 +131,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
public final AbilityManaPart getManaPartRecursive() {
|
public final AbilityManaPart getManaPartRecursive() {
|
||||||
SpellAbility tail = this;
|
SpellAbility tail = this;
|
||||||
while (tail != null) {
|
while (tail != null) {
|
||||||
if(tail.manaPart != null)
|
if (tail.manaPart != null) {
|
||||||
return tail.manaPart;
|
return tail.manaPart;
|
||||||
|
}
|
||||||
tail = tail.getSubAbility();
|
tail = tail.getSubAbility();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -140,14 +141,17 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
|
|
||||||
public final boolean isManaAbility() {
|
public final boolean isManaAbility() {
|
||||||
// Check whether spell or ability first
|
// Check whether spell or ability first
|
||||||
if (this.isSpell())
|
if (this.isSpell()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
// without a target
|
// without a target
|
||||||
if (this.usesTargeting()) return false;
|
if (this.usesTargeting()) { return false; }
|
||||||
if (getRestrictions() != null && getRestrictions().getPlaneswalker())
|
if (getRestrictions() != null && getRestrictions().getPlaneswalker()) {
|
||||||
return false; //Loyalty ability, not a mana ability.
|
return false; //Loyalty ability, not a mana ability.
|
||||||
if (this.isWrapper() && ((WrappedAbility) this).getTrigger().getMode() != TriggerType.TapsForMana)
|
}
|
||||||
|
if (this.isWrapper() && ((WrappedAbility) this).getTrigger().getMode() != TriggerType.TapsForMana) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return getManaPartRecursive() != null;
|
return getManaPartRecursive() != null;
|
||||||
}
|
}
|
||||||
@@ -1127,8 +1131,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
}
|
}
|
||||||
|
|
||||||
String[] validTgt = tr.getValidTgts();
|
String[] validTgt = tr.getValidTgts();
|
||||||
if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, this.getActivatingPlayer(), this.getHostCard()))
|
if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, this.getActivatingPlayer(), this.getHostCard())) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restrictions coming from target
|
// Restrictions coming from target
|
||||||
@@ -1298,7 +1303,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
while (null != parent.getParent()) {
|
while (null != parent.getParent()) {
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1487,10 +1491,10 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
targetChosen.add(card);
|
targetChosen.add(card);
|
||||||
|
|
||||||
final String desc;
|
final String desc;
|
||||||
|
|
||||||
if (!card.isFaceDown()) {
|
if (!card.isFaceDown()) {
|
||||||
desc = this.getHostCard().getName() + " - targeting " + card;
|
desc = this.getHostCard().getName() + " - targeting " + card;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
desc = this.getHostCard().getName() + " - targeting Morph(" + card.getUniqueNumber() + ")";
|
desc = this.getHostCard().getName() + " - targeting Morph(" + card.getUniqueNumber() + ")";
|
||||||
}
|
}
|
||||||
this.setStackDescription(desc);
|
this.setStackDescription(desc);
|
||||||
@@ -1533,7 +1537,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
return ImmutableList.<Card>of();
|
return ImmutableList.<Card>of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SpellAbility getSATargetingCard() {
|
public SpellAbility getSATargetingCard() {
|
||||||
return targetChosen.isTargetingAnyCard() ? this : getParentTargetingCard();
|
return targetChosen.isTargetingAnyCard() ? this : getParentTargetingCard();
|
||||||
}
|
}
|
||||||
@@ -1544,8 +1547,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
parent = ((WrappedAbility) parent).getWrappedAbility();
|
parent = ((WrappedAbility) parent).getWrappedAbility();
|
||||||
}
|
}
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
if (parent.targetChosen.isTargetingAnyCard())
|
if (parent.targetChosen.isTargetingAnyCard()) {
|
||||||
return parent;
|
return parent;
|
||||||
|
}
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -1675,15 +1679,21 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
final String[] incR = restriction.split("\\.", 2);
|
final String[] incR = restriction.split("\\.", 2);
|
||||||
|
|
||||||
if (incR[0].equals("Spell")) {
|
if (incR[0].equals("Spell")) {
|
||||||
if (!this.isSpell())
|
if (!this.isSpell()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (incR[0].equals("Triggered")) {
|
}
|
||||||
if (!this.isTrigger())
|
}
|
||||||
|
else if (incR[0].equals("Triggered")) {
|
||||||
|
if (!this.isTrigger()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (incR[0].equals("Activated")) {
|
}
|
||||||
if (!(this instanceof AbilityActivated))
|
}
|
||||||
|
else if (incR[0].equals("Activated")) {
|
||||||
|
if (!(this instanceof AbilityActivated)) {
|
||||||
return false;
|
return false;
|
||||||
} else { //not a spell/ability type
|
}
|
||||||
|
}
|
||||||
|
else { //not a spell/ability type
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1812,5 +1822,4 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
this.subAbility.setIntrinsic(i);
|
this.subAbility.setIntrinsic(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ public class HumanPlaySpellAbility {
|
|||||||
// SA Params as comma delimited list
|
// SA Params as comma delimited list
|
||||||
String announce = ability.getParam("Announce");
|
String announce = ability.getParam("Announce");
|
||||||
if (announce != null) {
|
if (announce != null) {
|
||||||
for(String aVar : announce.split(",")) {
|
for (String aVar : announce.split(",")) {
|
||||||
String varName = aVar.trim();
|
String varName = aVar.trim();
|
||||||
|
|
||||||
boolean isX = "X".equalsIgnoreCase(varName);
|
boolean isX = "X".equalsIgnoreCase(varName);
|
||||||
@@ -222,12 +222,12 @@ public class HumanPlaySpellAbility {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Announcing Requirements like choosing creature type or number
|
||||||
private boolean announceType() {
|
private boolean announceType() {
|
||||||
// Announcing Requirements like choosing creature type or number
|
|
||||||
String announce = ability.getParam("AnnounceType");
|
String announce = ability.getParam("AnnounceType");
|
||||||
PlayerController pc = ability.getActivatingPlayer().getController();
|
PlayerController pc = ability.getActivatingPlayer().getController();
|
||||||
if (announce != null) {
|
if (announce != null) {
|
||||||
for(String aVar : announce.split(",")) {
|
for (String aVar : announce.split(",")) {
|
||||||
String varName = aVar.trim();
|
String varName = aVar.trim();
|
||||||
if ("CreatureType".equals(varName)) {
|
if ("CreatureType".equals(varName)) {
|
||||||
String choice = pc.chooseSomeType("Creature", ability, CardType.getCreatureTypes(), new ArrayList<String>());
|
String choice = pc.chooseSomeType("Creature", ability, CardType.getCreatureTypes(), new ArrayList<String>());
|
||||||
|
|||||||
Reference in New Issue
Block a user