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

@ -52,7 +52,7 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
// check for Morph
Card card = game.getCard(perm.getId());
if (card != null) {
for (Ability ability : card.getAbilities()) {
for (Ability ability : card.getAbilities(game)) {
if (ability instanceof MorphAbility) {
this.turnFaceUpAbilityMap.put(card.getId(), new TurnFaceUpAbility(((MorphAbility) ability).getMorphCosts()));
}

View file

@ -45,7 +45,7 @@ public class ControlEnchantedEffect extends ContinuousEffectImpl {
switch (layer) {
case ControlChangingEffects_2:
if (sublayer == SubLayer.NA) {
permanent.changeControllerId(enchantment.getControllerId(), game);
permanent.changeControllerId(enchantment.getControllerId(), game, source);
permanent.getAbilities().forEach((ability) -> {
ability.setControllerId(enchantment.getControllerId());
});

View file

@ -122,7 +122,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
toDelete.add(entry.getKey());
continue;
}
permanent.changeControllerId(lockedControllers.get(permanent.getId()), game);
permanent.changeControllerId(lockedControllers.get(permanent.getId()), game, source);
permanent.getAbilities().setControllerId(lockedControllers.get(permanent.getId()));
if (destroyAttachedAuras) {
FilterPermanent filter = new FilterPermanent();
@ -130,7 +130,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
for (UUID attachmentId : new HashSet<>(permanent.getAttachments())) {
Permanent attachment = game.getPermanent(attachmentId);
if (attachment != null && filter.match(attachment, game)) {
attachment.destroy(source.getSourceId(), game, false);
attachment.destroy(source, game, false);
}
}
}

View file

@ -83,19 +83,13 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
if (permanent != null) {
oneTargetStillExists = true;
if (!permanent.isControlledBy(controllingPlayerId)) {
GameEvent loseControlEvent = GameEvent.getEvent(GameEvent.EventType.LOSE_CONTROL, permanentId, source.getId(), permanent.getControllerId());
if (game.replaceEvent(loseControlEvent)) {
return false;
}
boolean controlChanged = false;
if (controllingPlayerId != null) {
if (permanent.changeControllerId(controllingPlayerId, game)) {
permanent.getAbilities().setControllerId(controllingPlayerId);
if (permanent.changeControllerId(controllingPlayerId, game, source)) {
controlChanged = true;
}
} else {
if (permanent.changeControllerId(source.getControllerId(), game)) {
permanent.getAbilities().setControllerId(source.getControllerId());
if (permanent.changeControllerId(source.getControllerId(), game, source)) {
controlChanged = true;
}
}