Refactor: replaced sourceId by source and introduced source param in some methods;

This commit is contained in:
Oleg Agafonov 2020-12-12 20:23:19 +04:00
parent 2bb472607b
commit db239a1055
3205 changed files with 7080 additions and 6795 deletions

View file

@ -87,7 +87,7 @@ public class TestCardRenderDialog extends MageDialog {
game.loadCards(cardsList, controllerId);
PermanentCard perm = new PermanentCard(card, controllerId, game);
if (damage > 0) perm.damage(damage, controllerId, game);
if (damage > 0) perm.damage(damage, controllerId, null, game);
if (power > 0) perm.getPower().setValue(power);
if (toughness > 0) perm.getToughness().setValue(toughness);
perm.removeSummoningSickness();

View file

@ -94,7 +94,7 @@ public class PermanentView extends CardView {
if (permanent.isFaceDown(game) && card != null) {
if (controlled) {
// must be a morphed or manifested card
for (Ability permanentAbility : permanent.getAbilities()) {
for (Ability permanentAbility : permanent.getAbilities(game)) {
if (permanentAbility.getWorksFaceDown()) {
this.rules.add(permanentAbility.getRule(true));
} else if (permanentAbility instanceof TurnFaceUpAbility && !permanentAbility.getRuleVisible()) {

View file

@ -161,7 +161,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
for (UUID id : target.getTargets()) {
target.updateTarget(id, game);
if (!target.isNotTarget()) {
game.addSimultaneousEvent(GameEvent.getEvent(GameEvent.EventType.TARGETED, id, ability.getSourceId(), ability.getControllerId()));
game.addSimultaneousEvent(GameEvent.getEvent(GameEvent.EventType.TARGETED, id, ability, ability.getControllerId()));
}
}
}
@ -910,7 +910,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
}
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
logger.debug("selectBlockers");
declareBlockers(game, playerId);
}

View file

@ -398,7 +398,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
logger.debug("simulating -- triggered ability:" + ability);
game.getStack().push(new StackAbility(ability, playerId));
if (ability.activate(game, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability, ability.getControllerId()));
}
game.applyEffects();
game.getPlayers().resetPassed();
@ -420,7 +420,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
Game sim = game.copy();
sim.getStack().push(new StackAbility(ability, playerId));
if (ability.activate(sim, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability, ability.getControllerId()));
}
sim.applyEffects();
SimulationNode2 newNode = new SimulationNode2(parent, sim, depth, playerId);

View file

@ -68,14 +68,14 @@ public final class ArtificialScoringSystem {
int score = permanent.getCounters(game).getCount(CounterType.CHARGE) * 30;
score += permanent.getCounters(game).getCount(CounterType.LEVEL) * 30;
score -= permanent.getDamage() * 2;
if (!canTap(permanent)) {
if (!canTap(permanent, game)) {
score += getTappedScore(permanent);
}
if (permanent.getCardType().contains(CardType.CREATURE)) {
final int power = permanent.getPower().getValue();
final int toughness = permanent.getToughness().getValue();
int abilityScore = 0;
for (Ability ability : permanent.getAbilities()) {
for (Ability ability : permanent.getAbilities(game)) {
abilityScore += MagicAbility.getAbilityScore(ability);
}
score += power * 300 + getPositive(toughness) * 200 + abilityScore * (getPositive(power) + 1) / 2;
@ -85,7 +85,7 @@ public final class ArtificialScoringSystem {
MageObject object = game.getObject(uuid);
if (object instanceof Card) {
Card card = (Card) object;
int outcomeScore = object.getAbilities().getOutcomeTotal();
int outcomeScore = card.getAbilities(game).getOutcomeTotal();
if (card.getCardType().contains(CardType.ENCHANTMENT)) {
enchantments = enchantments + outcomeScore * 100;
} else {
@ -106,15 +106,15 @@ public final class ArtificialScoringSystem {
return score;
}
private static boolean canTap(Permanent permanent) {
private static boolean canTap(Permanent permanent, Game game) {
return !permanent.isTapped()
&& (!permanent.hasSummoningSickness()
|| !permanent.getCardType().contains(CardType.CREATURE)
|| permanent.getAbilities().contains(HasteAbility.getInstance()));
|| permanent.getAbilities(game).contains(HasteAbility.getInstance()));
}
private static int getPositive(int value) {
return value > 0 ? value : 0;
return Math.max(0, value);
}
public static int getTappedScore(final Permanent permanent) {

View file

@ -354,28 +354,6 @@ public final class CombatUtil {
if (attacker.getToughness().getValue() <= blocker.getPower().getValue()) {
sim.getBattlefield().removePermanent(attacker.getId());
}
/*
sim.getPlayer(defendingPlayerId).declareBlocker(blocker.getId(), attacker.getId(), sim);
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defendingPlayerId, defendingPlayerId));
sim.checkStateAndTriggered();
while (!sim.getStack().isEmpty()) {
sim.getStack().resolve(sim);
sim.applyEffects();
}
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKERS_STEP_POST, sim.getActivePlayerId(), sim.getActivePlayerId()));
simulateStep(sim, new FirstCombatDamageStep());
simulateStep(sim, new CombatDamageStep());
simulateStep(sim, new EndOfCombatStep());
// The following commented out call produces random freezes.
//sim.checkStateAndTriggered();
while (!sim.getStack().isEmpty()) {
sim.getStack().resolve(sim);
sim.applyEffects();
}
*/
return new SurviveInfo(!sim.getBattlefield().containsPermanent(attacker.getId()), !sim.getBattlefield().containsPermanent(blocker.getId()));
}

View file

@ -9,6 +9,8 @@ import mage.ConditionalMana;
import mage.MageObject;
import mage.Mana;
import mage.abilities.*;
import mage.abilities.costs.AlternativeSourceCosts;
import mage.abilities.costs.OptionalAdditionalSourceCosts;
import mage.abilities.costs.VariableCost;
import mage.abilities.costs.mana.*;
import mage.abilities.effects.Effect;
@ -1238,7 +1240,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
if (!isTestMode()) { // Test player already sends target event as they select the target
for (Target target : ability.getModes().getMode().getTargets()) {
for (UUID targetId : target.getTargets()) {
game.fireEvent(GameEvent.getEvent(EventType.TARGETED, targetId, ability.getId(), ability.getControllerId()));
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TARGETED, targetId, ability, ability.getControllerId()));
}
}
}
@ -1250,10 +1252,17 @@ public class ComputerPlayer extends PlayerImpl implements Player {
Set<Card> lands = new LinkedHashSet<>();
for (Card landCard : hand.getCards(new FilterLandCard(), game)) {
// remove lands that can not be played
if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, landCard.getId(), landCard.getId(), playerId), null, game, true)) {
break;
boolean canPlay = false;
for (Ability ability : landCard.getAbilities(game)) {
if (ability instanceof PlayLandAbility) {
if (!game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, landCard.getId(), ability, playerId), null, game, true)) {
canPlay = true;
}
}
}
if (canPlay) {
lands.add(landCard);
}
lands.add(landCard);
}
while (!lands.isEmpty() && this.canPlayLand()) {
if (lands.size() == 1) {
@ -1321,7 +1330,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
if (mana.enough(avail)) {
SpellAbility ability = card.getSpellAbility();
if (ability != null && ability.canActivate(playerId, game).canActivate()
&& !game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getSourceId(), ability.getSourceId(), playerId), ability, game, true)) {
&& !game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getSourceId(), ability, playerId), ability, game, true)) {
if (card.getCardType().contains(CardType.INSTANT)
|| card.hasAbility(FlashAbility.getInstance(), game)) {
playableInstant.add(card);
@ -1534,7 +1543,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
// pay phyrexian life costs
if (cost instanceof PhyrexianManaCost) {
return cost.pay(null, game, null, playerId, false, null) || approvingObject != null;
return cost.pay(ability, game, ability, playerId, false, null) || approvingObject != null;
}
// pay special mana like convoke cost (tap for pay)
@ -1899,7 +1908,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
log.debug("selectBlockers");
List<Permanent> blockers = getAvailableBlockers(game);
@ -1955,10 +1964,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
@Override
public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID attackerId, Ability source, Game game) {
log.debug("assignDamage");
//TODO: improve this
game.getPermanent(targets.get(0)).damage(damage, sourceId, game);
game.getPermanent(targets.get(0)).damage(damage, attackerId, source, game);
}
@Override

View file

@ -194,7 +194,7 @@ public class ComputerPlayerMCTS extends ComputerPlayer implements Player {
}
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
StringBuilder sb = new StringBuilder();
sb.append(game.getTurn().getValue(game.getTurnNum())).append(" player ").append(name).append(" blocking: ");
getNextAction(game, NextAction.SELECT_BLOCKERS);
@ -219,41 +219,6 @@ public class ComputerPlayerMCTS extends ComputerPlayer implements Player {
MCTSNode.logHitMiss();
}
// @Override
// public UUID chooseAttackerOrder(List<Permanent> attacker, Game game) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
//
// @Override
// public UUID chooseBlockerOrder(List<Permanent> blockers, Game game) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
//
// @Override
// public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
//
// @Override
// public int getAmount(int min, int max, String message, Game game) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
//
// @Override
// public void sideboard(Match match, Deck deck) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
//
// @Override
// public void construct(Tournament tournament, Deck deck) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
//
// @Override
// public void pickCard(List<Card> cards, Deck deck, Draft draft) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
protected long totalThinkTime = 0;
protected long totalSimulations = 0;

View file

@ -178,74 +178,11 @@ public class MCTSPlayer extends ComputerPlayer {
@Override
public boolean priority(Game game) {
// logger.info("Paused for Priority for player:" + getName());
game.pause();
nextAction = NextAction.PRIORITY;
return false;
}
// @Override
// public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
// game.end();
// }
//
// @Override
// public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
// game.end();
// }
//
// @Override
// public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
// game.end();
// }
//
// @Override
// public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
// game.end();
// }
//
// @Override
// public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
// game.end();
// }
//
// @Override
// public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
// game.end();
// }
//
// @Override
// public boolean chooseMulligan(Game game) {
// game.end();
// }
//
// @Override
// public boolean chooseUse(Outcome outcome, String message, Game game) {
// game.pause();
// nextAction = NextAction.CHOOSE_USE;
// return false;
// }
//
// @Override
// public boolean choose(Outcome outcome, Choice choice, Game game) {
// game.end();
// }
//
// @Override
// public int chooseEffect(List<ReplacementEffect> rEffects, Game game) {
// game.end();
// }
//
// @Override
// public TriggeredAbility chooseTriggeredAbility(TriggeredAbilities abilities, Game game) {
// game.end();
// }
//
// @Override
// public Mode chooseMode(Modes modes, Ability source, Game game) {
// game.end();
// }
@Override
public void selectAttackers(Game game, UUID attackingPlayerId) {
game.pause();
@ -253,29 +190,8 @@ public class MCTSPlayer extends ComputerPlayer {
}
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
game.pause();
nextAction = NextAction.SELECT_BLOCKERS;
}
// @Override
// public UUID chooseAttackerOrder(List<Permanent> attacker, Game game) {
// game.end();
// }
//
// @Override
// public UUID chooseBlockerOrder(List<Permanent> blockers, Game game) {
// game.end();
// }
//
// @Override
// public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
// game.end();
// }
//
// @Override
// public int getAmount(int min, int max, String message, Game game) {
// game.end();
// }
}

View file

@ -133,7 +133,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
if (ability.isUsesStack()) {
game.getStack().push(new StackAbility(ability, playerId));
if (ability.activate(game, false)) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability, ability.getControllerId()));
actionCount++;
return true;
}
@ -174,7 +174,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
}
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
// logger.info("select blockers");
int numGroups = game.getCombat().getGroups().size();
if (numGroups == 0) {
@ -403,7 +403,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
}
@Override
public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID attackerId, Ability source, Game game) {
if (this.isHuman()) {
int remainingDamage = damage;
UUID targetId;
@ -418,19 +418,19 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
}
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(amount, sourceId, game, false, true);
permanent.damage(amount, attackerId, source, game, false, true);
remainingDamage -= amount;
} else {
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(amount, sourceId, game);
player.damage(amount, attackerId, source, game);
remainingDamage -= amount;
}
}
targets.remove(targetId);
}
} else {
super.assignDamage(damage, targets, singleTargetName, sourceId, game);
super.assignDamage(damage, targets, singleTargetName, attackerId, source, game);
}
}

