Implement [M3C] Gluttonous Hellkite (part of #12206, related to #12393)

This commit is contained in:
Oleg Agafonov 2024-06-26 10:18:37 +04:00
parent c3903dc550
commit 3f5d2bb9b5
4 changed files with 262 additions and 9 deletions

View file

@ -12,12 +12,10 @@ import mage.players.Player;
import mage.target.common.TargetSacrifice;
import mage.util.CardUtil;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
* @author BetaSteward_at_googlemail.com, JayDi85
*/
public class SacrificeAllEffect extends OneShotEffect {
@ -25,6 +23,8 @@ public class SacrificeAllEffect extends OneShotEffect {
private final FilterPermanent filter;
private final boolean onlyOpponents;
private static final String VALUE_KEY = "sacrificeAllEffect_permanentsList";
/**
* Each player sacrifices a permanent
*
@ -52,9 +52,6 @@ public class SacrificeAllEffect extends OneShotEffect {
this(amount, filter, false);
}
/**
* Internal use for this and SacrificeOpponentsEffect
*/
protected SacrificeAllEffect(DynamicValue amount, FilterPermanent filter, boolean onlyOpponents) {
super(Outcome.Sacrifice);
this.amount = amount;
@ -99,15 +96,32 @@ public class SacrificeAllEffect extends OneShotEffect {
}
perms.addAll(target.getTargets());
}
List<Permanent> sacraficedPermanents = new ArrayList<>();
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
if (permanent != null && permanent.sacrifice(source, game)) {
sacraficedPermanents.add(permanent.copy());
}
}
saveSacrificedPermanentsList(source.getSourceId(), game, sacraficedPermanents);
return true;
}
public static void saveSacrificedPermanentsList(UUID sourceObjectId, Game game, List<Permanent> list) {
game.getState().setValue(CardUtil.getCardZoneString(VALUE_KEY, sourceObjectId, game), list);
}
/**
* Get detailed list of sacrificed permanents
*
* @param previous if you need to look in detailed list on battlefield, then use previous param to find data from a stack moment
*/
public static List<Permanent> getSacrificedPermanentsList(UUID sourceObjectId, Game game, boolean previous) {
return (List<Permanent>) game.getState().getValue(CardUtil.getCardZoneString(VALUE_KEY, sourceObjectId, game, previous));
}
private void setText() {
StringBuilder sb = new StringBuilder();
sb.append(onlyOpponents ? "each opponent sacrifices " : "each player sacrifices ");