forked from External/mage
* Added early event type check for replacement effects to speed up game execution (not all effects already implement the new check).
This commit is contained in:
parent
ba57478149
commit
9039eef0f9
40 changed files with 283 additions and 144 deletions
|
|
@ -324,14 +324,17 @@ public class ContinuousEffects implements Serializable {
|
|||
*/
|
||||
private HashMap<ReplacementEffect, HashSet<Ability>> getApplicableReplacementEffects(GameEvent event, Game game) {
|
||||
HashMap<ReplacementEffect, HashSet<Ability>> replaceEffects = new HashMap<>();
|
||||
if (planeswalkerRedirectionEffect.applies(event, null, game)) {
|
||||
if (planeswalkerRedirectionEffect.checksEventType(event, game) && planeswalkerRedirectionEffect.applies(event, null, game)) {
|
||||
replaceEffects.put(planeswalkerRedirectionEffect, null);
|
||||
}
|
||||
if(auraReplacementEffect.applies(event, null, game)){
|
||||
if(auraReplacementEffect.checksEventType(event, game) && auraReplacementEffect.applies(event, null, game)){
|
||||
replaceEffects.put(auraReplacementEffect, null);
|
||||
}
|
||||
//get all applicable transient Replacement effects
|
||||
for (ReplacementEffect effect: replacementEffects) {
|
||||
if (!effect.checksEventType(event, game)) {
|
||||
continue;
|
||||
}
|
||||
if (event.getAppliedEffects() != null && event.getAppliedEffects().contains(effect.getId())) {
|
||||
// Effect already applied to this event, ignore it
|
||||
// TODO: Handle also gained effect that are connected to different abilities.
|
||||
|
|
@ -357,6 +360,9 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
for (PreventionEffect effect: preventionEffects) {
|
||||
if (!effect.checksEventType(event, game)) {
|
||||
continue;
|
||||
}
|
||||
if (event.getAppliedEffects() != null && event.getAppliedEffects().contains(effect.getId())) {
|
||||
// Effect already applied to this event, ignore it
|
||||
// TODO: Handle also gained effect that are connected to different abilities.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue