mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Simplified the code found in forge.EndOfTurn and forge.GameAction.
This commit is contained in:
@@ -33,7 +33,7 @@ public class EndOfTurn implements java.io.Serializable
|
||||
|
||||
for (Card c : all) {
|
||||
if (!c.isFaceDown()
|
||||
&& c.getKeyword().contains("At the beginning of the end step, sacrifice CARDNAME."))
|
||||
&& c.hasKeyword("At the beginning of the end step, sacrifice CARDNAME."))
|
||||
{
|
||||
final Card card = c;
|
||||
final SpellAbility sac = new Ability(card, "0") {
|
||||
@@ -49,7 +49,8 @@ public class EndOfTurn implements java.io.Serializable
|
||||
AllZone.Stack.addSimultaneousStackEntry(sac);
|
||||
|
||||
}
|
||||
if(!c.isFaceDown() && c.getKeyword().contains("At the beginning of the end step, exile CARDNAME.")) {
|
||||
if (!c.isFaceDown()
|
||||
&& c.hasKeyword("At the beginning of the end step, exile CARDNAME.")) {
|
||||
final Card card = c;
|
||||
final SpellAbility exile = new Ability(card, "0") {
|
||||
@Override
|
||||
@@ -64,7 +65,8 @@ public class EndOfTurn implements java.io.Serializable
|
||||
AllZone.Stack.addSimultaneousStackEntry(exile);
|
||||
|
||||
}
|
||||
if(!c.isFaceDown() && c.getKeyword().contains("At the beginning of the end step, destroy CARDNAME.")) {
|
||||
if (!c.isFaceDown()
|
||||
&& c.hasKeyword("At the beginning of the end step, destroy CARDNAME.")) {
|
||||
final Card card = c;
|
||||
final SpellAbility destroy = new Ability(card, "0") {
|
||||
@Override
|
||||
@@ -80,7 +82,7 @@ public class EndOfTurn implements java.io.Serializable
|
||||
|
||||
}
|
||||
//Berserk is using this, so don't check isFaceDown()
|
||||
if(c.getKeyword().contains("At the beginning of the next end step, destroy CARDNAME if it attacked this turn.")) {
|
||||
if (c.hasKeyword("At the beginning of the next end step, destroy CARDNAME if it attacked this turn.")) {
|
||||
if (c.getCreatureAttackedThisTurn()) {
|
||||
final Card card = c;
|
||||
final SpellAbility sac = new Ability(card, "0") {
|
||||
@@ -100,7 +102,7 @@ public class EndOfTurn implements java.io.Serializable
|
||||
c.removeExtrinsicKeyword("At the beginning of the next end step, destroy CARDNAME if it attacked this turn.");
|
||||
}
|
||||
}
|
||||
if( c.getKeyword().contains("An opponent gains control of CARDNAME at the beginning of the next end step.")) {
|
||||
if ( c.hasKeyword("An opponent gains control of CARDNAME at the beginning of the next end step.")) {
|
||||
final Card vale = c;
|
||||
final SpellAbility change = new Ability(vale, "0") {
|
||||
@Override
|
||||
|
||||
@@ -516,9 +516,9 @@ public class GameAction {
|
||||
Card perm = c.getEnchanting().get(i);
|
||||
if (!AllZoneUtil.isCardInPlay(perm)
|
||||
|| CardFactoryUtil.hasProtectionFrom(c, perm)
|
||||
|| ((c.getKeyword().contains("Enchant creature") || c.getKeyword().contains("Enchant tapped creature") )
|
||||
|| ((c.hasKeyword("Enchant creature") || c.hasKeyword("Enchant tapped creature") )
|
||||
&& !perm.getType().contains("Creature"))
|
||||
|| (c.getKeyword().contains("Enchant tapped creature") && perm.isUntapped() ) ) {
|
||||
|| (c.hasKeyword("Enchant tapped creature") && perm.isUntapped() ) ) {
|
||||
c.unEnchantCard(perm);
|
||||
//changed from destroy (and rules-wise, I don't think it's a sacrifice)
|
||||
moveToGraveyard(c);
|
||||
@@ -526,7 +526,9 @@ public class GameAction {
|
||||
}
|
||||
}//if isAura
|
||||
|
||||
if(c.isCreature() && c.getNetDefense() <= c.getDamage() && !c.getKeyword().contains("Indestructible")) {
|
||||
if (c.isCreature()
|
||||
&& c.getNetDefense() <= c.getDamage()
|
||||
&& !c.hasKeyword("Indestructible")) {
|
||||
destroy(c);
|
||||
AllZone.Combat.removeFromCombat(c); //this is untested with instants and abilities but required for First Strike combat phase
|
||||
}
|
||||
@@ -601,7 +603,7 @@ public class GameAction {
|
||||
}
|
||||
|
||||
public boolean destroyNoRegeneration(Card c) {
|
||||
if(!AllZoneUtil.isCardInPlay(c) || c.getKeyword().contains("Indestructible")) return false;
|
||||
if (!AllZoneUtil.isCardInPlay(c) || c.hasKeyword("Indestructible")) return false;
|
||||
|
||||
if (c.isEnchanted())
|
||||
{
|
||||
@@ -610,7 +612,7 @@ public class GameAction {
|
||||
{
|
||||
public boolean addCard(Card crd)
|
||||
{
|
||||
return crd.getKeyword().contains("Totem armor");
|
||||
return crd.hasKeyword("Totem armor");
|
||||
}
|
||||
});
|
||||
CardListUtil.sortCMC(list);
|
||||
@@ -689,7 +691,7 @@ public class GameAction {
|
||||
if (!(owner.isComputer() || owner.isHuman()))
|
||||
throw new RuntimeException("GameAction : destroy() invalid card.getOwner() - " + c + " " + owner);
|
||||
|
||||
boolean persist = (c.getKeyword().contains("Persist") && c.getCounters(Counters.M1M1) == 0);
|
||||
boolean persist = (c.hasKeyword("Persist") && c.getCounters(Counters.M1M1) == 0);
|
||||
|
||||
Card newCard = moveToGraveyard(c);
|
||||
|
||||
@@ -726,7 +728,8 @@ public class GameAction {
|
||||
|
||||
public boolean destroy(Card c) {
|
||||
if (!AllZoneUtil.isCardInPlay(c)
|
||||
|| (c.getKeyword().contains("Indestructible") && (!c.isCreature() || c.getNetDefense() > 0))) return false;
|
||||
|| (c.hasKeyword("Indestructible")
|
||||
&& (!c.isCreature() || c.getNetDefense() > 0))) return false;
|
||||
|
||||
if (c.canBeShielded() && c.getShield() > 0) {
|
||||
c.subtractShield();
|
||||
@@ -743,7 +746,7 @@ public class GameAction {
|
||||
{
|
||||
public boolean addCard(Card crd)
|
||||
{
|
||||
return crd.getKeyword().contains("Totem armor");
|
||||
return crd.hasKeyword("Totem armor");
|
||||
}
|
||||
});
|
||||
CardListUtil.sortCMC(list);
|
||||
|
||||
Reference in New Issue
Block a user