Cleanup + fixes (#1523)

* Fix activator

* Clean up
This commit is contained in:
tool4ever
2022-09-15 15:12:40 +00:00
committed by GitHub
parent 4270f371c7
commit 63f9cbd446
21 changed files with 36 additions and 44 deletions

View File

@@ -887,8 +887,7 @@ public class Game {
ingamePlayers.remove(p);
lostPlayers.add(p);
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Player, p);
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(p);
getTriggerHandler().runTrigger(TriggerType.LosesGame, runParams, false);
}
@@ -1202,8 +1201,7 @@ public class Game {
// If an effect allows or instructs a player to reveal the card as its being drawn,
// its revealed after the spell becomes cast or the ability becomes activated.
final Map<AbilityKey, Object> runParams = Maps.newHashMap();
runParams.put(AbilityKey.Card, c);
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(c);
runParams.put(AbilityKey.Number, facedownWhileCasting.get(c));
runParams.put(AbilityKey.Player, this);
runParams.put(AbilityKey.CanReveal, true);

View File

@@ -2238,8 +2238,7 @@ public class GameAction {
game.setMonarch(p);
// Run triggers
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Player, p);
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(p);
game.getTriggerHandler().runTrigger(TriggerType.BecomeMonarch, runParams, false);
}
@@ -2264,8 +2263,7 @@ public class GameAction {
// You can take the initiative even if you already have it
// Run triggers
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Player, p);
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(p);
game.getTriggerHandler().runTrigger(TriggerType.TakesInitiative, runParams, false);
}
@@ -2354,8 +2352,7 @@ public class GameAction {
if (cause != null) {
// set up triggers (but not actually do them until later)
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Player, p);
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(p);
runParams.put(AbilityKey.ScryNum, numLookedAt);
game.getTriggerHandler().runTrigger(TriggerType.Scry, runParams, false);
}

View File

@@ -39,7 +39,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
if (sa.hasParam("Toughness")) {
toughness = AbilityUtils.calculateAmount(host, sa.getParam("Toughness"), sa);
}
final Game game = sa.getActivatingPlayer().getGame();
final Game game = host.getGame();
// Every Animate event needs a unique time stamp
final long timestamp = game.getNextTimestamp();
@@ -142,7 +142,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
list = getTargetPlayers(sa).getCardsIn(ZoneType.Battlefield);
}
list = CardLists.getValidCards(list, valid, host.getController(), host, sa);
list = CardLists.getValidCards(list, valid, sa.getActivatingPlayer(), host, sa);
for (final Card c : list) {
doAnimate(c, sa, power, toughness, types, removeTypes, finalColors, keywords, removeKeywords,
@@ -170,6 +170,6 @@ public class AnimateAllEffect extends AnimateEffectBase {
addUntilCommand(sa, unanimate);
}
}
} // animateAllResolve
}
}

View File

