mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
*If, for some reason, a ChangeZone ability is passed zero targets (if, say, a Faceless Devourer enters play without targeting anything) there will no longer be an NPE. Fixes the Faceless creatures, Oblivion Ring,Journey to Nowhere etc.
This commit is contained in:
@@ -827,51 +827,54 @@ public class AbilityFactory_ChangeZone {
|
|||||||
tgtCards.add(c);
|
tgtCards.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Card targetCard = null;
|
||||||
|
if(tgtCards.size() != 0)
|
||||||
|
{
|
||||||
|
|
||||||
Card targetCard = tgtCards.get(0);
|
targetCard = tgtCards.get(0);
|
||||||
|
|
||||||
for(Card tgtC : tgtCards){
|
for(Card tgtC : tgtCards){
|
||||||
PlayerZone originZone = AllZone.getZone(tgtC);
|
PlayerZone originZone = AllZone.getZone(tgtC);
|
||||||
// if Target isn't in the expected Zone, continue
|
// if Target isn't in the expected Zone, continue
|
||||||
if (!originZone.is(origin))
|
if (!originZone.is(origin))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (tgt != null && origin.equals("Battlefield")){
|
if (tgt != null && origin.equals("Battlefield")){
|
||||||
// check targeting
|
// check targeting
|
||||||
if (!CardFactoryUtil.canTarget(sa.getSourceCard(), tgtC))
|
if (!CardFactoryUtil.canTarget(sa.getSourceCard(), tgtC))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player pl = player;
|
Player pl = player;
|
||||||
if (!destination.equals("Battlefield"))
|
if (!destination.equals("Battlefield"))
|
||||||
pl = tgtC.getOwner();
|
pl = tgtC.getOwner();
|
||||||
|
|
||||||
if (destination.equals("Library")){
|
if (destination.equals("Library")){
|
||||||
// library position is zero indexed
|
// library position is zero indexed
|
||||||
int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0;
|
int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0;
|
||||||
|
|
||||||
AllZone.GameAction.moveToLibrary(tgtC, libraryPosition);
|
AllZone.GameAction.moveToLibrary(tgtC, libraryPosition);
|
||||||
|
|
||||||
if (params.containsKey("Shuffle")) // for things like Gaea's Blessing
|
if (params.containsKey("Shuffle")) // for things like Gaea's Blessing
|
||||||
player.shuffle();
|
player.shuffle();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (destination.equals("Battlefield")){
|
if (destination.equals("Battlefield")){
|
||||||
if (params.containsKey("Tapped"))
|
if (params.containsKey("Tapped"))
|
||||||
tgtC.tap();
|
tgtC.tap();
|
||||||
if (params.containsKey("GainControl"))
|
if (params.containsKey("GainControl"))
|
||||||
tgtC.setController(sa.getActivatingPlayer());
|
tgtC.setController(sa.getActivatingPlayer());
|
||||||
|
|
||||||
AllZone.GameAction.moveTo(AllZone.getZone(destination, tgtC.getOwner()),tgtC);
|
AllZone.GameAction.moveTo(AllZone.getZone(destination, tgtC.getOwner()),tgtC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AllZone.GameAction.moveTo(AllZone.getZone(destination, pl), tgtC);
|
AllZone.GameAction.moveTo(AllZone.getZone(destination, pl), tgtC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (af.hasSubAbility()){
|
if (af.hasSubAbility()){
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null){
|
if (abSub != null){
|
||||||
|
|||||||
Reference in New Issue
Block a user