CardProperty: extend blockedValidThisTurn and blockedByValidThisTurn using defined

This commit is contained in:
Hans Mackowiak
2020-03-03 14:30:39 +00:00
committed by Michael Kamensky
parent db396e6b5c
commit 4f0deea15f

View File

@@ -1518,27 +1518,38 @@ public class CardProperty {
} else if (property.startsWith("blockedByThisTurn")) { } else if (property.startsWith("blockedByThisTurn")) {
return !card.getBlockedByThisTurn().isEmpty(); return !card.getBlockedByThisTurn().isEmpty();
} else if (property.startsWith("blockedValidThisTurn ")) { } else if (property.startsWith("blockedValidThisTurn ")) {
if (card.getBlockedThisTurn() == null) { CardCollectionView blocked = card.getBlockedThisTurn();
if (blocked == null) {
return false; return false;
} }
String valid = property.split(" ")[1]; String valid = property.split(" ")[1];
for(Card c : card.getBlockedThisTurn()) { for(Card c : blocked) {
if (c.isValid(valid, card.getController(), source, spellAbility)) { if (c.isValid(valid, card.getController(), source, spellAbility)) {
return true; return true;
} }
} }
for(Card c : AbilityUtils.getDefinedCards(source, valid, spellAbility)) {
if (blocked.contains(c)) {
return true;
}
};
return false; return false;
} else if (property.startsWith("blockedByValidThisTurn ")) { } else if (property.startsWith("blockedByValidThisTurn ")) {
if (card.getBlockedByThisTurn() == null) { CardCollectionView blocked = card.getBlockedByThisTurn();
if (blocked == null) {
return false; return false;
} }
String valid = property.split(" ")[1]; String valid = property.split(" ")[1];
for(Card c : card.getBlockedByThisTurn()) { for(Card c : blocked) {
if (c.isValid(valid, card.getController(), source, spellAbility)) { if (c.isValid(valid, card.getController(), source, spellAbility)) {
return true; return true;
} }
} }
for(Card c : AbilityUtils.getDefinedCards(source, valid, spellAbility)) {
if (blocked.contains(c)) {
return true;
}
};
return false; return false;
} else if (property.startsWith("blockedBySourceThisTurn")) { } else if (property.startsWith("blockedBySourceThisTurn")) {
return source.getBlockedByThisTurn().contains(card); return source.getBlockedByThisTurn().contains(card);
@@ -1779,4 +1790,4 @@ public class CardProperty {
return true; return true;
} }
} }