mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Shared Fate - fixed game error (NPE error)
This commit is contained in:
parent
a18dcd9911
commit
6a9a4c78ca
1 changed files with 20 additions and 12 deletions
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.AsThoughEffectImpl;
|
import mage.abilities.effects.AsThoughEffectImpl;
|
||||||
|
@ -18,6 +17,8 @@ import mage.players.PlayerList;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.common.TargetOpponent;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author emerald000 / HCrescent
|
* @author emerald000 / HCrescent
|
||||||
*/
|
*/
|
||||||
|
@ -42,6 +43,14 @@ public final class SharedFate extends CardImpl {
|
||||||
public SharedFate copy() {
|
public SharedFate copy() {
|
||||||
return new SharedFate(this);
|
return new SharedFate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String prepareExileKey(Game game, Ability source, Permanent sourcePermanent, UUID affectedControllerId) {
|
||||||
|
return String.format("%s_%d_%s",
|
||||||
|
source.getSourceId().toString(),
|
||||||
|
sourcePermanent == null ? 0 : sourcePermanent.getZoneChangeCounter(game),
|
||||||
|
affectedControllerId.toString()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SharedFateReplacementEffect extends ReplacementEffectImpl {
|
class SharedFateReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
@ -83,9 +92,9 @@ class SharedFateReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
if (!playersInRange.contains(chosenPlayer.getId())) {
|
if (!playersInRange.contains(chosenPlayer.getId())) {
|
||||||
game.informPlayers(
|
game.informPlayers(
|
||||||
"Nothing exiled. " + playerToDraw.getLogName()
|
"Nothing exiled. " + playerToDraw.getLogName()
|
||||||
+ " chose to exile from " + chosenPlayer.getLogName() + "'s library. "
|
+ " chose to exile from " + chosenPlayer.getLogName() + "'s library. "
|
||||||
+ "That player is outside of " + controller.getLogName() + "'s range of influence."
|
+ "That player is outside of " + controller.getLogName() + "'s range of influence."
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -97,10 +106,9 @@ class SharedFateReplacementEffect extends ReplacementEffectImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerToDraw.moveCardsToExile(
|
UUID exileId = CardUtil.getExileZoneId(SharedFate.prepareExileKey(game, source, sourcePermanent, playerToDraw.getId()), game);
|
||||||
card, source, game, false,
|
String exileName = sourcePermanent.getIdName() + "-" + sourcePermanent.getZoneChangeCounter(game) + " (" + playerToDraw.getName() + ')';
|
||||||
CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + playerToDraw.getId().toString(), game),
|
playerToDraw.moveCardsToExile(card, source, game, false, exileId, exileName);
|
||||||
sourcePermanent.getIdName() + "-" + sourcePermanent.getZoneChangeCounter(game) + " (" + playerToDraw.getName() + ')');
|
|
||||||
card.setFaceDown(true, game);
|
card.setFaceDown(true, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -140,8 +148,8 @@ class SharedFatePlayEffect extends AsThoughEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
|
UUID exileId = CardUtil.getExileZoneId(SharedFate.prepareExileKey(game, source, sourcePermanent, affectedControllerId), game);
|
||||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||||
return exileZone != null && exileZone.contains(objectId);
|
return exileZone != null && exileZone.contains(objectId);
|
||||||
}
|
}
|
||||||
|
@ -173,8 +181,8 @@ class SharedFateLookEffect extends AsThoughEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
|
UUID exileId = CardUtil.getExileZoneId(SharedFate.prepareExileKey(game, source, sourcePermanent, affectedControllerId), game);
|
||||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||||
if (exileZone != null && exileZone.contains(objectId)) {
|
if (exileZone != null && exileZone.contains(objectId)) {
|
||||||
Card card = game.getCard(objectId);
|
Card card = game.getCard(objectId);
|
||||||
|
|
Loading…
Reference in a new issue