View file

@ -642,7 +642,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
}
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
logger.debug("selectBlockers");
if (combat != null && !combat.getGroups().isEmpty()) {
List<CombatGroup> groups = game.getCombat().getGroups();

View file

@ -214,7 +214,7 @@ public class SimulatedPlayer extends ComputerPlayer {
logger.debug("simulating -- triggered ability:" + ability);
game.getStack().push(new StackAbility(ability, playerId));
if (ability.activate(game, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability, ability.getControllerId()));
}
game.applyEffects();
game.getPlayers().resetPassed();
@ -235,7 +235,7 @@ public class SimulatedPlayer extends ComputerPlayer {
sim.getStack().push(new StackAbility(ability, playerId));
ability.activate(sim, false);
if (ability.activate(sim, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability, ability.getControllerId()));
}
sim.applyEffects();
SimulationNode newNode = new SimulationNode(parent, sim, playerId);

View file

@ -42,6 +42,7 @@ import mage.game.Game;
import mage.game.GameImpl;
import mage.game.combat.CombatGroup;
import mage.game.draft.Draft;
import mage.game.events.DeclareAttackerEvent;
import mage.game.events.GameEvent;
import mage.game.match.Match;
import mage.game.permanent.Permanent;
@ -1464,8 +1465,7 @@ public class HumanPlayer extends PlayerImpl {
}
for (Permanent attacker : game.getBattlefield().getAllActivePermanents(filterCreatureForCombat, getId(), game)) {
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
attackedDefender, attacker.getId(), attacker.getControllerId()), game)) {
new DeclareAttackerEvent(attackedDefender, attacker.getId(), attacker.getControllerId()), game)) {
continue;
}
// if attacker needs a specific defender to attack so select that one instead
@ -1560,8 +1560,7 @@ public class HumanPlayer extends PlayerImpl {
for (Permanent attacker : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getId(), game)) {
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
forcedToAttackId, attacker.getId(), attacker.getControllerId()), game)) {
new DeclareAttackerEvent(forcedToAttackId, attacker.getId(), attacker.getControllerId()), game)) {
continue;
}
// if attacker needs a specific defender to attack so select that one instead
@ -1657,7 +1656,7 @@ public class HumanPlayer extends PlayerImpl {
}
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
if (gameInCheckPlayableState(game)) {
return;
}
@ -1813,7 +1812,7 @@ public class HumanPlayer extends PlayerImpl {
}
@Override
public void assignDamage(int damage, java.util.List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
public void assignDamage(int damage, java.util.List<UUID> targets, String singleTargetName, UUID attackerId, Ability source, Game game) {
updateGameStatePriority("assignDamage", game);
int remainingDamage = damage;
while (remainingDamage > 0 && canRespond()) {
@ -1822,17 +1821,17 @@ public class HumanPlayer extends PlayerImpl {
if (singleTargetName != null) {
target.setTargetName(singleTargetName);
}
choose(Outcome.Damage, target, sourceId, game);
choose(Outcome.Damage, target, source.getSourceId(), game);
if (targets.isEmpty() || targets.contains(target.getFirstTarget())) {
int damageAmount = getAmount(0, remainingDamage, "Select amount", game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.damage(damageAmount, sourceId, game, false, true);
permanent.damage(damageAmount, attackerId, source, game, false, true);
remainingDamage -= damageAmount;
} else {
Player player = game.getPlayer(target.getFirstTarget());
if (player != null) {
player.damage(damageAmount, sourceId, game);
player.damage(damageAmount, attackerId, source, game);
remainingDamage -= damageAmount;
}
}

View file

@ -3,8 +3,10 @@ package mage.server.util;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.InfoEffect;
import mage.cards.Card;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
@ -245,10 +247,6 @@ public final class SystemUtil {
return com;
}
public static void addCardsForTesting(Game game) {
addCardsForTesting(game, null, null);
}
/**
* Replaces cards in player's hands by specified in config/init.txt.<br/>
* <br/>
@ -268,6 +266,10 @@ public final class SystemUtil {
*/
public static void addCardsForTesting(Game game, String fileSource, Player feedbackPlayer) {
// fake test ability for triggers and events
Ability fakeSourceAbility = new SimpleStaticAbility(Zone.OUTSIDE, new InfoEffect("adding testing cards"));
fakeSourceAbility.setControllerId(feedbackPlayer.getId());
try {
String fileName = fileSource;
if (fileName == null) {
@ -341,31 +343,25 @@ public final class SystemUtil {
// need to ask
logger.info("Found " + groups.size() + " groups. Need to select.");
if (feedbackPlayer != null) {
// choice dialog
Map<String, String> list = new LinkedHashMap<>();
Map<String, Integer> sort = new LinkedHashMap<>();
for (Integer i = 0; i < groups.size(); i++) {
list.put(Integer.toString(i + 1), groups.get(i).getPrintNameWithStats());
sort.put(Integer.toString(i + 1), i);
}
Choice groupChoice = new ChoiceImpl(false);
groupChoice.setMessage("Choose commands group to run");
groupChoice.setKeyChoices(list);
groupChoice.setSortData(sort);
if (feedbackPlayer.choose(Outcome.Benefit, groupChoice, game)) {
String need = groupChoice.getChoiceKey();
if ((need != null) && list.containsKey(need)) {
runGroup = groups.get(Integer.parseInt(need) - 1);
}
}
} else {
// select default
runGroup = groups.get(0);
// choice dialog
Map<String, String> list = new LinkedHashMap<>();
Map<String, Integer> sort = new LinkedHashMap<>();
for (int i = 0; i < groups.size(); i++) {
list.put(Integer.toString(i + 1), groups.get(i).getPrintNameWithStats());
sort.put(Integer.toString(i + 1), i);
}
Choice groupChoice = new ChoiceImpl(false);
groupChoice.setMessage("Choose commands group to run");
groupChoice.setKeyChoices(list);
groupChoice.setSortData(sort);
if (feedbackPlayer.choose(Outcome.Benefit, groupChoice, game)) {
String need = groupChoice.getChoiceKey();
if ((need != null) && list.containsKey(need)) {
runGroup = groups.get(Integer.parseInt(need) - 1);
}
}
}
if (runGroup == null) {
@ -381,85 +377,79 @@ public final class SystemUtil {
Player opponent = game.getPlayer(game.getOpponents(feedbackPlayer.getId()).iterator().next());
String info;
switch (runGroup.name) {
case COMMAND_SHOW_OPPONENT_HAND:
if (opponent != null) {
String info = getCardsListForSpecialInform(game, opponent.getHand(), runGroup.commands);
info = getCardsListForSpecialInform(game, opponent.getHand(), runGroup.commands);
game.informPlayer(feedbackPlayer, info);
}
break;
case COMMAND_SHOW_OPPONENT_LIBRARY:
if (opponent != null) {
String info = getCardsListForSpecialInform(game, opponent.getLibrary().getCardList(), runGroup.commands);
info = getCardsListForSpecialInform(game, opponent.getLibrary().getCardList(), runGroup.commands);
game.informPlayer(feedbackPlayer, info);
}
break;
case COMMAND_SHOW_MY_HAND:
if (feedbackPlayer != null) {
String info = getCardsListForSpecialInform(game, feedbackPlayer.getHand(), runGroup.commands);
info = getCardsListForSpecialInform(game, feedbackPlayer.getHand(), runGroup.commands);
game.informPlayer(feedbackPlayer, info);
}
break;
case COMMAND_SHOW_MY_LIBRARY:
if (feedbackPlayer != null) {
String info = getCardsListForSpecialInform(game, feedbackPlayer.getLibrary().getCardList(), runGroup.commands);
info = getCardsListForSpecialInform(game, feedbackPlayer.getLibrary().getCardList(), runGroup.commands);
game.informPlayer(feedbackPlayer, info);
}
break;
case COMMAND_ACTIVATE_OPPONENT_ABILITY:
// WARNING, maybe very bugged if called in wrong priority
// uses choose triggered ability dialog to select it
if (feedbackPlayer != null) {
UUID savedPriorityPlayer = null;
if (game.getActivePlayerId() != opponent.getId()) {
savedPriorityPlayer = game.getActivePlayerId();
}
UUID savedPriorityPlayer = null;
if (game.getActivePlayerId() != opponent.getId()) {
savedPriorityPlayer = game.getActivePlayerId();
}
// change active player to find and play selected abilities (it's danger and buggy code)
if (savedPriorityPlayer != null) {
game.getState().setPriorityPlayerId(opponent.getId());
game.firePriorityEvent(opponent.getId());
}
// change active player to find and play selected abilities (it's danger and buggy code)
if (savedPriorityPlayer != null) {
game.getState().setPriorityPlayerId(opponent.getId());
game.firePriorityEvent(opponent.getId());
}
List<ActivatedAbility> abilities = opponent.getPlayable(game, true);
Map<String, String> choices = new HashMap<>();
abilities.forEach(ability -> {
MageObject object = ability.getSourceObject(game);
choices.put(ability.getId().toString(), object.getName() + ": " + ability.toString());
});
// TODO: set priority for us?
Choice choice = new ChoiceImpl();
choice.setMessage("Choose playable ability to activate by opponent " + opponent.getName());
choice.setKeyChoices(choices);
if (feedbackPlayer.choose(Outcome.Detriment, choice, game) && choice.getChoiceKey() != null) {
String needId = choice.getChoiceKey();
Optional<ActivatedAbility> ability = abilities.stream().filter(a -> a.getId().toString().equals(needId)).findFirst();
if (ability.isPresent()) {
// TODO: set priority for player?
ActivatedAbility activatedAbility = ability.get();
game.informPlayers(feedbackPlayer.getLogName() + " as another player " + opponent.getLogName()
+ " trying to force an activate ability: " + activatedAbility.getGameLogMessage(game));
if (opponent.activateAbility(activatedAbility, game)) {
game.informPlayers("Force to activate ability: DONE");
} else {
game.informPlayers("Force to activate ability: FAIL");
}
List<ActivatedAbility> abilities = opponent.getPlayable(game, true);
Map<String, String> choices = new HashMap<>();
abilities.forEach(ability -> {
MageObject object = ability.getSourceObject(game);
choices.put(ability.getId().toString(), object.getName() + ": " + ability.toString());
});
// TODO: set priority for us?
Choice choice = new ChoiceImpl();
choice.setMessage("Choose playable ability to activate by opponent " + opponent.getName());
choice.setKeyChoices(choices);
if (feedbackPlayer.choose(Outcome.Detriment, choice, game) && choice.getChoiceKey() != null) {
String needId = choice.getChoiceKey();
Optional<ActivatedAbility> ability = abilities.stream().filter(a -> a.getId().toString().equals(needId)).findFirst();
if (ability.isPresent()) {
// TODO: set priority for player?
ActivatedAbility activatedAbility = ability.get();
game.informPlayers(feedbackPlayer.getLogName() + " as another player " + opponent.getLogName()
+ " trying to force an activate ability: " + activatedAbility.getGameLogMessage(game));
if (opponent.activateAbility(activatedAbility, game)) {
game.informPlayers("Force to activate ability: DONE");
} else {
game.informPlayers("Force to activate ability: FAIL");
}
}
// restore original priority player
if (savedPriorityPlayer != null) {
game.getState().setPriorityPlayerId(savedPriorityPlayer);
game.firePriorityEvent(savedPriorityPlayer);
}
}
// restore original priority player
if (savedPriorityPlayer != null) {
game.getState().setPriorityPlayerId(savedPriorityPlayer);
game.firePriorityEvent(savedPriorityPlayer);
}
break;
}
return;
}
@ -508,7 +498,7 @@ public final class SystemUtil {
Constructor<?> cons = c.getConstructor();
Object token = cons.newInstance();
if (token instanceof mage.game.permanent.token.Token) {
((mage.game.permanent.token.Token) token).putOntoBattlefield(command.Amount, game, null, player.getId(), false, false);
((mage.game.permanent.token.Token) token).putOntoBattlefield(command.Amount, game, fakeSourceAbility, player.getId(), false, false);
continue;
}
} else if ("emblem".equalsIgnoreCase(command.zone)) {
@ -528,7 +518,7 @@ public final class SystemUtil {
} else if ("loyalty".equalsIgnoreCase(command.zone)) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(player.getId())) {
if (perm.getName().equals(command.cardName) && perm.getCardType().contains(CardType.PLANESWALKER)) {
perm.addCounters(CounterType.LOYALTY.createInstance(command.Amount), null, game);
perm.addCounters(CounterType.LOYALTY.createInstance(command.Amount), fakeSourceAbility, game);
}
}
continue;
@ -551,7 +541,7 @@ public final class SystemUtil {
// move card from exile to stack
for (Card card : cardsToLoad) {
putCardToZone(game, player, card, Zone.STACK);
putCardToZone(fakeSourceAbility, game, player, card, Zone.STACK);
}
continue;
@ -626,7 +616,7 @@ public final class SystemUtil {
} else {
// as other card
for (Card card : cardsToLoad) {
putCardToZone(game, player, card, gameZone);
putCardToZone(fakeSourceAbility, game, player, card, gameZone);
}
}
}
@ -636,13 +626,14 @@ public final class SystemUtil {
}
/**
* Put card to specified (battlefield zone will be tranformed to permanent with initialized effects)
* Put card to specified zone (battlefield zone will be tranformed to permanent with initialized effects)
* Use it for cheats and tests only
*/
private static void putCardToZone(Game game, Player player, Card card, Zone zone) {
private static void putCardToZone(Ability source, Game game, Player player, Card card, Zone zone) {
// TODO: replace by player.move?
switch (zone) {
case BATTLEFIELD:
CardUtil.putCardOntoBattlefieldWithEffects(game, card, player);
CardUtil.putCardOntoBattlefieldWithEffects(source, game, card, player);
break;
case LIBRARY:
card.setZone(Zone.LIBRARY, game);

View file

@ -73,7 +73,7 @@ class AbolisherOfBloodlinesAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.TRANSFORMED;
return event.getType() == GameEvent.EventType.TRANSFORMED;
}
@Override

View file

@ -49,8 +49,8 @@ class AborothCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId);
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.addCounters(CounterType.M1M1.createInstance(), ability, game);
this.paid = true;
@ -60,7 +60,7 @@ class AborothCost extends CostImpl {
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
return true;
}

View file

@ -59,13 +59,13 @@ class AbyssalPersecutorCannotWinEffect extends ContinuousRuleModifyingEffectImpl
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.LOSES || event.getType() == EventType.WINS ;
return event.getType() == GameEvent.EventType.LOSES || event.getType() == GameEvent.EventType.WINS ;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ((event.getType() == EventType.LOSES && game.getOpponents(source.getControllerId()).contains(event.getPlayerId()))
|| (event.getType() == EventType.WINS && event.getPlayerId().equals(source.getControllerId()))) {
if ((event.getType() == GameEvent.EventType.LOSES && game.getOpponents(source.getControllerId()).contains(event.getPlayerId()))
|| (event.getType() == GameEvent.EventType.WINS && event.getPlayerId().equals(source.getControllerId()))) {
return true;
}
return false;

View file

@ -78,7 +78,7 @@ class AcademyResearchersEffect extends OneShotEffect {
if (auraInHand != null) {
game.getState().setValue("attachTo:" + auraInHand.getId(), academyResearchers);
controller.moveCards(auraInHand, Zone.BATTLEFIELD, source, game);
if (academyResearchers.addAttachment(auraInHand.getId(), game)) {
if (academyResearchers.addAttachment(auraInHand.getId(), source, game)) {
game.informPlayers(controller.getLogName() + " put " + auraInHand.getLogName() + " on the battlefield attached to " + academyResearchers.getLogName() + '.');
return true;
}

View file

@ -85,7 +85,7 @@ class AccursedWitchReturnTransformedEffect extends OneShotEffect {
Card card = game.getCard(source.getSourceId());
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
attachTo.addAttachment(card.getId(), game);
attachTo.addAttachment(card.getId(), source, game);
}
}
return true;

View file

@ -61,7 +61,7 @@ class AcidicSoilEffect extends OneShotEffect {
}
}
if (amount > 0) {
player.damage(amount, source.getSourceId(), game);
player.damage(amount, source.getSourceId(), source, game);
}
}
}

View file

@ -11,6 +11,7 @@ import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.events.PreventDamageEvent;
import mage.game.events.PreventedDamageEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
@ -83,11 +84,11 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
} else {
amount = 0;
}
GameEvent preventEvent = new PreventDamageEvent(source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent, ((DamageEvent) event).isCombatDamage());
GameEvent preventEvent = new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), toPrevent, ((DamageEvent) event).isCombatDamage());
if (game.replaceEvent(preventEvent)) {
return result;
}
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
Permanent targetCreature = game.getPermanent(event.getTargetId());
if (targetCreature == null) {
return result;
}
@ -105,12 +106,11 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
return result;
}
game.informPlayers("Acolyte's Reward prevented " + toPrevent + " to " + targetCreature.getName());
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
game.fireEvent(new PreventedDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), toPrevent));
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (targetPlayer != null) {
targetPlayer.damage(toPrevent, source.getSourceId(), game);
targetPlayer.damage(toPrevent, source.getSourceId(), source, game);
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetPlayer.getLogName());
return result;
}
@ -118,7 +118,7 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
if (targetDamageCreature == null) {
return result;
}
targetDamageCreature.damage(toPrevent, source.getSourceId(), game, false, true);
targetDamageCreature.damage(toPrevent, source.getSourceId(), source, game, false, true);
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetDamageCreature.getName());
return result;
}

View file

@ -72,7 +72,7 @@ class AcornCatapultEffect extends OneShotEffect {
}
if (player != null) {
new SquirrelToken().putOntoBattlefield(1, game, source.getSourceId(), player.getId());
new SquirrelToken().putOntoBattlefield(1, game, source, player.getId());
return true;
}

View file

@ -105,7 +105,7 @@ class ActOfAuthorityGainControlEffect extends ContinuousEffectImpl {
permanent = game.getPermanent(targetPointer.getFirst(game, source));
}
if (permanent != null) {
return permanent.changeControllerId(controller, game);
return permanent.changeControllerId(controller, game, source);
}
return false;
}

View file

@ -68,7 +68,7 @@ class AdNauseamEffect extends OneShotEffect {
controller.moveCards(card, Zone.HAND, source, game);
int cmc = card.getConvertedManaCost();
if (cmc > 0) {
controller.loseLife(cmc, game, false);
controller.loseLife(cmc, game, source, false);
}
controller.revealCards(sourceCard.getIdName() + " put into hand", new CardsImpl(card), game);

View file

@ -44,9 +44,9 @@ public final class AdamaroFirstToDesire extends CardImpl {
class MostCardsInOpponentsHandCount implements DynamicValue {
@Override
public int calculate(Game game, Ability source, Effect effect) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int maxCards = 0;
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
for (UUID opponentId : game.getOpponents(sourceAbility.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
int cards = opponent.getHand().size();

View file

@ -115,7 +115,7 @@ class AdarkarValkyrieDelayedTriggeredAbility extends DelayedTriggeredAbility {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.ZONE_CHANGE;
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override

View file

@ -73,7 +73,7 @@ class AdventureAwaitsEffect extends OneShotEffect {
player.putCardsOnBottomOfLibrary(cards, game, source, false);
} else {
player.putCardsOnBottomOfLibrary(cards, game, source, false);
player.drawCards(1, source.getSourceId(), game);
player.drawCards(1, source, game);
}
return true;
}

View file

@ -72,7 +72,7 @@ class AeonChroniclerTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.COUNTER_REMOVED;
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
}
@Override

View file

@ -61,7 +61,7 @@ class AetherBarrierEffect extends SacrificeEffect {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
Cost cost = ManaUtil.createManaCost(1, false);
if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
if (!cost.pay(source, game, source, player.getId(), false)) {
super.apply(game, source);
}
return true;

View file

@ -61,7 +61,7 @@ class AetherChargeTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD;
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
@ -111,7 +111,7 @@ class AetherChargeEffect extends OneShotEffect {
creature = (Permanent) game.getLastKnownInformation(creatureId, Zone.BATTLEFIELD);
}
if (creature != null) {
return game.damagePlayerOrPlaneswalker(source.getFirstTarget(), 4, creature.getId(), game, false, true) > 0;
return game.damagePlayerOrPlaneswalker(source.getFirstTarget(), 4, creature.getId(), source, game, false, true) > 0;
}
return false;
}

View file

@ -64,7 +64,7 @@ class AetherRiftEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.discardOne(true, source, game);
Card card = controller.discardOne(true, false, source, game);
if (card != null && card.isCreature()) {
Effect returnEffect = new ReturnFromGraveyardToBattlefieldTargetEffect();
returnEffect.setTargetPointer(new FixedTarget(card.getId()));

View file

@ -72,7 +72,7 @@ class AetherSnapEffect extends OneShotEffect {
}
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
permanent.removeCounters(counter, game);
permanent.removeCounters(counter, source, game);
}
}
controller.moveCards(tokens, Zone.EXILED, source, game);

View file

@ -55,7 +55,7 @@ class AetherStingTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.SPELL_CAST;
return event.getType() == GameEvent.EventType.SPELL_CAST;
}
@Override

View file

@ -92,7 +92,7 @@ class AetherbornMarauderEffect extends OneShotEffect {
numberToMove = controller.getAmount(0, numberOfCounters, "How many +1/+1 counters do you want to move?", game);
}
if (numberToMove > 0) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(numberToMove), game);
fromPermanent.removeCounters(CounterType.P1P1.createInstance(numberToMove), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(numberToMove), source, game);
}
}

View file

@ -70,10 +70,10 @@ class AethergeodeMinerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Aethergeode Miner", source.getSourceId(), game)) {
if (permanent.moveToExile(source.getSourceId(), "Aethergeode Miner", source, game)) {
Card card = game.getExile().getCard(source.getSourceId(), game);
if (card != null) {
return card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
return card.moveToZone(Zone.BATTLEFIELD, source, game, false);
}
}
}

View file

@ -127,7 +127,7 @@ class AetherspoutsEffect extends OneShotEffect {
}
// move all permanents to lib at the same time
for (Permanent permanent : toLibrary) {
player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, false);
player.moveCardToLibraryWithInfo(permanent, source, game, Zone.BATTLEFIELD, true, false);
}
// cards to bottom
cards.clear();
@ -165,7 +165,7 @@ class AetherspoutsEffect extends OneShotEffect {
}
// move all permanents to lib at the same time
for (Permanent permanent : toLibrary) {
player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, false, false);
player.moveCardToLibraryWithInfo(permanent, source, game, Zone.BATTLEFIELD, false, false);
}
player = playerList.getNext(game, false);
} while (player != null && !player.getId().equals(game.getActivePlayerId()) && activePlayer.canRespond());

