Some cleanup (#6696)

This commit is contained in:
tool4ever
2024-12-16 12:27:00 +01:00
committed by GitHub
parent 420f862e90
commit c7afe3ce7a
23 changed files with 27 additions and 45 deletions

View File

@@ -965,7 +965,6 @@ public class PlayerControllerAi extends PlayerController {
} }
} }
return defaultVal != null && defaultVal; return defaultVal != null && defaultVal;
case UntapTimeVault: return false; // TODO Should AI skip his turn for time vault?
case LeftOrRight: return brains.chooseDirection(sa); case LeftOrRight: return brains.chooseDirection(sa);
case OddsOrEvens: return brains.chooseEvenOdd(sa); // false is Odd, true is Even case OddsOrEvens: return brains.chooseEvenOdd(sa); // false is Odd, true is Even
default: default:

View File

@@ -338,10 +338,16 @@ public class CardStorageReader {
final int from = iPart * filesPerPart; final int from = iPart * filesPerPart;
final int till = iPart == maxParts - 1 ? totalFiles : from + filesPerPart; final int till = iPart == maxParts - 1 ? totalFiles : from + filesPerPart;
tasks.add(() -> { tasks.add(() -> {
try {
final List<CardRules> res = loadCardsInRange(allFiles, from, till); final List<CardRules> res = loadCardsInRange(allFiles, from, till);
return res;
} catch (Exception ex) {
throw ex;
} finally {
// make sure to continue loading when using multiple threads
cdl.countDown(); cdl.countDown();
progressObserver.report(maxParts - (int)cdl.getCount(), maxParts); progressObserver.report(maxParts - (int)cdl.getCount(), maxParts);
return res; }
}); });
} }
return tasks; return tasks;

View File

@@ -20,6 +20,7 @@ package forge.game;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -70,7 +71,7 @@ public final class GameOutcome implements Iterable<Entry<RegisteredPlayer, Playe
private int winningTeam = -1; private int winningTeam = -1;
private final HashMap<RegisteredPlayer, PlayerStatistics> playerRating = new HashMap<>(); private final HashMap<RegisteredPlayer, PlayerStatistics> playerRating = new HashMap<>();
private final HashMap<RegisteredPlayer, String> playerNames = new HashMap<>(); private final HashMap<RegisteredPlayer, String> playerNames = new LinkedHashMap<>();
private final Map<RegisteredPlayer, AnteResult> anteResult = new HashMap<>(); private final Map<RegisteredPlayer, AnteResult> anteResult = new HashMap<>();
private GameEndReason winCondition; private GameEndReason winCondition;

View File

