Clean script

This commit is contained in:
tool4EvEr
2023-02-12 14:11:34 +01:00
parent 19b0365ab0
commit bd7dfb8a27
8 changed files with 40 additions and 35 deletions

View File

@@ -67,14 +67,10 @@ public class SacrificeAllEffect extends SpellAbilityEffect {
// update cards that where using LKI
CardCollection gameList = new CardCollection();
for (Card sac : list) {
final Card gameCard = game.getCardState(sac, null);
// gameCard is LKI in that case, the card is not in game anymore
// or the timestamp did change
// this should check Self too
if (gameCard == null || !sac.equalsWithTimestamp(gameCard) || !gameCard.canBeSacrificedBy(sa, true)) {
if (!sac.canBeSacrificedBy(sa, true)) {
continue;
}
gameList.add(gameCard);
gameList.add(game.getCardState(sac, null));
}
list = gameList;

View File

@@ -6473,10 +6473,19 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
System.out.println("Trying to sacrifice immutables: " + this);
return false;
}
if (!isInPlay() || isPhasedOut()) {
return false;
}
final Card gameCard = game.getCardState(this, null);
// gameCard is LKI in that case, the card is not in game anymore
// or the timestamp did change
// this should check Self too
if (gameCard == null || !this.equalsWithTimestamp(gameCard)) {
return false;
}
return !StaticAbilityCantSacrifice.cantSacrifice(this, source, effect);
}

View File

@@ -117,22 +117,25 @@ public class CostSacrifice extends CostPartWithList {
Card originalEquipment = ability.getOriginalHost();
return originalEquipment.isEquipping() && originalEquipment.canBeSacrificedBy(ability, effect);
}
else if (!payCostFromSource()) { // You can always sac all
if ("All".equalsIgnoreCase(getAmount())) {
CardCollectionView typeList = activator.getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, getType().split(";"), activator, source, ability);
// it needs to check if everything can be sacrificed
return Iterables.all(typeList, CardPredicates.canBeSacrificedBy(ability, effect));
}
int amount = getAbilityAmount(ability);
return getMaxAmountX(ability, activator, effect) >= amount;
// If amount is null, it's either "ALL" or "X"
// if X is defined, it needs to be calculated and checked, if X is
// choice, it can be Paid even if it's 0
if (payCostFromSource()) {
return source.canBeSacrificedBy(ability, effect);
}
else return source.canBeSacrificedBy(ability, effect);
// You can always sac all
if ("All".equalsIgnoreCase(getAmount())) {
CardCollectionView typeList = activator.getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, getType().split(";"), activator, source, ability);
// it needs to check if everything can be sacrificed
return Iterables.all(typeList, CardPredicates.canBeSacrificedBy(ability, effect));
}
int amount = getAbilityAmount(ability);
// If amount is null, it's either "ALL" or "X"
// if X is defined, it needs to be calculated and checked, if X is
// choice, it can be Paid even if it's 0
return getMaxAmountX(ability, activator, effect) >= amount;
}
@Override