View file

@ -76,7 +76,7 @@ class MoveCounterToTargetFromSourceEffect extends OneShotEffect {
if (sourceObject != null && controller != null) {
Permanent toPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (toPermanent != null && sourceObject.getCounters(game).getCount(CounterType.P1P1) > 0) {
sourceObject.removeCounters(CounterType.P1P1.createInstance(), game);
sourceObject.removeCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source, game);
game.informPlayers("Moved a +1/+1 counter from " + sourceObject.getLogName() + " to " + toPermanent.getLogName());
}

View file

@ -60,7 +60,7 @@ class AfterlifeEffect extends OneShotEffect {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent != null) {
SpiritWhiteToken token = new SpiritWhiteToken();
token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
token.putOntoBattlefield(1, game, source, permanent.getControllerId());
}
return true;
}

View file

@ -81,7 +81,7 @@ class AgadeemOccultistEffect extends OneShotEffect {
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(1, 1, filter);
if (controller != null) {
if (target.canChoose(source.getControllerId(), game)
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
&& controller.choose(Outcome.GainControl, target, source.getSourceId(), game)) {
if (!target.getTargets().isEmpty()) {
Card card = game.getCard(target.getFirstTarget());

View file

@ -100,8 +100,8 @@ class AgadeemsAwakeningTarget extends TargetCardInYourGraveyard {
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID playerId, Game game) {
Set<UUID> possibleTargets = super.possibleTargets(sourceId, playerId, game);
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<Integer> cmcs = this.getTargets()
.stream()
.map(game::getCard)

View file

@ -55,7 +55,7 @@ class AgentOfMasksEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
int loseLife = 0;
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
loseLife += game.getPlayer(opponentId).loseLife(1, game, false);
loseLife += game.getPlayer(opponentId).loseLife(1, game, source, false);
}
if (loseLife > 0)
game.getPlayer(source.getControllerId()).gainLife(loseLife, game, source);

View file

@ -75,7 +75,7 @@ class AgonizingMemoriesEffect extends OneShotEffect {
if (you.choose(Outcome.Benefit, targetPlayer.getHand(), target, game)) {
Card card = targetPlayer.getHand().get(target.getFirstTarget(), game);
if (card != null) {
targetPlayer.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, true, false);
targetPlayer.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false);
}
}
}

View file

@ -89,7 +89,7 @@ class AgonizingRemorseEffect extends OneShotEffect {
return true;
}
controller.moveCards(card, Zone.EXILED, source, game);
controller.loseLife(1, game, false);
controller.loseLife(1, game, source, false);
return true;
}
}

View file

@ -66,7 +66,7 @@ class AjanisChosenEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Token token = new CatToken();
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
if (token.putOntoBattlefield(1, game, source, source.getControllerId())) {
Permanent enchantment = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (enchantment != null && enchantment.hasSubtype(SubType.AURA, game)) {
for (UUID tokenId : token.getLastAddedTokenIds()) {
@ -77,8 +77,8 @@ class AjanisChosenEffect extends OneShotEffect {
boolean canAttach = enchantment.getSpellAbility() == null
|| (!enchantment.getSpellAbility().getTargets().isEmpty() && enchantment.getSpellAbility().getTargets().get(0).canTarget(tokenPermanent.getId(), game));
if (canAttach && controller.chooseUse(Outcome.Neutral, "Attach " + enchantment.getName() + " to the token ?", source, game)) {
if (oldCreature.removeAttachment(enchantment.getId(), game)) {
tokenPermanent.addAttachment(enchantment.getId(), game);
if (oldCreature.removeAttachment(enchantment.getId(), source, game)) {
tokenPermanent.addAttachment(enchantment.getId(), source, game);
}
}
}

View file

@ -170,8 +170,8 @@ class AkiriFearlessVoyagerEffect extends OneShotEffect {
if (creature == null) {
return false;
}
creature.removeAttachment(equipment.getId(), game);
creature.tap(game);
creature.removeAttachment(equipment.getId(), source, game);
creature.tap(source, game);
game.addEffect(new GainAbilityTargetEffect(
IndestructibleAbility.getInstance(), Duration.EndOfTurn
).setTargetPointer(new FixedTarget(creature, game)), source);

View file

@ -69,7 +69,7 @@ class AkkiLavarunnerAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGED_PLAYER;
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
}
@Override

View file

@ -78,9 +78,9 @@ class AkoumFlameseekerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = controller.discard(1, false, source, game);
Cards cards = controller.discard(1, false, false, source, game);
if (!cards.isEmpty()) {
controller.drawCards(1, source.getSourceId(), game);
controller.drawCards(1, source, game);
}
return true;
}

View file

@ -119,18 +119,18 @@ class AkoumHellkiteDamageEffect extends OneShotEffect {
Player player = game.getPlayer(source.getFirstTarget());
if (land != null && player != null) {
if (land.hasSubtype(SubType.MOUNTAIN, game)) {
player.damage(2, source.getSourceId(), game);
player.damage(2, source.getSourceId(), source, game);
} else {
player.damage(1, source.getSourceId(), game);
player.damage(1, source.getSourceId(), source, game);
}
return true;
}
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (land != null && permanent != null) {
if (land.hasSubtype(SubType.MOUNTAIN, game)) {
permanent.damage(2, source.getSourceId(), game);
permanent.damage(2, source.getSourceId(), source, game);
} else {
permanent.damage(1, source.getSourceId(), game);
permanent.damage(1, source.getSourceId(), source, game);
}
return true;
}

View file

@ -112,7 +112,7 @@ class AkroanHorseGainControlEffect extends ContinuousEffectImpl {
permanent = game.getPermanent(targetPointer.getFirst(game, source));
}
if (permanent != null) {
return permanent.changeControllerId(controller, game);
return permanent.changeControllerId(controller, game, source);
}
return false;
}
@ -143,7 +143,7 @@ class AkroanHorseCreateTokenEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Token token = new SoldierToken();
token.putOntoBattlefield(1, game, source.getSourceId(), opponentId);
token.putOntoBattlefield(1, game, source, opponentId);
}
return true;
}

View file

@ -75,7 +75,7 @@ class AladdinsLampEffect extends ReplacementEffectImpl {
}
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
game.getState().processAction(game);
controller.drawCards(1, event.getSourceId(), game, event.getAppliedEffects());
controller.drawCards(1, source, game, event);
discard();
return true;
}

View file

@ -147,7 +147,7 @@ class AlhammarretHighArbiterCantCastEffect extends ContinuousRuleModifyingEffect
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.CAST_SPELL_LATE;
return event.getType() == GameEvent.EventType.CAST_SPELL_LATE;
}
@Override

View file

@ -9,6 +9,7 @@ import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.util.CardUtil;
import mage.watchers.common.CardsDrawnDuringDrawStepWatcher;
import java.util.UUID;
@ -97,7 +98,7 @@ class AlhammarretsArchiveReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(2, event.getSourceId(), game, event.getAppliedEffects());
controller.drawCards(2, source, game, event);
}
return true;
}

View file

@ -73,9 +73,9 @@ class AllHallowsEveEffect extends OneShotEffect {
if (allHallowsEve != null
&& controller != null
&& game.getExile().getCard(allHallowsEve.getId(), game) != null) {
allHallowsEve.removeCounters(CounterType.SCREAM.getName(), 1, game);
allHallowsEve.removeCounters(CounterType.SCREAM.getName(), 1, source, game);
if (allHallowsEve.getCounters(game).getCount(CounterType.SCREAM) == 0) {
allHallowsEve.moveToZone(Zone.GRAVEYARD, source.getId(), game, false);
allHallowsEve.moveToZone(Zone.GRAVEYARD, source, game, false);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {

View file

@ -50,7 +50,7 @@ class AllIsDustEffect extends OneShotEffect {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game);
for (Permanent p : permanents) {
if (!p.getColor(game).isColorless()) {
p.sacrifice(source.getSourceId(), game);
p.sacrifice(source, game);
}
}

View file

@ -64,7 +64,7 @@ class AlleyGriftersDiscardEffect extends OneShotEffect {
if (blockingCreature != null) {
Player opponent = game.getPlayer(blockingCreature.getControllerId());
if (opponent != null) {
opponent.discard(1, false, source, game);
opponent.discard(1, false, false, source, game);
return true;
}
}

View file

@ -74,8 +74,8 @@ class AlmsCollectorReplacementEffect extends ReplacementEffectImpl {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(event.getPlayerId());
if (controller != null && opponent != null) {
controller.drawCards(1, source.getSourceId(), game, event.getAppliedEffects());
opponent.drawCards(1, source.getSourceId(), game, event.getAppliedEffects());
controller.drawCards(1, source, game, event);
opponent.drawCards(1, source, game, event);
return true;
}
return false;

View file

@ -68,10 +68,10 @@ class AlphaBrawlEffect extends OneShotEffect {
if (player != null) {
int power = creature.getPower().getValue();
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
perm.damage(power, creature.getId(), game, false, true);
perm.damage(power, creature.getId(), source, game, false, true);
}
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
creature.damage(perm.getPower().getValue(), perm.getId(), game, false, true);
creature.damage(perm.getPower().getValue(), perm.getId(), source, game, false, true);
}
return true;
}

View file

@ -63,7 +63,7 @@ class AmassTheComponentsEffect extends OneShotEffect {
return false;
}
player.drawCards(3, source.getSourceId(), game);
player.drawCards(3, source, game);
if (!player.getHand().isEmpty()) {
FilterCard filter = new FilterCard("card from your hand to put on the bottom of your library");
TargetCard target = new TargetCard(Zone.HAND, filter);

View file

@ -98,7 +98,7 @@ class AminatouPlusEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(1, source.getSourceId(), game);
player.drawCards(1, source, game);
putOnLibrary(player, source, game);
return true;
}
@ -111,7 +111,7 @@ class AminatouPlusEffect extends OneShotEffect {
player.chooseTarget(Outcome.ReturnToHand, target, source, game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
return player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, true, false);
return player.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false);
}
}
return false;

View file

@ -60,7 +60,7 @@ class AmnesiaEffect extends OneShotEffect {
player.revealCards(source, hand, game);
Set<Card> cards = hand.getCards(game);
cards.removeIf(MageObject::isLand);
player.discard(new CardsImpl(cards), source, game);
player.discard(new CardsImpl(cards), false, source, game);
return true;
}
return false;

View file

@ -89,7 +89,7 @@ class AmphinMutineerEffect extends OneShotEffect {
return false;
}
player.moveCards(permanent, Zone.EXILED, source, game);
new SalamnderWarriorToken().putOntoBattlefield(1, game, source.getSourceId(), player.getId());
new SalamnderWarriorToken().putOntoBattlefield(1, game, source, player.getId());
return true;
}
}

View file

@ -52,7 +52,7 @@ class AmuletOfVigorTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD;
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override

View file

@ -90,10 +90,10 @@ class AnaBattlemageKickerEffect extends OneShotEffect {
boolean applied = false;
Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source));
if (targetCreature != null) {
applied = targetCreature.tap(game);
applied = targetCreature.tap(source, game);
Player controller = game.getPlayer(targetCreature.getControllerId());
if (controller != null) {
controller.damage(targetCreature.getPower().getValue(), source.getSourceId(), game);
controller.damage(targetCreature.getPower().getValue(), source.getSourceId(), source, game);
applied = true;
}
}

View file

@ -68,7 +68,7 @@ class AncestralBladeEffect extends CreateTokenEffect {
if (p == null) {
return false;
}
p.addAttachment(source.getSourceId(), game);
p.addAttachment(source.getSourceId(), source, game);
return true;
}

View file

@ -63,8 +63,8 @@ class AncientExcavationEffect extends OneShotEffect {
if (player != null) {
DynamicValue numCards = CardsInControllerHandCount.instance;
int amount = numCards.calculate(game, source, this);
player.drawCards(amount, source.getSourceId(), game);
player.discard(amount, false, source, game);
player.drawCards(amount, source, game);
player.discard(amount, false, false, source, game);
return true;
}
return false;

View file

@ -58,7 +58,7 @@ class AncientRunesDamageTargetEffect extends OneShotEffect {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
int damage = game.getBattlefield().getAllActivePermanents(new FilterControlledArtifactPermanent("artifacts"), targetPointer.getFirst(game, source), game).size();
player.damage(damage, source.getSourceId(), game);
player.damage(damage, source.getSourceId(), source, game);
return true;
}
return false;

View file

@ -99,7 +99,7 @@ class AngelOfCondemnationExileUntilEOTEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && permanent != null && sourcePermanent != null) {
if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) {
if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
//create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setText("return that card to the battlefield under its owner's control");

View file

@ -82,9 +82,9 @@ class AngelOfDeliveranceDealsDamageTriggeredAbility extends TriggeredAbilityImpl
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGED_PLAYER
|| event.getType() == EventType.DAMAGED_CREATURE
|| event.getType() == EventType.DAMAGED_PLANESWALKER;
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER
|| event.getType() == GameEvent.EventType.DAMAGED_CREATURE
|| event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER;
}
@Override

View file

@ -69,7 +69,7 @@ class AngelheartVialTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGED_PLAYER;
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
}
@Override

View file

@ -105,7 +105,7 @@ class AngelicArbiterEffect2 extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.CAST_SPELL;
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override

View file

@ -62,6 +62,6 @@ class AngelicAscensionEffect extends OneShotEffect {
if (permanent == null) {
return false;
}
return token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
return token.putOntoBattlefield(1, game, source, permanent.getControllerId());
}
}

View file

@ -57,7 +57,7 @@ class AngelicBenedictionTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}
@Override

View file

@ -50,7 +50,7 @@ class AngelicChorusTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD;
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override

View file

@ -64,14 +64,14 @@ class AngelsGraceEffect extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.WINS || event.getType() == EventType.LOSES;
return event.getType() == GameEvent.EventType.WINS || event.getType() == GameEvent.EventType.LOSES;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return (event.getType() == EventType.WINS
return (event.getType() == GameEvent.EventType.WINS
&& game.getOpponents(source.getControllerId()).contains(event.getPlayerId()))
|| (event.getType() == EventType.LOSES
|| (event.getType() == GameEvent.EventType.LOSES
&& event.getPlayerId().equals(source.getControllerId()));
}
@ -96,7 +96,7 @@ class AngelsGraceReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGE_CAUSES_LIFE_LOSS;
return event.getType() == GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS;
}
@Override

View file

@ -76,11 +76,11 @@ class AngelsTrumpetTapEffect extends OneShotEffect {
continue;
}
// Tap the rest.
creature.tap(game);
creature.tap(source, game);
count++;
}
if (count > 0) {
player.damage(count, source.getSourceId(), game);
player.damage(count, source.getSourceId(), source, game);
}
return true;
}

View file

@ -95,11 +95,11 @@ class AngrathMinotaurPirateThirdAbilityEffect extends OneShotEffect {
if (targetOpponent != null) {
int powerSum = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), game)) {
permanent.destroy(source.getSourceId(), game, false);
permanent.destroy(source, game, false);
powerSum += permanent.getPower().getValue();
}
game.getState().processAction(game);
targetOpponent.damage(powerSum, source.getSourceId(), game);
targetOpponent.damage(powerSum, source.getSourceId(), source, game);
}
return true;
}

View file

@ -92,7 +92,7 @@ class AngrathTheFlameUltimateEffect extends OneShotEffect {
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(opponentId);
if (player != null && !player.getGraveyard().isEmpty()) {
player.loseLife(player.getGraveyard().size(), game, false);
player.loseLife(player.getGraveyard().size(), game, source, false);
}
}
return true;

View file

@ -108,7 +108,7 @@ class AnimateDeadReAttachEffect extends OneShotEffect {
target.addTarget(enchantedCreature.getId(), source, game);
animateDead.getSpellAbility().getTargets().clear();
animateDead.getSpellAbility().getTargets().add(target);
enchantedCreature.addAttachment(animateDead.getId(), game);
enchantedCreature.addAttachment(animateDead.getId(), source, game);
ContinuousEffect effect = new AnimateDeadAttachToPermanentEffect();
effect.setTargetPointer(new FixedTarget(enchantedCreature, game));
game.addEffect(effect, source);
@ -144,7 +144,7 @@ class AnimateDeadLeavesBattlefieldTriggeredEffect extends OneShotEffect {
if (sourcePermanent.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo());
if (attachedTo != null && attachedTo.getZoneChangeCounter(game) == sourcePermanent.getAttachedToZoneChangeCounter()) {
attachedTo.sacrifice(source.getSourceId(), game);
attachedTo.sacrifice(source, game);
}
}
return true;
@ -180,7 +180,7 @@ class AnimateDeadAttachEffect extends OneShotEffect {
// Card have no attachedTo attribute yet so write ref only to enchantment now
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
enchantment.attachTo(card.getId(), game);
enchantment.attachTo(card.getId(), source, game);
}
return true;
}

View file

@ -151,7 +151,7 @@ class AnimationModuleEffect extends OneShotEffect {
if (player.getCounters().size() == 1) {
for (Counter counter : player.getCounters().values()) {
Counter newCounter = new Counter(counter.getName());
player.addCounters(newCounter, game);
player.addCounters(newCounter, source, game);
}
} else {
Choice choice = new ChoiceImpl(true);
@ -165,7 +165,7 @@ class AnimationModuleEffect extends OneShotEffect {
for (Counter counter : player.getCounters().values()) {
if (counter.getName().equals(choice.getChoice())) {
Counter newCounter = new Counter(counter.getName());
player.addCounters(newCounter, game);
player.addCounters(newCounter, source, game);
break;
}
}

View file

@ -58,7 +58,7 @@ class AnkhOfMishraAbility extends TriggeredAbilityImpl {
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD;
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override

View file

@ -134,7 +134,7 @@ class AnowonTheRuinThiefEffect extends OneShotEffect {
if (player.millCards(damage, source, game).count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(1, source.getSourceId(), game);
controller.drawCards(1, source, game);
}
}
return true;

View file

@ -73,7 +73,7 @@ class AnthroplasmEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
//Remove all +1/+1 counters
permanent.removeCounters(permanent.getCounters(game).get(CounterType.P1P1.getName()), game);
permanent.removeCounters(permanent.getCounters(game).get(CounterType.P1P1.getName()), source, game);
//put X +1/+1 counters
permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), source, game);
return true;

View file

@ -72,7 +72,7 @@ class AntiMagicAuraRuleEffect extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ATTACH || event.getType() == EventType.STAY_ATTACHED;
return event.getType() == GameEvent.EventType.ATTACH || event.getType() == GameEvent.EventType.STAY_ATTACHED;
}
@Override

View file

@ -66,16 +66,16 @@ class AnuridScavengerCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
if (targets.choose(Outcome.Removal, controllerId, sourceId, game)) {
if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), game)) {
for (UUID targetId: targets.get(0).getTargets()) {
Card card = game.getCard(targetId);
if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) {
return false;
}
paid |= controller.moveCardToLibraryWithInfo(card, sourceId, game, Zone.GRAVEYARD, false, true);
paid |= controller.moveCardToLibraryWithInfo(card, source, game, Zone.GRAVEYARD, false, true);
}
}
@ -84,8 +84,8 @@ class AnuridScavengerCost extends CostImpl {
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
return targets.canChoose(controllerId, game);
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
return targets.canChoose(source.getSourceId(), controllerId, game);
}
@Override