@@ -55,7 +55,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
}
CardCollectionView cards = game.getCardsIn(zone);
cards = CardLists.getValidCards(cards, valid, host.getController(), host, sa);
cards = CardLists.getValidCards(cards, valid, activator, host, sa);
if (sa.usesTargeting()) {
final Player pl = sa.getTargets().getFirstTargetedPlayer();
@@ -80,7 +80,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
ZoneType.smartValueOf(sa.getParam("ValidZone2")) : zone;
if (sa.hasParam("ValidCards2")) {
cards = CardLists.getValidCards(game.getCardsIn(zone2), sa.getParam("ValidCards2"),
host.getController(), host, sa);
activator, host, sa);
if (sa.usesTargeting()) {
cards = CardLists.filterControlledBy(cards, sa.getTargets().getFirstTargetedPlayer());
}

View File

@@ -613,8 +613,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
&& !sa.hasParam("CounterTypes") && !sa.hasParam("ChooseDifferent")
&& !sa.hasParam("PutOnEachOther") && !sa.hasParam("PutOnDefined")) {
try {
counterType = chooseTypeFromList(sa, sa.getParam("CounterType"), null,
placer.getController());
counterType = chooseTypeFromList(sa, sa.getParam("CounterType"), null, placer.getController());
} catch (Exception e) {
System.out.println("Counter type doesn't match, nor does an SVar exist with the type name.");
return;

View File

@@ -52,7 +52,7 @@ public class CountersRemoveAllEffect extends SpellAbilityEffect {
final Game game = sa.getActivatingPlayer().getGame();
CardCollectionView cards = game.getCardsIn(zone);
cards = CardLists.getValidCards(cards, valid, sa.getHostCard().getController(), sa.getHostCard(), sa);
cards = CardLists.getValidCards(cards, valid, sa.getActivatingPlayer(), sa.getHostCard(), sa);
if (sa.usesTargeting()) {
final Player pl = sa.getTargets().getFirstTargetedPlayer();

View File

@@ -83,7 +83,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
if (sa.hasParam("Optional")) {
String ctrs = cntToRemove > 1 ? Localizer.getInstance().getMessage("lblCounters") : num.equals("All") ? Localizer.getInstance().getMessage("lblAllCounters") : Localizer.getInstance().getMessage("lblACounters");
if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblRemove") + " " + ctrs + "?", null)) {
if (!pc.confirmAction(sa, null, Localizer.getInstance().getMessage("lblRemove") + " " + ctrs + "?", null)) {
return;
}
}
@@ -133,7 +133,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
if (num.equals("Any")) {
Map<String, Object> params = Maps.newHashMap();
params.put("CounterType", counterType);
srcCards = player.getController().chooseCardsForEffect(srcCards, sa, title, 0, srcCards.size(), true, params);
srcCards = pc.chooseCardsForEffect(srcCards, sa, title, 0, srcCards.size(), true, params);
}
} else if (sa.hasParam("Choices") && counterType != null) {
ZoneType choiceZone = sa.hasParam("ChoiceZone") ? ZoneType.smartValueOf(sa.getParam("ChoiceZone"))

View File

@@ -65,7 +65,7 @@ public class DamageEachEffect extends DamageBaseEffect {
FCollectionView<Card> sources = game.getCardsIn(ZoneType.Battlefield);
if (sa.hasParam("ValidCards")) {
sources = CardLists.getValidCards(sources, sa.getParam("ValidCards"), card.getController(), card, sa);
sources = CardLists.getValidCards(sources, sa.getParam("ValidCards"), sa.getActivatingPlayer(), card, sa);
}
final List<GameObject> tgts = getTargets(sa, "DefinedPlayers");
@@ -121,7 +121,7 @@ public class DamageEachEffect extends DamageBaseEffect {
final int dmg = AbilityUtils.calculateAmount(source, "X", sa);
final Card sourceLKI = source.getGame().getChangeZoneLKIInfo(source);
for (final Object o : sa.getHostCard().getRemembered()) {
for (final Object o : card.getRemembered()) {
if (o instanceof Card) {
Card rememberedcard = (Card) o;
damageMap.put(sourceLKI, rememberedcard, dmg);

View File

@@ -37,7 +37,7 @@ public class UntapAllEffect extends SpellAbilityEffect {
}
list = list2;
}
list = CardLists.getValidCards(list, valid, card.getController(), card, sa);
list = CardLists.getValidCards(list, valid, sa.getActivatingPlayer(), card, sa);
boolean remember = sa.hasParam("RememberUntapped");
for (Card c : list) {

View File

@@ -300,9 +300,9 @@ public class ManaCostBeingPaid {
}
int otherSubtract = manaToSubtract;
List<ManaCostShard> toRemove = Lists.newArrayList();
//TODO move that for parts into extra function if able
// try to remove multicolored hybrid shards
// for that, this shard need to be mono colored
if (shard.isMonoColor()) {
@@ -387,15 +387,14 @@ public class ManaCostBeingPaid {
}
}
}
unpaidShards.keySet().removeAll(toRemove);
//System.out.println("Tried to substract a " + shard.toString() + " shard that is not present in this ManaCostBeingPaid");
return;
}
int difference = manaToSubtract - sc.totalCount;
int difference = manaToSubtract - sc.totalCount;
if (manaToSubtract >= sc.totalCount) {
sc.xCount = 0;
sc.totalCount = 0;

View File

@@ -1605,9 +1605,8 @@ public class Player extends GameEntity implements Comparable<Player> {
}
// MilledAll trigger
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(this);
runParams.put(AbilityKey.Cards, milled);
runParams.put(AbilityKey.Player, this);
game.getTriggerHandler().runTrigger(TriggerType.MilledAll, runParams, false);
return milled;