mirror of
https://github.com/correl/mage.git
synced 2024-12-29 03:00:15 +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;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
|
@ -18,6 +17,8 @@ import mage.players.PlayerList;
|
|||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author emerald000 / HCrescent
|
||||
*/
|
||||
|
@ -42,6 +43,14 @@ public final class SharedFate extends CardImpl {
|
|||
public SharedFate copy() {
|
||||
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 {
|
||||
|
@ -83,9 +92,9 @@ class SharedFateReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
if (!playersInRange.contains(chosenPlayer.getId())) {
|
||||
game.informPlayers(
|
||||
"Nothing exiled. " + playerToDraw.getLogName()
|
||||
+ " chose to exile from " + chosenPlayer.getLogName() + "'s library. "
|
||||
+ "That player is outside of " + controller.getLogName() + "'s range of influence."
|
||||
"Nothing exiled. " + playerToDraw.getLogName()
|
||||
+ " chose to exile from " + chosenPlayer.getLogName() + "'s library. "
|
||||
+ "That player is outside of " + controller.getLogName() + "'s range of influence."
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -97,10 +106,9 @@ class SharedFateReplacementEffect extends ReplacementEffectImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
playerToDraw.moveCardsToExile(
|
||||
card, source, game, false,
|
||||
CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + playerToDraw.getId().toString(), game),
|
||||
sourcePermanent.getIdName() + "-" + sourcePermanent.getZoneChangeCounter(game) + " (" + playerToDraw.getName() + ')');
|
||||
UUID exileId = CardUtil.getExileZoneId(SharedFate.prepareExileKey(game, source, sourcePermanent, playerToDraw.getId()), game);
|
||||
String exileName = sourcePermanent.getIdName() + "-" + sourcePermanent.getZoneChangeCounter(game) + " (" + playerToDraw.getName() + ')';
|
||||
playerToDraw.moveCardsToExile(card, source, game, false, exileId, exileName);
|
||||
card.setFaceDown(true, game);
|
||||
return true;
|
||||
}
|
||||
|
@ -140,8 +148,8 @@ class SharedFatePlayEffect extends AsThoughEffectImpl {
|
|||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
UUID exileId = CardUtil.getExileZoneId(SharedFate.prepareExileKey(game, source, sourcePermanent, affectedControllerId), game);
|
||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||
return exileZone != null && exileZone.contains(objectId);
|
||||
}
|
||||
|
@ -173,8 +181,8 @@ class SharedFateLookEffect extends AsThoughEffectImpl {
|
|||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
UUID exileId = CardUtil.getExileZoneId(SharedFate.prepareExileKey(game, source, sourcePermanent, affectedControllerId), game);
|
||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||
if (exileZone != null && exileZone.contains(objectId)) {
|
||||
Card card = game.getCard(objectId);
|
||||
|
|
Loading…
Reference in a new issue