View file

@ -57,8 +57,8 @@ class AnvilOfBogardanEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.drawCards(1, source.getSourceId(), game);
targetPlayer.discard(1, false, source, game);
targetPlayer.drawCards(1, source, game);
targetPlayer.discard(1, false, false, source, game);
return true;
}
return false;

View file

@ -80,7 +80,7 @@ class ApathyEffect extends OneShotEffect {
return false;
}
if (!player.chooseUse(outcome, "Discard a card at random to untap enchanted creature?", source, game)
|| player.discardOne(true, source, game) == null) {
|| player.discardOne(true, false, source, game) == null) {
return false;
}
Permanent permanent = game.getPermanent(source.getSourceId());

View file

@ -79,7 +79,7 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) {
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
@ -87,7 +87,7 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
}
}
}
if (event.getType() == EventType.TURNFACEUP) {
if (event.getType() == GameEvent.EventType.TURNFACEUP) {
if (event.getTargetId().equals(source.getSourceId())) {
return true;
}

View file

@ -115,7 +115,7 @@ class ArachnusSpinnerEffect extends OneShotEffect {
if (permanent != null) {
game.getState().setValue("attachTo:" + card.getId(), permanent.getId());
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
permanent.addAttachment(card.getId(), game); // shouldn't this be done automatically by the logic using the "attachTo:" calue?
permanent.addAttachment(card.getId(), source, game); // shouldn't this be done automatically by the logic using the "attachTo:" calue?
}
}
}

View file

@ -69,7 +69,7 @@ class ArashinSovereignEffect extends OneShotEffect {
if (controller != null && sourceCard != null) {
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
boolean onTop = controller.chooseUse(outcome, "Put " + sourceCard.getName() + " on top of it's owners library (otherwise on bottom)?", source, game);
controller.moveCardToLibraryWithInfo(sourceCard, source.getSourceId(), game, Zone.GRAVEYARD, onTop, true);
controller.moveCardToLibraryWithInfo(sourceCard, source, game, Zone.GRAVEYARD, onTop, true);
}
return true;
}

View file

@ -78,7 +78,7 @@ class ArashinWarBeastTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.DAMAGED_CREATURE &&
if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE &&
event.getSourceId().equals(this.sourceId) &&
((DamagedCreatureEvent) event).isCombatDamage() &&
!usedForCombatDamageStep) {
@ -91,7 +91,7 @@ class ArashinWarBeastTriggeredAbility extends TriggeredAbilityImpl {
return true;
}
if (event.getType() == EventType.COMBAT_DAMAGE_STEP_POST) {
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST) {
usedForCombatDamageStep = false;
}
return false;

View file

@ -88,7 +88,7 @@ class AraumiOfTheDeadTideCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player player = game.getPlayer(controllerId);
if (player == null) {
return paid;
@ -96,7 +96,7 @@ class AraumiOfTheDeadTideCost extends CostImpl {
int oppCount = game.getOpponents(controllerId).size();
TargetCard target = new TargetCardInYourGraveyard(oppCount, StaticFilters.FILTER_CARD);
target.setNotTarget(true);
player.choose(Outcome.Exile, target, sourceId, game);
player.choose(Outcome.Exile, target, source.getSourceId(), game);
Cards cards = new CardsImpl(target.getTargets());
if (cards.size() < oppCount) {
return paid;
@ -111,7 +111,7 @@ class AraumiOfTheDeadTideCost extends CostImpl {
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
Player player = game.getPlayer(controllerId);
return player != null && player.getGraveyard().size() >= game.getOpponents(controllerId).size();
}

View file

@ -86,11 +86,11 @@ class ArcTrailEffect extends OneShotEffect {
}
if (permanent != null) {
applied |= (permanent.damage(damage, source.getSourceId(), game, false, true) > 0);
applied |= (permanent.damage(damage, source.getSourceId(), source, game, false, true) > 0);
}
Player player = game.getPlayer(target.getFirstTarget());
if (player != null) {
applied |= (player.damage(damage, source.getSourceId(), game) > 0);
applied |= (player.damage(damage, source.getSourceId(), source, game) > 0);
}
twoDamageDone = true;

View file

@ -91,7 +91,7 @@ class ArcaneArtisanCreateTokenEffect extends OneShotEffect {
if (player == null) {
return false;
}
player.drawCards(1, source.getSourceId(), game);
player.drawCards(1, source, game);
TargetCard target = new TargetCardInHand(1, StaticFilters.FILTER_CARD);
if (!player.chooseTarget(Outcome.Exile, player.getHand(), target, source, game)) {
return false;

View file

@ -74,7 +74,7 @@ class ArcaneDenialEffect extends OneShotEffect {
controller = game.getPlayer(game.getControllerId(targetId));
}
if (targetId != null
&& game.getStack().counter(targetId, source.getSourceId(), game)) {
&& game.getStack().counter(targetId, source, game)) {
countered = true;
}
if (controller != null) {

View file

@ -79,7 +79,7 @@ class MoveCounterFromTargetToSourceEffect extends OneShotEffect {
if (sourceObject != null && controller != null) {
Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), game);
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(), source, game);
game.informPlayers("Moved a +1/+1 counter from " + fromPermanent.getLogName() + " to " + sourceObject.getLogName());
}

View file

@ -57,7 +57,7 @@ class ArchangelsLightEffect extends OneShotEffect {
if (controller != null) {
controller.gainLife(value.calculate(game, source, this) * 2, game, source);
for (Card card: controller.getGraveyard().getCards(game)) {
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD, true, true);
controller.moveCardToLibraryWithInfo(card, source, game, Zone.GRAVEYARD, true, true);
}
controller.shuffleLibrary(source, game);
return true;

View file

@ -85,16 +85,16 @@ public final class ArchdemonOfGreed extends CardImpl {
if (player != null) {
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);
// if they can pay the cost, then they must pay
if (target.canChoose(player.getId(), game)) {
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent humanSacrifice = game.getPermanent(target.getFirstTarget());
if (humanSacrifice != null) {
// sacrifice the chosen card
return humanSacrifice.sacrifice(source.getSourceId(), game);
return humanSacrifice.sacrifice(source, game);
}
} else {
permanent.tap(game);
player.damage(9, source.getSourceId(), game);
permanent.tap(source, game);
player.damage(9, source.getSourceId(), source, game);
}
}
return true;

View file

@ -80,7 +80,7 @@ class ArchfiendOfDepravityEffect extends OneShotEffect {
}
}
for (Permanent creature : creaturesToSacrifice) {
creature.sacrifice(source.getSourceId(), game);
creature.sacrifice(source, game);
}
return true;
}

View file

@ -86,7 +86,7 @@ class ArchfiendOfDespairEffect extends OneShotEffect {
if (opponent != null) {
int lifeLost = watcher.getLifeLost(playerId);
if (lifeLost > 0) {
opponent.loseLife(lifeLost, game, false);
opponent.loseLife(lifeLost, game, source, false);
}
}
}

View file

@ -135,7 +135,7 @@ class ArchfiendOfSpiteEffect extends OneShotEffect {
null, "Lose " + amount + " life",
"Sacrifice " + amount + " permanents", source, game
)) {
return player.loseLife(amount, game, false) > 0;
return player.loseLife(amount, game, source, false) > 0;
}
return effect.apply(game, source);
}

Some files were not shown because too many files have changed in this diff Show more