@@ -1483,7 +1483,7 @@ public class AbilityUtils {
if (modifier.startsWith("Minus")) { if (modifier.startsWith("Minus")) {
int max = Integer.parseInt(modifier.substring(5)); int max = Integer.parseInt(modifier.substring(5));
if (sa.hasParam("UnlessUpTo") && beforePayment) { // Flash if (sa.hasParam("UnlessUpTo") && beforePayment) { // Flash
max = sa.getActivatingPlayer().getController().chooseNumber(sa, Localizer.getInstance().getMessage("lblChooseNumber"), 0, max); max = sa.getActivatingPlayer().getController().chooseNumberForCostReduction(sa, 0, max);
} }
newCost.decreaseGenericMana(max); newCost.decreaseGenericMana(max);
} else { } else {
@@ -4000,6 +4000,7 @@ public class AbilityUtils {
Set<String> types = new HashSet<>(); Set<String> types = new HashSet<>();
for (Card c1 : list) { for (Card c1 : list) {
c1.getType().getSubtypes().forEach(types::add); c1.getType().getSubtypes().forEach(types::add);
c1.getType().getCreatureTypes().forEach(types::add);
} }
return types.size(); return types.size();

View File

@@ -1,6 +1,7 @@
package forge.game.ability.effects; package forge.game.ability.effects;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.game.Game; import forge.game.Game;
import forge.game.ability.AbilityKey; import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
@@ -41,12 +42,9 @@ public class ChaosEnsuesEffect extends SpellAbilityEffect {
for (final Card c : AbilityUtils.getDefinedCards(host, sa.getParam("Defined"), sa)) { for (final Card c : AbilityUtils.getDefinedCards(host, sa.getParam("Defined"), sa)) {
for (Trigger t : c.getTriggers()) { for (Trigger t : c.getTriggers()) {
if (t.getMode() == TriggerType.ChaosEnsues) { // also allow current zone for any Defined if (t.getMode() == TriggerType.ChaosEnsues) { // also allow current zone for any Defined
//String zones = t.getParam("TriggerZones"); Set<ZoneType> zones = t.getActiveZone();
//t.putParam("TriggerZones", zones + "," + c.getZone().getZoneType().toString()); tweakedTrigs.put(t.getId(), EnumSet.copyOf(zones));
EnumSet<ZoneType> zones = (EnumSet<ZoneType>) t.getActiveZone();
tweakedTrigs.put(t.getId(), zones);
zones.add(c.getZone().getZoneType()); zones.add(c.getZone().getZoneType());
t.setActiveZone(zones);
affected.add(c); affected.add(c);
game.getTriggerHandler().registerOneTrigger(t); game.getTriggerHandler().registerOneTrigger(t);
} }

View File

@@ -51,7 +51,6 @@ public class ClashEffect extends SpellAbilityEffect {
} }
} }
// Run triggers
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(player); final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(player);
runParams.put(AbilityKey.Won, player.equals(winner) ? "True" : "False"); runParams.put(AbilityKey.Won, player.equals(winner) ? "True" : "False");
source.getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams, false); source.getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams, false);

View File

@@ -34,7 +34,7 @@ public class RingTemptsYouEffect extends EffectEffect {
// Then choose a ring-bearer (You may keep the same one). Auto pick if <2 choices. // Then choose a ring-bearer (You may keep the same one). Auto pick if <2 choices.
CardCollection creatures = p.getCreaturesInPlay(); CardCollection creatures = p.getCreaturesInPlay();
Card ringBearer = p.getController().chooseSingleEntityForEffect(creatures, sa, Localizer.getInstance().getMessageorUseDefault("lblChooseRingBearer", "Choose your Ring-bearer"), false, null); Card ringBearer = p.getController().chooseSingleEntityForEffect(creatures, sa, Localizer.getInstance().getMessage("lblChooseRingBearer"), false, null);
p.setRingBearer(ringBearer); p.setRingBearer(ringBearer);
// 701.52a That creature becomes your Ring-bearer until another player gains control of it. // 701.52a That creature becomes your Ring-bearer until another player gains control of it.
@@ -52,7 +52,6 @@ public class RingTemptsYouEffect extends EffectEffect {
ringBearer.addLeavesPlayCommand(loseCommand); ringBearer.addLeavesPlayCommand(loseCommand);
} }
// Run triggers
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(p); final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(p);
runParams.put(AbilityKey.Card, ringBearer); runParams.put(AbilityKey.Card, ringBearer);
game.getTriggerHandler().runTrigger(TriggerType.RingTemptsYou, runParams, false); game.getTriggerHandler().runTrigger(TriggerType.RingTemptsYou, runParams, false);

View File

@@ -96,7 +96,7 @@ public class CostGainControl extends CostPartWithList {
*/ */
@Override @Override
public String getHashForLKIList() { public String getHashForLKIList() {
return "ControllGained"; // why the hell double "L"? return "ControlGained";
} }
@Override @Override
public String getHashForCardList() { public String getHashForCardList() {

View File

@@ -1,9 +1,9 @@
package forge.game.mana; package forge.game.mana;
import com.google.common.collect.Lists;
import forge.game.event.EventValueChangeType; import forge.game.event.EventValueChangeType;
import forge.game.event.GameEventZone; import forge.game.event.GameEventZone;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.player.PlayerCollection;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
@@ -20,7 +20,7 @@ public class ManaRefundService {
} }
public void refundManaPaid() { public void refundManaPaid() {
List<Player> payers = Lists.newArrayList(); PlayerCollection payers = new PlayerCollection(activator);
// move non-undoable paying mana back to floating // move non-undoable paying mana back to floating
for (Mana mana : sa.getPayingMana()) { for (Mana mana : sa.getPayingMana()) {
@@ -29,10 +29,8 @@ public class ManaRefundService {
: mana.getManaAbility().getSourceSA().getActivatingPlayer(); : mana.getManaAbility().getSourceSA().getActivatingPlayer();
pl.getManaPool().addMana(mana); pl.getManaPool().addMana(mana);
if (!payers.contains(pl)) {
payers.add(pl); payers.add(pl);
} }
}
sa.getPayingMana().clear(); sa.getPayingMana().clear();

View File

@@ -60,7 +60,6 @@ public abstract class PlayerController {
PlayOrDraw, PlayOrDraw,
OddsOrEvens, OddsOrEvens,
UntapOrLeaveTapped, UntapOrLeaveTapped,
UntapTimeVault,
LeftOrRight, LeftOrRight,
AddOrRemove, AddOrRemove,
} }

View File

@@ -380,13 +380,6 @@ public class StaticAbility extends CardTraitBase implements IIdentifiable, Clone
} }
} }
if (hasParam("UnlessDefinedPlayer")) {
List<Player> players = AbilityUtils.getDefinedPlayers(hostCard, getParam("UnlessDefinedPlayer"), this);
if (!players.isEmpty()) {
return false;
}
}
if (hasParam("TopCardOfLibraryIs")) { if (hasParam("TopCardOfLibraryIs")) {
if (controller.getCardsIn(ZoneType.Library).isEmpty()) { if (controller.getCardsIn(ZoneType.Library).isEmpty()) {
return false; return false;

View File

@@ -5,6 +5,6 @@ T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.S
SVar:TrigMonarch:DB$ BecomeMonarch | Defined$ You SVar:TrigMonarch:DB$ BecomeMonarch | Defined$ You
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigCloneCopy | TriggerDescription$ At the beginning of your upkeep, choose up to one other target enchantment or artifact. If you're the monarch, you may create a token that's a copy of it. If you're not the monarch, you may have CARDNAME become a copy of it, except it has this ability. T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigCloneCopy | TriggerDescription$ At the beginning of your upkeep, choose up to one other target enchantment or artifact. If you're the monarch, you may create a token that's a copy of it. If you're not the monarch, you may have CARDNAME become a copy of it, except it has this ability.
SVar:TrigCloneCopy:DB$ Clone | Optional$ True | GainThisAbility$ True | AddSVars$ TrigCloneCopy | TgtPrompt$ Select up to one other target enchantment or artifact | ValidTgts$ Artifact.Other,Enchantment.Other | TargetMin$ 0 | TargetMax$ 1 | ConditionCheckSVar$ X | ConditionSVarCompare$ LT1 | SubAbility$ DBCopy SVar:TrigCloneCopy:DB$ Clone | Optional$ True | GainThisAbility$ True | AddSVars$ TrigCloneCopy | TgtPrompt$ Select up to one other target enchantment or artifact | ValidTgts$ Artifact.Other,Enchantment.Other | TargetMin$ 0 | TargetMax$ 1 | ConditionCheckSVar$ X | ConditionSVarCompare$ LT1 | SubAbility$ DBCopy
SVar:DBCopy:DB$ CopyPermanent | Defined$ Targeted | ConditionCheckSVar$ X | ConditionSVarCompare$ GE1 SVar:DBCopy:DB$ CopyPermanent | Optional$ True | Defined$ Targeted | ConditionCheckSVar$ X | ConditionSVarCompare$ GE1
SVar:X:Count$Monarch.1.0 SVar:X:Count$Monarch.1.0
Oracle:When Court of Vantress enters, you become the monarch.\nAt the beginning of your upkeep, choose up to one other target enchantment or artifact. If you're the monarch, you may create a token that's a copy of it. If you're not the monarch, you may have Court of Vantress become a copy of it, except it has this ability. Oracle:When Court of Vantress enters, you become the monarch.\nAt the beginning of your upkeep, choose up to one other target enchantment or artifact. If you're the monarch, you may create a token that's a copy of it. If you're not the monarch, you may have Court of Vantress become a copy of it, except it has this ability.

View File

@@ -6,5 +6,5 @@ A:SP$ Attach | Cost$ 2 U | ValidTgts$ Creature | AILogic$ KeepTapped | AITgts$ C
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigTap | TriggerDescription$ When CARDNAME enters, tap enchanted creature and you become the monarch. T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigTap | TriggerDescription$ When CARDNAME enters, tap enchanted creature and you become the monarch.
SVar:TrigTap:DB$ Tap | Defined$ Enchanted | SubAbility$ DBMonarch SVar:TrigTap:DB$ Tap | Defined$ Enchanted | SubAbility$ DBMonarch
SVar:DBMonarch:DB$ BecomeMonarch | Defined$ You SVar:DBMonarch:DB$ BecomeMonarch | Defined$ You
S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddHiddenKeyword$ CARDNAME doesn't untap during your untap step. | UnlessDefinedPlayer$ EnchantedController.isMonarch | Description$ Enchanted creature doesn't untap during its controller's untap step unless that player is the monarch. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+ControlledBy EnchantedController.!isMonarch | AddHiddenKeyword$ CARDNAME doesn't untap during your untap step. | Description$ Enchanted creature doesn't untap during its controller's untap step unless that player is the monarch.
Oracle:Enchant creature\nWhen Fall from Favor enters, tap enchanted creature and you become the monarch.\nEnchanted creature doesn't untap during its controller's untap step unless that player is the monarch. Oracle:Enchant creature\nWhen Fall from Favor enters, tap enchanted creature and you become the monarch.\nEnchanted creature doesn't untap during its controller's untap step unless that player is the monarch.

View File

@@ -2,7 +2,7 @@ Name:Rhystic Cave
ManaCost:no cost ManaCost:no cost
Types:Land Types:Land
A:AB$ ChooseColor | Cost$ T | AILogic$ MostProminentInComputerDeck | SubAbility$ DBMana | InstantSpeed$ True | SpellDescription$ Choose a color. Add one mana of that color unless any player pays {1}. Activate only as an instant. A:AB$ ChooseColor | Cost$ T | AILogic$ MostProminentInComputerDeck | SubAbility$ DBMana | InstantSpeed$ True | SpellDescription$ Choose a color. Add one mana of that color unless any player pays {1}. Activate only as an instant.
SVar:DBMana:DB$ Mana | Produced$ Chosen | UnlessCost$ 1 | UnlessPayer$ Player | SubAbility$ DBCleanup | SpellDescription$ Add one mana of the chosen color. SVar:DBMana:DB$ Mana | Produced$ Chosen | UnlessCost$ 1 | UnlessPayer$ Player | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearChosenColor$ True SVar:DBCleanup:DB$ Cleanup | ClearChosenColor$ True
AI:RemoveDeck:All AI:RemoveDeck:All
Oracle:{T}: Choose a color. Add one mana of that color unless any player pays {1}. Activate only as an instant. Oracle:{T}: Choose a color. Add one mana of that color unless any player pays {1}. Activate only as an instant.

View File

@@ -1378,7 +1378,6 @@ lblUntap=Enttappen
lblOdds=Ungerade lblOdds=Ungerade
lblEvens=Gerade lblEvens=Gerade
lblLeaveTapped=Getappt lassen lblLeaveTapped=Getappt lassen
lblUntapAndSkipThisTurn=Enttappen (und Zug beenden)
lblLeft=Links lblLeft=Links
lblRight=Rechts lblRight=Rechts
lblAddCounter=Marke(n) hinzufügen lblAddCounter=Marke(n) hinzufügen

View File

@@ -1396,7 +1396,6 @@ lblUntap=Untap
lblOdds=Odds lblOdds=Odds
lblEvens=Evens lblEvens=Evens
lblLeaveTapped=Leave tapped lblLeaveTapped=Leave tapped
lblUntapAndSkipThisTurn=Untap (and skip this turn)
lblLeft=Left lblLeft=Left
lblRight=Right lblRight=Right
lblAddCounter=Add Counter lblAddCounter=Add Counter

View File

@@ -1387,7 +1387,6 @@ lblUntap=Enderezar
lblOdds=Impares lblOdds=Impares
lblEvens=Pares lblEvens=Pares
lblLeaveTapped=Dejar girado lblLeaveTapped=Dejar girado
lblUntapAndSkipThisTurn=Enderezar (y saltarse este turno)
lblLeft=Izquierda lblLeft=Izquierda
lblRight=Derecha lblRight=Derecha
lblAddCounter=Añadir contador lblAddCounter=Añadir contador

View File

@@ -1382,7 +1382,6 @@ lblUntap=Dégager
lblOdds=Cote lblOdds=Cote
lblEvens=Pairs lblEvens=Pairs
lblLeaveTapped=Laisser tapé lblLeaveTapped=Laisser tapé
lblUntapAndSkipThisTurn=Dégager (et sauter ce tour)
lblLeft=Gauche lblLeft=Gauche
lblRight=Droite lblRight=Droite
lblAddCounter=Ajouter un marqueur lblAddCounter=Ajouter un marqueur

View File

@@ -1379,7 +1379,6 @@ lblUntap=Stappa
lblOdds=Dispari lblOdds=Dispari
lblEvens=Pari lblEvens=Pari
lblLeaveTapped=Lascia tappato lblLeaveTapped=Lascia tappato
lblUntapAndSkipThisTurn=Stappa (e salta questo turno)
lblLeft=Sinistra lblLeft=Sinistra
lblRight=Destra lblRight=Destra
lblAddCounter=Aggiungi un segnalino lblAddCounter=Aggiungi un segnalino

View File

@@ -1380,7 +1380,6 @@ lblUntap=アンタップ
lblOdds=奇数 lblOdds=奇数
lblEvens=偶数 lblEvens=偶数
lblLeaveTapped=タップしない lblLeaveTapped=タップしない
lblUntapAndSkipThisTurn=アンタップ(そしてこのターンをスキップ)
lblLeft= lblLeft=
lblRight= lblRight=
lblAddCounter=カウンターを追加 lblAddCounter=カウンターを追加

View File

@@ -1410,7 +1410,6 @@ lblUntap=Desvirar
lblOdds=Ímpares lblOdds=Ímpares
lblEvens=Pares lblEvens=Pares
lblLeaveTapped=Deixar virado lblLeaveTapped=Deixar virado
lblUntapAndSkipThisTurn=Desvirar (e pular este turno)
lblLeft=Esquerda lblLeft=Esquerda
lblRight=Direita lblRight=Direita
lblAddCounter=Adicionar Marcador lblAddCounter=Adicionar Marcador

View File

@@ -1386,7 +1386,6 @@ lblUntap=重置
lblOdds=赔率 lblOdds=赔率
lblEvens=偶数 lblEvens=偶数
lblLeaveTapped=轻按一下 lblLeaveTapped=轻按一下
lblUntapAndSkipThisTurn=取消点击(并跳过当前回合)
lblLeft= lblLeft=
lblRight= lblRight=
lblAddCounter=增加指示物 lblAddCounter=增加指示物

View File

@@ -1630,9 +1630,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
case UntapOrLeaveTapped: case UntapOrLeaveTapped:
labels = ImmutableList.of(localizer.getMessage("lblUntap"), localizer.getMessage("lblLeaveTapped")); labels = ImmutableList.of(localizer.getMessage("lblUntap"), localizer.getMessage("lblLeaveTapped"));
break; break;
case UntapTimeVault:
labels = ImmutableList.of(localizer.getMessage("lblUntapAndSkipThisTurn"), localizer.getMessage("lblLeaveTapped"));
break;
case PlayOrDraw: case PlayOrDraw:
labels = ImmutableList.of(localizer.getMessage("lblPlay"), localizer.getMessage("lblDraw")); labels = ImmutableList.of(localizer.getMessage("lblPlay"), localizer.getMessage("lblDraw"));
break; break;