- Cleanup in checkETBEffects.

This commit is contained in:
Sloth
2013-05-05 21:03:24 +00:00
parent 404d99a1ea
commit fea6ac738a

View File

@@ -219,7 +219,7 @@ public class SpellPermanent extends Spell {
final GameState game = ai.getGame(); final GameState game = ai.getGame();
if (card.isCreature() if (card.isCreature()
&& ai.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noCreatureETBTriggers)) { && game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noCreatureETBTriggers)) {
return api == null; return api == null;
} }
@@ -264,6 +264,11 @@ public class SpellPermanent extends Spell {
continue; continue;
} }
// if trigger is not mandatory - no problem
if (params.get("OptionalDecider") != null) {
continue;
}
// Maybe better considerations // Maybe better considerations
final String execute = params.get("Execute"); final String execute = params.get("Execute");
if (execute == null) { if (execute == null) {
@@ -282,26 +287,16 @@ public class SpellPermanent extends Spell {
if (sa != null) { if (sa != null) {
exSA.setActivatingPlayer(sa.getActivatingPlayer()); exSA.setActivatingPlayer(sa.getActivatingPlayer());
} }
else if (ai != null) {
exSA.setActivatingPlayer(ai);
}
else { else {
throw new InvalidParameterException("Either ai or sa must be not null!"); exSA.setActivatingPlayer(ai);
} }
exSA.setTrigger(true); exSA.setTrigger(true);
// Run non-mandatory trigger. // Run non-mandatory trigger.
// These checks only work if the Executing SpellAbility is an // These checks only work if the Executing SpellAbility is an Ability_Sub.
// Ability_Sub.
if ((exSA instanceof AbilitySub) && !exSA.doTrigger(false, ai)) { if ((exSA instanceof AbilitySub) && !exSA.doTrigger(false, ai)) {
// AI would not run this trigger if given the chance // AI would not run this trigger if given the chance
return false;
// if trigger is mandatory, return false
if (params.get("OptionalDecider") == null) {
return false;
}
// else
// otherwise, return false 50% of the time?
} }
} }
if (api != null && !rightapi) { if (api != null && !rightapi) {
@@ -349,11 +344,8 @@ public class SpellPermanent extends Spell {
if (sa != null) { if (sa != null) {
exSA.setActivatingPlayer(sa.getActivatingPlayer()); exSA.setActivatingPlayer(sa.getActivatingPlayer());
} }
else if (ai != null) {
exSA.setActivatingPlayer(ai);
}
else { else {
throw new InvalidParameterException("Either ai or sa must be not null!"); exSA.setActivatingPlayer(ai);
} }
if (exSA.getActivatingPlayer() == null) { if (exSA.getActivatingPlayer() == null) {
@@ -362,8 +354,7 @@ public class SpellPermanent extends Spell {
} }
// ETBReplacement uses overriding abilities. // ETBReplacement uses overriding abilities.
// These checks only work if the Executing SpellAbility is an // These checks only work if the Executing SpellAbility is an Ability_Sub.
// Ability_Sub.
if (exSA != null && (exSA instanceof AbilitySub) && !exSA.doTrigger(false, ai)) { if (exSA != null && (exSA instanceof AbilitySub) && !exSA.doTrigger(false, ai)) {
return false; return false;
} }