Replaced use of source.getId() by source.getSourceId() for Mage Framework.

This commit is contained in:
LevelX2 2014-08-13 14:22:32 +02:00
parent 8b4c454f1f
commit 3bbbd4c02b
33 changed files with 47 additions and 45 deletions

View file

@ -96,7 +96,7 @@ class PactEffect extends OneShotEffect {
if (player != null) {
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "?", game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getId(), source.getControllerId(), false)){
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)){
return true;
}
}

View file

@ -56,10 +56,10 @@ public class ControlsBiggestOrTiedCreatureCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Set<UUID> controllers = new HashSet<UUID>();
Set<UUID> controllers = new HashSet<>();
Integer maxPower = null;
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getId(), game);
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
if (permanent == null) {
continue;

View file

@ -45,7 +45,7 @@ import mage.game.permanent.Permanent;
public class EnchantedCreatureColorCondition implements Condition {
private FilterPermanent filter = new FilterCreaturePermanent();
private final FilterPermanent filter = new FilterCreaturePermanent();
public EnchantedCreatureColorCondition(ObjectColor color){
filter.add(new ColorPredicate(color));
@ -53,11 +53,11 @@ public class EnchantedCreatureColorCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantement = game.getPermanent(source.getSourceId());
if (enchantement != null) {
Permanent creature = game.getPermanent(enchantement.getAttachedTo());
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
if(filter.match(creature, source.getId(), enchantement.getControllerId(), game)){
if(filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)){
return true;
}
}

View file

@ -100,7 +100,7 @@ public class CipherEffect extends OneShotEffect {
effect.setTargetPointer(new FixedTarget(target.getFirstTarget()));
game.addEffect(effect, source);
game.informPlayers(new StringBuilder(sourceCard.getLogName()).append(": Spell ciphered to ").append(targetCreature.getLogName()).toString());
return sourceCard.moveToExile(null, "", source.getId(), game);
return sourceCard.moveToExile(null, "", source.getSourceId(), game);
} else {
return false;
}

View file

@ -65,7 +65,7 @@ public class DamageAllControlledTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
permanent.damage(amount, source.getId(), game, false, true);
permanent.damage(amount, source.getSourceId(), game, false, true);
}
return true;
}

View file

@ -70,7 +70,7 @@ public class DamageAllEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getId(), game);
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent: permanents) {
permanent.damage(amount.calculate(game, source), source.getSourceId(), game, false, true);
}

View file

@ -85,7 +85,7 @@ public class DamageControllerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.damage(amount.calculate(game, source), source.getId(), game, false, preventable);
player.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable);
return true;
}
return false;

View file

@ -61,7 +61,7 @@ public class DamageSelfEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.damage(amount, source.getId(), game, false, true);
permanent.damage(amount, source.getSourceId(), game, false, true);
return true;
}
return false;

View file

@ -62,7 +62,7 @@ public class DestroyAllControlledTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
permanent.destroy(source.getId(), game, false);
permanent.destroy(source.getSourceId(), game, false);
}
return true;
}

View file

@ -61,8 +61,9 @@ public class DestroyAllNamedPermanentsEffect extends OneShotEffect {
permanent.destroy(source.getSourceId(), game, false);
for (Permanent perm: game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (perm.getName().equals(name))
perm.destroy(source.getId(), game, false);
if (perm.getName().equals(name)) {
perm.destroy(source.getSourceId(), game, false);
}
}
return true;

View file

@ -70,7 +70,7 @@ public class DestroyMultiTargetEffect extends OneShotEffect {
for (UUID permanentId: target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.destroy(source.getId(), game, noRegen);
permanent.destroy(source.getSourceId(), game, noRegen);
affectedTargets++;
}
}

View file

@ -66,7 +66,7 @@ public class DestroySourceEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.destroy(source.getId(), game, noRegen);
permanent.destroy(source.getSourceId(), game, noRegen);
return true;
}
return false;

View file

