Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into lang-fr
Browse files Browse the repository at this point in the history
  • Loading branch information
add-le committed Mar 8, 2024
2 parents 81ae69f + aebec19 commit f3306ac
Show file tree
Hide file tree
Showing 780 changed files with 1,218 additions and 555 deletions.
2 changes: 1 addition & 1 deletion forge-adventure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>forge</artifactId>
<groupId>forge</groupId>
<version>1.6.60-SNAPSHOT</version>
<version>1.6.61-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion forge-ai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>forge</artifactId>
<groupId>forge</groupId>
<version>1.6.60-SNAPSHOT</version>
<version>1.6.61-SNAPSHOT</version>
</parent>

<artifactId>forge-ai</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion forge-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>forge</artifactId>
<groupId>forge</groupId>
<version>1.6.60-SNAPSHOT</version>
<version>1.6.61-SNAPSHOT</version>
</parent>

<artifactId>forge-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion forge-game/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>forge</artifactId>
<groupId>forge</groupId>
<version>1.6.60-SNAPSHOT</version>
<version>1.6.61-SNAPSHOT</version>
</parent>

<artifactId>forge-game</artifactId>
Expand Down
14 changes: 8 additions & 6 deletions forge-game/src/main/java/forge/game/ability/AbilityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3438,12 +3438,14 @@ public static int playerXProperty(final Player player, final String s, final Car
return doXMath(calculateAmount(source, ctb.getSVar(player.toString()), ctb), m, source, ctb);
}

if (value.contains("AllCounters")) {
return doXMath(Aggregates.sum(player.getCounters().values(), Functions.identity()), m, source, ctb);
}

