Merge branch 'master' into master2

This commit is contained in:
Anthony Calosa
2024-10-10 19:34:39 +08:00
41 changed files with 399 additions and 16 deletions

View File

@@ -1870,6 +1870,8 @@ public class GameAction {
public final CardCollection sacrifice(final Iterable<Card> list, final SpellAbility source, final boolean effect, Map<AbilityKey, Object> params) {
Multimap<Player, Card> lki = MultimapBuilder.hashKeys().arrayListValues().build();
final boolean showRevealDialog = source != null && source.hasParam("ShowSacrificedCards");
CardCollection result = new CardCollection();
for (Card c : list) {
if (c == null) {
@@ -1890,6 +1892,10 @@ public class GameAction {
if (changed != null) {
result.add(changed);
}
if (showRevealDialog) {
final String message = Localizer.getInstance().getMessage("lblSacrifice");
game.getAction().reveal(result, ZoneType.Graveyard, c.getOwner(), false, message, false);
}
}
for (Map.Entry<Player, Collection<Card>> e : lki.asMap().entrySet()) {
// Run triggers

View File

@@ -1296,7 +1296,7 @@ public class AbilityUtils {
}
}
} else if (defined.startsWith("ValidStack")) {
String valid = changedDef.split(" ", 2)[1];
String[] valid = changedDef.split(" ", 2)[1].split(",");
for (SpellAbilityStackInstance stackInstance : game.getStack()) {
SpellAbility instanceSA = stackInstance.getSpellAbility();
if (instanceSA != null && instanceSA.isValid(valid, player, card, sa)) {
@@ -2304,6 +2304,10 @@ public class AbilityUtils {
return doXMath(player.getNumDrawnThisTurn(), expr, c, ctb);
}
if (sq[0].equals("YouDrewLastTurn")) {
return doXMath(player.getNumDrawnLastTurn(), expr, c, ctb);
}
if (sq[0].equals("YouRollThisTurn")) {
return doXMath(player.getNumRollsThisTurn(), expr, c, ctb);
}

View File

@@ -6088,6 +6088,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
return getType().sharesCardTypeWith(c1.getType());
}
public final boolean sharesAllCardTypesWith(final Card c1) {
if (c1 == null) {
return false;
}
return getType().sharesAllCardTypesWith(c1.getType());
}
public final boolean sharesControllerWith(final Card c1) {
return c1 != null && getController().equals(c1.getController());
}

View File

@@ -114,6 +114,10 @@ public final class CardPredicates {
return c -> c.sharesCardTypeWith(card);
}
public static Predicate<Card> sharesAllCardTypesWith(final Card card) {
return c -> c.sharesAllCardTypesWith(card);
}
public static Predicate<Card> sharesCreatureTypeWith(final Card card) {
return c -> c.sharesCreatureTypeWith(card);
}

View File

@@ -35,10 +35,7 @@ import forge.util.collect.FCollectionView;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
public class CardProperty {
@@ -847,6 +844,11 @@ public class CardProperty {
}
}
}
} else if (property.startsWith("sharesAllCardTypesWithOther")) {
final String restriction = property.split("sharesAllCardTypesWithOther ")[1];
CardCollection list = AbilityUtils.getDefinedCards(source, restriction, spellAbility);
list.remove(card);
return Iterables.any(list, CardPredicates.sharesAllCardTypesWith(card));
} else if (property.startsWith("sharesLandTypeWith")) {
final String restriction = property.split("sharesLandTypeWith ")[1];
if (!Iterables.any(AbilityUtils.getDefinedCards(source, restriction, spellAbility), CardPredicates.sharesLandTypeWith(card))) {
@@ -1503,7 +1505,7 @@ public class CardProperty {
}
} else if (property.startsWith("power") || property.startsWith("toughness") || property.startsWith("cmc")
|| property.startsWith("totalPT") || property.startsWith("numColors")
|| property.startsWith("basePower") || property.startsWith("baseToughness")) {
|| property.startsWith("basePower") || property.startsWith("baseToughness") || property.startsWith("numTypes")) {
int x;
int y = 0;
String rhs = "";
@@ -1529,6 +1531,9 @@ public class CardProperty {
} else if (property.startsWith("numColors")) {
rhs = property.substring(11);
y = card.getColor().countColors();
} else if (property.startsWith("numTypes")) {
rhs = property.substring(10);
y = Iterables.size(card.getType().getCoreTypes());
}
x = AbilityUtils.calculateAmount(source, rhs, spellAbility);

View File

@@ -105,6 +105,7 @@ public class Player extends GameEntity implements Comparable<Player> {
private int numPowerSurgeLands;
private int numLibrarySearchedOwn; //The number of times this player has searched his library
private int numDrawnThisTurn;
private int numDrawnLastTurn;
private int numDrawnThisDrawStep;
private int numRollsThisTurn;
private int numExploredThisTurn;
@@ -1444,6 +1445,10 @@ public class Player extends GameEntity implements Comparable<Player> {
return numDrawnThisTurn;
}
public final int getNumDrawnLastTurn() {
return numDrawnLastTurn;
}
public final int numDrawnThisDrawStep() {
return numDrawnThisDrawStep;
}
@@ -2256,6 +2261,9 @@ public class Player extends GameEntity implements Comparable<Player> {
public final void setLandsPlayedLastTurn(int num) {
landsPlayedLastTurn = num;
}
public final void setNumDrawnLastTurn(int num) {
numDrawnLastTurn= num;
}
public final int getInvestigateNumThisTurn() {
return investigatedThisTurn;
@@ -2475,6 +2483,7 @@ public class Player extends GameEntity implements Comparable<Player> {
for (final PlayerZone pz : zones.values()) {
pz.resetCardsAddedThisTurn();
}
setNumDrawnLastTurn(getNumDrawnThisTurn());
resetNumDrawnThisTurn();
resetNumRollsThisTurn();
resetNumExploredThisTurn();