@ -173,20 +173,20 @@ public class LookLibraryControllerEffect extends OneShotEffect {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(targetZoneLookedCards, source.getId(), game, putOnTop);
card.moveToZone(targetZoneLookedCards, source.getSourceId(), game, putOnTop);
game.informPlayers(player.getName() + " moves a card to " + targetZoneLookedCards.toString());
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(targetZoneLookedCards, source.getId(), game, putOnTop);
card.moveToZone(targetZoneLookedCards, source.getSourceId(), game, putOnTop);
game.informPlayers(player.getName() + " moves a card to " + targetZoneLookedCards.toString());
}
break;
case GRAVEYARD:
for (Card card : cards.getCards(game)) {
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, true);
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
}
break;
default:

View file

@ -80,7 +80,7 @@ public class PutLibraryIntoGraveTargetEffect extends OneShotEffect {
for (int i = 0; i < cardsCount; i++) {
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
player.moveCardToGraveyardWithInfo(card, source.getId(), game, Zone.LIBRARY);
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
}
else {
break;

View file

@ -104,7 +104,7 @@ public class PutTopCardOfLibraryIntoGraveEachPlayerEffect extends OneShotEffect
for (int i = 0; i < cardsCount; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, true);
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
}
}
}

View file

@ -87,7 +87,7 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
return false;
}
game.informPlayers(controller.getName() + " moves " + card.getLogName() + " to " + zone.toString().toLowerCase());
card.moveToZone(zone, source.getId(), game, tapped);
card.moveToZone(zone, source.getSourceId(), game, tapped);
}
exile.clear();
}

View file

@ -62,7 +62,7 @@ public class ReturnSourceFromGraveyardToHandEffect extends OneShotEffect {
Card card = player.getGraveyard().get(source.getSourceId(), game);
if (card != null) {
player.removeFromGraveyard(card, game);
card.moveToZone(Zone.HAND, source.getId(), game, false);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
return true;
}
return false;

View file

@ -64,7 +64,7 @@ public class ReturnToBattlefieldUnderOwnerControlAttachedEffect extends OneShotE
Card card = game.getCard(((Permanent) object).getId());
if (card != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (card.putOntoBattlefield(game, currentZone, source.getId(), card.getOwnerId())) {
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), card.getOwnerId())) {
return true;
}
}

View file

@ -60,7 +60,7 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (card.putOntoBattlefield(game, currentZone, source.getId(), card.getOwnerId())) {
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), card.getOwnerId())) {
return true;
}
}

View file

@ -63,7 +63,7 @@ public class ReturnToBattlefieldUnderYourControlAttachedEffect extends OneShotEf
Card card = game.getCard(((Permanent)object).getId());
if (card != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (card.putOntoBattlefield(game, currentZone, source.getId(), source.getControllerId())) {
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId())) {
return true;
}
}

View file

@ -60,7 +60,7 @@ public class ReturnToBattlefieldUnderYourControlSourceEffect extends OneShotEffe
Card card = game.getCard(source.getSourceId());
if (card != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (card.putOntoBattlefield(game, currentZone, source.getId(), source.getControllerId())) {
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId())) {
return true;
}
}

View file

@ -62,7 +62,7 @@ public class ReturnToHandAttachedEffect extends OneShotEffect {
if (object != null && object instanceof Permanent) {
Card card = game.getCard(((Permanent)object).getId());
if (card != null) {
if (card.moveToZone(Zone.HAND, source.getId(), game, false)) {
if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) {
return true;
}
}

View file

@ -41,7 +41,7 @@ public class ReturnToHandSpellEffect extends PostResolveEffect implements MageSi
@Override
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
card.moveToZone(Zone.HAND, source.getId(), game, false);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
}
}

View file

@ -93,7 +93,7 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
Set<Card> cardsList = cards.getCards(game);
for (Card card : cardsList) {
if (filter.match(card, game)) {
card.moveToZone(Zone.HAND, source.getId(), game, true);
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
cards.remove(card);
}
}
@ -109,13 +109,13 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
}
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
}
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
}
return true;

View file