if (value.contains("PoisonCounters")) {
return doXMath(player.getPoisonCounters(), m, source, ctb);
if (value.contains("Counters")) {
int count = 0;
if (sq[1].equals("ALL")) {
count = Aggregates.sum(player.getCounters().values(), Functions.identity());
} else {
count = player.getCounters(CounterType.getType(sq[1]));
}
return doXMath(count, m, source, ctb);
}

if (value.contains("TopOfLibraryCMC")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.*;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import forge.game.Direction;
import forge.game.player.DelayedReveal;
import forge.game.player.PlayerView;
import forge.util.CardTranslation;
Expand Down Expand Up @@ -59,7 +59,7 @@ public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard();
final Player activator = sa.getActivatingPlayer();
final Game game = activator.getGame();
CardCollection chosen = new CardCollection();
CardCollection allChosen = new CardCollection();

final List<Player> tgtPlayers = getDefinedPlayersOrTargeted(sa);

Expand Down Expand Up @@ -100,9 +100,22 @@ public void resolve(SpellAbility sa) {

boolean revealTitle = (sa.hasParam("RevealTitle"));
for (Player p : tgtPlayers) {
CardCollectionView pChoices = choices;
CardCollection chosen = new CardCollection();
if (!p.isInGame()) {
p = getNewChooser(sa, activator, p);
}
if (sa.hasParam("ControlledByPlayer")) {
final String param = sa.getParam("ControlledByPlayer");
if (param.equals("Chooser")) {
pChoices = CardLists.filterControlledBy(pChoices, p);
} else if (param.equals("Left") || param.equals("Right")) {
pChoices = CardLists.filterControlledBy(pChoices, game.getNextPlayerAfter(p,
Direction.valueOf(param)));
} else {
pChoices = CardLists.filterControlledBy(pChoices, AbilityUtils.getDefinedPlayers(host, param, sa));
}
}
boolean dontRevealToOwner = true;
if (sa.hasParam("EachBasicType")) {
// Get all lands,
Expand All @@ -123,16 +136,17 @@ public void resolve(SpellAbility sa) {
}
}
}
} else if (sa.hasParam("ChooseParty")) {
Set<String> partyTypes = Sets.newHashSet("Cleric", "Rogue", "Warrior", "Wizard");
for (final String type : partyTypes) {
CardCollection valids = CardLists.filter(p.getCardsIn(ZoneType.Battlefield),
CardPredicates.isType(type));
valids.removeAll(chosen);
} else if (sa.hasParam("ChooseEach")) {
final String s = sa.getParam("ChooseEach");
final String[] types = s.equals("Party") ? new String[]{"Cleric","Thief","Warrior","Wizard"}
: s.split(" & ");
for (final String type : types) {
CardCollection valids = CardLists.filter(pChoices, CardPredicates.isType(type));
if (!valids.isEmpty()) {
final String prompt = Localizer.getInstance().getMessage("lblChoose") + " " +
Lang.nounWithNumeralExceptOne(1, type);
Card c = p.getController().chooseSingleEntityForEffect(valids, sa, prompt, true, null);
Card c = p.getController().chooseSingleEntityForEffect(valids, sa, prompt,
!sa.hasParam("Mandatory"), null);
if (c != null) {
chosen.add(c);
}
Expand Down Expand Up @@ -168,9 +182,9 @@ public void resolve(SpellAbility sa) {
CardCollection chosenPool = new CardCollection();
String title = Localizer.getInstance().getMessage("lblChooseCreature");
Card choice = null;
while (!choices.isEmpty() && chosenPool.size() < validAmount) {
while (!pChoices.isEmpty() && chosenPool.size() < validAmount) {
boolean optional = chosenPool.size() >= minAmount;
CardCollection creature = (CardCollection) choices;
CardCollection creature = (CardCollection) pChoices;
if (!chosenPool.isEmpty()) {
title = Localizer.getInstance().getMessage("lblChooseCreatureWithDiffPower");
}
Expand All @@ -180,7 +194,7 @@ public void resolve(SpellAbility sa) {
}
chosenPool.add(choice);
restrict = restrict + (restrict.contains(".") ? "+powerNE" : ".powerNE") + choice.getNetPower();
choices = CardLists.getValidCards(choices, restrict, activator, host, sa);
pChoices = CardLists.getValidCards(pChoices, restrict, activator, host, sa);
}
if (choice != null) {
chosenPool.add(choice);
Expand All @@ -189,7 +203,7 @@ public void resolve(SpellAbility sa) {
} else if (sa.hasParam("EachDifferentPower")) {
List<Integer> powers = new ArrayList<>();
CardCollection chosenPool = new CardCollection();
for (Card c : choices) {
for (Card c : pChoices) {
int pow = c.getNetPower();
if (!powers.contains(pow)) {
powers.add(c.getNetPower());
Expand All @@ -200,7 +214,7 @@ public void resolve(SpellAbility sa) {
re = re + (re.contains(".") ? "+powerEQ" : ".powerEQ");
for (int i : powers) {
String restrict = re + i;
CardCollection valids = CardLists.getValidCards(choices, restrict, activator, host, sa);
CardCollection valids = CardLists.getValidCards(pChoices, restrict, activator, host, sa);
Card choice = p.getController().chooseSingleEntityForEffect(valids, sa,
Localizer.getInstance().getMessage("lblChooseCreatureWithXPower", i), false, null);
chosenPool.add(choice);
Expand All @@ -209,17 +223,17 @@ public void resolve(SpellAbility sa) {
} else if (sa.hasParam("ControlAndNot")) {
String title = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : Localizer.getInstance().getMessage("lblChooseCreature");
// Targeted player (p) chooses N creatures that belongs to them
CardCollection tgtPlayerCtrl = CardLists.filterControlledBy(choices, p);
CardCollection tgtPlayerCtrl = CardLists.filterControlledBy(pChoices, p);
chosen.addAll(p.getController().chooseCardsForEffect(tgtPlayerCtrl, sa, title + " " + "you control", minAmount, validAmount,
!sa.hasParam("Mandatory"), null));
// Targeted player (p) chooses N creatures that don't belong to them
CardCollection notTgtPlayerCtrl = new CardCollection(choices);
CardCollection notTgtPlayerCtrl = new CardCollection(pChoices);
notTgtPlayerCtrl.removeAll(tgtPlayerCtrl);
chosen.addAll(p.getController().chooseCardsForEffect(notTgtPlayerCtrl, sa, title + " " + "you don't control", minAmount, validAmount,
!sa.hasParam("Mandatory"), null));
} else if (sa.hasParam("AtRandom") && !choices.isEmpty()) {
} else if (sa.hasParam("AtRandom") && !pChoices.isEmpty()) {
// don't pass FCollection for direct modification, the Set part would get messed up
chosen = new CardCollection(Aggregates.random(choices, validAmount));
chosen = new CardCollection(Aggregates.random(pChoices, validAmount));
dontRevealToOwner = false;
} else {
String title = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : Localizer.getInstance().getMessage("lblChooseaCard") + " ";
Expand Down Expand Up @@ -252,7 +266,7 @@ public void resolve(SpellAbility sa) {
DelayedReveal delayedReveal = new DelayedReveal(shown, ZoneType.Library, PlayerView.get(searched),
CardTranslation.getTranslatedName(host.getName()) + " - " +
Localizer.getInstance().getMessage("lblLookingCardIn") + " ");
Card choice = p.getController().chooseSingleEntityForEffect(choices, delayedReveal, sa, title,
Card choice = p.getController().chooseSingleEntityForEffect(pChoices, delayedReveal, sa, title,
!sa.hasParam("Mandatory"), p, null);
if (choice == null) {
return;
Expand All @@ -263,34 +277,38 @@ public void resolve(SpellAbility sa) {
p.removeController(controlTimestamp);
}
} else {
chosen.addAll(p.getController().chooseCardsForEffect(choices, sa, title, minAmount, validAmount,
chosen.addAll(p.getController().chooseCardsForEffect(pChoices, sa, title, minAmount, validAmount,
!sa.hasParam("Mandatory"), null));
}
}
if (sa.hasParam("Reveal") && !sa.hasParam("SecretlyChoose")) {
game.getAction().reveal(chosen, p, dontRevealToOwner, revealTitle ? sa.getParam("RevealTitle") :
Localizer.getInstance().getMessage("lblChosenCards") + " ", !revealTitle);
}
if (sa.hasParam("ChosenMap")) {
host.addToChosenMap(p, chosen);
}
allChosen.addAll(chosen);
}
if (sa.hasParam("Reveal") && sa.hasParam("SecretlyChoose")) {
for (final Player p : tgtPlayers) {
game.getAction().reveal(chosen, p, true, revealTitle ?
game.getAction().reveal(allChosen, p, true, revealTitle ?
sa.getParam("RevealTitle") : Localizer.getInstance().getMessage("lblChosenCards") + " ",
!revealTitle);
}
}
host.setChosenCards(chosen);
host.setChosenCards(allChosen);
if (sa.hasParam("ForgetOtherRemembered")) {
host.clearRemembered();
}
if (sa.hasParam("RememberChosen")) {
host.addRemembered(chosen);
host.addRemembered(allChosen);
}
if (sa.hasParam("ForgetChosen")) {
host.removeRemembered(chosen);
host.removeRemembered(allChosen);
}
if (sa.hasParam("ImprintChosen")) {
host.addImprintedCards(chosen);
host.addImprintedCards(allChosen);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void resolve(final SpellAbility sa) {
final Player activator = sa.getActivatingPlayer();
final Game game = host.getGame();
boolean useZoneTable = true;
boolean chosenMap = "ChosenMap".equals(sa.getParam("Defined"));
CardZoneTable triggerList = sa.getChangeZoneTable();
if (triggerList == null) {
triggerList = new CardZoneTable();
Expand All @@ -130,6 +131,8 @@ public void resolve(final SpellAbility sa) {
List<Player> controllers = Lists.newArrayList();
if (sa.hasParam("Controller")) {
controllers = AbilityUtils.getDefinedPlayers(host, sa.getParam("Controller"), sa);
} else if (chosenMap) {
controllers.addAll(host.getChosenMap().keySet());
}
if (controllers.isEmpty()) {
controllers.add(activator);
Expand Down Expand Up @@ -223,6 +226,12 @@ public void resolve(final SpellAbility sa) {
}
}
}
} else if (chosenMap) {
if (sa.hasParam("ChosenMapIndex")) {
final int index = Integer.valueOf(sa.getParam("ChosenMapIndex"));
if (index >= host.getChosenMap().get(controller).size()) continue;
tgtCards.add(host.getChosenMap().get(controller).get(index));
} else tgtCards = host.getChosenMap().get(controller);
} else {
tgtCards = getDefinedCardsOrTargeted(sa);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard();
final Player activator = sa.getActivatingPlayer();
final CounterType type = CounterType.getType(sa.getParam("CounterType"));
final int counterAmount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("CounterNum", "1"), sa);
int counterAmount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("CounterNum", "1"), sa);
final String valid = sa.getParam("ValidCards");
final ZoneType zone = sa.hasParam("ValidZone") ? ZoneType.smartValueOf(sa.getParam("ValidZone")) : ZoneType.Battlefield;
final Game game = activator.getGame();
Expand All @@ -63,20 +63,31 @@ public void resolve(SpellAbility sa) {
}

Player placer = activator;
boolean placerPerCard = false;
String placerPerCard = "";
if (sa.hasParam("Placer")) {
final String pstr = sa.getParam("Placer");
if (pstr.contains("Controller")) {
placerPerCard = true;
if (pstr.equals("Controller")) {
placerPerCard = "Controller";
} else if (pstr.equals("Owner")) {
placerPerCard = "Owner";
} else {
placer = AbilityUtils.getDefinedPlayers(host, pstr, sa).get(0);
}
}

GameEntityCounterTable table = new GameEntityCounterTable();
for (final Card tgtCard : cards) {
if (placerPerCard) {
if (placerPerCard.equals("Controller")) {
placer = tgtCard.getController();
} else if (placerPerCard.equals("Owner")) {
placer = tgtCard.getOwner();
}
if (sa.hasParam("AmountByChosenMap")) {
final String[] parse = sa.getParam("AmountByChosenMap").split(" INDEX ");
final int index = parse.length > 1 ? Integer.valueOf(parse[1]) : 0;
if (index >= host.getChosenMap().get(placer).size()) continue;
final Card chosen = host.getChosenMap().get(placer).get(index);
counterAmount = AbilityUtils.xCount(chosen, parse[0], sa);
}
tgtCard.addCounter(type, counterAmount, placer, table);
}
Expand All @@ -97,7 +108,7 @@ public void resolve(SpellAbility sa) {
AbilityUtils.calculateAmount(host, sa.getParam("CounterNum2"), sa) : counterAmount;

for (final Card tgtCard : cards) {
if (placerPerCard) {
if (placerPerCard.equals("Controller")) {
placer = tgtCard.getController();
}
tgtCard.addCounter(type2, counterAmount2, placer, table);
Expand Down
18 changes: 12 additions & 6 deletions forge-game/src/main/java/forge/game/card/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
private Map<Long, CardCollection> mustBlockCards = Maps.newHashMap();
private List<Card> blockedThisTurn = Lists.newArrayList();
private List<Card> blockedByThisTurn = Lists.newArrayList();
private Map<Player, CardCollection> chosenMap = Maps.newHashMap();

private CardCollection untilLeavesBattlefield = new CardCollection();

Expand Down Expand Up @@ -216,7 +217,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {

private boolean renowned;
private boolean solved = false;
private boolean suspected = false;
private Long suspectedTimestamp = null;
private StaticAbility suspectedStatic = null;

Expand Down Expand Up @@ -1163,6 +1163,13 @@ public final void clearImprintedCards() {
imprintedCards = view.clearCards(imprintedCards, TrackableProperty.ImprintedCards);
}

public final void addToChosenMap(final Player p, final CardCollection chosen) {
chosenMap.put(p, chosen);
}
public final Map<Player, CardCollection> getChosenMap() {
return chosenMap;
}

public final CardCollectionView getExiledCards() {
return CardCollection.getView(exiledCards);
}
Expand Down Expand Up @@ -2664,7 +2671,7 @@ else if (o.grantsZonePermissions())
if (solved) {
sb.append("Solved\r\n");
}
if (suspected) {
if (isSuspected()) {
sb.append("Suspected\r\n");
}
if (manifested) {
Expand Down Expand Up @@ -6343,14 +6350,13 @@ public void setSuspectedTimestamp(final Long timestamp) {
}

public final boolean isSuspected() {
return suspected;
return suspectedTimestamp != null;
}

public final boolean setSuspected(final boolean suspected) {
if (suspected && StaticAbilityCantBeSuspected.cantBeSuspected(this)) {
return false;
}
this.suspected = suspected;
if (suspected) {
if (suspectedTimestamp != null) {
// 701.58d A suspected permanent can’t become suspected again.
Expand All @@ -6365,11 +6371,11 @@ public final boolean setSuspected(final boolean suspected) {
String effect = "Mode$ CantBlockBy | ValidBlocker$ Creature.Self | Description$ CARDNAME can't block.";
suspectedStatic = StaticAbility.create(effect, this, getCurrentState(), false);
}
this.addChangedCardTraits(null, null, null, null, ImmutableList.of(suspectedStatic), false, false, suspectedTimestamp, 0);
addChangedCardTraits(null, null, null, null, ImmutableList.of(suspectedStatic), false, false, suspectedTimestamp, 0);
} else {
if (suspectedTimestamp != null) {
removeChangedCardKeywords(suspectedTimestamp, 0);
this.removeChangedCardTraits(suspectedTimestamp, 0);
removeChangedCardTraits(suspectedTimestamp, 0);
}
suspectedTimestamp = null;
}
Expand Down
Loading

0 comments on commit f3306ac

Please sign in to comment.