@ -199,7 +199,7 @@ class BuybackEffect extends ReplacementEffectImpl {
Card card = game.getCard(source.getSourceId());
if (card != null && source instanceof BuybackAbility) {
if (((BuybackAbility) source).isActivated()) {
return card.moveToZone(Zone.HAND, source.getId(), game, true, event.getAppliedEffects());
return card.moveToZone(Zone.HAND, source.getSourceId(), game, true, event.getAppliedEffects());
}
}
return false;

View file

@ -112,7 +112,7 @@ class CumulativeUpkeepEffect extends OneShotEffect {
}
if (player.chooseUse(Outcome.Benefit, "Pay " + totalCost.getText() + "?", game)) {
totalCost.clearPaid();
if (totalCost.payOrRollback(source, game, source.getId(), source.getControllerId())){
if (totalCost.payOrRollback(source, game, source.getSourceId(), source.getControllerId())){
return true;
}
}
@ -127,7 +127,7 @@ class CumulativeUpkeepEffect extends OneShotEffect {
if (player.chooseUse(Outcome.Benefit, totalCost.getText() + "?", game)) {
totalCost.clearPaid();
int bookmark = game.bookmarkState();
if (totalCost.pay(source, game, source.getId(), source.getControllerId(), false)){
if (totalCost.pay(source, game, source.getSourceId(), source.getControllerId(), false)){
return true;
}
else{

View file

@ -144,7 +144,7 @@ class EchoEffect extends OneShotEffect {
if (player != null && permanent != null) {
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() /* + " or sacrifice " + permanent.getName() */ + "?", game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
return true;
}
}

View file

@ -46,7 +46,7 @@ class LivingWeaponEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
GermToken token = new GermToken();
token.putOntoBattlefield(1, game, source.getId(), source.getControllerId());
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
Permanent p = game.getPermanent(token.getLastAddedToken());
if (p != null) {
p.addAttachment(source.getSourceId(), game);

View file

@ -124,7 +124,7 @@ class NinjutsuEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
card.putOntoBattlefield(game, Zone.HAND, source.getId(), source.getControllerId());
card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
UUID defendingPlayerId = null;

View file

@ -72,7 +72,7 @@ class TransmuteEffect extends OneShotEffect {
for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().remove(cardId, game);
if (card != null) {
card.moveToZone(Zone.HAND, source.getId(), game, false);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
revealed.add(card);
}
}

View file

@ -309,7 +309,7 @@ public class ManaPool implements Serializable {
} else {
this.manaItems.add(new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getColorless(), source.getSourceId(), mana.getFlag()));
}
GameEvent event = GameEvent.getEvent(GameEvent.EventType.MANA_ADDED, source.getSourceId(), source.getId(), source.getControllerId());
GameEvent event = GameEvent.getEvent(GameEvent.EventType.MANA_ADDED, source.getId(), source.getSourceId(), source.getControllerId());
event.setData(mana.toString());
game.fireEvent(event);
}

View file

@ -267,12 +267,12 @@ public abstract class TargetImpl implements Target {
amount += targets.get(id);
}
if (source != null && !skipEvent) {
if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getId(), source.getControllerId()))) {
if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getSourceId(), source.getControllerId()))) {
targets.put(id, amount);
rememberZoneChangeCounter(id, game);
chosen = targets.size() >= minNumberOfTargets;
if (!skipEvent) {
game.fireEvent(GameEvent.getEvent(EventType.TARGETED, id, source.getId(), source.getControllerId()));
game.fireEvent(GameEvent.getEvent(EventType.TARGETED, id, source.getSourceId(), source.getControllerId()));
}
}
} else {
@ -336,7 +336,7 @@ public abstract class TargetImpl implements Target {
continue; // it's not legal so continue to have a look at other targeted objects
}
}
if (!notTarget && game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId()))) {
if (!notTarget && game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getSourceId(), source.getControllerId()))) {
replacedTargets++;
continue;
}

View file

@ -63,6 +63,7 @@ public class TargetActivatedOrTriggeredAbility extends TargetObject {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
// rule 114.4. A spell or ability on the stack is an illegal target for itself.
if (source != null && source.getId().equals(id)) {
return false;
}